private void AddMenuItem(ToolStripMenuItem tsmiParent, MruMenuItemType t, string strText, Image img, object oTag, bool bEnabled, ref uint uAccessKey) { ToolStripMenuItem tsmi = CreateMenuItem(t, strText, img, oTag, bEnabled, uAccessKey); tsmiParent.DropDownItems.Add(tsmi); if (t == MruMenuItemType.Item) { m_lMruMenuItems.Add(tsmi); } else if (t == MruMenuItemType.Clear) { Debug.Assert(m_tsmiClear == null); m_tsmiClear = tsmi; } if (uAccessKey != 0) { ++uAccessKey; } }
private ToolStripMenuItem CreateMenuItem(MruMenuItemType t, string strText, Image img, object oTag, bool bEnabled, uint uAccessKey) { string strItem = strText; if (uAccessKey >= 1) { NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo; if (uAccessKey < 10) { strItem = @"&" + uAccessKey.ToString(nfi) + " " + strItem; } else if (uAccessKey == 10) { strItem = @"1&0 " + strItem; } else { strItem = uAccessKey.ToString(nfi) + " " + strItem; } } ToolStripMenuItem tsmi = new ToolStripMenuItem(strItem); if (img != null) { tsmi.Image = img; } if (oTag != null) { tsmi.Tag = oTag; } IOConnectionInfo ioc = (oTag as IOConnectionInfo); if (m_bMarkOpened && (ioc != null) && (Program.MainForm != null)) { foreach (PwDatabase pd in Program.MainForm.DocumentManager.GetOpenDatabases()) { if (pd.IOConnectionInfo.GetDisplayName().Equals( ioc.GetDisplayName(), StrUtil.CaseIgnoreCmp)) { // if(m_fItalic == null) // { // Font f = tsi.Font; // if(f != null) // m_fItalic = FontUtil.CreateFont(f, FontStyle.Italic); // else { Debug.Assert(false); } // } // if(m_fItalic != null) tsmi.Font = m_fItalic; // 153, 51, 153 tsmi.ForeColor = Color.FromArgb(64, 64, 255); tsmi.Text += " [" + KPRes.Opened + "]"; break; } } } if (t == MruMenuItemType.Item) { tsmi.Click += this.ClickHandler; } else if (t == MruMenuItemType.Clear) { tsmi.Click += this.ClearHandler; } // t == MruMenuItemType.None needs no handler if (!bEnabled) { tsmi.Enabled = false; } return(tsmi); }
private ToolStripMenuItem CreateMenuItem(MruMenuItemType t, string strText, Image img, object oTag, bool bEnabled, uint uAccessKey) { string strItem = strText; if(uAccessKey >= 1) { NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo; if(uAccessKey < 10) strItem = @"&" + uAccessKey.ToString(nfi) + " " + strItem; else if(uAccessKey == 10) strItem = @"1&0 " + strItem; else strItem = uAccessKey.ToString(nfi) + " " + strItem; } ToolStripMenuItem tsmi = new ToolStripMenuItem(strItem); if(img != null) tsmi.Image = img; if(oTag != null) tsmi.Tag = oTag; IOConnectionInfo ioc = (oTag as IOConnectionInfo); if(m_bMarkOpened && (ioc != null) && (Program.MainForm != null)) { foreach(PwDatabase pd in Program.MainForm.DocumentManager.GetOpenDatabases()) { if(pd.IOConnectionInfo.GetDisplayName().Equals( ioc.GetDisplayName(), StrUtil.CaseIgnoreCmp)) { // if(m_fItalic == null) // { // Font f = tsi.Font; // if(f != null) // m_fItalic = FontUtil.CreateFont(f, FontStyle.Italic); // else { Debug.Assert(false); } // } // if(m_fItalic != null) tsmi.Font = m_fItalic; // 153, 51, 153 tsmi.ForeColor = Color.FromArgb(64, 64, 255); tsmi.Text += " [" + KPRes.Opened + "]"; break; } } } if(t == MruMenuItemType.Item) tsmi.Click += this.ClickHandler; else if(t == MruMenuItemType.Clear) tsmi.Click += this.ClearHandler; // t == MruMenuItemType.None needs no handler if(!bEnabled) tsmi.Enabled = false; return tsmi; }
private void AddMenuItem(ToolStripMenuItem tsmiParent, MruMenuItemType t, string strText, Image img, object oTag, bool bEnabled, ref uint uAccessKey) { ToolStripMenuItem tsmi = CreateMenuItem(t, strText, img, oTag, bEnabled, uAccessKey); tsmiParent.DropDownItems.Add(tsmi); if(t == MruMenuItemType.Item) m_lMruMenuItems.Add(tsmi); else if(t == MruMenuItemType.Clear) { Debug.Assert(m_tsmiClear == null); m_tsmiClear = tsmi; } if(uAccessKey != 0) ++uAccessKey; }