public override bool Initialize(IPluginHost host)
        {
            Debug.Assert(host != null);
            if (host == null) return false;
            m_host = host;
            global_window_manager_window_added_handler = new EventHandler<GwmWindowEventArgs>(GlobalWindowManager_WindowAdded);
            GlobalWindowManager.WindowAdded += global_window_manager_window_added_handler;
            ToolStripItemCollection tsMenu = m_host.MainWindow.EntryContextMenu.Items;
            m_tsmi_set_template_parent = new ToolStripMenuItem();
            m_tsmi_set_template_parent.Text = "Set Template Parent";
            m_tsmi_set_template_parent.Click += m_tsmi_set_template_parent_Click;
            m_tsmi_set_template_parent.Image = Resources.Resources.B16x16_KOrganizer;
            tsMenu.Add(m_tsmi_set_template_parent);
            m_tsmi_copy_template_string = new ToolStripMenuItem();
            m_tsmi_copy_template_string.Text = "Copy Template String";
            m_tsmi_copy_template_string.Image = Resources.Resources.B16x16_KOrganizer;
            m_dynCustomStrings = new DynamicMenu(m_tsmi_copy_template_string);
            m_dynCustomStrings.MenuClick += m_dynCustomStrings_MenuClick;
            tsMenu.Add(m_tsmi_copy_template_string);

            entry_context_menu_opening_handler = new System.ComponentModel.CancelEventHandler(EntryContextMenu_Opening);
            m_host.MainWindow.EntryContextMenu.Opening += entry_context_menu_opening_handler;
            entry_templates_entry_creating_handler = new EventHandler<TemplateEntryEventArgs>(EntryTemplates_EntryCreating);
            EntryTemplates.EntryCreating += entry_templates_entry_creating_handler;

            return true;
        }
		public override bool Initialize(IPluginHost host)
		{
			Contract.Requires(host != null);

			this.host = host;

			ctxEntryShowQRCode = new ToolStripMenuItem
			{
				Image = Properties.Resources.icon,
				Text = CONTEXT_MENU_ITEM_LABEL
			};
			dynQRCodes = new DynamicMenu(ctxEntryShowQRCode.DropDownItems);
			dynQRCodes.MenuClick += OnShowQRCode;

			var insertAfterIndex = host.MainWindow.EntryContextMenu.Items.IndexOfKey(INSERT_AFTER_ENTRY_KEY);
			if (insertAfterIndex != -1)
			{
				//insert after "Save Attachements"
				host.MainWindow.EntryContextMenu.Items.Insert(insertAfterIndex + 1, ctxEntryShowQRCode);
			}
			else
			{
				//add at the end
				host.MainWindow.EntryContextMenu.Items.Add(ctxEntryShowQRCode);
			}
			host.MainWindow.EntryContextMenu.Opening += OnEntryContextMenuOpening;

			return true;
		}
Пример #3
0
        public OpenWithItem(string strFilePath, OwFilePathType tPath,
                            string strName, Image imgIcon, DynamicMenu dynMenu)
        {
            if (strFilePath == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("strFilePath");
            }
            if (strName == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("strName");
            }
            if (dynMenu == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("dynMenu");
            }

            m_strPath = strFilePath;
            m_tPath   = tPath;
            m_strName = strName.Trim();
            m_imgIcon = imgIcon;
            m_dynMenu = dynMenu;

            if (m_strName.Length == 0)
            {
                Debug.Assert(false);
                m_strName = m_strPath;
                if (m_strName.Length == 0)
                {
                    m_strName = KPRes.Unknown;
                }
            }
        }
Пример #4
0
        public OpenWithMenu(ToolStripMenuItem tsmiHost)
        {
            if(tsmiHost == null) { Debug.Assert(false); return; }

            m_tsmiHost = tsmiHost;
            m_dynMenu = new DynamicMenu(m_tsmiHost);
            m_dynMenu.MenuClick += this.OnOpenUrl;

            m_tsmiHost.DropDownOpening += this.OnMenuOpening;
        }
