Пример #1
0
 public AppContext()
 {
     InitializeComponent();
     ReadGeneralInfo();
     if (!_useDirectRef && (_login.Equals("") || _password.Equals("")))
     {
         var setView = new SettingsView(this);
         setView.Show();
     }
     _notifyIcon.Click += OnIconClick;
     var listener = new YotaListener(this);
     _yota = new YotaNavigator(_login, _password, _deviceId, _useDirectRef, listener);
     _animMgr = new ProcessAnimationManager(
         this,
         _backColor,
         _textColor,
         _textFont
      );
     _animMgr.SetText("?");
     if (Settings.Default.NeedScheduler)
         _scheduler = new Scheduler(_yota);
     else
     {
         if (_yota != null && _yota.UserDataIsFull())
             _yota.SetRate(-1);
     }
 }
Пример #2
0
 public ScheduleView(Scheduler scheduler, AppContext context)
 {
     InitializeComponent();
     _context = context;
     _scheduler = scheduler;
     _checkBoxes = new[] { startAppCheckBox, exitAppCheckBox, sleepStartCheckBox, sleepFinCheckBox, startProcessCheckBox, timeCheckBox};
     _keys = new[] { Scheduler.KeyOnStartApp, Scheduler.KeyOnExitApp, Scheduler.KeyOnStartSleep, Scheduler.KeyOnExitSleep, Scheduler.KeyOnStartProcess, Scheduler.KeyOnTime};
     _controls = new Control[] { startAppComboBox, exitAppComboBox, sleepBeginComboBox, sleepFinComboBox4, startProcessDataGridView, timeDataGridView};
     _comboBoxes = new[] { startAppComboBox, exitAppComboBox, sleepBeginComboBox, sleepFinComboBox4 };
     // устанавливаем значения CheckBox-ов
     for (int i = 0; i < _checkBoxes.Length; ++i)
         _checkBoxes[i].Checked = _scheduler.NeedChangeOnEvent(_keys[i]);
     // устанавливаем доступность элементов, соответствующих CheckBox-ам
     for (int i = 0; i < _checkBoxes.Length; ++i)
         if (_controls[i] != null)
             _controls[i].Enabled = _checkBoxes[i].Checked;
     // определяем списки тарифов
     YotaParser parser = _scheduler.GetParser();
     if (parser == null)
     {
         Close();
         return;
     }
     String deviceId = Settings.Default.DeviceID;
     if (!parser.DeviceIdExists(deviceId))
     {
         Close();
         return;
     }
     int rateCount = parser.GetRateCount(deviceId);
     _rateNames = new string[rateCount];
     _rateCodes = new string[rateCount];
     for (int i = 0; i < rateCount; ++i)
     {
         _rateNames[i] = parser.GetMiddleRateName(deviceId, i);
         _rateCodes[i] = parser.GetRateCode(deviceId, i);
     }
     // вставляем списки тарифов в элементы интерфейса
     for (int i = 0; i < _comboBoxes.Length; ++i)
     {
         _comboBoxes[i].Items.AddRange(_rateNames);
         _comboBoxes[i].SelectedIndex = _scheduler.RateNumOnChange(_keys[i]);
     }
     startProcessDataGridView.SetRates(_rateNames);
     timeDataGridView.SetRates(_rateNames);
     // заполняем таблицу процессов
     var procRates = _scheduler.GetProcessStartRates();
     foreach (var procName in procRates.Keys)
         startProcessDataGridView.AddRow(procName, procRates[procName]);
     // заполняем таблицу расписания
     var timeRates = _scheduler.GetTimeRates();
     foreach (var timeRate in timeRates)
         timeDataGridView.AddRow(timeRate.dayNum, timeRate.hours, timeRate.minutes, timeRate.seconds, timeRate.rateNum, timeRate.everyDay);
 }
Пример #3
0
 public ScheduleByTimerExecuter(Scheduler scheduler)
 {
     _scheduler = scheduler;
     _timer = new Timer();
     _timer.Interval = Scheduler.TimeExecutorInterval;
     _timer.Tick += new EventHandler(OnTick);
     _timer2 = new Timer();
     _timer2.Interval = Scheduler.TimeExecutorInterval2;
     _timer2.Tick += new EventHandler(OnTick2);
     _lastProcesses = new Dictionary<string, Process>();
 }