private void OnFormLoad(object sender, EventArgs e) { m_bFormLoading = true; GlobalWindowManager.CustomizeControl(this); GlobalWindowManager.CustomizeControl(m_ctxTray); m_strNeverExpiresText = KPRes.NeverExpires; this.Text = PwDefs.ProductName; this.Icon = Properties.Resources.KeePass; m_imgFileSaveEnabled = Properties.Resources.B16x16_FileSave; m_imgFileSaveDisabled = Properties.Resources.B16x16_FileSave_Disabled; // m_imgFileSaveAllEnabled = Properties.Resources.B16x16_File_SaveAll; // m_imgFileSaveAllDisabled = Properties.Resources.B16x16_File_SaveAll_Disabled; m_ilCurrentIcons = m_ilClientIcons; m_ctxEntryOpenUrl.Text = KPRes.OpenCmd; m_ntfTray = new NotifyIconEx(this.components); m_ntfTray.ContextMenuStrip = m_ctxTray; m_ntfTray.Visible = true; m_ntfTray.SetHandlers(OnSystemTrayClick, OnSystemTrayDoubleClick, OnSystemTrayMouseDown); m_ctxTrayTray.Font = FontUtil.CreateFont(m_ctxTrayTray.Font, FontStyle.Bold); m_nLockTimerMax = (int)Program.Config.Security.WorkspaceLocking.LockAfterTime; m_nClipClearMax = Program.Config.Security.ClipboardClearAfterSeconds; NativeLib.AllowNative = Program.Config.Native.NativeKeyTransformations; m_ctxEntryPreviewContextMenu.Attach(m_richEntryView, this); m_dynCustomStrings = new DynamicMenu(m_ctxEntryCopyCustomString.DropDownItems); m_dynCustomStrings.MenuClick += this.OnCopyCustomString; m_dynCustomBinaries = new DynamicMenu(m_ctxEntryAttachments.DropDownItems); m_dynCustomBinaries.MenuClick += this.OnEntryBinaryView; m_dynShowEntriesByTagsEditMenu = new DynamicMenu(m_menuEditShowByTag.DropDownItems); m_dynShowEntriesByTagsEditMenu.MenuClick += this.OnShowEntriesByTag; m_dynShowEntriesByTagsToolBar = new DynamicMenu(m_tbEntryViewsDropDown.DropDownItems); m_dynShowEntriesByTagsToolBar.MenuClick += this.OnShowEntriesByTag; m_dynAddTag = new DynamicMenu(m_ctxEntrySelectedAddTag.DropDownItems); m_dynAddTag.MenuClick += this.OnAddEntryTag; m_dynRemoveTag = new DynamicMenu(m_ctxEntrySelectedRemoveTag.DropDownItems); m_dynRemoveTag.MenuClick += this.OnRemoveEntryTag; m_dynOpenUrl = new OpenWithMenu(m_ctxEntryUrl); EntryTemplates.Init(m_tbAddEntry); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntrySelectAll, new EventHandler(OnEntrySelectAll), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntryDelete, new EventHandler(OnEntryDelete), true); InsertToolStripItem(m_menuEdit, m_ctxEntryDuplicate, new EventHandler(OnEntryDuplicate), true); InsertToolStripItem(m_menuEdit, m_ctxEntryEdit, new EventHandler(OnEntryEdit), true); InsertToolStripItem(m_menuEdit, m_ctxEntryAdd, new EventHandler(OnEntryAdd), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxGroupDelete, new EventHandler(OnGroupsDelete), true); InsertToolStripItem(m_menuEdit, m_ctxGroupEdit, new EventHandler(OnGroupsEdit), true); InsertToolStripItem(m_menuEdit, m_ctxGroupAdd, new EventHandler(OnGroupsAdd), true); UIUtil.ConfigureTbButton(m_tbNewDatabase, KPRes.ToolBarNew, null); UIUtil.ConfigureTbButton(m_tbOpenDatabase, KPRes.ToolBarOpen, null); UIUtil.ConfigureTbButton(m_tbSaveDatabase, KPRes.Save, null); UIUtil.ConfigureTbButton(m_tbSaveAll, KPRes.ToolBarSaveAll, null); UIUtil.ConfigureTbButton(m_tbAddEntry, KPRes.AddEntry, null); UIUtil.ConfigureTbButton(m_tbAddEntryDefault, KPRes.AddEntryBtn, null); UIUtil.ConfigureTbButton(m_tbCopyUserName, KPRes.CopyUserFull, null); UIUtil.ConfigureTbButton(m_tbCopyPassword, KPRes.CopyPasswordFull, null); UIUtil.ConfigureTbButton(m_tbFind, KPRes.Find + "...", null); UIUtil.ConfigureTbButton(m_tbEntryViewsDropDown, null, KPRes.ShowEntries); UIUtil.ConfigureTbButton(m_tbViewsShowAll, KPRes.ShowAllEntries, null); UIUtil.ConfigureTbButton(m_tbViewsShowExpired, KPRes.ShowExpiredEntries, null); UIUtil.ConfigureTbButton(m_tbLockWorkspace, KPRes.LockMenuLock, null); UIUtil.ConfigureTbButton(m_tbQuickFind, null, KPRes.SearchQuickPrompt + " (" + KPRes.KeyboardKeyCtrl + "+E)"); UIUtil.ConfigureTbButton(m_tbCloseTab, StrUtil.RemoveAccelerator( KPRes.CloseButton), null); UIUtil.EnableAutoCompletion(m_tbQuickFind, false); bool bVisible = Program.Config.MainWindow.ToolBar.Show; m_toolMain.Visible = bVisible; m_menuViewShowToolBar.Checked = bVisible; // Make a copy of the maximized setting (the configuration item might // get changed when the window's position/size is restored) bool bMaximizedSetting = Program.Config.MainWindow.Maximized; int wndX = Program.Config.MainWindow.X; int wndY = Program.Config.MainWindow.Y; int sizeX = Program.Config.MainWindow.Width; int sizeY = Program.Config.MainWindow.Height; bool bWndValid = ((wndX != -32000) && (wndY != -32000) && (wndX != -64000) && (wndY != -64000)); if((sizeX != AppDefs.InvalidWindowValue) && (sizeY != AppDefs.InvalidWindowValue) && bWndValid) this.Size = new Size(sizeX, sizeY); Rectangle rectRestWindow = new Rectangle(wndX, wndY, this.Size.Width, this.Size.Height); bool bWndPartVisible = UIUtil.IsScreenAreaVisible(rectRestWindow); if((wndX != AppDefs.InvalidWindowValue) && (wndY != AppDefs.InvalidWindowValue) && bWndValid && bWndPartVisible) { this.Location = new Point(wndX, wndY); } else { Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea; this.Location = new Point((rectScreen.Width - this.Size.Width) / 2, (rectScreen.Height - this.Size.Height) / 2); } SetMainWindowLayout(Program.Config.MainWindow.Layout == AceMainWindowLayout.SideBySide); ShowEntryView(Program.Config.MainWindow.EntryView.Show); UpdateColumnsEx(false); AceMainWindow mw = Program.Config.MainWindow; m_menuViewTanSimpleList.Checked = m_bSimpleTanView = mw.TanView.UseSimpleView; m_menuViewTanIndices.Checked = m_bShowTanIndices = mw.TanView.ShowIndices; m_menuViewShowEntriesOfSubGroups.Checked = Program.Config.MainWindow.ShowEntriesOfSubGroups; m_pListSorter = Program.Config.MainWindow.ListSorting; if((m_pListSorter.Column >= 0) && (m_pListSorter.Order != SortOrder.None)) m_lvEntries.ListViewItemSorter = m_pListSorter; else m_pListSorter = new ListSorter(); m_lvsmMenu = new ListViewSortMenu(m_menuViewSortBy, m_lvEntries, new SortCommandHandler(this.SortPasswordList)); m_menuViewAlwaysOnTop.Checked = mw.AlwaysOnTop; OnViewAlwaysOnTop(null, null); m_mruList.Initialize(this, m_menuFileRecent, m_menuFileSyncRecent); SerializeMruList(false); SetListFont(Program.Config.UI.StandardFont); m_ctxEntryColorLightRed.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightRed); m_ctxEntryColorLightGreen.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightGreen); m_ctxEntryColorLightBlue.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightBlue); m_ctxEntryColorLightYellow.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightYellow); // m_lvEntries.GridLines = mw.ShowGridLines; if(UIUtil.VistaStyleListsSupported) { // m_tvGroups.ItemHeight += 1; m_tvGroups.ShowRootLines = false; m_tvGroups.ShowLines = false; UIUtil.SetExplorerTheme(m_tvGroups.Handle); UIUtil.SetExplorerTheme(m_lvEntries.Handle); } m_clrAlternateItemBgColor = UIUtil.GetAlternateColor(m_lvEntries.BackColor); m_statusPartProgress.Visible = false; if(bMaximizedSetting) { if((this.WindowState == FormWindowState.Normal) && !IsTrayed()) UIUtil.SetWindowState(this, FormWindowState.Maximized); } try { float fSplitPos = mw.SplitterHorizontalFrac; if(fSplitPos == float.Epsilon) fSplitPos = 0.8333f; m_splitHorizontal.SplitterDistance = (int)Math.Round(fSplitPos * (double)m_splitHorizontal.Height); fSplitPos = mw.SplitterVerticalFrac; if(fSplitPos == float.Epsilon) fSplitPos = 0.25f; m_splitVertical.SplitterDistance = (int)Math.Round(fSplitPos * (double)m_splitVertical.Width); } catch(Exception) { Debug.Assert(false); } string strSearchTr = ((WinUtil.IsAtLeastWindowsVista ? string.Empty : " ") + KPRes.Search); UIUtil.SetCueBanner(m_tbQuickFind, strSearchTr); #if DEBUG Program.Config.CustomConfig.SetBool("TestItem", true); Program.KeyProviderPool.Add(new KeePassLib.Keys.SampleKeyProvider()); #endif m_sessionLockNotifier.Install(this.OnSessionLock); IpcBroadcast.StartServer(); int nInitColProvCount = Program.ColumnProviderPool.Count; m_pluginDefaultHost.Initialize(this, Program.CommandLineArgs, CipherPool.GlobalPool); m_pluginManager.Initialize(m_pluginDefaultHost); m_pluginManager.UnloadAllPlugins(); if(AppPolicy.Current.Plugins) m_pluginManager.LoadAllPlugins(UrlUtil.GetFileDirectory( WinUtil.GetExecutable(), false, true)); // Delete old files *after* loading plugins (when timestamps // of loaded plugins have been updated already) if(Program.Config.Application.Start.PluginCacheDeleteOld) PlgxCache.DeleteOldFilesAsync(); if(Program.ColumnProviderPool.Count != nInitColProvCount) UpdateColumnsEx(false); HotKeyManager.Initialize(this); Keys kAutoTypeKey = (Keys)Program.Config.Integration.HotKeyGlobalAutoType; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.AutoType, kAutoTypeKey); Keys kAutoTypeSelKey = (Keys)Program.Config.Integration.HotKeySelectedAutoType; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.AutoTypeSelected, kAutoTypeSelKey); Keys kShowWindowKey = (Keys)Program.Config.Integration.HotKeyShowWindow; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.ShowWindow, kShowWindowKey); Keys kEntryMenuKey = (Keys)Program.Config.Integration.HotKeyEntryMenu; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.EntryMenu, kEntryMenuKey); m_statusClipboard.Visible = false; UpdateClipboardStatus(); UpdateTrayIcon(); UpdateTagsMenu(m_dynShowEntriesByTagsEditMenu, false, false, false, false); // Ensure popup arrow UpdateTagsMenu(m_dynRemoveTag, false, false, false, false); UpdateUIState(false); ApplyUICustomizations(); ThreadPool.QueueUserWorkItem(new WaitCallback(OnFormLoadParallelAsync)); Program.TriggerSystem.RaiseEvent(EcasEventIDs.AppInitPost); if(Program.CommandLineArgs.FileName != null) OpenDatabase(IocFromCommandLine(), KeyUtil.KeyFromCommandLine( Program.CommandLineArgs), false); else if(Program.Config.Application.Start.OpenLastFile) { IOConnectionInfo ioLastFile = Program.Config.Application.LastUsedFile; if(ioLastFile.Path.Length > 0) OpenDatabase(ioLastFile, null, false); } if(Program.Config.Application.Start.CheckForUpdate) CheckForUpdate.StartAsync(PwDefs.VersionUrl, m_statusPartInfo); ResetDefaultFocus(null); MinimizeToTrayAtStartIfEnabled(true); m_bFormLoading = false; NotifyUserActivity(); // Initialize locking timeout Program.TriggerSystem.RaiseEvent(EcasEventIDs.AppLoadPost); }
private void SortPasswordList(bool bEnableSorting, int nColumn, SortOrder? soForce, bool bUpdateEntryList) { AceColumnType colType = GetAceColumn(nColumn).Type; if(bEnableSorting) { bool bSortTimes = AceColumn.IsTimeColumn(colType); bool bSortNaturally = (colType != AceColumnType.Uuid); int nOldColumn = m_pListSorter.Column; SortOrder sortOrder = m_pListSorter.Order; if(soForce.HasValue) sortOrder = soForce.Value; else if(nColumn == nOldColumn) { if(sortOrder == SortOrder.None) sortOrder = SortOrder.Ascending; else if(sortOrder == SortOrder.Ascending) sortOrder = SortOrder.Descending; else if(sortOrder == SortOrder.Descending) sortOrder = SortOrder.None; else { Debug.Assert(false); } } else sortOrder = SortOrder.Ascending; if(sortOrder != SortOrder.None) { m_pListSorter = new ListSorter(nColumn, sortOrder, bSortNaturally, bSortTimes); m_lvEntries.ListViewItemSorter = m_pListSorter; // Workaround for XP bug if(bUpdateEntryList && !KeePassLib.Native.NativeLib.IsUnix() && WinUtil.IsWindowsXP) UpdateEntryList(null, true); // Only required on XP } else { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } } else // Disable sorting { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } UpdateColumnSortingIcons(); UIUtil.SetAlternatingBgColors(m_lvEntries, m_clrAlternateItemBgColor, Program.Config.MainWindow.EntryListAlternatingBgColors); UpdateUI(false, null, false, null, false, null, false); // KPB 1134 }
private void UpdateMenu(object sender, EventArgs e) { if (m_lv == null) { Debug.Assert(false); return; } DeleteMenuItems(); IComparer icSorter = m_lv.ListViewItemSorter; ListSorter ls = ((icSorter != null) ? (icSorter as ListSorter) : null); if (ls != null) { m_iCurSortColumn = ls.Column; m_bCurSortAsc = (ls.Order != SortOrder.Descending); if ((ls.Order == SortOrder.None) || (m_iCurSortColumn >= m_lv.Columns.Count)) { m_iCurSortColumn = -1; } } else { m_iCurSortColumn = -1; } m_tsmiNoSort = new ToolStripMenuItem(KPRes.NoSort); if (m_iCurSortColumn < 0) { UIUtil.SetRadioChecked(m_tsmiNoSort, true); } m_tsmiNoSort.Click += this.OnNoSort; m_tsmiMenu.DropDownItems.Add(m_tsmiNoSort); m_tssSep0 = new ToolStripSeparator(); m_tsmiMenu.DropDownItems.Add(m_tssSep0); m_vColumns = new List <ToolStripMenuItem>(); foreach (ColumnHeader ch in m_lv.Columns) { string strText = (ch.Text ?? string.Empty); strText = StrUtil.EncodeMenuText(strText); ToolStripMenuItem tsmi = new ToolStripMenuItem(strText); if (ch.Index == m_iCurSortColumn) { UIUtil.SetRadioChecked(tsmi, true); } tsmi.Click += this.OnSortColumn; m_vColumns.Add(tsmi); m_tsmiMenu.DropDownItems.Add(tsmi); } m_tssSep1 = new ToolStripSeparator(); m_tsmiMenu.DropDownItems.Add(m_tssSep1); m_tsmiAsc = new ToolStripMenuItem(KPRes.Ascending); if ((m_iCurSortColumn >= 0) && m_bCurSortAsc) { UIUtil.SetRadioChecked(m_tsmiAsc, true); } m_tsmiAsc.Click += this.OnSortAscDesc; if (m_iCurSortColumn < 0) { m_tsmiAsc.Enabled = false; } m_tsmiMenu.DropDownItems.Add(m_tsmiAsc); m_tsmiDesc = new ToolStripMenuItem(KPRes.Descending); if ((m_iCurSortColumn >= 0) && !m_bCurSortAsc) { UIUtil.SetRadioChecked(m_tsmiDesc, true); } m_tsmiDesc.Click += this.OnSortAscDesc; if (m_iCurSortColumn < 0) { m_tsmiDesc.Enabled = false; } m_tsmiMenu.DropDownItems.Add(m_tsmiDesc); }
private void OnFormLoad(object sender, EventArgs e) { if(m_bFormLoadCalled && MonoWorkarounds.IsRequired(3574233558U)) return; m_bFormLoadCalled = true; m_bFormLoaded = false; GlobalWindowManager.CustomizeControl(this); GlobalWindowManager.CustomizeControl(m_ctxTray); m_strNeverExpiresText = KPRes.NeverExpires; this.Text = PwDefs.ShortProductName; this.Icon = Properties.Resources.KeePass; m_imgFileSaveEnabled = Properties.Resources.B16x16_FileSave; m_imgFileSaveDisabled = Properties.Resources.B16x16_FileSave_Disabled; // m_imgFileSaveAllEnabled = Properties.Resources.B16x16_File_SaveAll; // m_imgFileSaveAllDisabled = Properties.Resources.B16x16_File_SaveAll_Disabled; // m_ilCurrentIcons = m_ilClientIcons; UpdateImageLists(true); m_ctxEntryOpenUrl.Text = KPRes.OpenCmd; m_ntfTray = new NotifyIconEx(this.components); m_ntfTray.ContextMenuStrip = m_ctxTray; m_ntfTray.Visible = true; m_ntfTray.SetHandlers(this.OnSystemTrayClick, this.OnSystemTrayDoubleClick, this.OnSystemTrayMouseDown); m_ctxTrayTray.Font = FontUtil.CreateFont(m_ctxTrayTray.Font, FontStyle.Bold); m_nLockTimerMax = (int)Program.Config.Security.WorkspaceLocking.LockAfterTime; m_nClipClearMax = Program.Config.Security.ClipboardClearAfterSeconds; NativeLib.AllowNative = Program.Config.Native.NativeKeyTransformations; m_ctxEntryPreviewContextMenu.Attach(m_richEntryView, this); m_dynCustomStrings = new DynamicMenu(m_ctxEntryCopyString.DropDownItems); m_dynCustomStrings.MenuClick += this.OnCopyCustomString; m_dynCustomBinaries = new DynamicMenu(m_ctxEntryAttachments.DropDownItems); m_dynCustomBinaries.MenuClick += this.OnEntryBinaryOpen; m_dynShowEntriesByTagsEditMenu = new DynamicMenu(m_menuEditShowByTag.DropDownItems); m_dynShowEntriesByTagsEditMenu.MenuClick += this.OnShowEntriesByTag; m_dynShowEntriesByTagsToolBar = new DynamicMenu(m_tbEntryViewsDropDown.DropDownItems); m_dynShowEntriesByTagsToolBar.MenuClick += this.OnShowEntriesByTag; m_dynAddTag = new DynamicMenu(m_ctxEntrySelectedAddTag.DropDownItems); m_dynAddTag.MenuClick += this.OnAddEntryTag; m_dynRemoveTag = new DynamicMenu(m_ctxEntrySelectedRemoveTag.DropDownItems); m_dynRemoveTag.MenuClick += this.OnRemoveEntryTag; m_dynMoveToGroup = new DynamicMenu(m_ctxEntryMoveToGroup.DropDownItems); m_dynMoveToGroup.MenuClick += this.OnEntryMoveToGroup; m_dynAutoTypeAdv = new DynamicMenu(m_ctxEntryAutoTypeAdv.DropDownItems); m_dynAutoTypeAdv.MenuClick += this.OnEntryPerformAutoTypeAdv; string[] vAdvSeq = new string[] { @"{USERNAME}", @"{USERNAME}{ENTER}", @"{PASSWORD}", @"{PASSWORD}{ENTER}", @"{USERNAME}{TAB}{PASSWORD}", @"{USERNAME}{TAB}{PASSWORD}{ENTER}", @"{USERNAME}{TAB}{TAB}{PASSWORD}", @"{USERNAME}{TAB}{TAB}{PASSWORD}{ENTER}" }; Bitmap bmpAutoType = Properties.Resources.B16x16_KTouch; foreach(string strAdvSeq in vAdvSeq) { m_dynAutoTypeAdv.AddItem(strAdvSeq, bmpAutoType); } m_dynOpenUrl = new OpenWithMenu(m_ctxEntryUrl); m_dynOpenUrlToolBar = new OpenWithMenu(m_tbOpenUrl); EntryTemplates.Init(m_tbAddEntry); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntrySelectAll, new EventHandler(OnEntrySelectAll), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntryDelete, new EventHandler(OnEntryDelete), true); InsertToolStripItem(m_menuEdit, m_ctxEntryDuplicate, new EventHandler(OnEntryDuplicate), true); InsertToolStripItem(m_menuEdit, m_ctxEntryEdit, new EventHandler(OnEntryEdit), true); ToolStripMenuItem tsmiAddEntry = InsertToolStripItem(m_menuEdit, m_ctxEntryAdd, new EventHandler(OnEntryAdd), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxGroupDelete, new EventHandler(OnGroupsDelete), true); InsertToolStripItem(m_menuEdit, m_ctxGroupEdit, new EventHandler(OnGroupsEdit), true); InsertToolStripItem(m_menuEdit, m_ctxGroupAdd, new EventHandler(OnGroupsAdd), true); // Under .NET, we assign the shortcut keys directly (to avoid a // beep when pressing them); under Mono, this doesn't work, thus // we handle it in HandleMainWindowKeyMessage instead if(!MonoWorkarounds.IsRequired(2139)) UIUtil.AssignShortcut(tsmiAddEntry, Keys.Control | Keys.I); UIUtil.ConfigureTbButton(m_tbNewDatabase, KPRes.ToolBarNew, null, m_menuFileNew); UIUtil.ConfigureTbButton(m_tbOpenDatabase, KPRes.ToolBarOpen, null, m_menuFileOpenLocal); UIUtil.ConfigureTbButton(m_tbSaveDatabase, KPRes.Save, null, m_menuFileSave); UIUtil.ConfigureTbButton(m_tbSaveAll, KPRes.ToolBarSaveAll, null, null); UIUtil.ConfigureTbButton(m_tbAddEntry, KPRes.AddEntry, null, null); UIUtil.ConfigureTbButton(m_tbCopyUserName, KPRes.CopyUserFull, null, m_ctxEntryCopyUserName); UIUtil.ConfigureTbButton(m_tbCopyPassword, KPRes.CopyPasswordFull, null, m_ctxEntryCopyPassword); UIUtil.ConfigureTbButton(m_tbOpenUrl, KPRes.OpenUrl, null, m_ctxEntryOpenUrl); UIUtil.ConfigureTbButton(m_tbCopyUrl, KPRes.CopyUrlToClipboard, null, m_ctxEntryCopyUrl); UIUtil.ConfigureTbButton(m_tbAutoType, KPRes.PerformAutoType, null, m_ctxEntryPerformAutoType); UIUtil.ConfigureTbButton(m_tbFind, KPRes.Find + "...", null, m_menuEditFind); UIUtil.ConfigureTbButton(m_tbEntryViewsDropDown, null, KPRes.ShowEntries, null); UIUtil.ConfigureTbButton(m_tbLockWorkspace, KPRes.LockMenuLock, null, m_menuFileLock); UIUtil.ConfigureTbButton(m_tbQuickFind, null, KPRes.SearchQuickPrompt + " (" + KPRes.KeyboardKeyCtrl + "+E)", null); UIUtil.ConfigureTbButton(m_tbCloseTab, StrUtil.RemoveAccelerator( KPRes.CloseButton), null, m_menuFileClose); CopyMenuItemText(m_tbAddEntryDefault, m_ctxEntryAdd, null); CopyMenuItemText(m_tbOpenUrlDefault, m_ctxEntryOpenUrl, KPRes.OpenUrl); CopyMenuItemText(m_tbViewsShowAll, m_menuEditShowAll, null); CopyMenuItemText(m_tbViewsShowExpired, m_menuEditShowExp, null); UIUtil.EnableAutoCompletion(m_tbQuickFind, false); bool bVisible = Program.Config.MainWindow.ToolBar.Show; m_toolMain.Visible = bVisible; UIUtil.SetChecked(m_menuViewShowToolBar, bVisible); // Make a copy of the maximized setting (the configuration item might // get changed when the window's position/size is restored) bool bMaximizedSetting = Program.Config.MainWindow.Maximized; int wndX = Program.Config.MainWindow.X; int wndY = Program.Config.MainWindow.Y; int sizeX = Program.Config.MainWindow.Width; int sizeY = Program.Config.MainWindow.Height; bool bWndValid = ((wndX != -32000) && (wndY != -32000) && (wndX != -64000) && (wndY != -64000)); if((sizeX != AppDefs.InvalidWindowValue) && (sizeY != AppDefs.InvalidWindowValue) && bWndValid) { if(MonoWorkarounds.IsRequired(686017)) { sizeX = Math.Max(250, sizeX); sizeY = Math.Max(250, sizeY); } this.Size = new Size(sizeX, sizeY); } if(MonoWorkarounds.IsRequired(686017)) this.MinimumSize = new Size(250, 250); Rectangle rectRestWindow = new Rectangle(wndX, wndY, this.Size.Width, this.Size.Height); bool bWndPartVisible = UIUtil.IsScreenAreaVisible(rectRestWindow); if((wndX != AppDefs.InvalidWindowValue) && (wndY != AppDefs.InvalidWindowValue) && bWndValid && bWndPartVisible) { this.Location = new Point(wndX, wndY); } else { Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea; this.Location = new Point((rectScreen.Width - this.Size.Width) / 2, (rectScreen.Height - this.Size.Height) / 2); } SetMainWindowLayout(Program.Config.MainWindow.Layout == AceMainWindowLayout.SideBySide); ShowEntryView(Program.Config.MainWindow.EntryView.Show); UpdateColumnsEx(false); AceMainWindow mw = Program.Config.MainWindow; m_bSimpleTanView = mw.TanView.UseSimpleView; UIUtil.SetChecked(m_menuViewTanSimpleList, m_bSimpleTanView); m_bShowTanIndices = mw.TanView.ShowIndices; UIUtil.SetChecked(m_menuViewTanIndices, m_bShowTanIndices); UIUtil.SetChecked(m_menuViewShowEntriesOfSubGroups, Program.Config.MainWindow.ShowEntriesOfSubGroups); m_pListSorter = Program.Config.MainWindow.ListSorting; if((m_pListSorter.Column >= 0) && (m_pListSorter.Order != SortOrder.None)) m_lvEntries.ListViewItemSorter = m_pListSorter; else m_pListSorter = new ListSorter(); m_lvsmMenu = new ListViewSortMenu(m_menuViewSortBy, m_lvEntries, new SortCommandHandler(this.SortPasswordList)); m_lvgmMenu = new ListViewGroupingMenu(m_menuViewEntryListGrouping, this); UIUtil.SetChecked(m_menuViewAlwaysOnTop, mw.AlwaysOnTop); EnsureAlwaysOnTopOpt(); m_mruList.Initialize(this, m_menuFileRecent, m_menuFileSyncRecent); m_mruList.MarkOpened = true; SerializeMruList(false); SetListFont(Program.Config.UI.StandardFont); m_ctxEntryColorLightRed.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightRed); m_ctxEntryColorLightGreen.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightGreen); m_ctxEntryColorLightBlue.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightBlue); m_ctxEntryColorLightYellow.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightYellow); // m_lvEntries.GridLines = mw.ShowGridLines; if(UIUtil.VistaStyleListsSupported) { // m_tvGroups.ItemHeight += 1; m_tvGroups.ShowRootLines = false; m_tvGroups.ShowLines = false; UIUtil.SetExplorerTheme(m_tvGroups.Handle); UIUtil.SetExplorerTheme(m_lvEntries.Handle); } // m_tvGroups.QueryToolTip = UIUtil.GetPwGroupToolTipTN; UpdateAlternatingBgColor(); m_statusPartProgress.Visible = false; if(bMaximizedSetting) { if((this.WindowState == FormWindowState.Normal) && !IsTrayed()) { // bool bVis = this.Visible; // if(bVis) this.Visible = false; UIUtil.SetWindowState(this, FormWindowState.Maximized); // if(bVis) this.Visible = true; } } try { double dSplitPos = mw.SplitterHorizontalFrac; if(dSplitPos == double.Epsilon) dSplitPos = 0.8333; if(MonoWorkarounds.IsRequired(686017)) m_splitHorizontal.Panel1MinSize = 35; m_splitHorizontal.SplitterDistanceFrac = dSplitPos; dSplitPos = mw.SplitterVerticalFrac; if(dSplitPos == double.Epsilon) dSplitPos = 0.25; m_splitVertical.SplitterDistanceFrac = dSplitPos; } catch(Exception) { Debug.Assert(false); } string strSearchTr = ((WinUtil.IsAtLeastWindowsVista ? string.Empty : " ") + KPRes.Search); UIUtil.SetCueBanner(m_tbQuickFind, strSearchTr); #if DEBUG Program.Config.CustomConfig.SetBool("TestItem1", true); Program.Config.CustomConfig.SetULong("TestItem2", 13); Program.Config.CustomConfig.SetString("TestItem3", "TestValue"); Program.KeyProviderPool.Add(new KeePassLib.Keys.SampleKeyProvider()); #endif m_sessionLockNotifier.Install(this.OnSessionLock); IpcBroadcast.StartServer(); int nInitColProvCount = Program.ColumnProviderPool.Count; m_pluginDefaultHost.Initialize(this, Program.CommandLineArgs, CipherPool.GlobalPool); m_pluginManager.Initialize(m_pluginDefaultHost); m_pluginManager.UnloadAllPlugins(); if(AppPolicy.Current.Plugins) { string[] vExclNames = new string[] { AppDefs.FileNames.Program, AppDefs.FileNames.XmlSerializers, AppDefs.FileNames.NativeLib32, AppDefs.FileNames.NativeLib64, AppDefs.FileNames.ShInstUtil }; string strPlgRoot = UrlUtil.GetFileDirectory( WinUtil.GetExecutable(), false, true); m_pluginManager.LoadAllPlugins(strPlgRoot, SearchOption.TopDirectoryOnly, vExclNames); if(!NativeLib.IsUnix()) { string strPlgSub = UrlUtil.EnsureTerminatingSeparator(strPlgRoot, false) + AppDefs.PluginsDir; m_pluginManager.LoadAllPlugins(strPlgSub, SearchOption.AllDirectories, vExclNames); } else // Unix { try { DirectoryInfo diPlgRoot = new DirectoryInfo(strPlgRoot); foreach(DirectoryInfo diSub in diPlgRoot.GetDirectories()) { if(diSub == null) { Debug.Assert(false); continue; } if(string.Equals(diSub.Name, AppDefs.PluginsDir, StrUtil.CaseIgnoreCmp)) m_pluginManager.LoadAllPlugins(diSub.FullName, SearchOption.AllDirectories, vExclNames); } } catch(Exception) { Debug.Assert(false); } } } // Delete old files *after* loading plugins (when timestamps // of loaded plugins have been updated already) if(Program.Config.Application.Start.PluginCacheDeleteOld) PlgxCache.DeleteOldFilesAsync(); if(Program.ColumnProviderPool.Count != nInitColProvCount) UpdateColumnsEx(false); HotKeyManager.Initialize(this); Keys kAutoTypeKey = (Keys)Program.Config.Integration.HotKeyGlobalAutoType; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.AutoType, kAutoTypeKey); Keys kAutoTypeSelKey = (Keys)Program.Config.Integration.HotKeySelectedAutoType; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.AutoTypeSelected, kAutoTypeSelKey); Keys kShowWindowKey = (Keys)Program.Config.Integration.HotKeyShowWindow; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.ShowWindow, kShowWindowKey); Keys kEntryMenuKey = (Keys)Program.Config.Integration.HotKeyEntryMenu; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.EntryMenu, kEntryMenuKey); m_statusClipboard.Visible = false; UpdateClipboardStatus(); ToolStripItem[] vSbItems = new ToolStripItem[] { m_statusPartSelected, m_statusPartProgress, m_statusClipboard }; int[] vStdSbWidths = new int[] { 140, 150, 100 }; DpiUtil.ScaleToolStripItems(vSbItems, vStdSbWidths); // Workaround for .NET ToolStrip height bug; // https://sourceforge.net/p/keepass/discussion/329220/thread/19e7c256/ Debug.Assert((m_toolMain.Height == 25) || DpiUtil.ScalingRequired); m_toolMain.LockHeight(true); UpdateTrayIcon(); UpdateTagsMenu(m_dynShowEntriesByTagsEditMenu, false, false, TagsMenuMode.EnsurePopupOnly); UpdateTagsMenu(m_dynRemoveTag, false, false, TagsMenuMode.EnsurePopupOnly); UpdateEntryMoveMenu(true); UpdateUIState(false); ApplyUICustomizations(); MonoWorkarounds.ApplyTo(this); ThreadPool.QueueUserWorkItem(new WaitCallback(OnFormLoadParallelAsync)); HotKeyManager.CheckCtrlAltA(this); Program.TriggerSystem.RaiseEvent(EcasEventIDs.AppInitPost); if(Program.CommandLineArgs.FileName != null) OpenDatabase(IocFromCommandLine(), KeyUtil.KeyFromCommandLine( Program.CommandLineArgs), false); else if(Program.Config.Application.Start.OpenLastFile) { IOConnectionInfo ioLastFile = Program.Config.Application.LastUsedFile; if(ioLastFile.Path.Length > 0) OpenDatabase(ioLastFile, null, false); } UpdateCheckEx.EnsureConfigured(this); if(Program.Config.Application.Start.CheckForUpdate) UpdateCheckEx.Run(false, null); // UpdateCheck.StartAsync(PwDefs.VersionUrl, m_statusPartInfo); ResetDefaultFocus(null); MinimizeToTrayAtStartIfEnabled(true); m_bFormLoaded = true; NotifyUserActivity(); // Initialize locking timeout if(this.FormLoadPost != null) this.FormLoadPost(this, EventArgs.Empty); Program.TriggerSystem.RaiseEvent(EcasEventIDs.AppLoadPost); }
private void SortPasswordList(bool bEnableSorting, int nColumn, bool bUpdateEntryList) { if(bEnableSorting) { bool bSortTimes = ((nColumn >= (int)AppDefs.ColumnId.CreationTime) && (nColumn <= (int)AppDefs.ColumnId.ExpiryTime)); int nOldColumn = m_pListSorter.Column; SortOrder sortOrder = m_pListSorter.Order; if(nColumn == nOldColumn) { if(sortOrder == SortOrder.None) sortOrder = SortOrder.Ascending; else if(sortOrder == SortOrder.Ascending) sortOrder = SortOrder.Descending; else if(sortOrder == SortOrder.Descending) sortOrder = SortOrder.None; else { Debug.Assert(false); } } else sortOrder = SortOrder.Ascending; if(sortOrder != SortOrder.None) { m_pListSorter = new ListSorter(nColumn, sortOrder, bSortTimes); m_lvEntries.ListViewItemSorter = m_pListSorter; } else { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } } else // Disable sorting { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } UpdateColumnSortingIcons(); }
private void SortPasswordList(bool bEnableSorting, int nColumn, bool bUpdateEntryList) { AceColumnType colType = GetAceColumn(nColumn).Type; if(bEnableSorting) { bool bSortTimes = AceColumn.IsTimeColumn(colType); bool bSortNaturally = (colType != AceColumnType.Uuid); int nOldColumn = m_pListSorter.Column; SortOrder sortOrder = m_pListSorter.Order; if(nColumn == nOldColumn) { if(sortOrder == SortOrder.None) sortOrder = SortOrder.Ascending; else if(sortOrder == SortOrder.Ascending) sortOrder = SortOrder.Descending; else if(sortOrder == SortOrder.Descending) sortOrder = SortOrder.None; else { Debug.Assert(false); } } else sortOrder = SortOrder.Ascending; if(sortOrder != SortOrder.None) { m_pListSorter = new ListSorter(nColumn, sortOrder, bSortNaturally, bSortTimes); m_lvEntries.ListViewItemSorter = m_pListSorter; } else { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } } else // Disable sorting { m_pListSorter = new ListSorter(); m_lvEntries.ListViewItemSorter = null; if(bUpdateEntryList) UpdateEntryList(null, true); } UpdateColumnSortingIcons(); UIUtil.SetAlternatingBgColors(m_lvEntries, m_clrAlternateItemBgColor, Program.Config.MainWindow.EntryListAlternatingBgColors); }
private void OnFormLoad(object sender, EventArgs e) { m_bFormLoading = true; m_strNeverExpiresText = KPRes.NeverExpires; this.Icon = Properties.Resources.KeePass; m_imgFileSaveEnabled = Properties.Resources.B16x16_FileSave; m_imgFileSaveDisabled = Properties.Resources.B16x16_FileSave_Disabled; m_imgFileSaveAllEnabled = Properties.Resources.B16x16_File_SaveAll; m_imgFileSaveAllDisabled = Properties.Resources.B16x16_File_SaveAll_Disabled; m_ilCurrentIcons = m_ilClientIcons; m_nLockTimerMax = (int)Program.Config.Security.WorkspaceLocking.LockAfterTime; m_nClipClearMax = Program.Config.Security.ClipboardClearAfterSeconds; NativeLib.AllowNative = Program.Config.Native.NativeKeyTransformations; m_ctxEntryPreviewContextMenu.Attach(m_richEntryView); m_dynCustomStrings = new DynamicMenu(m_ctxEntryCopyCustomString); m_dynCustomStrings.MenuClick += this.OnCopyCustomString; m_dynCustomBinaries = new DynamicMenu(m_ctxEntryBinaries); m_dynCustomBinaries.MenuClick += this.OnEntryBinaryView; SelfTestResult st = SelfTest.Perform(); if(st != SelfTestResult.Success) MessageService.ShowFatal(KPRes.SelfTestFailed); EntryTemplates.Init(m_tbAddEntry); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntrySelectAll, new EventHandler(OnEntrySelectAll), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxEntryDelete, new EventHandler(OnEntryDelete), true); InsertToolStripItem(m_menuEdit, m_ctxEntryDuplicate, new EventHandler(OnEntryDuplicate), true); InsertToolStripItem(m_menuEdit, m_ctxEntryEdit, new EventHandler(OnEntryEdit), true); InsertToolStripItem(m_menuEdit, m_ctxEntryAdd, new EventHandler(OnEntryAdd), true); m_menuEdit.DropDownItems.Insert(0, new ToolStripSeparator()); InsertToolStripItem(m_menuEdit, m_ctxGroupDelete, new EventHandler(OnGroupsDelete), true); InsertToolStripItem(m_menuEdit, m_ctxGroupEdit, new EventHandler(OnGroupsEdit), true); InsertToolStripItem(m_menuEdit, m_ctxGroupAdd, new EventHandler(OnGroupsAdd), true); ConfigureTbButton(m_tbNewDatabase, KPRes.ToolBarNew, null); ConfigureTbButton(m_tbOpenDatabase, KPRes.ToolBarOpen, null); ConfigureTbButton(m_tbSaveDatabase, KPRes.Save, null); ConfigureTbButton(m_tbSaveAll, KPRes.ToolBarSaveAll, null); ConfigureTbButton(m_tbAddEntry, KPRes.AddEntry, null); ConfigureTbButton(m_tbAddEntryDefault, KPRes.AddEntryBtn, null); ConfigureTbButton(m_tbCopyUserName, KPRes.CopyUserFull, null); ConfigureTbButton(m_tbCopyPassword, KPRes.CopyPasswordFull, null); ConfigureTbButton(m_tbFind, KPRes.Search, null); ConfigureTbButton(m_tbViewsShowAll, KPRes.ShowAllEntries, null); ConfigureTbButton(m_tbViewsShowExpired, KPRes.ShowExpiredEntries, null); ConfigureTbButton(m_tbLockWorkspace, KPRes.LockMenuLock, null); ConfigureTbButton(m_tbQuickFind, null, KPRes.SearchQuickPrompt); bool bVisible = Program.Config.MainWindow.ToolBar.Show; m_toolMain.Visible = bVisible; m_menuViewShowToolBar.Checked = bVisible; int wndX = Program.Config.MainWindow.X; int wndY = Program.Config.MainWindow.Y; int sizeX = Program.Config.MainWindow.Width; int sizeY = Program.Config.MainWindow.Height; bool bWndValid = ((wndX != -32000) && (wndY != -32000) && (wndX != -64000) && (wndY != -64000)); if((sizeX != AppDefs.InvalidWindowValue) && (sizeY != AppDefs.InvalidWindowValue) && bWndValid) this.Size = new Size(sizeX, sizeY); Rectangle rectScreen = Screen.GetWorkingArea(this); if((wndX != AppDefs.InvalidWindowValue) && (wndY != AppDefs.InvalidWindowValue) && bWndValid) this.Location = new Point(wndX, wndY); else this.Location = new Point((rectScreen.Width - this.Size.Width) / 2, (rectScreen.Height - this.Size.Height) / 2); SetMainWindowLayout(Program.Config.MainWindow.Layout == AceMainWindowLayout.SideBySide); ShowEntryView(Program.Config.MainWindow.EntryView.Show); ColumnHeader ch; int nDefaultWidth = m_lvEntries.ClientRectangle.Width / 5; AceMainWindow mw = Program.Config.MainWindow; m_bDisableBlockingColumnSizing = true; ch = m_lvEntries.Columns.Add(KPRes.Title); ch.Width = mw.ColumnsDict[PwDefs.TitleField].SafeGetWidth(nDefaultWidth); ch = m_lvEntries.Columns.Add(KPRes.UserName); ch.Width = mw.ColumnsDict[PwDefs.UserNameField].SafeGetWidth(nDefaultWidth); ch = m_lvEntries.Columns.Add(KPRes.Password); ch.Width = mw.ColumnsDict[PwDefs.PasswordField].SafeGetWidth(nDefaultWidth); ch = m_lvEntries.Columns.Add(KPRes.Url); ch.Width = mw.ColumnsDict[PwDefs.UrlField].SafeGetWidth(nDefaultWidth); ch = m_lvEntries.Columns.Add(KPRes.Notes); ch.Width = mw.ColumnsDict[PwDefs.NotesField].SafeGetWidth(nDefaultWidth); ch = m_lvEntries.Columns.Add(KPRes.CreationTime); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnCreationTime].SafeGetWidth(0); ch = m_lvEntries.Columns.Add(KPRes.LastAccessTime); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnLastAccessTime].SafeGetWidth(0); ch = m_lvEntries.Columns.Add(KPRes.LastModificationTime); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnLastModificationTime].SafeGetWidth(0); ch = m_lvEntries.Columns.Add(KPRes.ExpiryTime); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnExpiryTime].SafeGetWidth(0); ch = m_lvEntries.Columns.Add(KPRes.Uuid); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnUuid].SafeGetWidth(0); ch = m_lvEntries.Columns.Add(KPRes.Attachments); ch.Width = mw.ColumnsDict[AppDefs.ColumnIdnAttachment].SafeGetWidth(0); m_bDisableBlockingColumnSizing = false; RestoreDisplayIndex(mw, PwDefs.TitleField, AppDefs.ColumnId.Title); RestoreDisplayIndex(mw, PwDefs.UserNameField, AppDefs.ColumnId.UserName); RestoreDisplayIndex(mw, PwDefs.PasswordField, AppDefs.ColumnId.Password); RestoreDisplayIndex(mw, PwDefs.UrlField, AppDefs.ColumnId.Url); RestoreDisplayIndex(mw, PwDefs.NotesField, AppDefs.ColumnId.Notes); RestoreDisplayIndex(mw, AppDefs.ColumnIdnAttachment, AppDefs.ColumnId.Attachment); RestoreDisplayIndex(mw, AppDefs.ColumnIdnCreationTime, AppDefs.ColumnId.CreationTime); RestoreDisplayIndex(mw, AppDefs.ColumnIdnExpiryTime, AppDefs.ColumnId.ExpiryTime); RestoreDisplayIndex(mw, AppDefs.ColumnIdnLastAccessTime, AppDefs.ColumnId.LastAccessTime); RestoreDisplayIndex(mw, AppDefs.ColumnIdnLastModificationTime, AppDefs.ColumnId.LastModificationTime); RestoreDisplayIndex(mw, AppDefs.ColumnIdnUuid, AppDefs.ColumnId.Uuid); Debug.Assert(m_lvEntries.Columns.Count == (int)AppDefs.ColumnId.Count); for(int iCol = 0; iCol < (int)AppDefs.ColumnId.Count; ++iCol) m_vShowColumns[iCol] = (m_lvEntries.Columns[iCol].Width > 0); m_menuViewColumnsShowTitle.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Title]; m_menuViewColumnsShowUserName.Checked = m_vShowColumns[(int)AppDefs.ColumnId.UserName]; m_menuViewColumnsShowPassword.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Password]; m_menuViewColumnsShowUrl.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Url]; m_menuViewColumnsShowNotes.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Notes]; m_menuViewColumnsShowCreation.Checked = m_vShowColumns[(int)AppDefs.ColumnId.CreationTime]; m_menuViewColumnsShowLastAccess.Checked = m_vShowColumns[(int)AppDefs.ColumnId.LastAccessTime]; m_menuViewColumnsShowLastMod.Checked = m_vShowColumns[(int)AppDefs.ColumnId.LastModificationTime]; m_menuViewColumnsShowExpire.Checked = m_vShowColumns[(int)AppDefs.ColumnId.ExpiryTime]; m_menuViewColumnsShowUuid.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Uuid]; m_menuViewColumnsShowAttachs.Checked = m_vShowColumns[(int)AppDefs.ColumnId.Attachment]; m_menuViewHideTitles.Checked = m_viewHideFields.ProtectTitle = mw.ColumnsDict[PwDefs.TitleField].HideWithAsterisks; m_menuViewHideUserNames.Checked = m_viewHideFields.ProtectUserName = mw.ColumnsDict[PwDefs.UserNameField].HideWithAsterisks; m_menuViewHidePasswords.Checked = m_viewHideFields.ProtectPassword = mw.ColumnsDict[PwDefs.PasswordField].HideWithAsterisks; m_menuViewHideURLs.Checked = m_viewHideFields.ProtectUrl = mw.ColumnsDict[PwDefs.UrlField].HideWithAsterisks; m_menuViewHideNotes.Checked = m_viewHideFields.ProtectNotes = mw.ColumnsDict[PwDefs.NotesField].HideWithAsterisks; m_menuViewTanSimpleList.Checked = m_bSimpleTanView = mw.TanView.UseSimpleView; m_menuViewTanIndices.Checked = m_bShowTanIndices = mw.TanView.ShowIndices; m_menuViewShowEntriesOfSubGroups.Checked = Program.Config.MainWindow.ShowEntriesOfSubGroups; m_pListSorter = Program.Config.MainWindow.ListSorting; if((m_pListSorter.Column >= 0) && (m_pListSorter.Order != SortOrder.None)) m_lvEntries.ListViewItemSorter = m_pListSorter; else m_pListSorter = new ListSorter(); m_menuViewAlwaysOnTop.Checked = mw.AlwaysOnTop; OnViewAlwaysOnTop(null, null); m_mruList.Initialize(this, m_menuFileRecent); m_mruList.MaxItemCount = Program.Config.Application.MostRecentlyUsed.MaxItemCount; for(uint uMru = 0; uMru < (uint)Program.Config.Application.MostRecentlyUsed.Items.Count; ++uMru) { IOConnectionInfo ioMru = Program.Config.Application.MostRecentlyUsed.Items[(int)uMru]; m_mruList.AddItem(ioMru.GetDisplayName(), ioMru.CloneDeep()); } m_mruList.UpdateMenu(); SetListFont(Program.Config.UI.StandardFont); m_ctxEntryColorLightRed.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightRed); m_ctxEntryColorLightGreen.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightGreen); m_ctxEntryColorLightBlue.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightBlue); m_ctxEntryColorLightYellow.Image = UIUtil.CreateColorBitmap24(16, 16, AppDefs.NamedEntryColor.LightYellow); m_lvEntries.GridLines = mw.ShowGridLines; m_statusPartProgress.Visible = false; if(mw.Maximized) this.WindowState = FormWindowState.Maximized; try { int nSplitPos = mw.SplitterHorizontalPosition; if(nSplitPos == AppDefs.InvalidWindowValue) nSplitPos = (m_splitHorizontal.ClientRectangle.Height * 5) / 6; m_splitHorizontal.SplitterDistance = nSplitPos; nSplitPos = mw.SplitterVerticalPosition; if(nSplitPos == AppDefs.InvalidWindowValue) nSplitPos = m_splitVertical.ClientRectangle.Width / 4; m_splitVertical.SplitterDistance = nSplitPos; } catch(Exception) { Debug.Assert(false); } string strSearchTr = ((WinUtil.IsAtLeastWindowsVista ? string.Empty : " ") + KPRes.Search); UIUtil.SetCueBanner(m_tbQuickFind, strSearchTr); m_sessionLockNotifier.Install(this.OnSessionLock); m_pluginDefaultHost.Initialize(this, Program.CommandLineArgs, CipherPool.GlobalPool); m_pluginManager.Initialize(m_pluginDefaultHost); m_pluginManager.UnloadAllPlugins(); if(AppPolicy.Current.Plugins) m_pluginManager.LoadAllPlugins(UrlUtil.GetFileDirectory(WinUtil.GetExecutable(), false)); HotKeyManager.ReceiverWindow = this.Handle; Keys kAutoTypeKey = (Keys)Program.Config.Integration.HotKeyGlobalAutoType; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.AutoType, kAutoTypeKey); Keys kShowWindowKey = (Keys)Program.Config.Integration.HotKeyShowWindow; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.ShowWindow, kShowWindowKey); Keys kEntryMenuKey = (Keys)Program.Config.Integration.HotKeyEntryMenu; HotKeyManager.RegisterHotKey(AppDefs.GlobalHotKeyId.EntryMenu, kEntryMenuKey); m_statusClipboard.Visible = false; UpdateClipboardStatus(); UpdateTrayIcon(); UpdateUIState(false); if(Program.CommandLineArgs.FileName != null) OpenDatabase(IOConnectionInfo.FromPath(Program.CommandLineArgs.FileName), KeyUtil.KeyFromCommandLine(Program.CommandLineArgs), false); else if(Program.Config.Application.Start.OpenLastFile) { IOConnectionInfo ioLastFile = Program.Config.Application.LastUsedFile; if(ioLastFile.Path.Length > 0) OpenDatabase(ioLastFile, null, false); } if(Program.Config.Application.Start.CheckForUpdate) CheckForUpdate.StartAsync(PwDefs.VersionUrl, m_statusPartInfo); ResetDefaultFocus(null); MinimizeToTrayAtStartIfEnabled(true); m_bFormLoading = false; }