Пример #1
0
 public MainPage()
 {
     InitializeComponent();
     if (!Directory.Exists(Dir))
     {
         Directory.CreateDirectory(Dir);
     }
     ChangeTimerSelection(-1);
     TmrSaveData.Start();
     resizeObj = new Resizer(this);
     Load     += ResizerLoad;
     Resize   += ResizerResize;
 }
Пример #2
0
        private void ChangeTimerSelection(int value)
        {
            switch (value)
            {
            case -1:
                TStrpMnuItmOff.Checked         = true;
                TStrpMnuItm15Timer.Checked     = false;
                TStrpMnuItm30Timer.Checked     = false;
                TStrpMnuItm60Timer.Checked     = false;
                TStrpMnuItmCustomTimer.Checked = false;
                TmrSaveData.Stop();
                break;

            case 0:
                TStrpMnuItmOff.Checked         = false;
                TStrpMnuItm15Timer.Checked     = true;
                TStrpMnuItm30Timer.Checked     = false;
                TStrpMnuItm60Timer.Checked     = false;
                TStrpMnuItmCustomTimer.Checked = false;
                TmrSaveData.Interval           = 900000;
                TmrSaveData.Start();
                break;

            case 1:
                TStrpMnuItmOff.Checked         = false;
                TStrpMnuItm15Timer.Checked     = false;
                TStrpMnuItm30Timer.Checked     = true;
                TStrpMnuItm60Timer.Checked     = false;
                TStrpMnuItmCustomTimer.Checked = false;
                TmrSaveData.Interval           = 1800000;
                TmrSaveData.Start();
                break;

            case 2:
                TStrpMnuItmOff.Checked         = false;
                TStrpMnuItm15Timer.Checked     = false;
                TStrpMnuItm30Timer.Checked     = false;
                TStrpMnuItm60Timer.Checked     = true;
                TStrpMnuItmCustomTimer.Checked = false;
                TmrSaveData.Interval           = 3600000;
                TmrSaveData.Start();
                break;

            case 3:
                string timerInput = Interaction.InputBox("Enter the time interval backups are saved at" +
                                                         "\n\nEnter the time in minutes (I.e.: 20, 75, 120, etc.)" +
                                                         "\n\nNOTE: Lower times = more CPU usage", "Enter Custom Timer");
                if (!double.TryParse(timerInput, out double TimerValue) && TimerValue > 0)
                {
                    _ = MessageBox.Show("Please enter in a valid number for the timer!", "Timer Set Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                try
                {
                    TmrSaveData.Interval = (int)(TimerValue * 60000);
                }
                catch (ArgumentOutOfRangeException)
                {
                    _ = MessageBox.Show("Please enter in a valid number for the timer!", "Timer Set Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (Exception)
                {
                    _ = MessageBox.Show("An error occured when trying to add the custom timer", "Timer Set Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!TStrpMnuItmDisableMsg.Checked)
                {
                    _ = MessageBox.Show($"The backup save timer is now set to run every {TimerValue} minutes", "Timer Set Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                TStrpMnuItm15Timer.Checked     = false;
                TStrpMnuItm30Timer.Checked     = false;
                TStrpMnuItm60Timer.Checked     = false;
                TStrpMnuItmCustomTimer.Checked = true;
                break;
            }
        }