public RequiredAppsControl(CMApplication app, DateTime enforcementTime, long id, DateTime?nextServiceTime) { InitializeComponent(); _requiredAppsSettings = Globals.Settings.RequiredAppsSettings; _nextServiceTime = nextServiceTime; _app = app; DataContext = _app; _isReschedule = true; _enforcementTime = enforcementTime; _scheduleId = id; TpPicker.SelectedDate = _enforcementTime; TpPicker.MaximumDate = _nextServiceTime != null ? ((DateTime)_nextServiceTime).DropSeconds() : _app.Deadline.DropSeconds(); TpPicker.MinimumDate = RoundUp(DateTime.Now); if (!string.IsNullOrEmpty(_app.Icon)) { var bmp = Utils.ToBitmapImage(_app.Icon); if (bmp != null) { Icon.Source = Utils.ToBitmapImage(_app.Icon); } } if (!string.IsNullOrEmpty(_app.Description)) { LoadMessage(_app.Description); } Globals.CcmWmiEventListener.OnStatusChange += CcmWmiEventListener_OnStatusChange; SetupTimer(); if (_nextServiceTime != null && !_app.InstallState.Equals("Installed")) { if (_enforcementTime > _nextServiceTime) { if (nextServiceTime <= RoundUp(DateTime.Now).AddMinutes(5)) { TpPicker.MinimumDate = ((DateTime)_nextServiceTime).AddMinutes(-10); TimeGrid.IsEnabled = false; ButtonGrid.IsEnabled = false; _timer.Stop(); } TpPicker.MaximumDate = (DateTime)_nextServiceTime; TpPicker.SelectedDate = (DateTime)_nextServiceTime; StatusGreen.Visibility = Visibility.Visible; StatusText.Text = Globals.Settings.RequiredAppsSettings.CoveredByServiceCycleText.Replace("%TIME%", _nextServiceTime.ToString()); return; } } SetStatus(_app); }
public RequiredAppsControl(CMApplication app, DateTime?nextServiceTime) { InitializeComponent(); _requiredAppsSettings = Globals.Settings.RequiredAppsSettings; _nextServiceTime = nextServiceTime; _app = app; DataContext = _app; TpPicker.MaximumDate = _app.InstallState.Equals("Installed") && _app.AllowedActions.Contains("Repair") ? DateTime.Now.AddYears(1) : _app.Deadline.DropSeconds(); TpPicker.MinimumDate = RoundUp(DateTime.Now); TpPicker.SelectedDate = RoundUp(DateTime.Now); BtInstall.IsEnabled = !_app.InstallState.Equals("Installed"); BtRepair.IsEnabled = _app.InstallState.Equals("Installed") && _app.AllowedActions.Contains("Repair"); if (!string.IsNullOrEmpty(_app.Icon.Trim())) { Icon.Source = Utils.ToBitmapImage(_app.Icon.Trim()); } if (!string.IsNullOrEmpty(_app.Description)) { LoadMessage(_app.Description); } Globals.CcmWmiEventListener.OnStatusChange += CcmWmiEventListener_OnStatusChange; SetupTimer(); if (_nextServiceTime != null && !_app.InstallState.Equals("Installed")) { if (_nextServiceTime < _app.Deadline) { if (_nextServiceTime <= RoundUp(DateTime.Now).AddMinutes(5)) { TpPicker.MinimumDate = ((DateTime)_nextServiceTime).AddMinutes(-5); TimeGrid.IsEnabled = false; ButtonGrid.IsEnabled = false; _timer.Stop(); } TpPicker.MaximumDate = (DateTime)_nextServiceTime; TpPicker.SelectedDate = (DateTime)_nextServiceTime; StatusGreen.Visibility = Visibility.Visible; StatusText.Text = Globals.Settings.RequiredAppsSettings.CoveredByServiceCycleText.Replace("%TIME%", _nextServiceTime.ToString()); return; } } SetStatus(_app); }