コード例 #1
0
 public MainForm()
 {
     InitializeComponent();
     m_screens = new UPScreens();
     RefreshScreens();
     LoadSettings();
     if (Directory.Exists(CurrentPath))
     {
         ListenToFolder();
     }
     else
     {
         StopListening();
     }
 }
コード例 #2
0
        public void RefreshScreens()
        {
            string strCurrent = "";

            if (m_currentScreen != null)
            {
                strCurrent = m_currentScreen.WindowsScreen.DeviceName;
            }
            m_screens = new UPScreens();
            lbScreens.Items.Clear();
            int iFirstNonPrimary = -1;

            foreach (var s in m_screens.Screens)
            {
                int i = lbScreens.Items.Add(s);
                if (iFirstNonPrimary < 0 && !s.WindowsScreen.Primary)
                {
                    iFirstNonPrimary = i;
                }

                if (strCurrent.Length > 0)
                {
                    if (s.WindowsScreen.DeviceName == strCurrent)
                    {
                        lbScreens.SelectedIndex = i;
                    }
                }
            }

            if (lbScreens.SelectedItem == null && iFirstNonPrimary > 0)
            {
                lbScreens.SelectedIndex = iFirstNonPrimary;
            }
            else
            {
                lbScreens.SelectedIndex = 0;  // No Second Monitor Has Been Found!
            }
        }