/// <summary> /// 构造函数 /// </summary> /// <returns></returns> public MainForm() { InitializeComponent(); FileManage.showMessage += this.ShowMessage; PointTrain.showMessage += this.ShowMessage; //读取工作配置 m_workConfig = WorkConfig.DeserializeXML(); OnConfigManage(null, null); string sampleFolder = m_workConfig.CurrentProject.SampleFolder; string pointFolder = m_workConfig.CurrentProject.PointFolder; SetFolder(sampleFolder, pointFolder); }
/// <summary> /// 从指定路径加载配置方案 /// </summary> /// <param name="path"></param> /// <returns></returns> public static WorkConfig DeserializeXML(string path) { WorkConfig config; try { XmlSerializer xs = new XmlSerializer(typeof(WorkConfig)); Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); config = xs.Deserialize(stream) as WorkConfig; stream.Close(); return config; } catch (System.Exception) { config = new WorkConfig(); return config; } }
public DialogResult ShowDialog(WorkConfig config) { this.Config = config; InitalEx(); return ShowDialog(); }