/***Methods***/ // the constructor of the Graph View Model - getting a client object and 3 plotviews for graphs public GraphViewModel(IClientModel c, ViewModelController vmc, OxyPlot.Wpf.PlotView Attpv, OxyPlot.Wpf.PlotView Corrpv, OxyPlot.Wpf.PlotView regLinepv) { //getting args from constructor clientModel = c; viewModelController = vmc; VM_pvAtt = Attpv; VM_pvCorr = Corrpv; VM_pvLR = regLinepv; //setting up timer timer = new Stopwatch(); lastUpdate = 0; timer.Start(); //parsing XML for buttons name clientModel.xmlParser(); //Plot models inti VM_AttPlotModel = new PlotModel(); VM_CorrPlotModel = new PlotModel(); VM_RegLinePlotModel = new PlotModel(); //init list for later floatAttList = new List <float>(); floatCorrList = new List <float>(); buttonsList = new List <Button>(); //onPropertyChanged methods clientModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { onPropertyChanged("VM_" + e.PropertyName); }; // responsible of updating the graphs clientModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "lineNumber" && VM_AttUserChoose != null && VM_corralative != null && VM_pvLR != null) { if (timer.ElapsedMilliseconds - lastUpdate > 500) { //setting up attPlotModel VM_AttPlotModel.Series.Clear(); SetUpModel(VM_AttPlotModel); LoadLineDataGraph(VM_currLine, VM_pvAtt, floatAttList, VM_AttPlotModel); VM_pvAtt.InvalidatePlot(true); //setting up corrPlotModel VM_CorrPlotModel.Series.Clear(); SetUpModel(VM_CorrPlotModel); LoadLineDataGraph(VM_currLine, VM_pvCorr, floatCorrList, VM_CorrPlotModel); VM_pvCorr.InvalidatePlot(true); //setting up regLinePlotModel or minCircle VM_RegLinePlotModel.Series.Clear(); VM_RegLinePlotModel.Annotations.Clear(); SetUpModel(VM_RegLinePlotModel); if (viewModelController.isRegLine) { LoadScatterGraphData(VM_currLine, VM_pvLR, floatAttList, floatCorrList, VM_RegLinePlotModel); } if (viewModelController.isCircel) { LoadCircleGraphData(VM_currLine, VM_pvLR, floatAttList, floatCorrList, VM_RegLinePlotModel); } VM_pvLR.InvalidatePlot(true); //updating lastUpdate timer lastUpdate = timer.ElapsedMilliseconds; } } }; viewModelController.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "VM_dllCounter" && viewModelController.VM_dllCounter > 0 && viewModelController.VM_AnomalyReport != null) { foreach (Button b in buttonsList) { foreach (KeyValuePair <string, List <int> > entry in viewModelController.VM_AnomalyReport) { if (entry.Key.Contains(b.Content.ToString())) { b.Background = Brushes.DarkRed; b.Foreground = Brushes.White; break; } else { b.Background = Brushes.LightGray; b.Foreground = Brushes.Black; } } } } ; }; }
public void xmlPraser() { clientModel.xmlParser(); }