void OnLanguageChanged() { bOk.Text = TranslateString("OK"); bCancel.Text = LangPack.TranslateString("Cancel"); aApply.Text = LangPack.TranslateString("Apply"); Text = LangPack.TranslateString("Options"); foreach (TreeNode rtn in tvItems.Nodes) { if (rtn.Tag.GetType() == typeof(string)) { string groupName = (string)rtn.Tag; rtn.Text = LangPack.TranslateString(groupName); } else { OptionControlInfo inf = (OptionControlInfo)rtn.Tag; rtn.Text = LangPack.TranslateString(inf.Group); inf.Instance.lCaption.Text = LangPack.TranslateString(inf.Group); } foreach (TreeNode tn in rtn.Nodes) { OptionControlInfo inf = (OptionControlInfo)tn.Tag; inf.Instance.lCaption.Text = LangPack.TranslateString(inf.Caption); tn.Text = LangPack.TranslateString(inf.Caption); } } }
public static void RegisterOptionControl(Type controlType, string group, int groupOrder, string caption, int order) { if (controlType.BaseType != typeof(BaseOptionsControl)) { throw new ArgumentException("Required BaseOptionsControl type", "controlType"); } foreach (OptionControlInfo inf in optionsControls) { if (inf.Group == group && inf.Caption == caption) { throw new ArgumentException("Item with same Caption and Group already exists"); } } OptionControlInfo infNew = new OptionControlInfo(controlType, group, groupOrder, caption, order); optionsControls.Add(infNew); }
void TvItemsAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { if (e.Node.Tag.GetType() == typeof(string)) { tvItems.SelectedNode = e.Node.Nodes[0]; } else { if (prevControl != null) { prevControl.Visible = false; } OptionControlInfo inf = (OptionControlInfo)e.Node.Tag; inf.Instance.Visible = true; inf.Instance.Activate(); prevControl = inf.Instance; } }
void BaseOptionsFormVisibleChanged(object sender, System.EventArgs e) { if (DesignMode) { return; } tvItems.ExpandAll(); if (Visible) { InitControls(); if (OnInitBaseOptionsForm != null) { OnInitBaseOptionsForm(this, new EventArgs()); } if (!string.IsNullOrEmpty(pageToActivate)) { foreach (TreeNode tn in tvItems.Nodes) { foreach (TreeNode childn in tn.Nodes) { OptionControlInfo inf = (OptionControlInfo)childn.Tag; if (inf.Caption == pageToActivate) { tvItems.SelectedNode = childn; pageToActivate = ""; return; } } } } } else { if (OnFinalizeBaseOptionsForm != null) { OnFinalizeBaseOptionsForm(this, new EventArgs()); } } }
void InitControls() { if (!controlsAdded) { tvItems.Nodes.Clear(); foreach (OptionControlInfo inf in OptionsControlsManager.OptionsControls) { inf.Instance = (BaseOptionsControl)Activator.CreateInstance(inf.ControlType); inf.Instance.Parent = pMain; inf.Instance.Dock = DockStyle.Fill; inf.Instance.Visible = false; inf.Instance.lCaption.Text = LangPack.TranslateString(inf.Caption); TreeNode rootNode = null; foreach (TreeNode tn in tvItems.Nodes) { if (inf.Group == (string)tn.Tag) { rootNode = tn; break; } } if (rootNode == null) { rootNode = new TreeNode(LangPack.TranslateString(inf.Group)); rootNode.Tag = inf.Group; tvItems.Nodes.Insert(inf.GroupOrder, rootNode); } TreeNode childNode = new TreeNode(LangPack.TranslateString(inf.Caption)); childNode.Tag = inf; if (inf.Order < rootNode.Nodes.Count) //monobug. Insert does not work { rootNode.Nodes.Insert(inf.Order, childNode); } else { rootNode.Nodes.Add(childNode); } } //when one item in group remove subitems foreach (TreeNode tn in tvItems.Nodes) { if (tn.Nodes.Count == 1) { tn.Tag = tn.Nodes[0].Tag; tn.Nodes.RemoveAt(0); OptionControlInfo inf = (OptionControlInfo)tn.Tag; inf.Instance.lCaption.Text = LangPack.TranslateString(inf.Group); } } controlsAdded = true; tvItems.ExpandAll(); tvItems.SelectedNode = tvItems.Nodes[0]; } foreach (OptionControlInfo inf in OptionsControlsManager.OptionsControls) { inf.Instance.Init(); } }
public static void RegisterOptionControl(Type controlType, string group, int groupOrder, string caption, int order) { if(controlType.BaseType != typeof(BaseOptionsControl)) throw new ArgumentException("Required BaseOptionsControl type", "controlType"); foreach(OptionControlInfo inf in optionsControls) { if(inf.Group == group && inf.Caption == caption) throw new ArgumentException("Item with same Caption and Group already exists"); } OptionControlInfo infNew = new OptionControlInfo(controlType, group, groupOrder, caption, order); optionsControls.Add(infNew); }