예제 #1
0
        private bool CheckSettings()
        {
            Redshift.ExecutableError exeError = Redshift.CheckExecutable(RedshiftPath);

            if (exeError == Redshift.ExecutableError.Ok)
            {
                return(true);
            }

            SettingsWindow settingsWindow;

            if (Common.WindowExistsFocus(out settingsWindow))
            {
                return(true);
            }

            settingsWindow = new SettingsWindow();
            if (!(bool)settingsWindow.ShowDialog())
            {
                return(false);
            }

            LoadSettings();
            return(true);
        }
예제 #2
0
 public SettingsWindow(Redshift.ExecutableError initialRedshiftErrorNote)
 {
     InitializeComponent();
       LoadPosition();
       LoadConfig();
       ExecutableErrorState = initialRedshiftErrorNote;
 }
예제 #3
0
 public SettingsWindow()
 {
     InitializeComponent();
     LoadPosition();
     LoadConfig();
     ExecutableErrorState = Redshift.CheckExecutable(RedshiftPath.Text);
     SetOkButtonEnabled();
 }
예제 #4
0
        public static string StartAndWaitForOutput(string path, params string[] Args)
        {
            Redshift redshift = new Redshift(path, Args);

            redshift.Start();
            redshift.RedshiftProcess.WaitForExit();

            return(redshift.GetStandardOutput());
        }
예제 #5
0
        public bool Initialize()
        {
            LoadSettings();
            if (!CheckSettings())
            {
                return(false);
            }

            Redshift.KillAllRunningInstances();
            ProgramStatus = Settings.RedshiftEnabledOnStart ? Status.Automatic : Status.Off;
            StartTrayIcon();

            return(true);
        }
예제 #6
0
        private static Redshift InitializeContinuousStart(string path, params string[] Args)
        {
            if (CheckExecutable(path) != ExecutableError.Ok)
            {
                throw new Exception("Invalid redshift start.");
            }

            if (Instance != null && !Instance.RedshiftProcess.HasExited)
            {
                Instance.RedshiftProcess.Exited -= Instance.RedshiftProcess_Crashed;
                Instance.RedshiftProcess.Kill();
                Instance.RedshiftQuit(true);
            }
            Instance = new Redshift(path, Args);

            return(Instance);
        }
예제 #7
0
        private void ButtonRedshift_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Title           = "Redshift path",
                Filter          = "Redshift|redshift.exe|All executables|*.exe",
                CheckFileExists = true
            };

            if (File.Exists(RedshiftPath.Text))
            {
                openFileDialog.InitialDirectory = Path.GetDirectoryName(RedshiftPath.Text);
            }

            if ((bool)openFileDialog.ShowDialog())
            {
                Settings.Default.RedshiftAppPath = openFileDialog.FileName;

                ExecutableErrorState = Redshift.CheckExecutable(RedshiftPath.Text);
            }
        }
예제 #8
0
 private void redshiftPath_LostFocus(object sender, RoutedEventArgs e)
 {
     ExecutableErrorState = Redshift.CheckExecutable(RedshiftPath.Text);
 }
예제 #9
0
 private void StartRedshiftAutomatic()
 {
     string[] args = Redshift.GetArgsBySettings(DummyMethod);
       RedshiftInstance = Redshift.StartContinuous(RedshiftPath, RedshiftInstance_OnRedshiftQuit, args);
 }
예제 #10
0
        private static Redshift InitializeContinuousStart(string path, params string[] Args)
        {
            if(CheckExecutable(path) != ExecutableError.Ok)
            throw new Exception("Invalid redshift start.");

              if(Instance != null && !Instance.RedshiftProcess.HasExited)
              {
            Instance.RedshiftProcess.Exited -= Instance.RedshiftProcess_Crashed;
            Instance.RedshiftProcess.Kill();
            Instance.RedshiftQuit(true);
              }
              Instance = new Redshift(path, Args);

              return Instance;
        }
예제 #11
0
        public static string StartAndWaitForOutput(string path, params string[] Args)
        {
            Redshift redshift = new Redshift(path, Args);
              redshift.Start();
              redshift.RedshiftProcess.WaitForExit();

              return redshift.GetStandardOutput();
        }
예제 #12
0
 private void ResetScreen()
 {
     string[] args = { $"-m {(DummyMethod ? Redshift.METHOD_DUMMY : Redshift.METHOD_WINGDI)}", "-x" };
     Redshift.StartAndWaitForOutput(RedshiftPath, args);
 }
예제 #13
0
 private void StartRedshiftAutomatic()
 {
     string[] args = Redshift.GetArgsBySettings(DummyMethod);
     RedshiftInstance = Redshift.StartContinuous(RedshiftPath, RedshiftInstance_OnRedshiftQuit, args);
 }