Ejemplo n.º 1
0
        private void SaveAsFileCommand_Executed(object prm)
        {
            // Save all changes to model
            ControllerVM.ProcessAllChanges();

            // Check data integrity: do not save wrong data
            string s = IntegrityChecker.IsControllerDataOK();

            if (s != null)
            {
                System.Windows.MessageBox.Show(s + "\n\nRegeling niet opgeslagen.", "Error bij opslaan: fout in regeling");
                return;
            }

            // Save data to disk, update saved state
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.Filter          = "TLCGen files|*.tlc|TLCGen compressed files|*.tlcgz";
            if (!string.IsNullOrWhiteSpace(DataProvider.Instance.FileName))
            {
                saveFileDialog.FileName = DataProvider.Instance.FileName;
            }
            if (saveFileDialog.ShowDialog() == true)
            {
                DataProvider.Instance.FileName = saveFileDialog.FileName;
                DataProvider.Instance.SaveController();
                ControllerVM.HasChanged = false;
                OnPropertyChanged("ProgramTitle");
                MessageManager.Instance.Send(new UpdateTabsEnabledMessage());
                ControllerVM.SetStatusText("regeling opgeslagen");
            }
        }
Ejemplo n.º 2
0
        private void SaveFileCommand_Executed(object prm)
        {
            if (string.IsNullOrWhiteSpace(DataProvider.Instance.FileName))
            {
                SaveAsFileCommand.Execute(null);
            }
            else
            {
                // Save all changes to model
                ControllerVM.ProcessAllChanges();

                // Check data integrity: do not save wrong data
                string s = IntegrityChecker.IsControllerDataOK();
                if (s != null)
                {
                    System.Windows.MessageBox.Show(s + "\n\nRegeling niet opgeslagen.", "Error bij opslaan: fout in regeling");
                    return;
                }

                // Save data to disk, update saved state
                DataProvider.Instance.SaveController();
                ControllerVM.HasChanged = false;
                MessageManager.Instance.Send(new UpdateTabsEnabledMessage());
                ControllerVM.SetStatusText("regeling opgeslagen");
            }
        }
Ejemplo n.º 3
0
        private void ImportControllerCommand_Executed(object obj)
        {
            if (obj == null)
            {
                throw new NotImplementedException();
            }
            ITLCGenImporter imp = obj as ITLCGenImporter;

            if (imp == null)
            {
                throw new NotImplementedException();
            }

            // Import into existing controller
            if (!ControllerHasChanged())
            {
                if (imp.ImportsIntoExisting)
                {
                    // Check data integrity
                    string s1 = IntegrityChecker.IsControllerDataOK(ControllerVM.Controller);
                    if (s1 != null)
                    {
                        System.Windows.MessageBox.Show("Kan niet importeren:\n\n" + s1, "Error bij importeren: fout in regeling");
                        return;
                    }
                    // Import to clone of original (so we can discard if wrong)
                    ControllerModel c1 = DeepCloner.DeepClone(ControllerVM.Controller);
                    ControllerModel c2 = imp.ImportController(c1);

                    // Do nothing if the importer returned nothing
                    if (c2 == null)
                    {
                        return;
                    }

                    // Check data integrity
                    s1 = IntegrityChecker.IsControllerDataOK(c2);
                    if (s1 != null)
                    {
                        System.Windows.MessageBox.Show("Fout bij importeren:\n\n" + s1, "Error bij importeren: fout in data");
                        return;
                    }
                    if (ControllerVM != null)
                    {
                        ControllerVM.HasChanged = false; // Set forcefully, in case the user decided to ignore changes above
                    }
                    SetController(c2);
                    ControllerVM.ReloadController();
                    ControllerVM.HasChanged = true;
                }
                // Import as new controller
                else
                {
                    ControllerModel c1 = imp.ImportController();

                    // Do nothing if the importer returned nothing
                    if (c1 == null)
                    {
                        return;
                    }

                    // Check data integrity
                    string s1 = IntegrityChecker.IsControllerDataOK(c1);
                    if (s1 != null)
                    {
                        System.Windows.MessageBox.Show("Fout bij importeren:\n\n" + s1, "Error bij importeren: fout in data");
                        return;
                    }
                    if (ControllerVM != null)
                    {
                        ControllerVM.HasChanged = false; // Set forcefully, in case the user decided to ignore changes above
                    }
                    SetNewController(c1);
                    ControllerVM.ReloadController();
                    ControllerVM.HasChanged = true;
                }
            }
        }