Пример #1
0
        private void LoadData()
        {
            IsBusy = true;

            ViewModelLocator.CurrentInstance.AbstractTorqueData.LoadHomeData((success, eventMessages, result) =>
            {
                if (success)
                {
                    CarInfo = result;
                    CarInfo.CostCharging = Decimal.Round((ElectricityPrice * CarInfo.TotalCharging) / 100, 2);
                    CarInfo.CostFuel     = Decimal.Round(FuelPrice * CarInfo.TotalFuelUsed, 2);
                    CarInfo.TotalCost    = Decimal.Round(CarInfo.CostFuel + CarInfo.CostCharging, 2);

                    if (CarInfo.TotalKM != 0)
                    {
                        CarInfo.CostPer100KM = Decimal.Round((CarInfo.TotalCost / CarInfo.TotalKM) * 100, 2);
                    }

                    BasicLinesGVM.GraphConsumption(0, "Home$SerieFuelC", CarInfo.DateFuelConsumption, CarInfo.FuelConsumptionList);
                }
                else
                {
                    VoltAnalyzerMessage.Send <string>(MessageConstants.ShowMessageView, eventMessages);
                }

                IsBusy = false;
            }, SelectedFolder);
        }
Пример #2
0
        public HomePVM()
        {
            LoadTorqueDataCommand   = new RelayCommand(LoadTorqueData);
            DefaultDirectoryCommand = new RelayCommand(DefaultDirectory);

            CloseCommand    = new RelayCommand <IWindow>(Close);
            ExpandCommand   = new RelayCommand <IWindow>(Expand);
            MinimizeCommand = new RelayCommand <IWindow>(Minimize);
            MoveCommand     = new RelayCommand <IWindow>(Move);

            foreach (string item in LanguageManager.ManageLanguage.GetAllLanguages())
            {
                LanguageList.Add(new LanguageSelectorVM(item));
            }

            SelectedLanguage = LanguageList[1];

            RaisePropertyChanged("LanguageList");

            if (ConfigurationManager.AppSettings.AllKeys.Contains("SelectedFolder"))
            {
                SelectedFolder = ConfigurationManager.AppSettings.GetValues("SelectedFolder")[0].ToString();
            }

            if (ConfigurationManager.AppSettings.AllKeys.Contains("FuelPrice"))
            {
                FuelPrice = decimal.Parse(ConfigurationManager.AppSettings.GetValues("FuelPrice")[0].ToString(), CultureInfo.InvariantCulture);
            }

            if (ConfigurationManager.AppSettings.AllKeys.Contains("ElectricityPrice"))
            {
                ElectricityPrice = decimal.Parse(ConfigurationManager.AppSettings.GetValues("ElectricityPrice")[0].ToString(), CultureInfo.InvariantCulture);
            }

            VoltAnalyzerMessage.Subscribe <string>(this, MessageConstants.SetBusyMessage, (string Message) =>
            {
                WaitMessage = Message;
            });

            VoltAnalyzerMessage.Subscribe <string>(this, MessageConstants.ChangeGraph, (string a_type) =>
            {
                switch (a_type)
                {
                case "FuelC":
                    BasicLinesGVM.GraphConsumption(0, "Home$SerieFuelC", CarInfo.DateFuelConsumption, CarInfo.FuelConsumptionList);
                    break;

                case "EVC":
                    BasicLinesGVM.GraphConsumption(8, "Home$SerieEVC", CarInfo.DateEVConsumption, CarInfo.EVConsumptionList);
                    break;

                default:
                    break;
                }
            });

            GraphListGVM.Add(new GraphListVM()
            {
                ID = "FuelC", Name = "Fuel consumption"
            });
            GraphListGVM.Add(new GraphListVM()
            {
                ID = "EVC", Name = "EV consumption"
            });
        }