Esempio n. 1
0
        private void LoadLayout()
        {
            optionsDialog   = new Options(this);
            aboutDialog     = new AboutBox();
            sessionEditor   = new SessionEditorForm();
            hotKeyChooser   = new HotkeyChooser(this);
            synchronizeForm = new SynchronizeForm();

            // Attempt to override the system and taskbar tray icons
            string iconFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\psm.ico";

            if (File.Exists(iconFile))
            {
                try
                {
                    Icon psmIcon = new Icon(iconFile);
                    systrayIcon.Icon = psmIcon;
                    this.Icon        = psmIcon;
                }
                catch (Exception)
                {
                    // Do nothing
                }
            }

            if (Properties.Settings.Default.CloseToTray)
            {
                systrayIcon.Visible = true;
            }

            // Restore the size of the application
            this.ClientSize = Properties.Settings.Default.WindowSize;

            // Restore the location of the application
            Point savedLocation = Properties.Settings.Default.Location;

            // Get the screen that will display the point
            Screen display = Screen.FromPoint(savedLocation);

            // Check that the selected display contains the point
            // if not - restore the application in the top left hand corner
            if (display != null && display.Bounds.Contains(savedLocation))
            {
                this.DesktopLocation = Properties.Settings.Default.Location;
            }
            else
            {
                this.DesktopLocation = new Point(0, 0);
            }

            // Reset the display to either the tree or the list
            displayTreeToolStripMenuItem.Checked = Properties.Settings.Default.DisplayTree;

            // Register the new session hotkey if enabled
            if (Properties.Settings.Default.HotkeyNewEnabled)
            {
                hkc.RegisterHotkey(this, HotkeyController.HotKeyId.HKID_NEW);
            }

            // Register the minimize hotkey if enabled
            if (Properties.Settings.Default.HotkeyMinimizeEnabled)
            {
                hkc.RegisterHotkey(this, HotkeyController.HotKeyId.HKID_MINIMIZE);
            }

            // Invalidate the session list to force a refresh of all forms
            sc.invalidateSessionList(this, true);

            // Expand the tree if requested on startup
            if (Properties.Settings.Default.ExpandTreeOnStartup)
            {
                sessionTreeControl.expandFullTree();
            }

            // Setup the display
            setDisplay();
        }
        private void LoadLayout()
        {
            optionsDialog = new Options(this);
            aboutDialog   = new AboutBox();
            sessionEditor = new SessionEditorForm();
            hotKeyChooser = new HotkeyChooser(this);
            synchronizeForm = new SynchronizeForm();

            // Attempt to override the system and taskbar tray icons
            string iconFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\psm.ico";
            if (File.Exists(iconFile))
            {
                try
                {
                    Icon psmIcon = new Icon(iconFile);
                    systrayIcon.Icon = psmIcon;
                    this.Icon = psmIcon;
                }
                catch (Exception)
                {
                  // Do nothing
                }
            }
            systrayIcon.Visible = true;

            // Restore the size of the application
            this.ClientSize = Properties.Settings.Default.WindowSize;

            // Restore the location of the application
            Point savedLocation = Properties.Settings.Default.Location;

            // Get the screen that will display the point
            Screen display = Screen.FromPoint(savedLocation);

            // Check that the selected display contains the point
            // if not - restore the application in the top left hand corner
            if (display != null && display.Bounds.Contains(savedLocation))
                this.DesktopLocation = Properties.Settings.Default.Location;
            else
                this.DesktopLocation = new Point(0, 0);

            // Reset the display to either the tree or the list
            displayTreeToolStripMenuItem.Checked = Properties.Settings.Default.DisplayTree;

            // Register the new session hotkey if enabled
            if (Properties.Settings.Default.HotkeyNewEnabled)
                hkc.RegisterHotkey(this, HotkeyController.HotKeyId.HKID_NEW);

            // Register the minimize hotkey if enabled
            if (Properties.Settings.Default.HotkeyMinimizeEnabled)
                hkc.RegisterHotkey(this, HotkeyController.HotKeyId.HKID_MINIMIZE);

            // Invalidate the session list to force a refresh of all forms
            sc.invalidateSessionList(this, true);

            // Expand the tree if requested on startup
            if (Properties.Settings.Default.ExpandTreeOnStartup)
                sessionTreeControl1.expandFullTree();

            // Setup the display
            setDisplay();
        }