/// <summary>
        /// Updates the location of the form relevant to the selected display
        /// </summary>
        /// <param name="collapse">Display form in a collapsed/shrunk state</param>
        private void RefreshSwitchUI(bool collapse)
        {
            //Only set if form state changing
            if (iscollapsed != collapse)
            {
                //Set required size for form and show/hide panels with relevant controls
                if (!collapse)
                {
                    this.Size = new Size(370, 95); pnlMin.Hide(); pnlMain.Show(); this.ControlBox = true;
                }
                else
                {
                    this.Size = new Size(136, 95); pnlMain.Hide(); pnlMin.Show(); this.ControlBox = false;
                }
            }

            //Test if form is to be collapsed, and set the appropriate position for the form
            if (!collapse)
            {
                int[] windowpos = VNC_Screen.PositionForDisplay(false, RegistryManagement.GetRegistryValue("DisplayDevice")); this.Left = windowpos[0]; this.Top = windowpos[1];
            }
            else
            {
                int[] windowpos = VNC_Screen.PositionForDisplay(true, RegistryManagement.GetRegistryValue("DisplayDevice")); this.Left = windowpos[0]; this.Top = windowpos[1];
            }

            iscollapsed = collapse;
        }
示例#2
0
 /// <summary>
 /// Event fired when tmrCheckPrimaryScreen elapses - used to ensure we have recorded the correct primary display
 /// </summary>
 private void tmrCheckPrimaryScreen_Tick(object sender, EventArgs e)
 {
     if (RegistryManagement.GetRegistryValue("PrimaryMonitor") != VNC_Screen.GetPrimaryScreen().DeviceName)
     {
         RegistryManagement.SetRegistryValue("PrimaryMonitor", VNC_Screen.GetPrimaryScreen().DeviceName);
     }
 }
示例#3
0
        /// <summary>
        /// Event fired when tmrShowSwitchUI elapses - used to force frmSwitchUI to show if invoked via an appropriate command
        /// </summary>
        private void tmrShowSwitchUI_Tick(object sender, EventArgs e)
        {
            bool showuinow = false;

            if (RegistryManagement.GetRegistryValue("ShowUINow") != "")
            {
                showuinow = Convert.ToBoolean(RegistryManagement.GetRegistryValue("ShowUINow"));
            }

            if (showuinow)
            {
                RegistryManagement.SetRegistryValue("ShowUINow", "false"); ShowSwitchUI(true);
            }
        }
 /// <summary>
 /// Event for our Registry polling Timer
 /// </summary>
 private void tmrCheckReg_Tick(object sender, EventArgs e)
 {
     //Don't fire if user is currently selecting a display
     if (!cmbDisplaySelector.DroppedDown)
     {
         //Only fire if the last session state indicates a user is currently logged in
         if (RegistryManagement.GetRegistryValue("SessionChange") == "SessionLogon" || RegistryManagement.GetRegistryValue("SessionChange") == "SessionUnlock")
         {
             //Check if the selected value is different to the set value
             if (cmbDisplaySelector.SelectedValue.ToString() != RegistryManagement.GetRegistryValue("DisplayDevice"))
             {
                 //Set the combobox value to match the displayed screen from Registry
                 if (RegistryManagement.GetRegistryValue("DisplayDevice") != "")
                 {
                     cmbDisplaySelector.SelectedIndex = VNC_Screen.EnumerateScreens().FindIndex(x => x.DeviceName == RegistryManagement.GetRegistryValue("DisplayDevice"));
                 }
                 else
                 {
                     cmbDisplaySelector.SelectedIndex = 0;
                 }
             }
         }
     }
 }
        /// <summary>
        /// COnstructor for the formo
        /// </summary>
        /// <param name="_allowclose">Is the form allowed to be closed (e.g. shown when VNC session not in progress)</param>
        public frmSwitchUI(bool _allowclose)
        {
            InitializeComponent();

            allowclose = _allowclose;

            //Set datasource for combobox to a list of currently connected screens
            cmbDisplaySelector.DataSource = VNC_Screen.EnumerateScreens();

            //Set combobox selection to match the current screen displayed from Registry value
            cmbDisplaySelector.SelectedIndex = VNC_Screen.EnumerateScreens().FindIndex(x => x.DeviceName == RegistryManagement.GetRegistryValue("DisplayDevice"));

            //Display full form
            RefreshSwitchUI(false);

            //Attach event handler for combobox
            cmbDisplaySelector.SelectedIndexChanged += new EventHandler(cmbDisplaySelector_SelectedIndexChanged);
        }