Form providing help information on the Tray TOTP Plugin.
Inheritance: System.Windows.Forms.Form
コード例 #1
0
ファイル: TrayTOTP_Plugin.cs プロジェクト: elmarl/KeeTrayTOTP
        /// <summary>
        /// Initialization of the plugin, adding menus, handlers and forms.
        /// </summary>
        /// <param name="host">Plugin host for access to KeePass functions.</param>
        /// <returns>Successful loading of the plugin, if not the plugin is removed.</returns>
        public override bool Initialize(IPluginHost host)
        {
            // Internalize Host Handle.
            if (host == null)
            {
                return(false);
            }

            PluginHost = host;

            // Instantiate Help Form.
            _helpForm = new FormHelp();

            // Register events.
            PluginHost.MainWindow.Shown += MainWindow_Shown;

            // Notify Icon Context Menus.
            PluginHost.MainWindow.TrayContextMenu.Opening += OnNotifyMenuOpening;
            _niMenuTitle       = new ToolStripMenuItem(Localization.Strings.TrayTOTPPlugin);
            _niMenuTitle.Image = Properties.Resources.TOTP;
            PluginHost.MainWindow.TrayContextMenu.Items.Insert(0, _niMenuTitle);
            _niMenuSeperator = new ToolStripSeparator();
            PluginHost.MainWindow.TrayContextMenu.Items.Insert(1, _niMenuSeperator);

            PluginHost.MainWindow.TrayContextMenu.Opened += OnTrayContextMenuOpened;

            // Register auto-type function.
            if (PluginHost.CustomConfig.GetBool(setname_bool_AutoType_Enable, true))
            {
                SprEngine.FilterCompile += SprEngine_FilterCompile;
                SprEngine.FilterPlaceholderHints.Add(PluginHost.CustomConfig.GetString(setname_string_AutoType_FieldName, setdef_string_AutoType_FieldName).ExtWithBrackets());
            }

            // List Column TOTP.
            _liColumnTotp = new TrayTOTP_CustomColumn(this);
            PluginHost.ColumnProviderPool.Add(_liColumnTotp);

            // Refresh Timer.
            _liRefreshTimer.Interval = setstat_int_EntryList_RefreshRate;
            _liRefreshTimer.Enabled  = true;
            _liRefreshTimer.Tick    += OnTimerTick;

            //Time Correction.
            TimeCorrections = new TimeCorrectionCollection(PluginHost.CustomConfig.GetBool(setname_bool_TimeCorrection_Enable, false));
            TimeCorrectionProvider.Interval = Convert.ToInt16(PluginHost.CustomConfig.GetULong(KeeTrayTOTPExt.setname_ulong_TimeCorrection_RefreshTime, KeeTrayTOTPExt.setdef_TimeCorrection_RefreshTime));
            TimeCorrections.AddRangeFromList(PluginHost.CustomConfig.GetString(setname_string_TimeCorrection_List, string.Empty).Split(';').ToList());

            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Occurs when the main window is shown.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Shown(object sender, EventArgs e)
 {
     if (!m_host.CustomConfig.GetBool(setname_bool_FirstInstall_Shown, false))
     {
         m_host.CustomConfig.SetBool(setname_bool_FirstInstall_Shown, true);
         if (!HelpForm.Visible)
         {
             HelpForm = new FormHelp(this, true);
             HelpForm.Show();
         }
         else
         {
             HelpForm.Focus();
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Occurs when the main window is shown.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Shown(object sender, EventArgs e)
 {
     if (!Settings.FirstInstallShown)
     {
         Settings.FirstInstallShown = true;
         if (!_helpForm.Visible)
         {
             _helpForm = new FormHelp(true);
             _helpForm.Show();
         }
         else
         {
             _helpForm.Focus();
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Initialization of the plugin, adding menus, handlers and forms.
        /// </summary>
        /// <param name="host">Plugin host for access to KeePass functions.</param>
        /// <returns>Successful loading of the plugin, if not the plugin is removed.</returns>
        public override bool Initialize(IPluginHost host)
        {
            // Internalize Host Handle.
            if (host == null)
            {
                return(false);
            }

            PluginHost = host;

            Settings           = new Settings(host.CustomConfig);
            TOTPEntryValidator = new TOTPEntryValidator(Settings);

            _menuItemProvider = new MenuItemProvider(this, PluginHost);

            // Instantiate Help Form.
            _helpForm = new FormHelp();

            // Register events.
            PluginHost.MainWindow.Shown += MainWindow_Shown;

            // Register auto-type function.
            if (Settings.AutoTypeEnable)
            {
                SprEngine.FilterCompile += SprEngine_FilterCompile;
                SprEngine.FilterPlaceholderHints.Add(Settings.AutoTypeFieldName.ExtWithBrackets());
            }

            // List Column TOTP.
            columnProvider = new TrayTOTP_ColumnProvider(this);
            PluginHost.ColumnProviderPool.Add(columnProvider);

            // Refresh Timer.
            _liRefreshTimer.Interval = Settings.EntryListRefreshRate;
            _liRefreshTimer.Enabled  = true;
            _liRefreshTimer.Tick    += OnTimerTick;

            //Time Correction.
            TimeCorrectionProvider.Interval = Convert.ToInt16(Settings.TimeCorrectionRefreshTime);
            TimeCorrections = new TimeCorrectionCollection(Settings.TimeCorrectionEnable);
            TimeCorrections.AddRangeFromList(Settings.TimeCorrectionList);

            PluginHost.MainWindow.UIStateUpdated += MainWindow_UIStateUpdated;

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Initialization of the plugin, adding menus, handlers and forms.
        /// </summary>
        /// <param name="host">Plugin host for access to KeePass functions.</param>
        /// <returns>Successful loading of the plugin, if not the plugin is removed.</returns>
        public override bool Initialize(IPluginHost host)
        {
            //Internalise Host Handle.
            if (host == null)
            {
                return(false);
            }
            m_host = host;

            //Instanciate Help Form.
            HelpForm = new FormHelp(this);

            //Register form events.
            m_host.MainWindow.Shown += MainWindow_Shown;

            //Tools Menus.
            toMenuTrayTOTP       = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strTrayTOTPPlugin);
            toMenuTrayTOTP.Image = Properties.Resources.TOTP;
            m_host.MainWindow.ToolsMenu.DropDownItems.Add(toMenuTrayTOTP);
            toSubMenuSettings        = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strSettings);
            toSubMenuSettings.Image  = Properties.Resources.TOTP_Settings;
            toSubMenuSettings.Click += OnMenuSettingsClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuSettings);
            toSubMenuSeperator1 = new ToolStripSeparator();
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuSeperator1);
            toSubMenuHelp        = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strHelp);
            toSubMenuHelp.Image  = Properties.Resources.TOTP_Help;
            toSubMenuHelp.Click += OnMenuHelpClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuHelp);
            toSubMenuAbout        = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strAbout + "...");
            toSubMenuAbout.Image  = Properties.Resources.TOTP_Info;
            toSubMenuAbout.Click += OnMenuAboutClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuAbout);

            //Entry Context Menus.
            m_host.MainWindow.EntryContextMenu.Opening += OnEntryMenuOpening;
            m_host.MainWindow.EntryContextMenu.Closed  += OnEntryMenuClosed;
            enMenuCopyTOTP              = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strCopyTOTP);
            enMenuCopyTOTP.Image        = Properties.Resources.TOTP;
            enMenuCopyTOTP.ShortcutKeys = (Keys)Shortcut.CtrlT;
            enMenuCopyTOTP.Click       += OnEntryMenuTOTPClick;
            m_host.MainWindow.EntryContextMenu.Items.Insert(m_host.MainWindow.EntryContextMenu.Items.IndexOfKey(keeobj_string_EntryContextMenuCopyPassword_Name) + 1, enMenuCopyTOTP);
            enMenuSetupTOTP              = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strSetupTOTP);
            enMenuSetupTOTP.Image        = Properties.Resources.TOTP_Setup;
            enMenuSetupTOTP.ShortcutKeys = (Keys)Shortcut.CtrlShiftI;
            enMenuSetupTOTP.Click       += OnEntryMenuSetupClick;
            enMenuShowQR              = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strShowQR);
            enMenuShowQR.Image        = Properties.Resources.TOTP_Setup;
            enMenuShowQR.ShortcutKeys = (Keys)Shortcut.CtrlShiftJ;
            enMenuShowQR.Click       += OnEntryMenuShowQRClick;
            var ContextMenu = (ToolStripMenuItem)m_host.MainWindow.EntryContextMenu.Items.Find(keeobj_string_EntryContextMenuEntriesSubMenu_Name, true)[0];

            ContextMenu.DropDownItems.Insert(ContextMenu.DropDownItems.IndexOfKey(keeobj_string_EntryContextMenuEntriesSubMenuSeperator1_Name) + 1, enMenuSetupTOTP);
            ContextMenu.DropDownItems.Insert(ContextMenu.DropDownItems.IndexOfKey(keeobj_string_EntryContextMenuEntriesSubMenuSeperator1_Name) + 2, enMenuShowQR);
            enMenuSeperator = new ToolStripSeparator();
            ContextMenu.DropDownItems.Insert(ContextMenu.DropDownItems.IndexOf(enMenuShowQR) + 1, enMenuSeperator);

            //Notify Icon Context Menus.
            m_host.MainWindow.TrayContextMenu.Opening += OnNotifyMenuOpening;
            niMenuTitle       = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strTrayTOTPPlugin);
            niMenuTitle.Image = Properties.Resources.TOTP;
            m_host.MainWindow.TrayContextMenu.Items.Insert(0, niMenuTitle);
            niMenuSeperator = new ToolStripSeparator();
            m_host.MainWindow.TrayContextMenu.Items.Insert(1, niMenuSeperator);

            //Register auto-type function.
            if (m_host.CustomConfig.GetBool(setname_bool_AutoType_Enable, true))
            {
                SprEngine.FilterCompile += SprEngine_FilterCompile;
                SprEngine.FilterPlaceholderHints.Add(m_host.CustomConfig.GetString(setname_string_AutoType_FieldName, setdef_string_AutoType_FieldName).ExtWithBrackets());
            }

            //List Column TOTP.
            liColumnTOTP = new TrayTOTP_CustomColumn(this);
            m_host.ColumnProviderPool.Add(liColumnTOTP);

            //Refresh Timer.
            liRefreshTimer.Interval = setstat_int_EntryList_RefreshRate;
            liRefreshTimer.Enabled  = true;
            liRefreshTimer.Tick    += OnTimerTick;

            //Time Correction.
            TimeCorrections = new TimeCorrectionCollection(m_host.CustomConfig.GetBool(setname_bool_TimeCorrection_Enable, false));
            TimeCorrectionProvider.Interval = Convert.ToInt16(m_host.CustomConfig.GetULong(KeeTrayTOTPExt.setname_ulong_TimeCorrection_RefreshTime, KeeTrayTOTPExt.setdef_ulong_TimeCorrection_RefreshTime));
            TimeCorrections.AddRangeFromList(m_host.CustomConfig.GetString(setname_string_TimeCorrection_List, string.Empty).Split(';').ToList());

            return(true);
        }
