コード例 #1
0
        private void ChangeScreenResolution()
        {
            if (Utils.lastScreenChanged == null)
            {
                Utils.lastScreenChanged = DateTime.Now;
            }
            else
            {
                if (DateTime.Now.Subtract(Utils.lastScreenChanged).Seconds > 1)
                {
                    Utils.lastScreenChanged = DateTime.Now;

                    DisplayInfos currentDisplay = DisplayInfos.GetCurrentMode();

                    // get index of current display in displayList
                    int currentDisplayIndex = MainWindow.displayList.FindIndex(display => (display.width == currentDisplay.width) && (display.height == currentDisplay.height) && (display.color == currentDisplay.color));

                    DisplayInfos selectedDisplay = MainWindow.displayList[screenResolutionIndex];

                    // if current display index != displayIndex selected
                    if (screenResolutionIndex != currentDisplayIndex)
                    {
                        new LogWriter(LogWriter.LogType.INFORMATION, "Change display setting from " +
                                      currentDisplay.width + "x" + currentDisplay.height + "(" + currentDisplay.color + ") to " +
                                      selectedDisplay.width + "x" + selectedDisplay.height + "(" + selectedDisplay.color + ")");

                        ChangeResolutionResult result = (ChangeResolutionResult)DisplayInfos.ChangeDisplaySettings(selectedDisplay.width, selectedDisplay.height, selectedDisplay.color);

                        new LogWriter(LogWriter.LogType.WARNING, "Resolution change with this code : " + result.ToString());
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Add one app to tracking list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTrackedApp(object sender, RoutedEventArgs e)
        {
            DisplayInfos currentDisplay   = DisplayInfos.GetCurrentMode();
            int          currentModeIndex = displayList.FindIndex(display => (display.width == currentDisplay.width) && (display.height == currentDisplay.height) && (display.color == currentDisplay.color));

            TrackedApp newTrackedApp = new TrackedApp("select .exe file", StateType.noState, new List <ActionApp>(), new List <ActionApp>(), currentModeIndex, false);

            trackedListGrid.Items.Add(newTrackedApp);
        }