Example #1
0
        /// <summary>
        /// Initialize PuTTY STORM sessions form (Form2) and register hotkeys for
        /// easy and fast swithing between TabPages.
        /// </summary>
        public SessionsForm(List <ProcessInfo> _my_ProcessInfo_List_TC_1, TabControl _tabcontrol1, TabControl _tabcontrol2,
                            SplitContainer _SessionsSplitContainer, List <GroupBox> _containers_list, GlobalHotKeysWorker _TabPagesForwardGlobalHotKeyWorker,
                            GlobalHotKeysWorker _TabPagesBackwardGlobalHotKeyWorker, GlobalHotKeysWorker _SplitScreenGlobalHotKeyWorker,
                            GlobalHotKeysWorker _SFTPManagerGlobalHotKeyWorker, GlobalHotKeysWorker _KotarakGlobalHotKeyWorker)
        {
            this.tabcontrol1 = _tabcontrol1;
            this.tabcontrol2 = _tabcontrol2;
            this.my_ProcessInfo_List_TC_1 = _my_ProcessInfo_List_TC_1;
            this.SessionsSplitContainer   = _SessionsSplitContainer;
            this.containers_list          = _containers_list;

            // GlobalHotKeys Configuration settings
            tabPagesForwardGlobalHotKeySettings  = new TabPagesForwardGlobalHotKeySettings();
            tabPagesbackwardGlobalHotKeySettings = new TabPagesBackwardGlobalHotKeySettings();
            splitScreenGlobalHotKeySettings      = new SplitScreenGlobalHotKeySettings();
            sftpManagerGlobalHotKeySettings      = new SFTPManagerGlobalHotKeySettings();
            kotarakGlobalHotKeySettings          = new KotarakGlobalHotKeySettings();

            // GlobalHotKeys registration
            this.TabPagesForwardGlobalHotKeyWorker  = _TabPagesForwardGlobalHotKeyWorker;
            this.TabPagesBackwardGlobalHotKeyWorker = _TabPagesBackwardGlobalHotKeyWorker;
            this.SplitScreenGlobalHotKeyWorker      = _SplitScreenGlobalHotKeyWorker;
            this.SFTPManagerGlobalHotKeyWorker      = _SFTPManagerGlobalHotKeyWorker;
            this.KotarakGlobalHotKeyWorker          = _KotarakGlobalHotKeyWorker;

            saved_data     = new GetSavedSessions();
            IsPasswordLess = new PasswordLess();

            // Initialize GlobalHotKeys to the default values if config is empty (application first run)!
            GlobalHotKeysFirstStart();

            // Register GlobalHotKeys
            this.TabPagesForwardGlobalHotKeyWorker.Handle = this.Handle;
            this.TabPagesForwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(tabPagesForwardGlobalHotKeySettings.key),
                                                                        tabPagesForwardGlobalHotKeySettings.modifier);

            this.TabPagesBackwardGlobalHotKeyWorker.Handle = this.Handle;
            this.TabPagesBackwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(tabPagesbackwardGlobalHotKeySettings.key),
                                                                         tabPagesbackwardGlobalHotKeySettings.modifier);

            this.SplitScreenGlobalHotKeyWorker.Handle = this.Handle;
            this.SplitScreenGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(splitScreenGlobalHotKeySettings.key),
                                                                    splitScreenGlobalHotKeySettings.modifier);

            this.SFTPManagerGlobalHotKeyWorker.Handle = this.Handle;
            this.SFTPManagerGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(sftpManagerGlobalHotKeySettings.key),
                                                                    sftpManagerGlobalHotKeySettings.modifier);

            this.KotarakGlobalHotKeyWorker.Handle = this.Handle;
            this.KotarakGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(kotarakGlobalHotKeySettings.key),
                                                                kotarakGlobalHotKeySettings.modifier);


            WindowEvents = new GlobalWindowEvents();
            SessionsForm.WindowEvents.SystemSwitch += new EventHandler <GlobalWindowEventArgs>(OnSystemSwitch);
        }
        public GlobalHotKeysManager(GlobalHotKeysWorker _TabPagesForwardGlobalHotKeyWorker, GlobalHotKeysWorker _TabPagesBackwardGlobalHotKeyWorker,
                                    GlobalHotKeysWorker _SplitScreenGlobalHotKeyWorker, GlobalHotKeysWorker _SFTPManagerGlobalHotKeyWorker, GlobalHotKeysWorker _KotarakGlobalHotKeyWorker)
        {
            // GlobalHotKeys Manager Main Form settings
            tabPagesForwardModifiersCheckBoxes  = new List <CheckBox>();
            tabPagesbackwardModifiersCheckBoxes = new List <CheckBox>();
            splitScreenModifiersCheckBoxes      = new List <CheckBox>();
            sftpManagerModifierCheckBoxes       = new List <CheckBox>();
            kotarakModifierCheckBoxes           = new List <CheckBox>();

            // GlobalHotKeysSettings
            tabPagesForwardGlobalHotKeySettings  = new TabPagesForwardGlobalHotKeySettings();
            tabPagesbackwardGlobalHotKeySettings = new TabPagesBackwardGlobalHotKeySettings();
            splitScreenGlobalHotKeySettings      = new SplitScreenGlobalHotKeySettings();
            sftpManagerGlobalHotKeySettings      = new SFTPManagerGlobalHotKeySettings();
            kotarakGlobalHotKeySettings          = new KotarakGlobalHotKeySettings();

            // GlobalHotKeys registration
            this.TabPagesForwardGlobalHotKeyWorker  = _TabPagesForwardGlobalHotKeyWorker;
            this.TabPagesBackwardGlobalHotKeyWorker = _TabPagesBackwardGlobalHotKeyWorker;
            this.SplitScreenGlobalHotKeyWorker      = _SplitScreenGlobalHotKeyWorker;
            this.SFTPManagerGlobalHotKeyWorker      = _SFTPManagerGlobalHotKeyWorker;
            this.KotarakGlobalHotKeyWorker          = _KotarakGlobalHotKeyWorker;

            // Fill Key comboboxes with strings of Keys type
            object      keys       = Enum.GetValues(typeof(Keys));
            IEnumerable enumerable = keys as IEnumerable;

            InitializeComponent();

            if (enumerable != null)
            {
                foreach (object element in enumerable)
                {
                    TabPagesForwardCombobox.Items.Add(element);
                    TabPagesBackwardCombobox.Items.Add(element);
                    SplitScreenCombobox.Items.Add(element);
                    SFTPManagerCombobox.Items.Add(element);
                    KotarakCombobox.Items.Add(element);
                }
            }
        }