コード例 #6
0
 /// <summary>
 /// Occurs when the main window is shown.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Shown(object sender, EventArgs e)
 {
     if (!m_host.CustomConfig.GetBool(setname_bool_FirstInstall_Shown, false))
     {
         m_host.CustomConfig.SetBool(setname_bool_FirstInstall_Shown, true);
         if (!HelpForm.Visible)
         {
             HelpForm = new FormHelp(this, true);
             HelpForm.Show();
         }
         else
         {
             HelpForm.Focus();
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// Initialization of the plugin, adding menus, handlers and forms.
        /// </summary>
        /// <param name="host">Plugin host for access to KeePass functions.</param>
        /// <returns>Successful loading of the plugin, if not the plugin is removed.</returns>
        public override bool Initialize(IPluginHost host)
        {
            //Internalise Host Handle.
            if (host == null) return false;
            m_host = host;

            //Instanciate Help Form.
            HelpForm = new FormHelp(this);

            //Register form events.
            m_host.MainWindow.Shown += MainWindow_Shown;

            //Tools Menus.
            toMenuTrayTOTP = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strTrayTOTPPlugin);
            toMenuTrayTOTP.Image = Properties.Resources.TOTP;
            m_host.MainWindow.ToolsMenu.DropDownItems.Add(toMenuTrayTOTP);
            toSubMenuSettings = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strSettings);
            toSubMenuSettings.Image = Properties.Resources.TOTP_Settings;
            toSubMenuSettings.Click += OnMenuSettingsClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuSettings);
            toSubMenuSeperator1 = new ToolStripSeparator();
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuSeperator1);
            toSubMenuHelp = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strHelp);
            toSubMenuHelp.Image = Properties.Resources.TOTP_Help;
            toSubMenuHelp.Click += OnMenuHelpClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuHelp);
            toSubMenuAbout = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strAbout + "...");
            toSubMenuAbout.Image = Properties.Resources.TOTP_Info;
            toSubMenuAbout.Click += OnMenuAboutClick;
            toMenuTrayTOTP.DropDownItems.Add(toSubMenuAbout);

            //Entry Context Menus.
            m_host.MainWindow.EntryContextMenu.Opening += OnEntryMenuOpening;
            enMenuCopyTOTP = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strCopyTOTP);
            enMenuCopyTOTP.Image = Properties.Resources.TOTP;
            enMenuCopyTOTP.ShortcutKeys = (Keys)Shortcut.CtrlT;
            enMenuCopyTOTP.Click += OnEntryMenuTOTPClick;
            m_host.MainWindow.EntryContextMenu.Items.Insert(m_host.MainWindow.EntryContextMenu.Items.IndexOfKey(keeobj_string_EntryContextMenuCopyPassword_Name) + 1, enMenuCopyTOTP);
            enMenuSetupTOTP = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strSetupTOTP);
            enMenuSetupTOTP.Image = Properties.Resources.TOTP_Setup;
            enMenuSetupTOTP.ShortcutKeys = (Keys)Shortcut.CtrlShiftI;
            enMenuSetupTOTP.Click += OnEntryMenuSetupClick;
            var ContextMenu = (ToolStripMenuItem)m_host.MainWindow.EntryContextMenu.Items.Find(keeobj_string_EntryContextMenuEntriesSubMenu_Name, true)[0];
            ContextMenu.DropDownItems.Insert(ContextMenu.DropDownItems.IndexOfKey(keeobj_string_EntryContextMenuEntriesSubMenuSeperator1_Name) + 1, enMenuSetupTOTP);
            enMenuSeperator = new ToolStripSeparator();
            ContextMenu.DropDownItems.Insert(ContextMenu.DropDownItems.IndexOf(enMenuSetupTOTP) + 1, enMenuSeperator);

            //Notify Icon Context Menus.
            m_host.MainWindow.MainNotifyIcon.ContextMenuStrip.Opening += OnNotifyMenuOpening;
            niMenuTitle = new ToolStripMenuItem(TrayTOTP_Plugin_Localization.strTrayTOTPPlugin);
            niMenuTitle.Image = Properties.Resources.TOTP;
            m_host.MainWindow.MainNotifyIcon.ContextMenuStrip.Items.Insert(0, niMenuTitle);
            niMenuSeperator = new ToolStripSeparator();
            m_host.MainWindow.MainNotifyIcon.ContextMenuStrip.Items.Insert(1, niMenuSeperator);

            //Register auto-type function.
            if (m_host.CustomConfig.GetBool(setname_bool_AutoType_Enable, true))
            {
                SprEngine.FilterCompile += SprEngine_FilterCompile;
                SprEngine.FilterPlaceholderHints.Add(m_host.CustomConfig.GetString(setname_string_AutoType_FieldName, setdef_string_AutoType_FieldName).ExtWithBrackets());
            }

            //List Column TOTP.
            liColumnTOTP = new TrayTOTP_CustomColumn(this);
            m_host.ColumnProviderPool.Add(liColumnTOTP);

            //Refresh Timer.
            liRefreshTimer.Interval = setstat_int_EntryList_RefreshRate;
            liRefreshTimer.Enabled = true;
            liRefreshTimer.Tick += OnTimerTick;

            //Time Correction.
            TimeCorrections = new TimeCorrectionCollection(m_host.CustomConfig.GetBool(setname_bool_TimeCorrection_Enable, false));
            TimeCorrectionProvider.Interval = Convert.ToInt16(m_host.CustomConfig.GetULong(KeeTrayTOTPExt.setname_ulong_TimeCorrection_RefreshTime, KeeTrayTOTPExt.setdef_ulong_TimeCorrection_RefreshTime));
            TimeCorrections.AddRangeFromList(m_host.CustomConfig.GetString(setname_string_TimeCorrection_List, string.Empty).Split(';').ToList());

            return true;
        }