private void Button_LoadData_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = "Xml documents(.xml)|*.xml"; if (dlg.ShowDialog() == true) { UFRoot xml = XmlUtils.XmlDeserializeFromFile <UFRoot>(dlg.FileName, Encoding.UTF8); if (xml.Data.Count != 0) { connections = xml.Data; DrawLine(connections); MyDataGrid.ItemsSource = connections; } } }
private void Button_SaveData_Click(object sender, RoutedEventArgs e) { if (connections.Count == 0) { return; } Microsoft.Win32.SaveFileDialog slg = new Microsoft.Win32.SaveFileDialog(); slg.Filter = "Xml documents(.xml)|*.xml"; if (slg.ShowDialog() == true) { UFRoot ufRoot = new UFRoot { Header = new Header(), Data = connections }; XmlUtils.XmlSerializeToFile(ufRoot, slg.FileName, Encoding.UTF8); } }