Exemple #1
0
        Task IUIView.TryActivateAsync()
        {
            AdvancedOptionsViewModel model = (AdvancedOptionsViewModel)DataContext;

            _list1.LoadLists(model.Easy1);
            _list2.LoadLists(model.Game1);
            return(Task.CompletedTask);
        }
Exemple #2
0
        protected override Task TryActivateAsync()
        {
            AdvancedOptionsViewModel model = (AdvancedOptionsViewModel)BindingContext;

            _list1.LoadLists(model.Easy1);
            _list2.LoadLists(model.Game1);

            return(this.RefreshBindingsAsync(_aggregator));
        }
Exemple #3
0
        public MainViewModel(AdvancedOptionsViewModel AdvancedOptions, SettingsViewModel Settings)
        {
            // Master list of command line options this is a reactive list so we can track changes and build the command
            Options = new ReactiveList <LsmppOption>()
            {
                ChangeTrackingEnabled = true
            };

            // Track changes to options and when an option value changes set it to active
            Options.ItemChanged.Where(x => x.PropertyName == "Value").Select(x => x.Sender).Subscribe(x => x.IsActive = true);

            // Here we are updating the command for mpp any time an option changes
            Options.ItemChanged.Select(_ => String.Join(" ", Options.Where(x => x.IsActive).Select(x => x.ToString()).ToArray())).ToProperty(this, x => x.mppCommand, out _mppCommand);

            // Add all the various commandline options to Options
            MpiExe = new LsmppOption("MPI EXE", "");
            Options.Add(MpiExe);
            Processors = new LsmppOption("Processors", "-np ");
            Options.Add(Processors);
            Affinity = new LsmppOption("Affinity", "", "-affinity");
            Options.Add(Affinity);
            Options.Add(Settings.LicenseType);
            Options.Add(Settings.LicenseFile);
            Options.Add(Settings.LicenseServer);
            Options.Add(Settings.LicensePort);
            ExtraMPICommands = new LsmppOption("Extra MPI commands", "");
            Options.Add(ExtraMPICommands);
            Solver = new LsmppOption("Solver", "");
            Options.Add(Solver);
            InputFile = new LsmppOption("Input File", "I=");
            Options.Add(InputFile);
            RestartFile = new LsmppOption("Restart File", "R=");
            Options.Add(RestartFile);
            OutputFile = new LsmppOption("Output File", "O=");
            Options.Add(OutputFile);
            Memory = new LsmppOption("Memory", "Memory=");
            Options.Add(Memory);
            Memory2 = new LsmppOption("Memory2", "Memory2=");
            Options.Add(Memory2);
            ExtraMPPCommands = new LsmppOption("Extra MPP commands", "");
            Options.Add(ExtraMPPCommands);

            // Advanced Options
            Options.Add(AdvancedOptions.AcousticOuput);
            Options.Add(AdvancedOptions.InterfaceSegment);
            Options.Add(AdvancedOptions.VdaGeometry);
            Options.Add(AdvancedOptions.Cal3dInput);
            Options.Add(AdvancedOptions.Topaz3dfile);
            Options.Add(AdvancedOptions.StressInitialization);
            Options.Add(AdvancedOptions.MappingInputFile);
            Options.Add(AdvancedOptions.Graphics);
            Options.Add(AdvancedOptions.TimeHistories);
            Options.Add(AdvancedOptions.InterfaceForce);
            Options.Add(AdvancedOptions.FsiInterfaceForce);
            Options.Add(AdvancedOptions.DynamicRelaxation);
            Options.Add(AdvancedOptions.AcousticOuput);
            Options.Add(AdvancedOptions.DemInterfaceForce);
            Options.Add(AdvancedOptions.InputEcho);
            Options.Add(AdvancedOptions.RestartDump);
            Options.Add(AdvancedOptions.InterfaceSegmentSave);
            Options.Add(AdvancedOptions.RemapCrackDatabase);
            Options.Add(AdvancedOptions.RunningRestartDump);
            Options.Add(AdvancedOptions.PropertyOutput);
            Options.Add(AdvancedOptions.MappingOutputFile);

            // Set the working directory when the user selects an input or restart file
            this.WhenAny(
                x => x.InputFile.Value,
                x => x.RestartFile.Value,
                (input, restart) => ToWorkingDir(input.Value, restart.Value)).ToProperty(this, x => x.WorkingDir, out _workingDir);

            BrowseInputFile   = ReactiveCommand.Create();
            BrowseRestartFile = ReactiveCommand.Create();
            BrowseOutputFile  = ReactiveCommand.Create();
            BrowseSolver      = ReactiveCommand.Create();

            var canRunMPP = this.WhenAny(
                x => x.InputFile.Value,
                x => x.RestartFile.Value,
                x => x.OutputFile.Value,
                x => x.Solver.Value,
                x => x.Processors.Value,
                (input, restart, output, solver, processors) => (!String.IsNullOrWhiteSpace(input.Value) || !String.IsNullOrWhiteSpace(restart.Value)) && !String.IsNullOrWhiteSpace(output.Value) && !String.IsNullOrWhiteSpace(solver.Value) && processors.Value != "0");

            Run               = ReactiveCommand.Create(canRunMPP);
            SWRestartStop     = ReactiveCommand.Create(canRunMPP);
            SWRestartContinue = ReactiveCommand.Create(canRunMPP);
            SWRezonerToggle   = ReactiveCommand.Create(canRunMPP);
            SWTimeAndCycle    = ReactiveCommand.Create(canRunMPP);
            SWVisToggle       = ReactiveCommand.Create(canRunMPP);
            SWPlotState       = ReactiveCommand.Create(canRunMPP);
            SWASCIIFlush      = ReactiveCommand.Create(canRunMPP);
            SWStop            = ReactiveCommand.Create(canRunMPP);

            this.WhenAnyValue(x => x.RestartFile.Value).Where(x => x.ToLowerInvariant().Contains("full")).Subscribe(_ => this.RestartFile.Flag = "N=");
            this.WhenAnyValue(x => x.RestartFile.Value).Where(x => x.ToLowerInvariant().Contains("dump")).Subscribe(_ => this.RestartFile.Flag = "R=");
            this.WhenAnyValue(x => x.MemorySize).Subscribe(_ => this.Memory.Value = this.Memory.Value + this.MemorySize);
        }