Esempio n. 1
0
        private void UpdateDataDataModel()
        //private async Task UpdateDataDataModel()
        {
            try
            {
                DataModel.Topology = PathInfo.GetCurrentTopology();

                var displayList = Display.GetDisplays().ToList();
                DataModel.DisplayCount = displayList.Count;

                DataModel.Displays.ClearDynamicChildren();
                for (int i = 0; i < displayList.Count; i++)
                {
                    DataModel.Displays.AddDynamicChild(
                        $"[{i}] - {displayList[i].DeviceName}",
                        new DisplaySettingDataModel()
                    {
                        IsPrimary       = displayList[i].IsGDIPrimary,
                        Name            = displayList[i].DeviceName,
                        Number          = i,
                        Adapter         = displayList[i].Adapter.DeviceName,
                        RefreshRate     = displayList[i].CurrentSetting.Frequency,
                        Resolution      = displayList[i].CurrentSetting.Resolution,
                        Position        = displayList[i].CurrentSetting.Position,
                        ColorDepth      = displayList[i].CurrentSetting.ColorDepth,
                        DisplayRotation = displayList[i].CurrentSetting.Orientation,
                    }
                        );

                    /*
                     * DataModel.Displays.AddDynamicChild(
                     *   new DisplaySettingDataModel()
                     *   {
                     *       IsPrimary = displayList[i].IsGDIPrimary,
                     *       Name = displayList[i].DeviceName,
                     *       Number = i,
                     *       Adapter = displayList[i].Adapter.DeviceName,
                     *       RefreshRate = displayList[i].CurrentSetting.Frequency,
                     *       Resolution = displayList[i].CurrentSetting.Resolution,
                     *       Position = displayList[i].CurrentSetting.Position,
                     *       ColorDepth = displayList[i].CurrentSetting.ColorDepth,
                     *       DisplayRotation = displayList[i].CurrentSetting.Orientation,
                     *   },
                     *   string.Format("[{0}] - {1}", i, displayList[i].DeviceName),
                     *   string.Format("[{0}] - {1}", i, displayList[i].DeviceName)
                     * );
                     */
                }
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString());
            }
        }