Пример #5
0
        private OpenWithItem(string strFilePath, string strMenuText,
                             Image imgIcon, DynamicMenu dynMenu)
        {
            m_strPath     = strFilePath;
            m_strMenuText = strMenuText;
            m_imgIcon     = imgIcon;

            m_tsmi = dynMenu.AddItem(m_strMenuText, m_imgIcon, this);

            try { m_tsmi.ToolTipText = m_strPath; }
            catch (Exception) { }            // Too long?
        }
Пример #6
0
		public OpenWithItem(string strFilePath, OwFilePathType tPath,
			string strMenuText, Image imgIcon, DynamicMenu dynMenu)
		{
			m_strPath = strFilePath;
			m_tPath = tPath;
			m_strMenuText = strMenuText;
			m_imgIcon = imgIcon;

			m_tsmi = dynMenu.AddItem(m_strMenuText, m_imgIcon, this);

			try { m_tsmi.ToolTipText = m_strPath; }
			catch(Exception) { } // Too long?
		}
Пример #7
0
        public OpenWithMenu(ToolStripDropDownItem tsmiHost)
        {
            if (tsmiHost == null)
            {
                Debug.Assert(false); return;
            }

            m_tsmiHost           = tsmiHost;
            m_dynMenu            = new DynamicMenu(m_tsmiHost);
            m_dynMenu.MenuClick += this.OnOpenUrl;

            m_tsmiHost.DropDownOpening += this.OnMenuOpening;
        }
Пример #8
0
        public void Destroy()
        {
            if (m_dynMenu != null)
            {
                m_dynMenu.Clear();
                m_dynMenu.MenuClick -= this.OnOpenUrl;
                m_dynMenu            = null;

                m_tsmiHost.DropDownOpening -= this.OnMenuOpening;
                m_tsmiHost = null;

                // After the menu has been destroyed:
                ReleaseOpenWithList();                 // Release icons, ...
            }
        }
Пример #9
0
        public void Destroy()
        {
            if(m_dynMenu != null)
            {
                m_dynMenu.Clear();
                m_dynMenu.MenuClick -= this.OnOpenUrl;
                m_dynMenu = null;

                m_tsmiHost.DropDownOpening -= this.OnMenuOpening;
                m_tsmiHost = null;

                // After the menu has been destroyed:
                ReleaseOpenWithList(); // Release icons, ...
            }
        }
Пример #10
0
        public OpenWithItem(string strFilePath, OwFilePathType tPath,
                            string strMenuText, Image imgIcon, DynamicMenu dynMenu)
        {
            if (strFilePath == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("strFilePath");
            }
            if (strMenuText == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("strMenuText");
            }
            if (dynMenu == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("dynMenu");
            }

            m_strPath     = strFilePath;
            m_tPath       = tPath;
            m_strMenuText = strMenuText;
            m_imgIcon     = imgIcon;

            m_tsmi = dynMenu.AddItem(m_strMenuText, m_imgIcon, this);

            try
            {
                string strTip = strFilePath;
                if (strTip.StartsWith("cmd://", StrUtil.CaseIgnoreCmp))
                {
                    strTip = strTip.Substring(6);
                }

                if (strTip.Length != 0)
                {
                    m_tsmi.ToolTipText = strTip;
                }
            }
            catch (Exception) { Debug.Assert(false); }            // Too long?
        }
Пример #11
0
 public static OpenWithItem Create(string strFilePath, string strMenuText,
     Image imgIcon, DynamicMenu dynMenu)
 {
     return new OpenWithItem(strFilePath, strMenuText, imgIcon, dynMenu);
 }
