Example #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);
        }
 public SettingsWindow(Redshift.ExecutableError initialRedshiftErrorNote)
 {
     InitializeComponent();
       LoadPosition();
       LoadConfig();
       ExecutableErrorState = initialRedshiftErrorNote;
 }
Example #3
0
 public SettingsWindow()
 {
     InitializeComponent();
     LoadPosition();
     LoadConfig();
     ExecutableErrorState = Redshift.CheckExecutable(RedshiftPath.Text);
     SetOkButtonEnabled();
 }
Example #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());
        }
Example #5
0
        public bool Initialize()
        {
            LoadSettings();
            if (!CheckSettings())
            {
                return(false);
            }

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

            return(true);
        }
Example #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);
        }
Example #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);
            }
        }
Example #8
0
 private void redshiftPath_LostFocus(object sender, RoutedEventArgs e)
 {
     ExecutableErrorState = Redshift.CheckExecutable(RedshiftPath.Text);
 }
Example #9
0
 private void StartRedshiftAutomatic()
 {
     string[] args = Redshift.GetArgsBySettings(DummyMethod);
       RedshiftInstance = Redshift.StartContinuous(RedshiftPath, RedshiftInstance_OnRedshiftQuit, args);
 }
Example #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;
        }
Example #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();
        }
Example #12
0
 private void ResetScreen()
 {
     string[] args = { $"-m {(DummyMethod ? Redshift.METHOD_DUMMY : Redshift.METHOD_WINGDI)}", "-x" };
     Redshift.StartAndWaitForOutput(RedshiftPath, args);
 }
Example #13
0
 private void StartRedshiftAutomatic()
 {
     string[] args = Redshift.GetArgsBySettings(DummyMethod);
     RedshiftInstance = Redshift.StartContinuous(RedshiftPath, RedshiftInstance_OnRedshiftQuit, args);
 }