/// <summary> /// Builds the settings for a TreeNode and adds them to the Tag as SectionDetails. /// </summary> private void BuildSettings(TreeNode node) { if (node.Tag == null || !(node.Tag is SectionDetails)) { return; } SectionDetails sectionTag = (SectionDetails)node.Tag; sectionTag.RightToLeft = _rightToLeft; sectionTag.Width = _panelSectionSettings.Width; // Create controls FormDesigner designer = new FormDesigner(GetSectionPath(node)); designer.Help = _help; designer.ConfigChangedHandler = UpdateConfigItem; designer.YesNoChange = YesNoChange; designer.MultiSelectionListChange = MultiSelectionListChange; designer.SingleSelectionListChange = SingleSelectionListChange; designer.ListBoxSelectionChange = ListSelectionChanged; designer.ButtonClick = ButtonClicked; designer.EntryLeave = EntryChange; designer.NumUpDownChanged = NumUpDownChanged; sectionTag.Control = designer.BuildToPanel(_rightToLeft, _panelSectionSettings.Width); sectionTag.Designed = true; node.Tag = sectionTag; }
/// <summary> /// Returns a TreeNode created from a SettingBase. /// </summary> /// <param name="section">Setting to create TreeNode from.</param> /// <returns></returns> private TreeNode CreateTreeNode(ConfigSection section) { TreeNode node = new TreeNode(); SectionDetails sectionTag = new SectionDetails(); sectionTag.Section = section; node.Tag = sectionTag; node.Text = section.Text.Evaluate(); node.ImageIndex = _treeSections.ImageList.Images.Count; node.SelectedImageIndex = _treeSections.ImageList.Images.Count; AddPNGToImageList(_treeSections.ImageList, section.SectionMetadata.IconSmallFilePath); return(node); }
/// <summary> /// Applies all settings. /// </summary> private void ApplyAll() { // Apply configuration ServiceScope.Get <IConfigurationManager>().Apply(); // Apply language if (_languageChange) { // Update text on buttons if (_btnSave.Tag is IResourceString) { _btnSave.Text = ((IResourceString)_btnSave.Tag).Evaluate(); } if (_btnApply.Tag is IResourceString) { _btnApply.Text = ((IResourceString)_btnApply.Tag).Evaluate(); } // Update text in section tree, // all section details controls need to be redrawn. foreach (TreeNode node in _treeSections.Nodes) { if (node.Tag is SectionDetails) { SectionDetails details = (SectionDetails)node.Tag; node.Text = details.Section.Text.Evaluate(); details.Designed = false; } foreach (TreeNode subnode in node.Nodes) { if (subnode.Tag is SectionDetails) { SectionDetails details = (SectionDetails)subnode.Tag; subnode.Text = details.Section.Text.Evaluate(); details.Designed = false; } } } // Clear all help text -> needs to be localized again _help.RemoveAll(); // Redraw currently selected section details DrawSettings(); _languageChange = false; } }
/// <summary> /// Gets the IConfigurationManager path for the IConfigurationNode related to the specified TreeNode. /// </summary> /// <param name="node"></param> private string GetSectionPath(TreeNode node) { if (node == null || node.Tag == null || !(node.Tag is SectionDetails)) { return(""); } SectionDetails sectionTag = (SectionDetails)node.Tag; if (sectionTag.Section == null) { return(""); } StringBuilder location = new StringBuilder(sectionTag.Section.Metadata.Id + "/"); while (node.Parent != null && node.Parent.Tag != null && node.Parent.Tag is SectionDetails) { location.Insert(0, ((SectionDetails)node.Parent.Tag).Section.Metadata.Id + "/"); node = node.Parent; } return(location.ToString()); }
/// <summary> /// Returns a TreeNode created from a SettingBase. /// </summary> /// <param name="section">Setting to create TreeNode from.</param> /// <returns></returns> private TreeNode CreateTreeNode(ConfigSection section) { TreeNode node = new TreeNode(); SectionDetails sectionTag = new SectionDetails(); sectionTag.Section = section; node.Tag = sectionTag; node.Text = section.Text.Evaluate(); node.ImageIndex = _treeSections.ImageList.Images.Count; node.SelectedImageIndex = _treeSections.ImageList.Images.Count; AddPNGToImageList(_treeSections.ImageList, section.SectionMetadata.IconSmallFilePath); return node; }