Ejemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var dialog = new AddProgramDialog();
            var result = dialog.ShowDialog();

            if (result == DialogResult.OK && dialog.ProgramContainerToCreate != null)
            {
                if (_userConfig.Programs.Any(p => p.ExecutableName == dialog.ProgramContainerToCreate.ExecutableName))
                {
                    DuplicateValidationLabel.Visible = true;
                    return;
                }

                DuplicateValidationLabel.Visible = false;

                _userConfig.Programs.Add(dialog.ProgramContainerToCreate);
                ProgramListBox.DataSource = null;
                ProgramListBox.DataSource = _userConfig.Programs;

                ReadWriteHelper.CreateFolderIfMissing(_pathToConfigFolder);
                ReadWriteHelper.WriteToBinaryFile(_pathToConfig, _userConfig);

                //If service is currently running, restart it so it loads new config
                var runningProcess = Process.GetProcesses().Where(p => p.ProcessName == "SaveReminder.service").ToList();
                if (runningProcess.Any())
                {
                    runningProcess.ForEach(p => p.Kill());

                    StartService();
                }
            }
        }
Ejemplo n.º 2
0
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            if (ProgramListBox.SelectedItem != null)
            {
                DuplicateValidationLabel.Visible = false;

                _userConfig.Programs.RemoveAll(p =>
                                               p.ExecutableName == ((ProgramContainer)ProgramListBox.SelectedItem).ExecutableName);

                ReadWriteHelper.CreateFolderIfMissing(_pathToConfigFolder);
                ReadWriteHelper.WriteToBinaryFile(_pathToConfig, _userConfig);

                ProgramListBox.DataSource = null;
                ProgramListBox.DataSource = _userConfig.Programs;
            }
        }
Ejemplo n.º 3
0
        public static ReflectionProjectContent LoadProjectContent(Stream stream, ProjectContentRegistry registry)
        {
            ReflectionProjectContent pc;
            BinaryReader             reader = new BinaryReader(stream);

            try {
                pc = new ReadWriteHelper(reader).ReadProjectContent(registry);
                if (pc != null)
                {
                    pc.InitializeSpecialClasses();
                }
                return(pc);
            } catch (EndOfStreamException) {
                LoggingService.Warn("Read dom: EndOfStreamException");
                return(null);
            }
            // do not close the stream
        }
Ejemplo n.º 4
0
        public SaveReminderContext()
        {
            _notifyIcon      = new NotifyIcon();
            _icon            = Icon.FromHandle(Properties.Resources.baseline_save_white_24dp.GetHicon());
            _notifyIcon.Icon = _icon;

            _pauseOneHourMenuItem      = new MenuItem("Pause For an Hour", OnPauseOneHour);
            _pauseTwelveHoursMenuItem  = new MenuItem("Pause For 12 Hours", OnPauseTwelveHours);
            _pauseIndefinitelyMenuItem = new MenuItem("Pause Indefinitely", OnPauseIndefinitely);
            _resumeMenuItem            = new MenuItem("Resume", OnResume);
            _resumeMenuItem.Visible    = false;

            _notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] {
                _pauseOneHourMenuItem,
                _pauseTwelveHoursMenuItem,
                _pauseIndefinitelyMenuItem,
                _resumeMenuItem,
                new MenuItem("Configuration", OnConfiguration),
                new MenuItem("Exit", OnExit)
            });
            _notifyIcon.Visible = false;
            _notifyIcon.Text    = "Save Reminder";
            _notifyIcon.Visible = true;

            if (File.Exists(_pathToConfig))
            {
                _userConfig = ReadWriteHelper.ReadFromBinaryFile <UserDataV1>(_pathToConfig);
            }
            else
            {
                _notifyIcon.BalloonTipText = "Couldn't find config file!  Please use the config utility to setup a reminder.";
                _notifyIcon.ShowBalloonTip(5000);
                _userConfig = new UserDataV1();
            }

            _timer.Interval  = 65000; // 65 seconds
            _timer.AutoReset = true;
            _timer.Elapsed  += new System.Timers.ElapsedEventHandler(OnTimer);
            _timer.Start();

            OnTimer(null, null);
        }
Ejemplo n.º 5
0
        public ConfigGui()
        {
            InitializeComponent();
            VersionLabel.Text = "Version " + Version;

            _updateRunningStatusTimer.Elapsed  += (o, args) => OnUpdateRunningStatus();
            _updateRunningStatusTimer.AutoReset = false;

            if (File.Exists(_pathToConfig))
            {
                _userConfig = ReadWriteHelper.ReadFromBinaryFile <UserDataV1>(_pathToConfig);
            }
            else
            {
                _userConfig = new UserDataV1();
            }

            ProgramListBox.DataSource   = _userConfig.Programs;
            ProgramListBox.SelectedItem = null;
            _listInitialized            = true;
        }
Ejemplo n.º 6
0
 public static ReflectionProjectContent LoadProjectContent(Stream stream, ProjectContentRegistry registry)
 {
     ReflectionProjectContent pc;
     BinaryReader reader = new BinaryReader(stream);
     try {
         pc = new ReadWriteHelper(reader).ReadProjectContent(registry);
         if (pc != null) {
             pc.InitializeSpecialClasses();
             pc.AssemblyCompilationUnit.Freeze();
         }
         return pc;
     } catch (EndOfStreamException) {
         LoggingService.Warn("Read dom: EndOfStreamException");
         return null;
     } catch (Exception ex) {
         HostCallback.ShowMessage("Error loading cached code-completion data.\n" +
                                  "The cached file might be corrupted and will be regenerated.\n\n" +
                                  ex.ToString());
         return null;
     }
     // do not close the stream
 }
Ejemplo n.º 7
0
        public static ReflectionProjectContent LoadProjectContent(Stream stream, ProjectContentRegistry registry)
        {
            ReflectionProjectContent pc;
            BinaryReader             reader = new BinaryReader(stream);

            try {
                pc = new ReadWriteHelper(reader).ReadProjectContent(registry);
                if (pc != null)
                {
                    pc.InitializeSpecialClasses();
                }
                return(pc);
            } catch (EndOfStreamException) {
                LoggingService.Warn("Read dom: EndOfStreamException");
                return(null);
            } catch (Exception ex) {
                HostCallback.ShowMessage("Error loading cached code-completion data.\n" +
                                         "The cached file might be corrupted and will be regenerated.\n\n" +
                                         ex.ToString());
                return(null);
            }
            // do not close the stream
        }
Ejemplo n.º 8
0
		public static ReflectionProjectContent LoadProjectContent(Stream stream, ProjectContentRegistry registry)
		{
			ReflectionProjectContent pc;
			BinaryReader reader = new BinaryReader(stream);
			try {
				pc = new ReadWriteHelper(reader).ReadProjectContent(registry);
				if (pc != null) {
					pc.InitializeSpecialClasses();
				}
				return pc;
			} catch (EndOfStreamException) {
				LoggingService.Warn("Read dom: EndOfStreamException");
				return null;
			}
			// do not close the stream
		}