public ActionResult Report() { try { var tty = GetCompanies(); if (!tty.Any()) { var txy = new WellViewModel { Companies = new List <Company>(), WellReportObjects = new List <WellReportObject>() }; return(View(txy)); } return(View(new WellViewModel { Companies = tty, WellReportObjects = new List <WellReportObject>() })); } catch (Exception ex) { return(View(new WellViewModel { Companies = new List <Company>(), WellReportObjects = new List <WellReportObject>() })); } }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> public SceneViewModel() { SurfacePlotViewModel = new SurfacePlotViewModel(); WellViewModel = new WellViewModel(); SizeableViewModel = new SizeableViewModel(); VisualModels = new ObservableCollection <string>(Constants.VisualModels); }
void WellView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue is WellViewModel) { SelectedPoint.Collection.Clear(); foreach (var g in _obsGraphs) { ObsGraph.Children.Remove(g); } _obsGraphs.Clear(); foreach (var g in _extGraphs) { PumpingGraph.Children.Remove(g); } _extGraphs.Clear(); WellViewModel wm = (WellViewModel)e.NewValue; int Pencount = 0; foreach (var ts in wm.HeadObservations) { ts.Value.SetXMapping(var => dateAxis.ConvertToDouble(var.Time)); ts.Value.SetYMapping(var => var.Value); var g = ObsGraph.AddLineGraph(ts.Value, pens[Pencount], new PenDescription(ts.Key.ToString())); _obsGraphs.Add(g); Pencount++; if (Pencount == pens.Count()) { Pencount = 0; } } Pencount = 0; foreach (var ts in wm.Extractions.Where(var => var.Item2.Count() > 0)) { EnumerableDataSource <Time.Core.TimestampValue> ds = new EnumerableDataSource <TimestampValue>(ts.Item2); ds.SetXMapping(var => dateAxisExt.ConvertToDouble(var.Time)); ds.SetYMapping(var => var.Value); var g = PumpingGraph.AddLineGraph(ds, pens[Pencount], new PenDescription(ts.Item1)); _extGraphs.Add(g); Pencount++; if (Pencount == pens.Count()) { Pencount = 0; } } } ZoomToTimeScale(); }
public DWellControl() { InitializeComponent(); // 将View中控件传到ViewModel,目前有2种方法,第一种方法是通过属性赋值来实现,如下注释 // 第二种方式是在View的控件中(mc)增加Loaded命令,由命令来将mc控件,传到ViewModel中,存在问题是Loaded加载两次,原因不明,目前采用第一种方式 WellViewModel _vm = new WellViewModel() { mc = this.mc }; //WellViewModel _vm = WellViewModel.CreateInstance(); //_vm.mc = this.mc; }
public void ZoomToTimeScale() { if (SelectionEndTime != DateTime.MinValue) { WellViewModel wm = DataContext as WellViewModel; DataRect visible; double xmin = dateAxis.ConvertToDouble(SelectionStartTime); double xlength = dateAxis.ConvertToDouble(SelectionEndTime) - dateAxis.ConvertToDouble(SelectionStartTime); ObsGraph.FitToView(); visible = new DataRect(xmin, ObsGraph.Visible.Y, xlength, ObsGraph.Visible.Height); //Zoom the observation graph if (wm != null && wm.HeadObservations.Count != 0) { var select = wm.HeadObservations.SelectMany(var => var.Value.Collection.Where(var2 => var2.Time >= SelectionStartTime & var2.Time <= SelectionEndTime)); if (select != null && select.Count() != 0) { double ymin = select.Min(y => y.Value); double yheight = select.Max(y => y.Value) - ymin; ymin = ymin - 0.05 * yheight; yheight *= 1.1; visible = new DataRect(xmin, ymin, xlength, yheight); } } ObsGraph.Visible = visible; DataRect visible2; PumpingGraph.FitToView(); visible2 = new DataRect(xmin, PumpingGraph.Visible.Y, xlength, PumpingGraph.Visible.Height); //Zoom the extraction graph if (wm != null && wm.Extractions.Count != 0) { var select = wm.Extractions.SelectMany(var => var.Item2.Where(var2 => var2.Time >= SelectionStartTime & var2.Time <= SelectionEndTime)); if (select != null && select.Count() != 0) { double ymin = select.Min(y => y.Value); double yheight = select.Max(y => y.Value) - ymin; ymin = ymin - 0.05 * yheight; yheight *= 1.1; visible2 = new DataRect(xmin, ymin, xlength, yheight); } } PumpingGraph.Visible = visible2; } }
public WellView(Well wellObject) { InitializeComponent(); DataContext = new WellViewModel(Token, wellObject); }
public WellView() { InitializeComponent(); DataContext = new WellViewModel(Token); ScreenType = typeof(Well); }