//private void SetInfo(string hint, bool isError = true) //{ // txtInfo.Text = hint; // Brush txtBrush = isError ? Brushes.Red : Brushes.Black; // txtInfo.Foreground = txtBrush; //} private void btnAddPlateVector_Click(object sender, RoutedEventArgs e) { var names = plateVectorCollection.PlateVectors.Select(x => x.Name).ToList(); string vectorName = Utility.GetNextName(names); PlateVector plateVector = new PlateVector(vectorName); plateVectorCollection.Add(plateVector); }
private void SavePlateVector(PlateVector plateVector) { string name = plateVector.Name; string sFile = FolderHelper.GetVectorFolder() + name + ".xml"; if (File.Exists(sFile)) { File.Delete(sFile); } SerializeHelper.Save <PlateVector>(plateVector, sFile); //SetInfo(string.Format("向量已经成功保存到{0}", sFile),false); }
static public void LoadSettings(ref PlateVector vector, string sFile) { if (!File.Exists(sFile)) { throw new FileNotFoundException(string.Format("位于:{0}的配置文件不存在", sFile)); } Stream stream = new FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read); XmlSerializer xs = new XmlSerializer(typeof(PlateVector)); vector = xs.Deserialize(stream) as PlateVector; stream.Close(); }
static public void SaveSettings(PlateVector vector, string sFile) { int pos = sFile.LastIndexOf("\\"); string sDir = sFile.Substring(0, pos); if (!Directory.Exists(sDir)) { Directory.CreateDirectory(sDir); } if (File.Exists(sFile)) { File.Delete(sFile); } XmlSerializer xs = new XmlSerializer(typeof(PlateVector)); Stream stream = new FileStream(sFile, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite); xs.Serialize(stream, vector); stream.Close(); }
internal void Add(PlateVector plateVector) { plateVectors.Add(plateVector); SelectedPlateVector = plateVector; }