private static ContextMenuStrip Construct() { CustomContextMenuStripEx ctx = new CustomContextMenuStripEx(); // Clone the image list in order to prevent event handlers // from the global client icons list to the context menu ctx.ImageList = UIUtil.CloneImageList(Program.MainForm.ClientIcons, true); bool bAppendSeparator = false; foreach(PwDocument ds in Program.MainForm.DocumentManager.Documents) { if(ds.Database.IsOpen) { if(bAppendSeparator) ctx.Items.Add(new ToolStripSeparator()); foreach(PwGroup pg in ds.Database.RootGroup.Groups) { ToolStripMenuItem tsmi = MenuCreateGroup(ds, pg); ctx.Items.Add(tsmi); MenuProcessGroup(ds, tsmi, pg); } bAppendSeparator = true; } } GlobalWindowManager.CustomizeControl(ctx); return ctx; }
private ContextMenuStrip CreateContextMenu() { CustomContextMenuStripEx ctx = new CustomContextMenuStripEx(); int iPos = -1; m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Undo, Properties.Resources.B16x16_Undo, this.OnUndoCommand); ctx.Items.Add(new ToolStripSeparator()); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Cut, Properties.Resources.B16x16_Cut, this.OnCutCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Copy, Properties.Resources.B16x16_EditCopy, this.OnCopyCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Paste, Properties.Resources.B16x16_EditPaste, this.OnPasteCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Delete, Properties.Resources.B16x16_EditDelete, this.OnDeleteCommand); ctx.Items.Add(new ToolStripSeparator()); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.CopyLink, Properties.Resources.B16x16_EditCopyLink, this.OnCopyLinkCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.CopyAll, Properties.Resources.B16x16_EditShred, this.OnCopyAllCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.SelectAll, Properties.Resources.B16x16_Edit, this.OnSelectAllCommand); Debug.Assert(iPos == ((int)RtbCtxCommands.Count - 1)); return(ctx); }
private void DisposeContextMenu() { if (m_ctx != null) { m_ctx.Dispose(); m_ctx = null; } }
private void ConstructContextMenu() { DisposeContextMenu(); m_ctx = new CustomContextMenuStripEx(); m_ctx.SuspendLayout(); m_ctx.Items.AddRange(ConstructMenuItems().ToArray()); m_ctx.ResumeLayout(true); }
public void Attach(RichTextBox rtb, Form fParent) { Detach(); m_rtb = rtb; m_form = fParent; m_ctx = CreateContextMenu(); m_ctx.Opening += this.OnMenuOpening; m_rtb.ContextMenuStrip = m_ctx; }
public void Attach(RichTextBox rtb, Form fParent) { Detach(); m_rtb = rtb; m_form = fParent; m_ctx = CreateContextMenu(); m_ctx.Opening += this.OnMenuOpening; GlobalWindowManager.CustomizeControl(m_ctx); m_rtb.ContextMenuStrip = m_ctx; }
public void Detach() { if (m_rtb != null) { m_rtb.ContextMenuStrip = null; m_ctx.Opening -= this.OnMenuOpening; m_ctx = null; for (int i = 0; i < (int)RtbCtxCommands.Count; ++i) { m_vMenuItems[i] = null; } m_rtb = null; m_form = null; } }
private void RecreateToolsContextMenu() { DestroyToolsContextMenu(); m_ctxTools = new CustomContextMenuStripEx(); m_tsmiColumns = new ToolStripMenuItem(KPRes.Columns); m_ctxTools.Items.Add(m_tsmiColumns); long lFlags = Program.Config.UI.AutoTypeCtxFlags; ToolStripMenuItem tsmi = new ToolStripMenuItem(KPRes.Title); UIUtil.SetChecked(tsmi, true); tsmi.Tag = AceAutoTypeCtxFlags.ColTitle; tsmi.Click += this.OnToggleColumn; tsmi.Enabled = false; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.UserName); UIUtil.SetChecked(tsmi, ((lFlags & (long)AceAutoTypeCtxFlags.ColUserName) != 0)); tsmi.Tag = AceAutoTypeCtxFlags.ColUserName; tsmi.Click += this.OnToggleColumn; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Password); UIUtil.SetChecked(tsmi, (((lFlags & (long)AceAutoTypeCtxFlags.ColPassword) != 0) && m_bCanShowPasswords)); tsmi.Tag = AceAutoTypeCtxFlags.ColPassword; tsmi.Click += this.OnToggleColumn; if(!m_bCanShowPasswords) tsmi.Enabled = false; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Url); UIUtil.SetChecked(tsmi, ((lFlags & (long)AceAutoTypeCtxFlags.ColUrl) != 0)); tsmi.Tag = AceAutoTypeCtxFlags.ColUrl; tsmi.Click += this.OnToggleColumn; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Notes); UIUtil.SetChecked(tsmi, ((lFlags & (long)AceAutoTypeCtxFlags.ColNotes) != 0)); tsmi.Tag = AceAutoTypeCtxFlags.ColNotes; tsmi.Click += this.OnToggleColumn; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Sequence + " - " + KPRes.Comments); UIUtil.SetChecked(tsmi, ((lFlags & (long)AceAutoTypeCtxFlags.ColSequenceComments) != 0)); tsmi.Tag = AceAutoTypeCtxFlags.ColSequenceComments; tsmi.Click += this.OnToggleColumn; m_tsmiColumns.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Sequence); UIUtil.SetChecked(tsmi, ((lFlags & (long)AceAutoTypeCtxFlags.ColSequence) != 0)); tsmi.Tag = AceAutoTypeCtxFlags.ColSequence; tsmi.Click += this.OnToggleColumn; m_tsmiColumns.DropDownItems.Add(tsmi); }
private void DestroyToolsContextMenu() { if(m_ctxTools == null) return; foreach(ToolStripItem tsi in m_tsmiColumns.DropDownItems) tsi.Click -= this.OnToggleColumn; m_tsmiColumns = null; m_ctxTools.Dispose(); m_ctxTools = null; }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pwEntry != null); if(m_pwEntry == null) throw new InvalidOperationException(); Debug.Assert(m_pwEditMode != PwEditMode.Invalid); if(m_pwEditMode == PwEditMode.Invalid) throw new ArgumentException(); Debug.Assert(m_pwDatabase != null); if(m_pwDatabase == null) throw new InvalidOperationException(); Debug.Assert(m_ilIcons != null); if(m_ilIcons == null) throw new InvalidOperationException(); m_bInitializing = true; GlobalWindowManager.AddWindow(this); GlobalWindowManager.CustomizeControl(m_ctxTools); GlobalWindowManager.CustomizeControl(m_ctxPwGen); GlobalWindowManager.CustomizeControl(m_ctxStrMoveToStandard); m_pwInitialEntry = m_pwEntry.CloneDeep(); StrUtil.NormalizeNewLines(m_pwInitialEntry.Strings, true); m_ttRect.SetToolTip(m_btnIcon, KPRes.SelectIcon); // m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnGenPw, KPRes.GeneratePassword); m_ttRect.SetToolTip(m_btnStandardExpires, KPRes.StandardExpireSelect); m_ttBalloon.SetToolTip(m_tbRepeatPassword, KPRes.PasswordRepeatHint); m_dynGenProfiles = new DynamicMenu(m_ctxPwGen.Items); m_dynGenProfiles.MenuClick += this.OnProfilesDynamicMenuClick; m_ctxNotes.Attach(m_rtNotes, this); m_ctxBinOpen = new CustomContextMenuStripEx(); m_ctxBinOpen.Opening += this.OnCtxBinOpenOpening; m_dynBinOpen = new DynamicMenu(m_ctxBinOpen.Items); m_dynBinOpen.MenuClick += this.OnDynBinOpen; m_btnBinOpen.SplitDropDownMenu = m_ctxBinOpen; string strTitle = string.Empty, strDesc = string.Empty; if(m_pwEditMode == PwEditMode.AddNewEntry) { strTitle = KPRes.AddEntry; strDesc = KPRes.AddEntryDesc; } else if(m_pwEditMode == PwEditMode.EditExistingEntry) { strTitle = KPRes.EditEntry; strDesc = KPRes.EditEntryDesc; } else if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { strTitle = KPRes.ViewEntry; strDesc = KPRes.ViewEntryDesc; } else { Debug.Assert(false); } BannerFactory.CreateBannerEx(this, m_bannerImage, KeePass.Properties.Resources.B48x48_KGPG_Sign, strTitle, strDesc); this.Icon = Properties.Resources.KeePass; this.Text = strTitle; m_imgPwGen = UIUtil.CreateDropDownImage(Properties.Resources.B16x16_Key_New); m_imgStdExpire = UIUtil.CreateDropDownImage(Properties.Resources.B16x16_History); UIUtil.SetButtonImage(m_btnTools, Properties.Resources.B16x16_Package_Settings, true); UIUtil.SetButtonImage(m_btnGenPw, m_imgPwGen, true); UIUtil.SetButtonImage(m_btnStandardExpires, m_imgStdExpire, true); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) m_bLockEnabledState = true; // UIUtil.SetExplorerTheme(m_lvStrings, true); // UIUtil.SetExplorerTheme(m_lvBinaries, true); // UIUtil.SetExplorerTheme(m_lvAutoType, true); // UIUtil.SetExplorerTheme(m_lvHistory, true); UIUtil.PrepareStandardMultilineControl(m_rtNotes, true, true); bool bForceHide = !AppPolicy.Current.UnhidePasswords; if(Program.Config.UI.Hiding.SeparateHidingSettings) m_cbHidePassword.Checked = (Program.Config.UI.Hiding.HideInEntryWindow || bForceHide); else { AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); m_cbHidePassword.Checked = (((colPw != null) ? colPw.HideWithAsterisks : true) || bForceHide); } InitEntryTab(); InitAdvancedTab(); InitPropertiesTab(); InitAutoTypeTab(); InitHistoryTab(); UpdateEntryStrings(false, true, false); UpdateEntryBinaries(false, false); if(PwDefs.IsTanEntry(m_pwEntry)) m_btnTools.Enabled = false; CustomizeForScreenReader(); m_bInitializing = false; if(m_bInitSwitchToHistory) // Before 'Advanced' tab switch m_tabMain.SelectedTab = m_tabHistory; else if(m_bShowAdvancedByDefault) m_tabMain.SelectedTab = m_tabAdvanced; ResizeColumnHeaders(); EnableControlsEx(); ThreadPool.QueueUserWorkItem(delegate(object state) { try { InitOverridesBox(); } catch(Exception) { Debug.Assert(false); } }); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) m_btnCancel.Select(); else { if(m_bSelectFullTitle) m_tbTitle.Select(0, m_tbTitle.TextLength); else m_tbTitle.Select(0, 0); m_tbTitle.Select(); } }
private ContextMenuStrip CreateContextMenu() { CustomContextMenuStripEx ctx = new CustomContextMenuStripEx(); int iPos = -1; m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Undo, Properties.Resources.B16x16_Undo, this.OnUndoCommand); ctx.Items.Add(new ToolStripSeparator()); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Cut, Properties.Resources.B16x16_Cut, this.OnCutCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Copy, Properties.Resources.B16x16_EditCopy, this.OnCopyCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Paste, Properties.Resources.B16x16_EditPaste, this.OnPasteCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.Delete, Properties.Resources.B16x16_EditDelete, this.OnDeleteCommand); ctx.Items.Add(new ToolStripSeparator()); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.CopyLink, Properties.Resources.B16x16_EditCopyLink, this.OnCopyLinkCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.CopyAll, Properties.Resources.B16x16_EditShred, this.OnCopyAllCommand); m_vMenuItems[++iPos] = ctx.Items.Add(KPRes.SelectAll, Properties.Resources.B16x16_Edit, this.OnSelectAllCommand); Debug.Assert(iPos == ((int)RtbCtxCommands.Count - 1)); return ctx; }