////////////////////////////////////////////////////////////////////////// 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); } }
////////////////////////////////////////////////////////////////////////// public void SetValue(string Path, Color Val) { SettingsNode Node = GetNode(Path, false, true); if (Node != null) { Node.SetValue(Val); } }
////////////////////////////////////////////////////////////////////////// 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 override void SaveSettings(SettingsNode RootNode) { RootNode.SetValue("GeshiOutputDir", TxtOutputDir.Text); }