Пример #12
0
		private void UpdateTagsMenu(DynamicMenu dm, bool bWithSeparator, bool bPrefixTag,
			TagsMenuMode tmm)
		{
			if(dm == null) { Debug.Assert(false); return; }
			dm.Clear();

			if(bWithSeparator) dm.AddSeparator();

			string strNoTags = "(" + KPRes.TagsNotFound + ")";
			PwDatabase pd = m_docMgr.ActiveDatabase;
			if(!pd.IsOpen || (tmm == TagsMenuMode.EnsurePopupOnly))
			{
				ToolStripMenuItem tsmi = dm.AddItem(strNoTags, null, string.Empty);
				tsmi.Enabled = false;
				return;
			}

			bool bReqEntrySel = ((tmm == TagsMenuMode.Add) || (tmm == TagsMenuMode.Remove));
			IDictionary<string, uint> dAllTags = pd.RootGroup.BuildEntryTagsDict(true);
			PwGroup pgSel = GetSelectedEntriesAsGroup();
			uint uSelCount = pgSel.Entries.UCount;
			bool bForceDisabled = (bReqEntrySel && (uSelCount == 0));

			Dictionary<string, bool> dEnabledTags = null;
			if((tmm == TagsMenuMode.Add) && (uSelCount > 0))
			{
				dEnabledTags = new Dictionary<string, bool>(StrUtil.CaseIgnoreComparer);
				List<string> lIntersect = pgSel.Entries.GetAt(0).Tags;
				for(uint u = 1; u < uSelCount; ++u)
					lIntersect = new List<string>(MemUtil.Intersect(lIntersect,
						pgSel.Entries.GetAt(u).Tags, StrUtil.CaseIgnoreComparer));
				foreach(string strTag in MemUtil.Except(dAllTags.Keys, lIntersect,
					StrUtil.CaseIgnoreComparer))
					dEnabledTags[strTag] = true;
			}
			else if(tmm == TagsMenuMode.Remove)
			{
				dEnabledTags = new Dictionary<string, bool>(StrUtil.CaseIgnoreComparer);
				List<string> lSelectedTags = pgSel.BuildEntryTagsList(false);
				foreach(string strTag in lSelectedTags)
					dEnabledTags[strTag] = true;
			}

			string strPrefix = StrUtil.EncodeMenuText(KPRes.Tag + ": ");
			Image imgIcon = Properties.Resources.B16x16_KNotes;

			List<char> lAvailKeys = new List<char>(PwCharSet.MenuAccels);
			foreach(KeyValuePair<string, uint> kvp in dAllTags)
			{
				string strTag = kvp.Key;

				string strText = StrUtil.EncodeMenuText(strTag);
				strText = StrUtil.AddAccelerator(strText, lAvailKeys);
				if(bPrefixTag) strText = strPrefix + strText;

				ToolStripMenuItem tsmi = dm.AddItem(strText, imgIcon, strTag);
				if(tmm == TagsMenuMode.All)
					tsmi.ShortcutKeyDisplayString = "(" + kvp.Value.ToString() + ")";

				if(bForceDisabled) tsmi.Enabled = false;
				else if(dEnabledTags != null)
				{
					if(!dEnabledTags.ContainsKey(strTag)) tsmi.Enabled = false;
				}
			}

			if(dAllTags.Count == 0)
			{
				ToolStripMenuItem tsmi = dm.AddItem(strNoTags, null, string.Empty);
				tsmi.Enabled = false;
			}
		}
