public void UsageView_Loaded(object sender, RoutedEventArgs args)
        {
            UnityContainer container =
                (UnityContainer)Application.Current.Resources["UnityIoC"];

            InputView _inputView = (InputView)container.Resolve <IView>("InputView");

            if (ActiveGeneratorInformation
                .GetActiveGeneratorInformation().IsGenActive)
            {
                DateTime lastGenTime = (DateTime)ActiveGeneratorInformation
                                       .GetActiveGeneratorInformation()
                                       .ActiveGenStartedTime;

                this.dtepkrAnotherDay.DisplayDateStart = (DateTime?)lastGenTime;

                string[] LastGenTimeParts = TimeParts(lastGenTime);
                this.cmbxHrGenStd.SelectedValue   = LastGenTimeParts[0];
                this.cmbxMinGenStd.SelectedValue  = LastGenTimeParts[1];
                this.cmbxSecsGenStd.SelectedValue = LastGenTimeParts[2];
                this.cmbxAMPMGenStd.SelectedValue = LastGenTimeParts[3];

                DateTime currGenTime   = DateTime.Now;
                string[] CurrTimeParts = TimeParts(currGenTime);
                this.cmbxHrGenSpd.SelectedValue   = CurrTimeParts[0];
                this.cmbxMinGenSpd.SelectedValue  = CurrTimeParts[1];
                this.cmbxSecsGenSpd.SelectedValue = CurrTimeParts[2];
                this.cmbxAMPMGenSpd.SelectedValue = CurrTimeParts[3];
            }
        }
Пример #2
0
        private void InputView_Loaded(object sender, RoutedEventArgs e)
        {
            IsGenActive = ActiveGeneratorInformation
                          .GetActiveGeneratorInformation()
                          .IsGenActive;

            var inputViewModel = this.DataContext as InputViewModel;

            if (IsGenActive)
            {
                inputViewModel.LoadActiveGeneratorRecord
                .Execute(new Tuple <DatePicker, ComboBox>
                             (this.dtepkrGenInfo,
                             this.cmbxGenInfo));
            }
            else
            {
                this.wppnlLoadActiveGen.Visibility = Visibility.Collapsed;
                this.lblGenName.Content            = "";
                this.lblGenState.Content           = "OFF";
                this.cmbxGenInfo.SelectedItem      = null;
            }
        }
Пример #3
0
        private void lblGenIndicator_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!IsGenActive)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show($"Do you want to " +
                                                      $"stop active generator?",
                                                      "Confirmation",
                                                      MessageBoxButton.YesNoCancel,
                                                      MessageBoxImage.Question);

            switch (result)
            {
            case MessageBoxResult.None:
            case MessageBoxResult.Cancel:
            case MessageBoxResult.No:
                break;

            case MessageBoxResult.OK:
            case MessageBoxResult.Yes:
                UnityContainer container = (UnityContainer)Application
                                           .Current.Resources["UnityIoC"];

                UsageView _usageView = (UsageView)container.Resolve <IView>("UsageView");

                _usageView.lblCurrentGeneratorName.Content = this.cmbxGenInfo.Text;

                if (this.lblGenTimeStarted.Content != null)
                {
                    _usageView.lblGenRecordDate
                    .Content = $"{this.dtepkrGenInfo.SelectedDate.Value.ToShortDateString()} " +
                               $"{ this.lblGenTimeStarted.Content.ToString()}";
                }
                else
                {
                    _usageView.lblGenRecordDate
                    .Content = $"{this.dtepkrGenInfo.SelectedDate.Value.ToShortDateString()}";
                }

                DateTime lastGenTime = (DateTime)ActiveGeneratorInformation
                                       .GetActiveGeneratorInformation()
                                       .ActiveGenStartedTime;

                string[] LastGenTimeParts = TimeParts(lastGenTime);
                _usageView.cmbxHrGenStd.SelectedValue   = LastGenTimeParts[0];
                _usageView.cmbxMinGenStd.SelectedValue  = LastGenTimeParts[1];
                _usageView.cmbxSecsGenStd.SelectedValue = LastGenTimeParts[2];
                _usageView.cmbxAMPMGenStd.SelectedValue = LastGenTimeParts[3];


                DateTime currGenTime   = DateTime.Now;
                string[] CurrTimeParts = TimeParts(currGenTime);
                _usageView.cmbxHrGenSpd.SelectedValue   = CurrTimeParts[0];
                _usageView.cmbxMinGenSpd.SelectedValue  = CurrTimeParts[1];
                _usageView.cmbxSecsGenSpd.SelectedValue = CurrTimeParts[2];
                _usageView.cmbxAMPMGenSpd.SelectedValue = CurrTimeParts[3];

                IView mainView = container.Resolve <IView>("MainView");
                (mainView as MainView).GeneratorStartedControls(false);
                (mainView as MainView).GeneratorStoppedControls(true);
                (mainView as MainView).MainViewFrame.Navigate(_usageView);

                break;

            default:
                break;
            }
        }