private void ShowDisplayDiagnostics()
        {
            var details = DisplayDetails.GetMonitorDetails();

            #region Diagnostics
            Debug.WriteLine("****************** GetWorkingArea: {0}", Screen.GetWorkingArea(new System.Drawing.Point(0, 0)));
            Debug.WriteLine("****************** GetBounds: {0}", Screen.GetBounds(new System.Drawing.Point(0, 0)));
            Debug.WriteLine("****************** Primary Screen: {0}", Screen.PrimaryScreen.DeviceName, 0);
            Debug.WriteLine("****************** EntireDesktop Res: {0}", ScreenHelpers.GetEntireDesktopArea(), 0);
            foreach (var displayDetails in details)
            {
                Debug.WriteLine("DETAILS:");
                Debug.WriteLine("\t\tAvailability: {0}", displayDetails.Availability);
                Debug.WriteLine("\t\tModel: {0}", displayDetails.Model, 0);
                Debug.WriteLine("\t\tMonitorID: {0}", displayDetails.MonitorID, 0);
                Debug.WriteLine("\t\tPixelHeight: {0}", displayDetails.PixelHeight, 0);
                Debug.WriteLine("\t\tPixelWidth: {0}", displayDetails.PixelWidth);
                Debug.WriteLine("\t\tPnPID: {0}", displayDetails.PnPID, 0);
                Debug.WriteLine("\t\tSerialNumber: {0}", displayDetails.SerialNumber, 0);
            }
            Debug.WriteLine("********* SCREENS *********");
            var screens = Screen.AllScreens;
            foreach (var screen in screens)
            {
                Debug.WriteLine("SCREEN:");
                Debug.WriteLine("\t\tBitsPerPixel: {0}", screen.BitsPerPixel, 0);
                Debug.WriteLine("\t\tBounds: {0}", screen.Bounds, 0);
                Debug.WriteLine("\t\tDeviceName: {0}", screen.DeviceName, 0);
                Debug.WriteLine("\t\tPrimary: {0}", screen.Primary, 0);
                Debug.WriteLine("\t\tWorkingArea: {0}", screen.WorkingArea, 0);
            }
            #endregion
        }
        public static DisplayDetails GetMonitorInformation(string dbcc_name)
        {
            DisplayDetails details = DisplayDetails.GetMonitorDetails().Where(x => dbcc_name.ToLower().Contains(x.PnPID.ToLower())).FirstOrDefault();



            return(details);
        }
