private void button_Save_Click(object sender, RoutedEventArgs e) { controller.Pause(); button.Content = "Paused"; var unit4save = new OneDemExample(); unit4save.Rebuild(); int newVal = (int)slider.Value; int index = newVal < vm.SolPointList.Value.Count ? newVal : vm.SolPointList.Value.Count - 1; if (index < 0) { return; } unit4save.SynchMeTo(vm.SolPointList.Value[index]); var sd = new SaveFileDialog() { Filter = "XML Files|*.xml", FileName = "sph1D" }; if (sd.ShowDialog() == true) { var sw = new StreamWriter(sd.FileName); unit4save.Serialize(sw); sw.Close(); } }
public ViewModel() { _curr4Draw = new OneDemExample(); _curr4Draw.Rebuild(); Model1Rx = new VMPropRx <PlotModel, SolPoint>(() => { var Model1 = GetNewModel("params", "X", "p,Ro,V"); P = new ScatterSeries() { Title = "P", MarkerType = MarkerType.Triangle, MarkerSize = 2, MarkerFill = OxyColors.Green }; Model1.Series.Add(P); Ro = new ScatterSeries() { Title = "Ro", MarkerType = MarkerType.Diamond, MarkerSize = 2, MarkerFill = OxyColors.DarkOrange }; Model1.Series.Add(Ro); V = new ScatterSeries() { Title = "V", MarkerType = MarkerType.Circle, MarkerSize = 2, MarkerFill = OxyColors.Blue }; Model1.Series.Add(V); E = new ScatterSeries() { Title = "E", MarkerType = MarkerType.Circle, MarkerSize = 2, MarkerFill = OxyColors.Red }; Model1.Series.Add(E); return(Model1); }, (sp, pm) => { _curr4Draw.SynchMeTo(sp); Draw(sp.T, pm); return(pm); } ); SolPointList = new VMPropRx <List <SolPoint>, SolPoint>( () => new List <SolPoint>(), (sp, lst) => { lst.Add(sp); return(lst); }); }
public void SetDts() { if (!(Owner is OneDemExample)) { throw new Exception("Sad"); } owner2 = Owner as OneDemExample; AddDiffPropToParam(pX, pV); AddDiffPropToParam(pV, pdV); AddDiffPropToParam(pE, pdE); //AddDiffPropToParam(pRo,pdRo); //double dro= 0, de = 0, dv = 0; ////SetDiff(pRo,t => { //// return dro; ////}); //SynchMeAfter += t => { // var matdW = owner2.matr_dW; // var matV = owner2.matr_ViminVj; // var matSignX = owner2.matr_SignXiminXj; // var matII = owner2.matr_II; // int i = MInd; // dro = 0d; // de = 0d; // dv = 0d; // bool neib_bool = false; // for(int j = 0; j < matdW.ColumnDimension; j++) { // if(matdW[i,j] == 0d) { // //if(neib_bool) // // break; // continue; // } // if(i == j) // continue; // //neib_bool = true; // var neib = owner2.AllParticles[j]; // dro += neib.M * matV[i,j] * matSignX[i,j] * matdW[i,j]; // de += 0.5*neib.M * matV[i,j] * matSignX[i,j] * matdW[i,j] // * (neib.P / (neib.Ro * neib.Ro) + P / (Ro * Ro) + matII[i,j]); // dv -= neib.M * matSignX[i,j] * matdW[i,j] // * (neib.P / (neib.Ro * neib.Ro) + P / (Ro * Ro) + matII[i,j]); // } //}; }
private void initObs(OneDemExample calc) { pr = calc; v0 = pr.Rebuild(pr.TimeSynch); sol = Ode.RK45(pr.TimeSynch, v0, pr.f, pr.dt).WithStepRx(0.01, out controller); controller.Pause(); sol.ObserveOnDispatcher().Subscribe(sp => { vm.SolPointList.Update(sp); slider.Maximum = (double)(vm.SolPointList.Value.Count > 0 ? vm.SolPointList.Value.Count : 0); }); }
private void button_Copy1_Click(object sender, RoutedEventArgs e) { controller.Pause(); button.Content = "Paused"; var unit4load = new OneDemExample(); unit4load.Rebuild(); var sd = new OpenFileDialog() { Filter = "XML Files|*.xml", FileName = "sph1D" }; if (sd.ShowDialog() == true) { var sr = new StreamReader(sd.FileName); unit4load.Deserialize(sr); sr.Close(); controller.Cancel(); vm.SolPointList.Value.Clear(); initObs(unit4load); } }