Beispiel #1
0
        public void ChooseEditButtonClick(object sender, System.EventArgs e)
        {
            if (!Logic.CompareXml(objectXML, ForCompareXML)) return;

            OpenFileDialog myDialog = new OpenFileDialog();

            myDialog.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            myDialog.CheckFileExists = true;
            myDialog.Multiselect = false;
            myDialog.ShowDialog();
            PathXML = myDialog.FileName;

            try
            {
                objectXML = Logic.ReadXml(PathXML);
                ForCompareXML = Logic.ReadXml(PathXML);
                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;
                this.Title = PathXML;
            }
            catch (ArgumentException)
            {

            }
            catch (XmlException)
            {
                Logic.FileErrorDialog();
            }
        }
Beispiel #2
0
 public void ChooseNewButtonClick(object sender, System.EventArgs e)
 {
     if (!Logic.CompareXml(objectXML, ForCompareXML)) return;
     ForCompareXML = new Logic.ObjectXML();
     objectXML = new Logic.ObjectXML();
     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;
     this.Title = "Untitled";
     PathXML = null;
 }
Beispiel #3
0
 private void SaveClick(object sender, RoutedEventArgs e)
 {
     try
     {
         Logic.WriteXml(objectXML, PathXML);
         ForCompareXML = objectXML;
     }
     catch (Exception ex)
     {
         if (ex is ArgumentNullException || ex is ArgumentException)
         {
             try
             {
                 Logic.SaveAs(objectXML);
                 ForCompareXML = objectXML;
                 this.Title = PathXML;
             }
             catch (ArgumentException)
             {
                 return;
             }
         }
     }
 }
Beispiel #4
0
 private void SaveAs_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Logic.SaveAs(objectXML);
         if (PathXML != null)
             this.Title = PathXML;
         ForCompareXML = objectXML;
     }
     catch (ArgumentException)
     {
         return;
     }
 }
        public void ChooseNewButtonClick(object sender, EventArgs e)
        {
            if (!Logic.CompareXml(objectXML, ForCompareXML))
                return;

            LastActiveCoords.rowCoord = 0;
            LastActiveCoords.colCoord = 0;
            ForCompareXML = new Logic.ObjectXML();
            objectXML = new Logic.ObjectXML();

            ListBox1.Items.Clear();
            EditCell.Visibility = Visibility.Collapsed;
            EditHeader.Visibility = Visibility.Collapsed;
            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;

            Title = "Untitled";
            PathXML = null;
            Logic.ClearControls(this);

        }
 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);
 }
        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;
            }

        }
        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);
            }
            
        }