Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns relative location to draw a control for a specific display
        /// </summary>
        /// <param name="collapsed">Collapsed or full form location required</param>
        /// <param name="screenname">The DeviceName of the display</param>
        /// <returns>Integer array of offset x and y co-ordinates for display</returns>
        public static int[] PositionForDisplay(bool collapsed, string screenname)
        {
            VNC_Screen screen = GetScreenByDeviceName(screenname);

            if (collapsed)
            {
                return(new int[] { screen.X + 20, screen.Height - 95 - 20 });
            }
            else
            {
                return(new int[] { screen.X + 20, screen.Y + 20 });
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 /// <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;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns the VNC_Screen for the Primary display
 /// </summary>
 /// <returns>The matching VNC_Screen object</returns>
 public static VNC_Screen GetPrimaryScreen()
 {
     return(VNC_Screen.EnumerateScreens().Find(x => x.Primary == true));
 }