Ejemplo n.º 1
0
        private void CreateDefaults()
        {
            UIControls = new UIControls();

            AddPlatforms(CreateBorder);
            AddPlatforms(CreateCheckBox);
            AddPlatforms(CreateComboBox);
            AddPlatforms(CreateDataGrid);
            AddPlatforms(CreateDatePicker);
            AddPlatforms(CreateGrid);
            AddPlatforms(CreateImage);
            AddPlatforms(CreateLabel);
            AddPlatforms(CreateTextBlock);
            AddPlatforms(CreateTextBox);
        }
Ejemplo n.º 2
0
        //!+ Routine to load settings.

        /// <summary>
        /// Gets the settings.
        /// </summary>
        /// <returns>
        /// The UIControls.
        /// </returns>
        public UIControls Load()
        {
            logger.Trace("Entered Load()");

            if (!Directory.Exists(_saveSettingsFolderName))
            {
                logger.Info("Creating settings folder.");
                Directory.CreateDirectory(_saveSettingsFolderName);
            }

            if (!File.Exists(saveSettingsFilename))
            {
                //+ If the settings file does not exit, create it.
                logger.Info("Creating initial settings file.");
                CreateDefaults();
                Save(false);
            }
            else
            {
                try
                {
                    //+ Otherwise start with an empty UIControls
                    if (UIControls != null)
                    {
                        UIControls.Clear();
                        UIControls = null;
                    }

                    //+ And deserialize the stream into UIControls.
                    using (var fs = new FileStream(saveSettingsFilename, FileMode.Open))
                    {
                        UIControls = Deserialize(fs) as UIControls;
                    }
                }
                catch (Exception ex)
                {
                    //+ If that doesn't work, just use defaults.
                    UIUtilities.ShowExceptionMessage("Settings File",
                                                     "Unable to load previous settings file.  Creating new settings file.");
                    logger.Debug("Unable to load previous settings file.", ex);
                    CreateDefaults();
                    Save(false);
                }
            }
            return(UIControls);
        }
Ejemplo n.º 3
0
        //!+ Routine to load settings.

        /// <summary>
        ///     Gets the settings.
        /// </summary>
        /// <returns>
        ///     .
        /// </returns>
        public UIControls Load()
        {
            if (!Directory.Exists(_saveSettingsFolderName))
            {
                Directory.CreateDirectory(_saveSettingsFolderName);
            }

            if (!File.Exists(_saveSettingsFilename))
            {
                //+ If the settings file does not exit, create it.
                CreateDefaults();
                Save(false);
                //UIUtilities.ShowExceptionMessage("Settings File Created", "Your settings file has been created for you.  You can configure your settings using the Set Control Defaults command.");
            }
            else
            {
                try
                {
                    //+ Otherwise start with an empty UIControls
                    if (UIControls != null)
                    {
                        UIControls.Clear();
                        UIControls = null;
                    }

                    //+ And deserialize the stream into UIControls.
                    using (var fs = new FileStream(_saveSettingsFilename, FileMode.Open))
                    {
                        UIControls = Deserialize(fs) as UIControls;
                    }
                }
                catch (Exception ex)
                {
                    //+ If that doesn't work, just use defaults.
                    UIUtilities.ShowExceptionMessage("Settings File", "Unable to load previous settings file.  Creating new settings file.",
                                                     string.Empty, ex.ToString());
                    CreateDefaults();
                    Save(false);
                }
            }
            return(UIControls);
        }