Esempio n. 1
0
 private void SaveFileCommand_Executed(object prm)
 {
     if (TLCGenControllerDataProvider.Default.SaveController())
     {
         Messenger.Default.Send(new UpdateTabsEnabledMessage());
         GuiActionsManager.SetStatusBarMessage(
             DateTime.Now.ToLongTimeString() +
             " - Regeling " + TLCGenControllerDataProvider.Default.Controller.Data.Naam ?? "" + " opgeslagen");
         FileSaved?.Invoke(this, TLCGenControllerDataProvider.Default.ControllerFileName);
     }
 }
Esempio n. 2
0
        private void CloseFileCommand_Executed(object prm)
        {
            string lastfilename = TLCGenControllerDataProvider.Default.ControllerFileName;

            if (TLCGenControllerDataProvider.Default.CloseController())
            {
                DefaultsProvider.Default.Controller = null;
                Messenger.Default.Send(new ControllerFileNameChangedMessage(TLCGenControllerDataProvider.Default.ControllerFileName, lastfilename));
                RaisePropertyChanged("HasController");
                RaisePropertyChanged("ProgramTitle");
                GuiActionsManager.SetStatusBarMessage("");
            }
        }
Esempio n. 3
0
        private void SaveAsFileCommand_Executed(object prm)
        {
            string lastfilename = TLCGenControllerDataProvider.Default.ControllerFileName;

            if (TLCGenControllerDataProvider.Default.SaveControllerAs())
            {
                Messenger.Default.Send(new ControllerFileNameChangedMessage(TLCGenControllerDataProvider.Default.ControllerFileName, lastfilename));
                Messenger.Default.Send(new UpdateTabsEnabledMessage());
                RaisePropertyChanged("ProgramTitle");
                GuiActionsManager.SetStatusBarMessage(
                    DateTime.Now.ToLongTimeString() +
                    " - Regeling " + TLCGenControllerDataProvider.Default.Controller.Data.Naam ?? "" + " opgeslagen");
                FileSaved?.Invoke(this, TLCGenControllerDataProvider.Default.ControllerFileName);
            }
        }
Esempio n. 4
0
 private void OnControllerProjectGenerated(ControllerProjectGeneratedMessage message)
 {
     GuiActionsManager.SetStatusBarMessage(
         DateTime.Now.ToLongTimeString() +
         " - Project voor regeling " + TLCGenControllerDataProvider.Default.Controller.Data.Naam + " gegenereerd");
 }
Esempio n. 5
0
        private void ImportControllerCommand_Executed(object obj)
        {
            if (obj == null)
            {
                throw new NullReferenceException();
            }
            if (!(obj is ITLCGenImporter imp))
            {
                throw new InvalidCastException();
            }

            // Import into existing controller
            if (TLCGenControllerDataProvider.Default.CheckChanged())
            {
                return;
            }
            if (imp.ImportsIntoExisting)
            {
                // Request to process all synchronisation data from matrix to model
                Messenger.Default.Send(new ProcessSynchronisationsRequest());

                // Check data integrity
                var s1 = TLCGenIntegrityChecker.IsConflictMatrixOK(ControllerVM.Controller);
                if (s1 != null)
                {
                    TLCGenDialogProvider.Default.ShowMessageBox("Kan niet importeren:\n\n" + s1, "Error bij importeren: fout in regeling");
                    return;
                }
                // Import to clone of original (so we can discard if wrong)
                var c1 = DeepCloner.DeepClone(ControllerVM.Controller);
                var c2 = imp.ImportController(c1);

                // Do nothing if the importer returned nothing
                if (c2 == null)
                {
                    TLCGenDialogProvider.Default.ShowMessageBox("Importeren is afgebroken door de gebruiker", "Importeren afgebroken");
                    return;
                }

                // Check data integrity
                c2.Data.GarantieOntruimingsTijden = false;
                s1 = TLCGenIntegrityChecker.IsConflictMatrixOK(c2);
                if (s1 != null)
                {
                    TLCGenDialogProvider.Default.ShowMessageBox("Fout bij importeren:\n\n" + s1, "Error bij importeren: fout in data");
                    return;
                }
                if (c1.Data.GarantieOntruimingsTijden)
                {
                    TLCGenDialogProvider.Default.ShowMessageBox("De bestaande regeling had garantie ontruimingstijden.\nDeze zijn nu uitgeschakeld.", "Garantie ontruimingstijden uitrgeschakeld");
                }
                SetController(c2);
                ControllerVM.ReloadController();
                GuiActionsManager.SetStatusBarMessage(
                    DateTime.Now.ToLongTimeString() +
                    " - Data in regeling " + TLCGenControllerDataProvider.Default.Controller.Data.Naam + " geïmporteerd");
            }
            // Import as new controller
            else
            {
                var c1 = imp.ImportController();

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

                // Check data integrity
                var s1 = TLCGenIntegrityChecker.IsConflictMatrixOK(c1);
                if (s1 != null)
                {
                    TLCGenDialogProvider.Default.ShowMessageBox("Fout bij importeren:\n\n" + s1, "Error bij importeren: fout in data");
                    return;
                }
                TLCGenControllerDataProvider.Default.CloseController();
                DefaultsProvider.Default.SetDefaultsOnModel(c1.Data);
                DefaultsProvider.Default.SetDefaultsOnModel(c1.OVData);
                SetController(c1);
                ControllerVM.ReloadController();
                GuiActionsManager.SetStatusBarMessage(
                    DateTime.Now.ToLongTimeString() +
                    " - Regeling geïmporteerd");
            }
            Messenger.Default.Send(new UpdateTabsEnabledMessage());
            RaisePropertyChanged("HasController");
        }