Esempio n. 1
0
        /// <summary>
        /// Construct a new Window.
        /// </summary>
        public MainWindow()
        {
            //Set highest priority on main process.
            Process currentProcess = Process.GetCurrentProcess();

            currentProcess.PriorityClass  = ProcessPriorityClass.High;
            Thread.CurrentThread.Priority = ThreadPriority.Normal;

            if (Settings.Default.minimizeOnStart)
            {
                this.ShowActivated = false;
                this.WindowState   = System.Windows.WindowState.Minimized;
            }

            string currentVmultiMonitor        = VmultiUtil.getCurrentMonitorDevicePath();
            IEnumerable <MonitorInfo> monInfos = DeviceUtil.GetMonitorList();

            if (VmultiDevice.Current.isAvailable())
            {
                //See if the selected monitor is still connected to the computer
                if (currentVmultiMonitor != null)
                {
                    string primaryMonitor = null;
                    foreach (MonitorInfo monInfo in monInfos)
                    {
                        if (monInfo.DevicePath == currentVmultiMonitor)
                        {
                            primaryMonitor = currentVmultiMonitor;
                        }
                    }
                    if (primaryMonitor != null)                           //The vmulti monitor is still connected.
                    {
                        Settings.Default.primaryMonitor = primaryMonitor; //Make sure the same value is in settings.
                    }
                    else //The selected monitor is not connected
                    {
                        VmultiUtil.setCurrentMonitor(monInfos.First()); //Use the first monitor in the list.
                    }
                }
                else
                {
                    VmultiUtil.setCurrentMonitor(monInfos.First()); //No setting found, default to first found monitor.
                }
            }
            else
            {
                Settings.Default.primaryMonitor = "";
            }

            defaultInstance = this;

            // Load from the XAML.
            InitializeComponent();
        }
 private void MonitorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!this.initializing)
     {
         MonitorInfo monInfo = ((ComboBoxItem)this.MonitorComboBox.SelectedItem).DataContext as MonitorInfo;
         if (monInfo != null)
         {
             VmultiUtil.setCurrentMonitor(monInfo);
         }
     }
 }