public SimConfig Clone() { SimConfig cfg = new SimConfig(); cfg.sPlotSettings = Copy2DStringArray(sPlotSettings); cfg.Name = Name; cfg.N = N; cfg.dt = dt; cfg.x0 = CopyArray <double>(x0); if (Exps == null) { cfg.Exps = null; } else { cfg.Exps = new ExpConfig[Exps.Length]; for (int i = 0; i < Exps.Length; i++) { cfg.Exps[i] = Exps[i].Clone(); } } cfg.PlotMap = Copy2DStringArray(PlotMap); cfg.u = CopyArray <string>(u); cfg.ParamFileName = ParamFileName; cfg.PlotHeights = CopyArray <double>(PlotHeights); cfg.PlotStep = PlotStep; cfg.PlotTimeStep = PlotTimeStep; cfg.InputFromFile = InputFromFile; cfg.InputFileName = InputFileName; return(cfg); }
public static void SaveConfig(string sFileName, SimConfig cfg) { try { XmlSerializer writer = new XmlSerializer(typeof(SimConfig)); StreamWriter file = new StreamWriter(sFileName); writer.Serialize(file, cfg); file.Close(); } catch (Exception ex) { string s = ex.Message; } }
private void LoadFile(string sFileName) { sCurFileName = sFileName; SimConfig.LoadConfig(sFileName, out cfg); //SimConfig.LoadConfig(sFileName, out file_cfg); file_cfg = cfg.Clone(); //create default string, can be copied from watch and hardcoded //string sTmp = String.Join(",",cfg.sPlotSettings[0]); UpdateGUI(); }
public static bool LoadConfig(string sFileName, out SimConfig cfg) { cfg = null; try { XmlSerializer reader = new XmlSerializer(typeof(SimConfig)); StreamReader file = new StreamReader(sFileName); cfg = (SimConfig)reader.Deserialize(file); file.Close(); return(true); } catch (Exception ex) { string s = ex.Message; return(false); } }
public bool Compare(SimConfig cfg) { bool bEqual = true; bEqual &= Compare2DStringArray(sPlotSettings, cfg.sPlotSettings); bEqual &= (Name == cfg.Name); bEqual &= (N == cfg.N); bEqual &= (dt == cfg.dt); bEqual &= CompareArray <double>(x0, cfg.x0); bEqual &= CompareArray <ExpConfig>(Exps, cfg.Exps); bEqual &= Compare2DStringArray(PlotMap, cfg.PlotMap); bEqual &= CompareArray <string>(u, cfg.u); bEqual &= (ParamFileName == cfg.ParamFileName); bEqual &= CompareArray <double>(PlotHeights, cfg.PlotHeights); bEqual &= (PlotStep == cfg.PlotStep); bEqual &= (PlotTimeStep == cfg.PlotTimeStep); bEqual &= (InputFromFile == cfg.InputFromFile); bEqual &= (InputFileName == cfg.InputFileName); return(bEqual); }
private void MakeNew() { sCurFileName = ""; cfg = new SimConfig(); cfg.sPlotSettings = new string[gr.Length][]; for (int i = 0; i < gr.Length; i++) { cfg.sPlotSettings[i] = gr[i].GetConfig(); } cfg.Name = "Default"; string sDefSet = @"Line,True,False,Series1,Red,White,Black,False,-100,100,-100,100,10,10,2,Dot,LightGray,None,Red,Numeric,True,5,Consolas; 12pt,X - axis,Y - axis,False,False,ArrayVsIndex,50,1000,Trace,,0.00,False,False,0,Microsoft Sans Serif; 8.25pt"; cfg.sPlotSettings = new string[gr.Length][]; for (int i = 0; i < gr.Length; i++) { cfg.sPlotSettings[i] = sDefSet.Split(','); } file_cfg = cfg.Clone(); UpdateGUI(); }
private void SaveFile(string sFileName) { sCurFileName = sFileName; SimConfig.SaveConfig(sFileName, cfg); file_cfg = cfg.Clone(); }