private async void SaveClick(object sender, RoutedEventArgs e) { MessageDialogStyle stylo = MessageDialogStyle.AffirmativeAndNegative; MessageDialogResult saveConfirm = await this.ShowMessageAsync("Save Changes?","Save Changes?",stylo); switch (saveConfirm) { case MessageDialogResult.Affirmative: { if (PathXML != null && PathXML != "") { if (!Logic.WriteXml(objectXML, PathXML)) { LoadFile fileload = new LoadFile(Logic.ReadXml); IAsyncResult result = fileload.BeginInvoke(PathXML, null, null); ForCompareXML = fileload.EndInvoke(result); result = fileload.BeginInvoke(PathXML, null, null); objectXML = fileload.EndInvoke(result); } return; } else { Logic.SaveAs(objectXML); if (PathXML != null && PathXML != "") { Title = PathXML; LoadFile fileload = new LoadFile(Logic.ReadXml); IAsyncResult result = fileload.BeginInvoke(PathXML, null, null); ForCompareXML = fileload.EndInvoke(result); result = fileload.BeginInvoke(PathXML, null, null); objectXML = fileload.EndInvoke(result); } return; } } case MessageDialogResult.Negative: return; } }
private void SaveAs_Click(object sender, RoutedEventArgs e) { Logic.SaveAs(objectXML); if (PathXML != null && PathXML != "") Title = PathXML; if (PathXML == null || PathXML == "") return; LoadFile fileload = new LoadFile(Logic.ReadXml); IAsyncResult result = fileload.BeginInvoke(PathXML, null, null); ForCompareXML = fileload.EndInvoke(result); result = fileload.BeginInvoke(PathXML, null, null); objectXML = fileload.EndInvoke(result); }
public void ChooseEditButtonClick(object sender, EventArgs e) { if (!Logic.CompareXml(objectXML, ForCompareXML)) return; PathXML = null; OpenFileDialog myDialog = new OpenFileDialog(); myDialog.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; myDialog.CheckFileExists = true; myDialog.Multiselect = false; myDialog.ShowDialog(); PathXML = myDialog.FileName; if (PathXML == null || PathXML == "") return; try { LastActiveCoords.rowCoord = 0; LastActiveCoords.colCoord = 0; LoadFile fileload = new LoadFile(Logic.ReadXml); IAsyncResult result = fileload.BeginInvoke(PathXML, null, null); objectXML = fileload.EndInvoke(result); result = fileload.BeginInvoke(PathXML, null, null); ForCompareXML = fileload.EndInvoke(result); EditCell.Visibility = Visibility.Collapsed; EditHeader.Visibility = Visibility.Collapsed; ListBox1.Items.Clear(); Logic.DisplayXML(ListBox1, objectXML); AddColBtn.Visibility = Visibility.Visible; AddRowBtn.Visibility = Visibility.Visible; DelColBtn.Visibility = Visibility.Visible; DelRowBtn.Visibility = Visibility.Visible; SaveAsBtn.Visibility = Visibility.Visible; SaveBtn.Visibility = Visibility.Visible; SaveAsMenuBtn.IsEnabled = true; SaveMenuBtn.IsEnabled = true; Adapter.Visibility = Visibility.Collapsed; Title = PathXML; Logic.ClearControls(this); } catch (XmlException) { Logic.FileErrorDialog(this); } }