/// <summary> /// Initializes each viewmodel after the MainViewModel has been constructed. /// </summary> public void Init() { if (VehicleViewModel == null) VehicleViewModel = new VehicleViewModel(); if (CommunicationViewModel == null) CommunicationViewModel = new CommunicationViewModel(); if (AutoControlViewModel == null) AutoControlViewModel = new AutoControlViewModel(); if (VisualizationViewModel == null) VisualizationViewModel = new VisualizationViewModel(); }
public OxyPlotVisualizationViewModelAdapter(VisualizationViewModel viewModel) { _plotModel = new PlotModel(); _vizualizationViewModel = viewModel; _viewModel = viewModel.DataViewModel as ChartViewModel; _viewModel.ChartSeries.CollectionChanged += ChartSeries_CollectionChanged; _vizualizationViewModel.PropertyChanged += _viewModel_PropertyChanged; }
public OxyPlotVisualizationViewModel(VisualizationViewModel viewModel) : base(viewModel.DataViewModel) { Dispatcher = viewModel.Dispatcher; Name = viewModel.Name; this.DataViewModel = viewModel.DataViewModel; OnDispose += (sender, args) => viewModel.Dispose(); _adapter = new OxyPlotVisualizationViewModelAdapter(viewModel); _adapter.PlotModelChanged += _adapter_PlotModelChanged; _adapter.PlotDataUpdate += _adapter_PlotDataUpdate; }
public ShellViewModel(IWindowManager windowManager, IEventAggregator eventAggregator) { this.windowManager = windowManager; this.eventAggregator = eventAggregator; this.eventAggregator.Subscribe(this); VisualizationViewModel visualization = new VisualizationViewModel("DesktopViewModel", VisualizationViewModelType.Screen); this.Handle(visualization); //InicializarDatosPrueba(); }
public void Handle(VisualizationViewModel visualization) { IScreen viewModelScreen = ScreenLocator.Get(visualization.ViewModel); if (visualization.VisualizationViewModelType == VisualizationViewModelType.Screen) { ActivateItem(viewModelScreen); } else { windowManager.ShowWindow(viewModelScreen, null, null); } }
private void Animation_Completed(object sender, EventArgs e) { Console.WriteLine("zakończenie animacji2"); if (TrainViewModel.nextTrain == 1) { ViewModel.VisualizationViewModel.StartNewTrainReturn(); TrainViewModel.nextTrain = 0; } foreach (int key in TrainViewModel.trainList.Keys) { Console.WriteLine(key.ToString()); } VisualizationViewModel.RemoveTrain2(newTrain); trainInMove = false; }
// GET: Visualization public ActionResult Index(VisualizationViewModel vvm) { if (vvm == null) { vvm = new VisualizationViewModel(); } if (vvm.PatientId != null) { int[] ids = Globals.GetIdsFromString(vvm.PatientId); if (ids.Length == 1) { int id = ids.FirstOrDefault(); Patient patient = DB.Patients.FirstOrDefault(x => x.PatientId == id); if (patient != null) { vvm.MainPatientId = id; return(RedirectToAction("Show", "Visualization", new { id = vvm.MainPatientId })); } } } User user = (Session["user"] as User); if (user?.Employee != null) { vvm.Patients = DB.Patients.ToList(); } else if (user?.Patient != null) { User patient = DB.Users.FirstOrDefault(x => x.UserId == user.UserId); if (patient != null) { vvm.Patients = DB.Patients.Where(x => x.PatientId == patient.Patient.PatientId || x.ParentPatientId == patient.Patient.PatientId).ToList(); } } else { vvm.Patients = new List <Patient>(); } return(View("Index", vvm)); }
public void Add(T item, bool show) { _items.Add(item); var dataViewModel = item as DataViewModelBase; var vizViewModel = new VisualizationViewModel(dataViewModel); var vizualizationViewModel = new VisualizationWindowViewModel { Visualization = vizViewModel, VisualizationState = new VisualizationStateViewModel( item.Name, dataViewModel.AllRecords ) }; vizualizationViewModel.Visualization.OnDispose += (s, a) => Remove(item); var view = show ? Manager.Show(vizualizationViewModel) : Manager.Create(vizualizationViewModel); _viewMap.Add(item, view); }
public IActionResult ReadCSVFile(VisualizationViewModel visualizationModel) { if (ModelState.IsValid) { if (!_context.CheckIfNameOfFileIsUnique(visualizationModel.NameOfFile)) { return(RedirectToAction("Index")); } var folderName = "Upload"; ReadFromCSVCollectionWithErrors records = new ReadFromCSVCollectionWithErrors(); var savePath = Path.Combine(_environment.WebRootPath, folderName, visualizationModel.CsvFile.FileName); using (var fileStream = new FileStream(savePath, FileMode.Create)) { visualizationModel.CsvFile.CopyTo(fileStream); } records = _csvReader.ReadContentOfCsvFile(savePath); if (records.Errors.Count == 0) { try { _context.AddDataFromNewCSVFile(records.CollectionOfRecords, visualizationModel.NameOfFile); return(RedirectToAction("Index", new { ModelNotValid = false })); } catch (Exception e) { records.Errors.Add("There was an error during saving data to database"); } } return(RedirectToAction("Index", new { ModelNotValid = true, Errors = records.Errors })); } else { return(RedirectToAction("Index", new { ModelNotValid = true })); } }
public ActionResult Show(VisualizationViewModel vvm, int?id) { if (!(vvm != null && vvm.MainPatientId != null && DB.Patients.Count(x => x.PatientId == vvm.MainPatientId) == 1 || id != null && DB.Patients.Count(x => x.PatientId == id) == 1)) { return(RedirectToAction("Index", "Visualization")); } if (vvm == null) { vvm = new VisualizationViewModel(); vvm.MainPatientId = id; } if (vvm.MainPatientId == null) { vvm.MainPatientId = id; } List <ActivityInputData> datas = DB.ActivityInputDatas.Where(x => x.Patient.PatientId == vvm.MainPatientId && x.Visit.DateConfirmed >= vvm.DateStart && x.Visit.DateConfirmed <= vvm.DateEnd && (String.Compare(x.ActivityActivityInput.ActivityInput.Title, Globals.SystolicBloodPressureTitle, StringComparison.Ordinal) == 0 || String.Compare(x.ActivityActivityInput.ActivityInput.Title, Globals.DiastolicBloodPressureTitle, StringComparison.Ordinal) == 0) ).ToList(); vvm.Dates = datas.OrderBy(z => z.Visit.DateConfirmed).Select(x => x.Visit.DateConfirmed).ToArray().Distinct().ToList(); vvm.SystolicValues = datas.Where(x => String.Compare(x.ActivityActivityInput.ActivityInput.Title, Globals.SystolicBloodPressureTitle, StringComparison.Ordinal) == 0).OrderBy(z => z.Visit.DateConfirmed).Select(y => double.Parse(y.Value)).ToList(); vvm.DiastolicValues = datas.Where(x => String.Compare(x.ActivityActivityInput.ActivityInput.Title, Globals.DiastolicBloodPressureTitle, StringComparison.Ordinal) == 0).OrderBy(z => z.Visit.DateConfirmed).Select(y => double.Parse(y.Value)).ToList(); return(View("Show", vvm)); }
public void MostrarPopupViewModel(string viewModel) { VisualizationViewModel visualization = new VisualizationViewModel(viewModel, VisualizationViewModelType.Window); this.eventAggregator.PublishOnUIThread(visualization); }
public IActionResult Index(VisualizationViewModel visualizationModel, bool ModelNotValid, ICollection <string> Errors) { visualizationModel.AvailableFiles = new List <SelectListItem>(); visualizationModel.AvailableFiles = _context.GetFileNamesAsSelectList().ToList(); if (visualizationModel.SelectedFiles == null) { visualizationModel.SelectedFiles = visualizationModel.AvailableFiles.Select(z => z.Text).ToList(); } visualizationModel.Errors = Errors; visualizationModel.DonatorsWithDonations = _context.GetDonatorsWithDonations(visualizationModel.SelectedFiles); if (visualizationModel.DonatorsWithDonations.Count != 0) { // łączna ilość zebranej krwi przez wszystkich donatorów var amountOfBlood = visualizationModel.DonatorsWithDonations.Sum(z => z.Donations.Sum(s => s.QuantityOfBlood)); List <NameValueViewModel> TotalAmountOfDonatedBlood = new List <NameValueViewModel> { new NameValueViewModel { name = "Total amount of Donated Blood \n (l)", steps = amountOfBlood / 1000 } }; // łączna zebrana ilość krwi w każdym z plików var TotalAmountOfBloodBySingleFile = new List <NameValueViewModel>(); foreach (var file in visualizationModel.SelectedFiles) { var PartialSum = visualizationModel.DonatorsWithDonations.Select(z => z.Donations.Where(d => d.OriginFileName == file).Sum(c => c.QuantityOfBlood)).Sum(); NameValueViewModel AmountOfBloodInSingleFile = new NameValueViewModel { name = file, steps = PartialSum }; TotalAmountOfBloodBySingleFile.Add(AmountOfBloodInSingleFile); } // średnia oddawana ilość krwi w każdym z plików na 1 donację var AverageAmountOfBloodBySingleFile = new List <NameValueViewModel>(); foreach (var file in visualizationModel.SelectedFiles) { var AmountOfDonations = visualizationModel.DonatorsWithDonations.Select(z => z.Donations.Where(d => d.OriginFileName == file)).Count(); NameValueViewModel AverageAmountOfBloodInSingleFile = new NameValueViewModel { name = file, steps = (TotalAmountOfBloodBySingleFile.Where(z => z.name == file).Select(z => z.steps).FirstOrDefault() / AmountOfDonations) }; AverageAmountOfBloodBySingleFile.Add(AverageAmountOfBloodInSingleFile); } //// liczba donacji na osobę //var QuantityOfDonationsPerPerson = visualizationModel.DonatorsWithDonations.Select(z => new { Person = z.FirstName + " " + z.LastName, Value = z.Donations.Count }).ToList(); //// średnia ilość oddanej krwi każdej osoby //var AvgQuantityOfDonatedBloodPerPerson = visualizationModel.DonatorsWithDonations.Select(z => new NameValueViewModel { name = z.FirstName + " " + z.LastName, steps = z.Donations.Sum(c => c.QuantityOfBlood)/z.Donations.Select(s=> s.DonatorId).Count() }).ToList(); // liczba donacji na osobę połączona ze średnią ilością oddanej krwi danej osoby var AvgQuantityOfDonatedBloodWithQuantityOfDonationsPerPerson = visualizationModel.DonatorsWithDonations.Select(z => new NameValueValueViewModel { name = z.FirstName + " " + z.LastName, steps = z.Donations.Sum(c => c.QuantityOfBlood) / z.Donations.Select(s => s.DonatorId).Count(), steps2 = z.Donations.Count }).ToList(); // średnia ilość oddanej krwi var avgQuantityOfDonatedBlood = visualizationModel.DonatorsWithDonations.Select(z => new { Person = z.FirstName + " " + z.LastName, z.Donations.Count, Value = z.Donations.Sum(c => c.QuantityOfBlood) }).Select(z => z.Value / z.Count).Average(); List <NameValueViewModel> AvgQuantityOfDonatedBlood = new List <NameValueViewModel> { new NameValueViewModel { name = "Average Quantity Of \n Donated Blood \n (ml)", steps = (int)(avgQuantityOfDonatedBlood) } }; // 20 osób które oddały najwięcej krwi var Top20Donators = visualizationModel.DonatorsWithDonations.Select(z => new NameValueViewModel { name = z.FirstName[0] + ". " + z.LastName, steps = z.Donations.Sum(s => s.QuantityOfBlood) }).OrderByDescending(z => z.steps).Take(20).ToList(); // procent ludzi z daną grupą krwi var BloodGroupPercentage = visualizationModel.DonatorsWithDonations.GroupBy(z => z.BloodGroup).Select(z => new NameValueViewModel { name = z.Key, steps = z.Count() }).ToList(); // procent ludzi z danym czynnikiem krwi var BloodFactorPercentage = visualizationModel.DonatorsWithDonations.GroupBy(z => z.BloodFactor).Select(z => new NameValueViewModel { name = z.Key, steps = z.Count() }).ToList(); visualizationModel.TotalAmountOfDonatedBlood = JsonConvert.SerializeObject(TotalAmountOfDonatedBlood); visualizationModel.Top20DonatorsSum = JsonConvert.SerializeObject(Top20Donators); visualizationModel.TotalAmountOfDonatedBloodInSingleFile = JsonConvert.SerializeObject(TotalAmountOfBloodBySingleFile); visualizationModel.AverageAmountOfBloodBySingleFile = JsonConvert.SerializeObject(AverageAmountOfBloodBySingleFile); visualizationModel.AvgQuantityOfDonatedBloodWithQuantityOfDonationsPerPerson = JsonConvert.SerializeObject(AvgQuantityOfDonatedBloodWithQuantityOfDonationsPerPerson); visualizationModel.AvgQuantityOfDonatedBlood = JsonConvert.SerializeObject(AvgQuantityOfDonatedBlood); visualizationModel.BloodGroupPercentage = JsonConvert.SerializeObject(BloodGroupPercentage); visualizationModel.BloodFactorPercentage = JsonConvert.SerializeObject(BloodFactorPercentage); } visualizationModel.CsvFile = null; visualizationModel.NameOfFile = null; if (!ModelNotValid) { ModelState.Clear(); } return(View(visualizationModel)); }
public IActionResult SelectFiles(VisualizationViewModel visualizationModel) { return(RedirectToAction("Index", new { SelectedFiles = visualizationModel.SelectedFiles })); }