private void ExecuteSaveAsCommand(object sender, ExecutedRoutedEventArgs eventArgs) { try { var sc = new SonarConfig(); sc.VelCmd = SurVelSrcIndex; if (AvgVelIndex == 1) sc.VelCmd = sc.VelCmd | 0x04; sc.SurVel = SurVel; sc.AvgVel = AvgVel; sc.FixedGain = FixedGain; sc.TVGCmd = TVGCmd; sc.FixedTVG = FixedTVG; sc.TVGSampling = TVGSampling; sc.TVGSamples = TVGSamples; sc.TVGA1 = TVGA1; sc.TVGA2 = TVGA2; sc.TVGA3 = TVGA3; sc.PingPeriod = PingPeriod; sc.ADSaved = ADSaved; sc.PoseSaved = PoseSaved; sc.PosSaved = PosSaved; sc.SonarDepth = SonarDepth; sc.SonarGPSx = SonarGPSx; sc.SonarGPSy = SonarGPSy; sc.SonarGPSz = SonarGPSz; sc.Pitchfixed = Pitchfixed; sc.Rollfixed = Rollfixed; sc.Headingfixed = Headingfixed; ///////////////////////////////////////////////////////////////////////////////////// SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "参数文件 (*.dat)|*.dat"; saveFileDialog.FilterIndex = 2; saveFileDialog.Title = "保存参数文件"; saveFileDialog.RestoreDirectory = true; saveFileDialog.OverwritePrompt = true; saveFileDialog.ValidateNames = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { if (saveFileDialog.FileName!="") { var bw = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate); bw.Write(sc.SavePackage(), 0, sc.SavePackage().Length); bw.Close(); } } } catch (Exception ex) { UnitCore.Instance.EventAggregator.PublishMessage(new ErrorEvent(ex, LogType.Both)); return; } }
public void SaveSonarSetting(SonarConfig scConfig) { if (SonarSetting == null) { var MyExecPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); MyExecPath += "SonarConfig"; SonarSetting = new FileStream(MyExecPath,FileMode.OpenOrCreate); } SonarSetting.Write(scConfig.SavePackage(), 0, 288); }