Пример #13
0
        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 init_pwgen_button()
        {
            m_ctxPwGenOpen = new ToolStripMenuItem();
            m_ctxPwGenSep0 = new ToolStripSeparator();
            m_ctxPwGenProfiles = new ToolStripMenuItem();
            m_ctxPwGenProfiles.Name = "m_ctxPwGenProfiles";
            m_ctxPwGenProfiles.Size = new Size(208, 22);
            m_ctxPwGenProfiles.Text = "Generate Using Profile";
            m_btnGenPw = new Button();
            m_btnGenPw.Image = Resources.Resources.B15x13_KGPG_Gen;
            m_btnGenPw.Location = new Point(423, 90);
            m_btnGenPw.Size = new Size(32, 23);
            m_btnGenPw.UseVisualStyleBackColor = true;
            m_btnGenPw.Click += OnPwGenClick;
            m_ctxPwGen = new ContextMenuStrip();
            m_dynGenProfiles = new DynamicMenu(m_ctxPwGenProfiles);
            m_dynGenProfiles.MenuClick += OnProfilesDynamicMenuClick;

            m_ctxPwGen.Items.AddRange(new ToolStripItem[] {
            m_ctxPwGenOpen,
            m_ctxPwGenSep0,
            m_ctxPwGenProfiles});
            m_ctxPwGen.Name = "m_ctxPwGen";
            m_ctxPwGen.Size = new Size(209, 54);
            //
            // m_ctxPwGenOpen
            //
            m_ctxPwGenOpen.Image = Resources.Resources.B16x16_KGPG_Gen;
            m_ctxPwGenOpen.Name = "m_ctxPwGenOpen";
            m_ctxPwGenOpen.Size = new Size(208, 22);
            m_ctxPwGenOpen.Text = "&Open Password Generator...";
            m_ctxPwGenOpen.Click += OnPwGenOpen;
            //
            // m_ctxPwGenSep0
            //
            m_ctxPwGenSep0.Name = "m_ctxPwGenSep0";
            m_ctxPwGenSep0.Size = new Size(205, 6);
            //
            // m_ctxPwGenProfiles
            //
            m_ctxPwGenProfiles.Name = "m_ctxPwGenProfiles";
            m_ctxPwGenProfiles.Size = new Size(208, 22);
            m_ctxPwGenProfiles.Text = "Generate Using Profile";
        }
Пример #15
0
        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();

            GlobalWindowManager.AddWindow(this);

            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_clrNormalBackColor = m_tbPassword.BackColor;
            m_dynGenProfiles = new DynamicMenu(m_ctxPwGenProfiles);
            m_dynGenProfiles.MenuClick += this.OnProfilesDynamicMenuClick;
            m_ctxNotes.Attach(m_rtNotes);

            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); }

            int w = m_bannerImage.ClientRectangle.Width;
            int h = m_bannerImage.ClientRectangle.Height;
            m_bannerImage.Image = BannerFactory.CreateBanner(w, h,
                BannerStyle.Default,
                KeePass.Properties.Resources.B48x48_KGPG_Sign,
                strTitle, strDesc);
            this.Icon = Properties.Resources.KeePass;
            this.Text = strTitle;

            if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry)
                m_bLockEnabledState = true;

            UIUtil.PrepareStandardMultilineControl(m_rtNotes);

            m_bInitializing = true;

            if(Program.Config.UI.Hiding.SeparateHidingSettings)
                m_cbHidePassword.Checked = Program.Config.UI.Hiding.HideInEntryWindow;
            else
                m_cbHidePassword.Checked = Program.Config.MainWindow.ColumnsDict[
                    PwDefs.PasswordField].HideWithAsterisks;

            InitEntryTab();
            InitAdvancedTab();
            InitPropertiesTab();
            InitAutoTypeTab();
            InitHistoryTab();

            if(PwDefs.IsTanEntry(m_pwEntry))
                m_btnTools.Enabled = false;

            CustomizeForScreenReader();

            m_bInitializing = false;

            if(m_bShowAdvancedByDefault)
                m_tabMain.SelectedTab = m_tabAdvanced;

            ResizeColumnHeaders();
            EnableControlsEx();

            if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry)
                m_btnCancel.Select();
            else
            {
                m_tbTitle.Select(0, 0);
                m_tbTitle.Select();
            }
        }
