MainForm - PrepareLayout: Unable to set background

Asked by Jacopo Moronato

My client it's spawning the above message every ten seconds.
However, I did not set any kind of background. In fact, in my xlf files background attribute has empty value (="").
The problem (if any) should be in this chunk of code.

            try
            {
                if (layoutAttributes["background"] == null)
                {
                    // Assume there is no background image
                    BackgroundImage = null;
                    options.backgroundImage = "";
                }
                else
                {
                    string bgFilePath = Properties.Settings.Default.LibraryPath + @"\backgrounds\" + backgroundWidth + "x" + backgroundHeight + "_" + layoutAttributes["background"].Value;

                    // Create a correctly sized background image in the temp folder
                    if (!File.Exists(bgFilePath))
                        GenerateBackgroundImage(layoutAttributes["background"].Value, backgroundWidth, backgroundHeight, bgFilePath);

                    BackgroundImage = new Bitmap(bgFilePath);
                    options.backgroundImage = bgFilePath;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("MainForm - PrepareLayout", "Unable to set background: " + ex.Message), LogType.Error.ToString());

                // Assume there is no background image
                this.BackgroundImage = null;
                options.backgroundImage = "";
            }

Question information

Language:
English Edit question
Status:
Answered
For:
Xibo Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dan Garner (dangarner) said :
#1

if (layoutAttributes["background"] == null) should probably be if (string.IsNullOrEmpty(layoutAttributes["background"]))

Its not a problem as such, but would be nice from a error tidiness perspective. I'll create a bug.

Can you help with this problem?

Provide an answer of your own, or ask Jacopo Moronato for more information if necessary.

To post a message you must log in.