コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();
            if (!File.Exists(RetroFE.GetAbsolutePath() + "/Core/RetroFE.exe"))
            {
                MessageBox.Show("Could not find RetroFE executable. Exiting.");
                Close();
            }
            else
            {
                MessageBox.Show("This tool has not had a lot of testing. " + Environment.NewLine + Environment.NewLine + "Back up your files and use at your own risk before using this tool.");
                ObservableCollection <string> layouts = new ObservableCollection <string>();
                LauncherListVM   launcher             = this.TryFindResource("LauncherConfig") as LauncherListVM;
                CollectionListVM collection           = this.TryFindResource("CollectionConfig") as CollectionListVM;
                ControllerVM     controller           = this.TryFindResource("ControllerConfig") as ControllerVM;
                MainVM           main = this.TryFindResource("MainConfig") as MainVM;
                Builder          b    = new Builder();

                launcher.LauncherCollection = b.LoadLaunchers();
                collection.CollectionList   = b.LoadCollections(launcher.LauncherCollection);
                main.Layouts = b.LoadLayouts();
                b.LoadMain(ref main, main.Layouts, collection.CollectionList);
                b.LoadController(ref controller);
            }
        }
コード例 #2
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");
            }
        }
コード例 #3
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");
            }
        }
コード例 #4
0
        public void CtrlVM_UpdateNameUpdatesModel()
        {
            // arrange
            var model   = new Controller();
            var subject = new ControllerVM(model);

            // act
            subject.Name = "testval";

            // assert
            Assert.AreEqual("testval", model.Name);
        }
コード例 #5
0
ファイル: Builder.cs プロジェクト: variablebits/RetroFE
        public void LoadController(ref ControllerVM vm)
        {
            //todo :make paths relative
            ConfFileParser ini = new ConfFileParser(RetroFE.GetAbsolutePath() + "/Controls.conf");

            vm.ScrollNext     = ini.GetSetting("nextItem");
            vm.ScrollPrevious = ini.GetSetting("previousItem");
            vm.PageUp         = ini.GetSetting("pageUp");
            vm.PageDown       = ini.GetSetting("pageDown");
            vm.SelectItem     = ini.GetSetting("select");
            vm.Back           = ini.GetSetting("back");
            vm.Quit           = ini.GetSetting("quit");
        }
コード例 #6
0
        public void CtrlVM_ZoneCountCanIncrement()
        {
            // arrange
            var model   = new Controller();
            var subject = new ControllerVM(model);

            // act
            Assert.AreEqual(0, subject.Zones.Count);
            subject.ZoneCountIncrement.Execute(null);

            // assert
            Assert.AreEqual(1, model.Zones.Count);
            Assert.AreEqual(1, subject.Zones.Count);
            Assert.AreEqual("New zone", subject.Zones[0].Name);
        }
コード例 #7
0
        public void CtrlVM_ZoneCountCanDecrement()
        {
            // arrange
            var model = new Controller();

            model.Zones.Add(new Zone(1, "tz"));
            var subject = new ControllerVM(model);

            // act
            Assert.AreEqual(1, subject.Zones.Count);
            subject.ZoneCountDecrement.Execute(null);

            // assert
            Assert.AreEqual(0, model.Zones.Count);
            Assert.AreEqual(0, subject.Zones.Count);
        }
コード例 #8
0
        public void CtrlVM_ZoneCountCanBeSetSpecificallyLess()
        {
            // arrange
            var model = new Controller();

            model.Zones.Add(new Zone(1, "tz1"));
            model.Zones.Add(new Zone(2, "tz2"));
            model.Zones.Add(new Zone(3, "tz3"));
            var subject = new ControllerVM(model);

            // act
            Assert.AreEqual(3, subject.Zones.Count);
            subject.ZoneCountSet.Execute(1);

            // assert
            Assert.AreEqual(1, model.Zones.Count);
            Assert.AreEqual(1, subject.Zones.Count);
            Assert.AreEqual("tz1", subject.Zones[0].Name);
        }
コード例 #9
0
        public void CtrlVM_ZoneCountCanBeSetSpecificallyMore()
        {
            // arrange
            var model = new Controller();

            model.Zones.Add(new Zone(1, "tz"));
            var subject  = new ControllerVM(model);
            var newcount = 3;

            // act
            Assert.AreEqual(1, subject.Zones.Count);
            subject.ZoneCountSet.Execute(newcount);

            // assert
            Assert.AreEqual(newcount, model.Zones.Count);
            Assert.AreEqual(newcount, subject.Zones.Count);
            for (var i = 1; i < newcount; i++)
            {
                Assert.AreEqual("New zone", subject.Zones[i].Name);
                Assert.AreEqual(i + 1, subject.Zones[i].ID);
            }
        }
コード例 #10
0
 private void Save(string tabItem)
 {
     if (tabItem == "General")
     {
         MainVM main = this.TryFindResource("MainConfig") as MainVM;
         main.Save();
     }
     else if (tabItem == "Controller")
     {
         ControllerVM vm = this.TryFindResource("ControllerConfig") as ControllerVM;
         vm.Save();
     }
     else if (tabItem == "Launchers")
     {
         LauncherListVM vm = this.TryFindResource("LauncherConfig") as LauncherListVM;
         vm.Save(vm.SelectedLauncher);
     }
     else if (tabItem == "Collections")
     {
         CollectionListVM vm = this.TryFindResource("CollectionConfig") as CollectionListVM;
         vm.Save(vm.SelectedCollection);
     }
 }
コード例 #11
0
 /// <summary>
 /// Updates the ViewModel structure, causing the View to reload all bound properties.
 /// </summary>
 public void UpdateController()
 {
     ControllerVM.ReloadController();
     RaisePropertyChanged("");
 }
コード例 #12
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");
        }
コード例 #13
0
 /// <summary>
 /// Updates the ViewModel structure, causing the View to reload all bound properties.
 /// </summary>
 public void UpdateController()
 {
     ControllerVM.ReloadController();
     OnPropertyChanged(null);
 }
コード例 #14
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;
                }
            }
        }
コード例 #15
0
        private void GenerateVisualCommand_Executed(object prm)
        {
            string result = SelectedGenerator?.Generator?.GenerateProjectFiles(ControllerVM.Controller, System.IO.Path.GetDirectoryName(DataProvider.Instance.FileName));

            ControllerVM.SetStatusText(result);
        }