Пример #16
0
		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();

			GlobalWindowManager.AddWindow(this);
			GlobalWindowManager.CustomizeControl(m_ctxTools);
			GlobalWindowManager.CustomizeControl(m_ctxPwGen);
			GlobalWindowManager.CustomizeControl(m_ctxStrMoveToStandard);

			m_pwInitialEntry = m_pwEntry.CloneDeep();

			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_clrNormalBackColor = m_tbPassword.BackColor;
			m_dynGenProfiles = new DynamicMenu(m_ctxPwGenProfiles.DropDownItems);
			m_dynGenProfiles.MenuClick += this.OnProfilesDynamicMenuClick;
			m_ctxNotes.Attach(m_rtNotes);

			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); }

			int w = m_bannerImage.ClientRectangle.Width;
			int h = m_bannerImage.ClientRectangle.Height;
			m_bannerImage.Image = BannerFactory.CreateBanner(w, h,
				BannerStyle.Default,
				KeePass.Properties.Resources.B48x48_KGPG_Sign,
				strTitle, strDesc);
			this.Icon = Properties.Resources.KeePass;
			this.Text = strTitle;

			UIUtil.SetButtonImage(m_btnTools,
				Properties.Resources.B16x16_Package_Settings, true);
			UIUtil.SetButtonImage(m_btnStandardExpires,
				Properties.Resources.B16x16_History, true);

			if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry)
				m_bLockEnabledState = true;

			UIUtil.PrepareStandardMultilineControl(m_rtNotes, true);

			m_bInitializing = 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);
			UpdateEntryBinaries(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();

			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();
			}
		}
Пример #17
0
		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);
		}
Пример #18
0
        private void UpdateTagsMenu(DynamicMenu dm, bool bWithSeparator, bool bPrefixTag,
            bool bRequireEntrySelected, bool bEnableOnlySelected)
        {
            if(dm == null) { Debug.Assert(false); return; }
            dm.Clear();

            if(bWithSeparator) dm.AddSeparator();

            string strNoTags = "(" + KPRes.TagsNotFound + ")";
            PwDatabase pd = m_docMgr.ActiveDatabase;
            if(!pd.IsOpen)
            {
                ToolStripMenuItem tsmi = dm.AddItem(strNoTags, null, string.Empty);
                tsmi.Enabled = false;
                return;
            }

            List<string> vTags = pd.RootGroup.BuildEntryTagsList(true);
            string strPrefix = KPRes.Tag + ": ";
            Image imgIcon = Properties.Resources.B16x16_KNotes;
            bool bEnable = (m_lvEntries.SelectedIndices.Count > 0);

            List<string> vEnabledTags = null;
            if(bEnableOnlySelected)
            {
                PwGroup pgSel = GetSelectedEntriesAsGroup();
                vEnabledTags = pgSel.BuildEntryTagsList(true);
            }

            for(int i = 0; i < vTags.Count; ++i)
            {
                string strTag = vTags[i];
                ToolStripMenuItem tsmi = dm.AddItem(bPrefixTag ? (strPrefix + strTag) :
                    strTag, imgIcon, strTag);

                if(bRequireEntrySelected && !bEnable) tsmi.Enabled = false;
                else if(vEnabledTags != null)
                {
                    if(vEnabledTags.IndexOf(strTag) < 0) tsmi.Enabled = false;
                }
            }

            if(vTags.Count == 0)
            {
                ToolStripMenuItem tsmi = dm.AddItem(strNoTags, null, string.Empty);
                tsmi.Enabled = false;
            }
        }
Пример #19
0
 public static OpenWithItem Create(string strFilePath, string strMenuText,
                                   Image imgIcon, DynamicMenu dynMenu)
 {
     return(new OpenWithItem(strFilePath, strMenuText, imgIcon, dynMenu));
 }
Пример #20
0
        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();

            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 ContextMenuStrip();
            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);

            m_bInitializing = 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();
            }
        }
Пример #21
0
        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;
        }