Esempio n. 3
0
        public void GetScreens()
        {
            _screenCollection.Clear();
            foreach (Screen screen in Screen.AllScreens)
            {
                const int dwf         = 0;
                var       info        = new DISPLAY_DEVICE();
                string    monitorname = null;
                string    deviceId    = null;
                info.cb = Marshal.SizeOf(info);
                if (EnumDisplayDevices(screen.DeviceName, 0, info, dwf))
                {
                    monitorname = info.DeviceString;
                    deviceId    = info.DeviceID;
                }
                if (monitorname == null)
                {
                    monitorname = "";
                }
                if (deviceId == null)
                {
                    deviceId = "";
                }

                foreach (AdapterInformation adapter in Manager.Adapters)
                {
                    bool detectedId = false;
                    if (screen.DeviceName.Equals(adapter.Information.DeviceName.Trim()))
                    {
                        foreach (var display in DisplayDetails.GetMonitorDetails())
                        {
                            // double check to add display with name from extracted EDID
                            if (("MONITOR" + "\\" + display.MonitorID + "\\" + display.DriverID).Equals(info.DeviceID))
                            {
                                _screenCollection.Add(
                                    new Tuple <string, string, string>((
                                                                           string.Format("{0} ({1}x{2}) on {3}", display.Model, adapter.CurrentDisplayMode.Width,
                                                                                         adapter.CurrentDisplayMode.Height, adapter.Information.Description)), deviceId, adapter.Information.DeviceName.Trim()));
                                detectedId = true;
                                break;
                            }
                        }
                        if (!detectedId)
                        {
                            _screenCollection.Add(
                                new Tuple <string, string, string>((
                                                                       string.Format("{0} ({1}x{2}) on {3}", monitorname, adapter.CurrentDisplayMode.Width,
                                                                                     adapter.CurrentDisplayMode.Height, adapter.Information.Description)), deviceId, adapter.Information.DeviceName.Trim()));
                            break;
                        }
                    }
                }
            }
        }
        public override void LoadSettings()
        {
            int       indexAdapter   = 0;
            DataTable dtblDataSource = new DataTable();

            dtblDataSource.Columns.Add("DisplayMember");
            dtblDataSource.Columns.Add("ValueMember");
            dtblDataSource.Columns.Add("AdditionalInfo");
            dtblDataSource.Columns.Add("MonitorDisplayName");
            cbScreen.DataSource.SafeDispose();
            cbScreen.Items.Clear();
            cbScreen.DataSource    = dtblDataSource;
            cbScreen.DisplayMember = "DisplayMember";
            cbScreen.ValueMember   = "ValueMember";

            foreach (Screen screen in Screen.AllScreens)
            {
                const int dwf         = 0;
                var       info        = new DISPLAY_DEVICE();
                string    monitorname = null;
                string    deviceId    = null;
                info.cb = Marshal.SizeOf(info);
                if (EnumDisplayDevices(screen.DeviceName, 0, ref info, dwf))
                {
                    monitorname = info.DeviceString;
                    deviceId    = info.DeviceID;
                }
                if (monitorname == null)
                {
                    monitorname = "";
                }
                if (deviceId == null)
                {
                    deviceId = "";
                }

                foreach (AdapterInformation adapter in Manager.Adapters)
                {
                    bool detectedId = false;
                    if (screen.DeviceName.Equals(adapter.Information.DeviceName.Trim()))
                    {
                        foreach (var display in DisplayDetails.GetMonitorDetails())
                        {
                            // double check to add display with name from extracted EDID
                            if (("MONITOR" + "\\" + display.MonitorID + "\\" + display.DriverID).Equals(info.DeviceID))
                            {
                                if (!string.IsNullOrEmpty(display.Model))
                                {
                                    dtblDataSource.Rows.Add(string.Format("{0} ({1}x{2}) on {3} - Screen Primary : {4}", display.Model,
                                                                          adapter.CurrentDisplayMode.Width, adapter.CurrentDisplayMode.Height, adapter.Information.Description, screen.Primary ? "Yes" : "No"),
                                                            indexAdapter, info.DeviceID, adapter.Information.DeviceName.Trim());
                                    indexAdapter++;
                                    detectedId = true;
                                    break;
                                }
                                dtblDataSource.Rows.Add(string.Format("{0} ({1}x{2}) on {3} - Screen Primary : {4}", monitorname,
                                                                      adapter.CurrentDisplayMode.Width, adapter.CurrentDisplayMode.Height, adapter.Information.Description, screen.Primary ? "Yes" : "No"),
                                                        indexAdapter, info.DeviceID, adapter.Information.DeviceName.Trim());
                                indexAdapter++;
                                detectedId = true;
                                break;
                            }
                        }
                        if (!detectedId)
                        {
                            dtblDataSource.Rows.Add(string.Format("{0} ({1}x{2}) on {3} - Screen Primary : {4}", monitorname,
                                                                  adapter.CurrentDisplayMode.Width, adapter.CurrentDisplayMode.Height, adapter.Information.Description, screen.Primary ? "Yes" : "No"),
                                                    indexAdapter, deviceId, adapter.Information.DeviceName.Trim());
                            indexAdapter++;
                            break;
                        }
                    }
                }
            }

            using (Settings xmlreader = new MPSettings())
            {
                // Load general settings
                for (int index = 0; index < _sectionEntries.Length; index++)
                {
                    string[] currentSection = _sectionEntries[index];
                    settingsCheckedListBox.SetItemChecked(index, xmlreader.GetValueAsBool(currentSection[0], currentSection[1], bool.Parse(currentSection[2])));
                }

                _screennumber     = xmlreader.GetValueAsInt("screenselector", "screennumber", 0);
                _screenDeviceId   = xmlreader.GetValueAsString("screenselector", "screendeviceid", "");
                _usePrimaryScreen = xmlreader.GetValueAsBool("general", "useprimaryscreen", false);

                while (cbScreen.Items.Count <= _screennumber)
                {
                    dtblDataSource.Rows.Add("screen nr :" + cbScreen.Items.Count + " (currently unavailable)");
                }

                for (int index = 0; index < cbScreen.Items.Count; index++)
                {
                    //Get additional info for selected item
                    var dataRowView = cbScreen.Items[index] as DataRowView;
                    if (dataRowView != null)
                    {
                        string screenDeviceId = dataRowView["AdditionalInfo"].ToString();
                        if (screenDeviceId.Equals(_screenDeviceId))
                        {
                            cbScreen.SelectedIndex = index;
                            _screennumber          = index;
                        }
                    }
                }

                // Check if screen are present and if not force to use primary screen
                if (cbScreen.SelectedIndex == -1)
                {
                    cbScreen.SelectedIndex = 0;
                }

                if (_usePrimaryScreen)
                {
                    cbScreen.Enabled = false;
                }

                nudDelay.Value = xmlreader.GetValueAsInt("general", "delay", 0);
                mpCheckBoxMpStartup.Checked = xmlreader.GetValueAsBool("general", "delay startup", false);
                mpCheckBoxMpResume.Checked  = xmlreader.GetValueAsBool("general", "delay resume", false);
            }

            // On single seat WaitForTvService is forced enabled !
            cbWaitForTvService.Checked = Network.IsSingleSeat();
        }