private static void AddControl(KPFormCustomization kpfc, Control c) { if ((kpfc == null) || (c == null)) { Debug.Assert(false); return; } bool bAdd = true; Type t = c.GetType(); if (c.Text.Length == 0) { bAdd = false; } else if (c.Name.Length == 0) { bAdd = false; } else if (t == typeof(MenuStrip)) { bAdd = false; } else if (t == typeof(PictureBox)) { bAdd = false; } else if (t == typeof(TreeView)) { bAdd = false; } else if (t == typeof(ToolStrip)) { bAdd = false; } else if (t == typeof(WebBrowser)) { bAdd = false; } else if (t == typeof(Panel)) { bAdd = false; } else if (t == typeof(StatusStrip)) { bAdd = false; } else if (c.Text.StartsWith(@"<") && c.Text.EndsWith(@">")) { bAdd = false; } if (t == typeof(TabControl)) { bAdd = true; } else if (t == typeof(ProgressBar)) { bAdd = true; } else if (t == typeof(TextBox)) { bAdd = true; } else if (t == typeof(PromptedTextBox)) { bAdd = true; } else if (t == typeof(RichTextBox)) { bAdd = true; } else if (t == typeof(KeePass.UI.CustomRichTextBoxEx)) { bAdd = true; } else if (t == typeof(ComboBox)) { bAdd = true; } else if (t == typeof(KeePass.UI.ImageComboBoxEx)) { bAdd = true; } else if (t == typeof(Label)) { bAdd = true; } else if (t == typeof(ListView)) { bAdd = true; } else if (t == typeof(CustomListViewEx)) { bAdd = true; } else if (t == typeof(Button)) { bAdd = true; } else if (t == typeof(KeePass.UI.QualityProgressBar)) { bAdd = true; } else if (t == typeof(DateTimePicker)) { bAdd = true; } else if (t == typeof(CheckedListBox)) { bAdd = true; } if (bAdd && (c.Name.Length > 0)) { KPControlCustomization kpcc = new KPControlCustomization(); kpcc.Name = c.Name; kpcc.BaseHash = KPControlCustomization.HashControl(c); if ((t != typeof(TabControl)) && (t != typeof(NumericUpDown))) { kpcc.TextEnglish = c.Text; } else { kpcc.TextEnglish = string.Empty; } kpfc.Controls.Add(kpcc); } foreach (Control cSub in c.Controls) { AddControl(kpfc, cSub); } }
private void UpdateStatusImages(TreeNodeCollection vtn) { if (vtn == null) { vtn = m_tvControls.Nodes; } foreach (TreeNode tn in vtn) { KPFormCustomization kpfc = (tn.Tag as KPFormCustomization); KPControlCustomization kpcc = (tn.Tag as KPControlCustomization); if (kpfc != null) { tn.ImageIndex = m_inxWindow; tn.SelectedImageIndex = m_inxWindow; } else if (kpcc != null) { int iCurrentImage = tn.ImageIndex, iNewImage; if (Array.IndexOf <string>(m_vEmpty, kpcc.TextEnglish) >= 0) { iNewImage = ((kpcc.Text.Length == 0) ? m_inxOk : m_inxWarning); } else if ((kpcc.TextEnglish.Length > 0) && (kpcc.Text.Length > 0)) { iNewImage = m_inxOk; } else if ((kpcc.TextEnglish.Length > 0) && (kpcc.Text.Length == 0)) { iNewImage = m_inxMissing; } else if ((kpcc.TextEnglish.Length == 0) && (kpcc.Text.Length == 0)) { iNewImage = m_inxOk; } else if ((kpcc.TextEnglish.Length == 0) && (kpcc.Text.Length > 0)) { iNewImage = m_inxWarning; } else { iNewImage = m_inxWarning; } if (iNewImage != iCurrentImage) { tn.ImageIndex = iNewImage; tn.SelectedImageIndex = iNewImage; } } else { Debug.Assert(false); } if (tn.Nodes != null) { UpdateStatusImages(tn.Nodes); } } }
private static void AddControl(KPFormCustomization kpfc, Control c) { if ((kpfc == null) || (c == null)) { Debug.Assert(false); return; } bool bAdd = true; Type t = c.GetType(); if (string.IsNullOrEmpty(c.Name)) { bAdd = false; } else if (string.IsNullOrEmpty(c.Text)) { bAdd = false; } else if (c.Text.StartsWith("<") && c.Text.EndsWith(">")) { bAdd = false; } else if (t == typeof(MenuStrip)) { bAdd = false; } else if (t == typeof(Panel)) { bAdd = false; } else if (t == typeof(PictureBox)) { bAdd = false; } else if (t == typeof(StatusStrip)) { bAdd = false; } else if (t == typeof(ToolStrip)) { bAdd = false; } else if (t == typeof(TreeView)) { bAdd = false; } else if (t == typeof(WebBrowser)) { bAdd = false; } // For layout adjustments if (t == typeof(Button)) { bAdd = true; } else if (t == typeof(CheckedListBox)) { bAdd = true; } else if (t == typeof(ComboBox)) { bAdd = true; } else if (t == typeof(CustomListViewEx)) { bAdd = true; } else if (t == typeof(CustomRichTextBoxEx)) { bAdd = true; } else if (t == typeof(DateTimePicker)) { bAdd = true; } else if (t == typeof(HotKeyControlEx)) { bAdd = true; } else if (t == typeof(ImageComboBoxEx)) { bAdd = true; } else if (t == typeof(Label)) { bAdd = true; } else if (t == typeof(ListView)) { bAdd = true; } else if (t == typeof(ProgressBar)) { bAdd = true; } else if (t == typeof(PromptedTextBox)) { bAdd = true; } else if (t == typeof(QualityProgressBar)) { bAdd = true; } else if (t == typeof(RichTextBox)) { bAdd = true; } else if (t == typeof(SecureTextBoxEx)) { bAdd = true; } else if (t == typeof(TabControl)) { bAdd = true; } else if (t == typeof(TextBox)) { bAdd = true; } if (bAdd && !string.IsNullOrEmpty(c.Name)) { KPControlCustomization kpcc = new KPControlCustomization(); kpcc.Name = c.Name; kpcc.BaseHash = KPControlCustomization.HashControl(c); if ((t == typeof(HotKeyControlEx)) || (t == typeof(NumericUpDown)) || (t == typeof(TabControl))) { kpcc.TextEnglish = string.Empty; } else { kpcc.TextEnglish = (c.Text ?? string.Empty); } kpfc.Controls.Add(kpcc); } foreach (Control cSub in c.Controls) { AddControl(kpfc, cSub); } }