Exemplo n.º 1
0
		private static string Validate(KPFormCustomization kpfc)
		{
			if(kpfc == null) { Debug.Assert(false); return null; }
			if(kpfc.FormEnglish == null) { Debug.Assert(false); return null; }

			string str = Validate(kpfc, kpfc.FormEnglish, null);
			if(str != null) return str;

			return null;
		}
Exemplo n.º 2
0
		private static string Validate(KPFormCustomization kpfc, Control c,
			Dictionary<char, string> dictParent)
		{
			if(kpfc == null) { Debug.Assert(false); return null; }
			if(kpfc.FormEnglish == null) { Debug.Assert(false); return null; }
			if(c == null) { Debug.Assert(false); return null; }

			Dictionary<char, string> dictAccel = new Dictionary<char, string>();

			foreach(Control cSub in c.Controls)
			{
				string strText = Translate(kpfc, cSub);
				char chKey = GetAccelKey(strText);
				if(chKey == char.MinValue) continue;

				string strId = kpfc.FullName + "." + cSub.Name + " - \"" +
					strText + "\"";

				bool bCollides = dictAccel.ContainsKey(chKey);
				bool bCollidesParent = ((dictParent != null) ?
					dictParent.ContainsKey(chKey) : false);

				if(bCollides || bCollidesParent)
				{
					string strMsg = "Key " + chKey.ToString() + ":";
					strMsg += MessageService.NewLine;
					strMsg += (bCollides ? dictAccel[chKey] : dictParent[chKey]);
					strMsg += MessageService.NewLine + strId;
					return strMsg;
				}

				dictAccel.Add(chKey, strId);
			}

			Dictionary<char, string> dictSub = MergeDictionaries(dictParent, dictAccel);
			foreach(Control cSub in c.Controls)
			{
				string str = Validate(kpfc, cSub, dictSub);
				if(str != null) return str;
			}

			return null;
		}
Exemplo n.º 3
0
		private static string Translate(KPFormCustomization kpfc, Control c)
		{
			string strName = c.Name;
			if(string.IsNullOrEmpty(strName)) return string.Empty;

			foreach(KPControlCustomization cc in kpfc.Controls)
			{
				if(cc.Name == strName)
				{
					if(!string.IsNullOrEmpty(cc.TextEnglish))
					{
						Debug.Assert(c.Text == cc.TextEnglish);
					}

					return cc.Text;
				}
			}

			return c.Text;
		}
Exemplo n.º 4
0
        private void UpdatePreviewForm(KPFormCustomization kpfc)
        {
            // bool bResizeEng = (string.IsNullOrEmpty(kpfc.Window.Layout.Width) &&
            //	string.IsNullOrEmpty(kpfc.Window.Layout.Height));

            m_prev.CopyForm(kpfc.FormEnglish);
            kpfc.ApplyTo(m_prev);
        }
Exemplo n.º 5
0
        private static void MergeFormCustomizations(KPFormCustomization kpInto,
            KPFormCustomization kpFrom, StringBuilder sbUnusedText)
        {
            MergeControlCustomizations(kpInto.Window, kpFrom.Window, sbUnusedText);

            foreach(KPControlCustomization ccInto in kpInto.Controls)
            {
                foreach(KPControlCustomization ccFrom in kpFrom.Controls)
                {
                    if(ccInto.Name == ccFrom.Name)
                        MergeControlCustomizations(ccInto, ccFrom, sbUnusedText);
                }
            }
        }
Exemplo n.º 6
0
        private static void AddForm(List<KPFormCustomization> listForms, Form f)
        {
            KPFormCustomization kpfc = new KPFormCustomization();

            kpfc.FullName = f.GetType().FullName;
            kpfc.FormEnglish = f;

            kpfc.Window.TextEnglish = f.Text;
            kpfc.Window.BaseHash = KPControlCustomization.HashControl(f);

            foreach(Control c in f.Controls) AddControl(kpfc, c);

            kpfc.Controls.Sort();

            listForms.Add(kpfc);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 private void UpdatePreviewForm(KPFormCustomization kpfc)
 {
     m_prev.Controls.Clear();
     m_prev.CopyForm(kpfc.FormEnglish);
     kpfc.ApplyTo(m_prev);
 }