Ejemplo n.º 1
0
        private void HandleURLFields()
        {
            #region URL context menu
            tsmiOpen.Text   = KPRes.OpenCmd;
            tsmiOpen.Image  = (Image)Program.Resources.GetObject("B16x16_FTP");
            tsmiOpen.Click += OnOpenUrl;
            ctxOpenWith.Items.Insert(0, tsmiOpen);
            Dictionary <string, string> translations = Program.Translation.SafeGetStringTableDictionary("KeePass.Forms.MainForm.m_ctxPwList");
            string translated = string.Empty;
            if (translations.TryGetValue("m_ctxEntryCopyUrl", out translated))
            {
                tsmiCopy.Text = translated;
            }
            else
            {
                tsmiCopy.Text = KPRes.Copy;
            }
            tsmiCopy.Image  = (Image)Program.Resources.GetObject("B16x16_EditCopyUrl");
            tsmiCopy.Click += OnCopyUrl;
            ctxOpenWith.Items.Insert(1, tsmiCopy);

            #region Add additional "Open with" entries
            ToolStripMenuItem tsmiOpenWith = new ToolStripMenuItem();
            m_dynOpenUrl = new OpenWithMenu(tsmiOpenWith);
            //Show dropdown to have the entries created
            try
            {
                //Use reflection first
                //Use 'ShowDropDown' as fallback, won't work on Mono
                MethodInfo mi_OnMenuOpening = m_dynOpenUrl.GetType().GetMethod("OnMenuOpening", BindingFlags.Instance | BindingFlags.NonPublic);
                if (mi_OnMenuOpening != null)
                {
                    mi_OnMenuOpening.Invoke(m_dynOpenUrl, new object[] { null, null });
                }
                else
                {
                    tsmiOpenWith.ShowDropDown();
                    tsmiOpenWith.HideDropDown();
                }
            }
            catch { }
            while (tsmiOpenWith.DropDownItems.Count > 0)
            {
                ToolStripItem x = tsmiOpenWith.DropDownItems[0];
                tsmiOpenWith.DropDownItems.Remove(x);
                if (!string.IsNullOrEmpty(m_pcadata.URL2) && (x is ToolStripMenuItem))
                {
                    ToolStripMenuItem newItem = new ToolStripMenuItem(x.Text, x.Image);
                    newItem.Tag    = x.Tag;
                    newItem.Click += OnOpenUrl;
                    x              = newItem;
                }
                ctxOpenWith.Items.Add(x);
            }
            ;
            tsmiOpenWith.Dispose();
            #endregion
            #endregion

            lURL.Links.Clear();
            lURL.Text = KPRes.Url + ": " + KPRes.Empty;
            if (!string.IsNullOrEmpty(m_pcadata.URL))
            {
                string url = CompileUrl(m_pcadata.URL);
                lURL.Links.Add(KPRes.Url.Length + 2, m_pcadata.URL.Length, m_pcadata.URL);
                lURL.Text = KPRes.Url + ": " + GetDisplayUrl(m_pcadata.URL, 60);
            }

            lURL2.Links.Clear();
            lURL2.Text   = KPRes.Url + ": ";
            tbURL2.Left  = lURL2.Left + lURL2.Width;
            tbURL2.Width = ClientSize.Width - tbURL2.Left - lURL2.Left;
            if (!string.IsNullOrEmpty(m_pcadata.URL2))
            {
                tbURL2.Text = m_pcadata.URL2;
            }
        }
Ejemplo n.º 2
0
 void _clear_Click(object sender, EventArgs e)
 {
     Clear();
     menu.HideDropDown();
 }