Example #1
0
        public static Settings Load(DelegateManager delegateManager)
        {
            delegateManager.AddResult(Result.NewInfo("Loading Settings...."));

            Settings settings = null;

            if (System.IO.File.Exists(SettingsXmlFile))
            {
                try
                {
                    settings = System.IO.File.ReadAllText(SettingsXmlFile).FromXML<Settings>();
                }
                catch (Exception exc)
                {
                    var backUpFileName = string.Format(SettingsXmlFileBackup, Guid.NewGuid());

                    System.IO.File.Move(SettingsXmlFileBackup, backUpFileName);

                    delegateManager.AddResult(Result.NewCritical(string.Format("Error Loading Settings: {0}. Settings file was backed up to {0}.", exc.Message, backUpFileName)));
                }
            }

            if (settings == null)
            {
                delegateManager.AddResult(Result.NewInfo("Initializing new Settings."));

                settings = new Settings(true);
            }

            delegateManager.AddResult(Result.NewInfo("Loading Settings Completed!"));

            return settings;
        }
Example #2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            this.statusStripProgressList = new SortedList<Guid, StatusStripProgress>();
            this.delegateManager = new DelegateManager();
            this.uiManager = new UIManager(MainDockPanel, this.delegateManager);
            this.uiManager.InitUI();
            this.settings = Local.Settings.Load(this.delegateManager);
            this.uiManager.InitSettings(this.settings);

        }
Example #3
0
        public void Save(DelegateManager delegateManager)
        {
            var xml = this.ToXml();

            try
            {
                delegateManager.AddResult(Result.NewInfo("Saving Settings...."));
                System.IO.File.WriteAllText(SettingsXmlFile, xml);
                delegateManager.AddResult(Result.NewInfo("Saved Settings!"));
            }
            catch (Exception exc)
            {
                var backUpFileName = string.Format(SettingsXmlFileBackup, Guid.NewGuid());

                System.IO.File.WriteAllText(backUpFileName, xml);

                delegateManager.AddResult(Result.NewCritical(string.Format("Error Saving Settings: {0}. Settings file was backed up to {0}.", exc.Message, backUpFileName)));
            }
        }
Example #4
0
 public UIManager(DockPanel dockPanel, DelegateManager delegateManager)
 {
     this.DockPanel = dockPanel;
     this.DelegateManager = delegateManager;
 }