////////////////////////////////////////////////////////////////////////// protected void LoadControls(Control ParentControl, SettingsNode RootNode) { foreach (Control C in ParentControl.Controls) { if (C is ILayoutAwareControl) { ((ILayoutAwareControl)C).LoadControlLayout(RootNode); } else { if (C is SplitContainer) { SplitContainer Ctrl = C as SplitContainer; if (!Ctrl.IsSplitterFixed) { SettingsNode Node = RootNode.GetNode(Ctrl.Name); if (Node != null) { try { Ctrl.SplitterDistance = Node.GetInt("SplitterDistance", Ctrl.SplitterDistance); } catch { } } } } if (C is ListView) { ListView Ctrl = C as ListView; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { for (int i = 0; i < Ctrl.Columns.Count; i++) { ColumnHeader Col = Ctrl.Columns[i]; Col.Width = Node.GetInt("Col" + i.ToString() + "Width", Col.Width); } } } if(C is TabControl) { TabControl Ctrl = C as TabControl; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { int SelIndex = Node.GetInt("SelectedIndex", Ctrl.SelectedIndex); if (SelIndex >= 0 && SelIndex < Ctrl.TabCount) Ctrl.SelectedIndex = SelIndex; } } } if (C.Controls.Count > 0) LoadControls(C, RootNode); } }
////////////////////////////////////////////////////////////////////////// protected void SaveControls(Control ParentControl, SettingsNode RootNode) { foreach (Control C in ParentControl.Controls) { if (C is ILayoutAwareControl) { ((ILayoutAwareControl)C).SaveControlLayout(RootNode); } else { if (C is SplitContainer) { SplitContainer Ctrl = C as SplitContainer; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { Node.SetValue("SplitterDistance", Ctrl.SplitterDistance); } } if (C is ListView) { ListView Ctrl = C as ListView; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { for (int i = 0; i < Ctrl.Columns.Count; i++) { Node.SetValue("Col" + i.ToString() + "Width", Ctrl.Columns[i].Width); } } } if (C is TabControl) { TabControl Ctrl = C as TabControl; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { Node.SetValue("SelectedIndex", Ctrl.SelectedIndex); } } } if (C.Controls.Count > 0) { SaveControls(C, RootNode); } } }
////////////////////////////////////////////////////////////////////////// public virtual void SaveControlLayout(SettingsNode RootNode) { SettingsNode Node = RootNode.GetNode(this.Name, false, true); if (Node != null) { for (int i = 0; i < Columns.Count; i++) { Node.SetValue("Col" + i.ToString() + "Width", Columns[i].Width); } } }
////////////////////////////////////////////////////////////////////////// public virtual void LoadControlLayout(SettingsNode RootNode) { SettingsNode Node = RootNode.GetNode(this.Name, false, true); if (Node != null) { for (int i = 0; i < Columns.Count; i++) { TreeColumn Col = Columns[i]; Col.Width = Node.GetInt("Col" + i.ToString() + "Width", Col.Width); } } }
////////////////////////////////////////////////////////////////////////// protected void SaveLayout(SettingsNode RootNode) { SettingsNode LayoutNode = RootNode.GetNode("Layout\\" + this.Name, false, true); if (LayoutNode != null) { LayoutNode.SetValue("FormState", (int)this.WindowState); LayoutNode.SetValue("FormPosX", FormStateRect.Location.X); LayoutNode.SetValue("FormPosY", FormStateRect.Location.Y); LayoutNode.SetValue("FormWidth", FormStateRect.Size.Width); LayoutNode.SetValue("FormHeight", FormStateRect.Size.Height); SaveControls(this, LayoutNode); } }
////////////////////////////////////////////////////////////////////////// private void LoadSettings(SettingsNode RootNode) { SettingsNode Section = RootNode.GetNode(this.Name, true); if (Section != null) { TxtProjectFile.Text = Section.GetString("ProjectFile"); TxtExtensions.Text = Section.GetString("ScriptExtensions"); foreach (IntegratorModule Mod in modules) { Mod.LoadSettings(Section); } } if (TxtExtensions.Text == "") TxtExtensions.Text = "script inc"; }
////////////////////////////////////////////////////////////////////////// protected void LoadLayout(SettingsNode RootNode) { SettingsNode LayoutNode = RootNode.GetNode("Layout\\" + this.Name); if (LayoutNode != null) { // load position Point FormLoc = new Point(LayoutNode.GetInt("FormPosX", this.Location.X), LayoutNode.GetInt("FormPosY", this.Location.Y)); // load size if (this.FormBorderStyle == FormBorderStyle.Sizable || this.FormBorderStyle == FormBorderStyle.SizableToolWindow) { this.Size = new Size(LayoutNode.GetInt("FormWidth", this.Size.Width), LayoutNode.GetInt("FormHeight", this.Size.Height)); } // make sure the position/size is valid on current monitor setup bool FoundScreen = false; Point LowerRight = new Point(FormLoc.X + this.Size.Width, FormLoc.Y + this.Size.Height); foreach (Screen Scr in Screen.AllScreens) { if (Scr.Bounds.Contains(FormLoc) || Scr.Bounds.Contains(LowerRight)) { FoundScreen = true; } } if (FoundScreen) { this.Location = FormLoc; } // remember window position FormStateRect.Location = this.Location; FormStateRect.Size = this.Size; this.WindowState = (FormWindowState)LayoutNode.GetInt("FormState", (int)FormWindowState.Normal); LoadControls(this, LayoutNode); } else { FormStateRect.Location = this.Location; FormStateRect.Size = this.Size; } }
////////////////////////////////////////////////////////////////////////// public void SaveSettings(SettingsNode RootNode) { SettingsNode Section = RootNode.GetNode("General", true, true); if (Section == null) return; Section.Clear(); Section.SetValue("SelectionColor", SelectionColor); Section.SetValue("BoxColor", BoxColor); Section.SetValue("BackgroundColor", WindowCanvas.BackColor); Section.SetValue("GridWidth", GridSize.Width); Section.SetValue("GridHeight", GridSize.Height); SettingsNode RecentList = new SettingsNode("RecentFiles"); foreach (string RecentFile in _RecentFiles) { RecentList.Children.Add(new SettingsNode("RecentFile", RecentFile)); } Section.Children.Add(RecentList); }
////////////////////////////////////////////////////////////////////////// public void LoadSettings(SettingsNode RootNode) { SettingsNode Section = RootNode.GetNode("General", true); if (Section == null) return; SelectionColor = Section.GetColor("SelectionColor", SelectionColor); BoxColor = Section.GetColor("BoxColor", BoxColor); WindowCanvas.BackColor = Section.GetColor("BackgroundColor", WindowCanvas.BackColor); GridSize = new Size(Section.GetInt("GridWidth", GridSize.Width), Section.GetInt("GridHeight", GridSize.Height)); _RecentFiles.Clear(); SettingsNode RecentList = Section.GetNode("RecentFiles"); if (RecentList != null) { foreach (SettingsNode Node in RecentList.Children) { string RecentFile = Node.GetString(); if(File.Exists(RecentFile)) _RecentFiles.Add(RecentFile); } } }
////////////////////////////////////////////////////////////////////////// protected void LoadControls(Control ParentControl, SettingsNode RootNode) { foreach (Control C in ParentControl.Controls) { if (C is ILayoutAwareControl) { ((ILayoutAwareControl)C).LoadControlLayout(RootNode); } else { if (C is SplitContainer) { SplitContainer Ctrl = C as SplitContainer; if (!Ctrl.IsSplitterFixed) { SettingsNode Node = RootNode.GetNode(Ctrl.Name); if (Node != null) { try { Ctrl.SplitterDistance = Node.GetInt("SplitterDistance", Ctrl.SplitterDistance); } catch { } } } } if (C is ListView) { ListView Ctrl = C as ListView; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { for (int i = 0; i < Ctrl.Columns.Count; i++) { ColumnHeader Col = Ctrl.Columns[i]; Col.Width = Node.GetInt("Col" + i.ToString() + "Width", Col.Width); } } } if (C is TabControl) { TabControl Ctrl = C as TabControl; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { int SelIndex = Node.GetInt("SelectedIndex", Ctrl.SelectedIndex); if (SelIndex >= 0 && SelIndex < Ctrl.TabCount) { Ctrl.SelectedIndex = SelIndex; } } } } if (C.Controls.Count > 0) { LoadControls(C, RootNode); } } }
////////////////////////////////////////////////////////////////////////// protected void SaveLayout(SettingsNode RootNode) { SettingsNode LayoutNode = RootNode.GetNode("Layout\\" + this.Name, false, true); if (LayoutNode != null) { LayoutNode.SetValue("FormState", (int)this.WindowState); LayoutNode.SetValue("FormPosX", FormStateRect.Location.X); LayoutNode.SetValue("FormPosY", FormStateRect.Location.Y); LayoutNode.SetValue("FormWidth", FormStateRect.Size.Width); LayoutNode.SetValue("FormHeight", FormStateRect.Size.Height); SaveControls(this, LayoutNode); } }
////////////////////////////////////////////////////////////////////////// protected void SaveControls(Control ParentControl, SettingsNode RootNode) { foreach (Control C in ParentControl.Controls) { if (C is ILayoutAwareControl) { ((ILayoutAwareControl)C).SaveControlLayout(RootNode); } else { if (C is SplitContainer) { SplitContainer Ctrl = C as SplitContainer; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { Node.SetValue("SplitterDistance", Ctrl.SplitterDistance); } } if (C is ListView) { ListView Ctrl = C as ListView; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { for (int i = 0; i < Ctrl.Columns.Count; i++) { Node.SetValue("Col" + i.ToString() + "Width", Ctrl.Columns[i].Width); } } } if (C is TabControl) { TabControl Ctrl = C as TabControl; SettingsNode Node = RootNode.GetNode(Ctrl.Name, false, true); if (Node != null) { Node.SetValue("SelectedIndex", Ctrl.SelectedIndex); } } } if (C.Controls.Count > 0) SaveControls(C, RootNode); } }
////////////////////////////////////////////////////////////////////////// protected void LoadLayout(SettingsNode RootNode) { SettingsNode LayoutNode = RootNode.GetNode("Layout\\" + this.Name); if (LayoutNode != null) { // load position Point FormLoc = new Point(LayoutNode.GetInt("FormPosX", this.Location.X), LayoutNode.GetInt("FormPosY", this.Location.Y)); // load size if (this.FormBorderStyle == FormBorderStyle.Sizable || this.FormBorderStyle == FormBorderStyle.SizableToolWindow) { this.Size = new Size(LayoutNode.GetInt("FormWidth", this.Size.Width), LayoutNode.GetInt("FormHeight", this.Size.Height)); } // make sure the position/size is valid on current monitor setup bool FoundScreen = false; Point LowerRight = new Point(FormLoc.X + this.Size.Width, FormLoc.Y + this.Size.Height); foreach (Screen Scr in Screen.AllScreens) { if (Scr.Bounds.Contains(FormLoc) || Scr.Bounds.Contains(LowerRight)) FoundScreen = true; } if (FoundScreen) this.Location = FormLoc; // remember window position FormStateRect.Location = this.Location; FormStateRect.Size = this.Size; this.WindowState = (FormWindowState)LayoutNode.GetInt("FormState", (int)FormWindowState.Normal); LoadControls(this, LayoutNode); } else { FormStateRect.Location = this.Location; FormStateRect.Size = this.Size; } }
////////////////////////////////////////////////////////////////////////// private void SaveSettings(SettingsNode RootNode) { SettingsNode Section = RootNode.GetNode(this.Name, true, true); if (Section == null) return; Section.Clear(); Section.SetValue("ProjectFile", TxtProjectFile.Text); Section.SetValue("ScriptExtensions", TxtExtensions.Text); foreach(IntegratorModule Mod in modules) { Mod.SaveSettings(Section); } }