예제 #1
0
        public MainWindowViewModel(AppCore appCore, Config config)
        {
            IeReleaseBuild     = config.ToReactivePropertyAsSynchronized(x => x.IsReleaseBuild).AddTo(Trashes);
            IsTieredJit        = config.ToReactivePropertyAsSynchronized(x => x.IsTieredJit).AddTo(Trashes);
            IsFileMonitoring   = config.ToReactivePropertyAsSynchronized(x => x.IsFileMonitoring).AddTo(Trashes);
            MonitoringFilePath = config.ToReactivePropertyAsSynchronized(x => x.MonitoringFilePath).AddTo(Trashes);
            IsInBuilding       = appCore.BuildingUnit.ObserveProperty(x => x.IsInBuilding).ToReadOnlyReactiveProperty().AddTo(Trashes);

            SourceCode         = appCore.BuildingUnit.ToReactivePropertyAsSynchronized(x => x.SourceCode).AddTo(Trashes);
            BuildResult        = appCore.BuildingUnit.ObserveProperty(x => x.BuildResult).ToReadOnlyReactiveProperty().AddTo(Trashes);
            BuildMessage       = appCore.BuildingUnit.ObserveProperty(x => x.BuildMessage).ToReadOnlyReactiveProperty().AddTo(Trashes);
            BuildDetailMessage = appCore.BuildingUnit.ObserveProperty(x => x.BuildDetailMessages).ToReadOnlyReactiveProperty().AddTo(Trashes);
            IsBuildOk          = appCore.BuildingUnit.ObserveProperty(x => x.IsBuildOk).ToReadOnlyReactiveProperty().AddTo(Trashes);

            OpenMonitoringFileCommand = new ReactiveCommand <OpeningFileSelectionMessage>().AddTo(Trashes);
            OpenMonitoringFileCommand.Subscribe(x =>
            {
                var selectedFile = x?.Response?.FirstOrDefault();
                if (string.IsNullOrEmpty(selectedFile) == false)
                {
                    config.MonitoringFilePath = selectedFile !;
                }
            }).AddTo(Trashes);

            ApplyTemplateFileCommand = new ReactiveCommand().AddTo(Trashes);
            ApplyTemplateFileCommand.Subscribe(_ => appCore.ApplyTemplateFile()).AddTo(Trashes);

            OpenConfigFolderCommand = new ReactiveCommand().AddTo(Trashes);
            OpenConfigFolderCommand.Subscribe(_ => appCore.OpenConfigFolder()).AddTo(Trashes);

            OpenAboutDialogCommand = new AsyncReactiveCommand().AddTo(Trashes);
            OpenAboutDialogCommand.Subscribe(async _ =>
            {
                using var aboutDialogViewModel = new AboutDialogViewModel(appCore);

                // ReSharper disable once AsyncConverter.AsyncAwaitMayBeElidedHighlighting
                await Messenger.RaiseAsync(new TransitionMessage(aboutDialogViewModel, "OpenAboutDialog")).ConfigureAwait(false);
            }).AddTo(Trashes);
        }