public NewItemDialogViewModel(IProjectFolder folder) : base("New Item") { var shell = IoC.Get <IShell>(); templates = new ObservableCollection <ICodeTemplate>(); var compatibleTemplates = shell.CodeTemplates.Where(t => t.IsCompatible(folder.Project)); foreach (var template in compatibleTemplates) { templates.Add(template); } SelectedTemplate = templates.FirstOrDefault(); this.folder = folder; OKCommand = ReactiveCommand.Create(); OKCommand.Subscribe(_ => { SelectedTemplate?.Generate(folder); Close(); }); }
public TestFormViewModel() { OKCommand.Subscribe(item => { item.Result = true; if (Position.Value == ItemsSource.Count - 1) { TestFinished(); return; } Position.Value++; }); NGCommand.Subscribe(item => { item.Result = false; }); Position.Subscribe(pos => { if (ItemsSource == null) { return; } _prevItem?.CancelAction?.Invoke(); ItemsSource[pos].Action?.Invoke(); _prevItem = ItemsSource[pos]; }); }
public STM32ProjectSetupModalDialogViewModel() : base("New STM32 Project", true, true) { OKCommand = ReactiveCommand.Create(); OKCommand.Subscribe((o) => { Close(); }); }
public VerificationCodePageViewModel(INavigationService navigationService) : base(navigationService) { Title = "Verification Code"; OKCommand = VerificationCode.Select(s => !string.IsNullOrEmpty(s)).ToReactiveCommand(); OKCommand.Subscribe(() => navigationService.GoBackAsync(VerificationCode.Value)); CancelCommand = new ReactiveCommand(); CancelCommand.Subscribe(() => navigationService.GoBackAsync()); }
public NewProjectDialogViewModel() : base("New Project", true, true) { shell = IoC.Get <IShell>(); projectTemplates = new ObservableCollection <IProjectTemplate>(); Languages = new List <ILanguageService>(shell.LanguageServices); location = Platform.ProjectDirectory; SelectedLanguage = Languages.FirstOrDefault(); SelectedTemplate = ProjectTemplates.FirstOrDefault(); BrowseLocationCommand = ReactiveCommand.Create(); BrowseLocationCommand.Subscribe(async o => { var ofd = new OpenFolderDialog(); ofd.InitialDirectory = location; var result = await ofd.ShowAsync(); if (result != string.Empty) { Location = result; } }); OKCommand = ReactiveCommand.Create(this.WhenAny(x => x.Location, x => x.SolutionName, (location, solution) => !Directory.Exists(Path.Combine(location.Value, solution.Value)))); OKCommand.Subscribe(async o => { bool generateSolutionDirs = false; if (solution == null) { generateSolutionDirs = true; var destination = Path.Combine(location, solutionName); solution = Solution.Create(destination, solutionName, false); } if (await selectedTemplate.Generate(solution, name) != null) { if (generateSolutionDirs) { if (!Directory.Exists(solution.CurrentDirectory)) { Directory.CreateDirectory(solution.CurrentDirectory); } } } solution.Save(); shell.CurrentSolution = solution; solution = null; Close(); }); }
public ProjectConfigurationDialogViewModel(IProject project, Action onClose) : base("Project Configuration", true, false) { ConfigPages = new List <object>(); ConfigPages.AddRange(project.ConfigurationPages); OKCommand = ReactiveCommand.Create(); OKCommand.Subscribe(o => { onClose(); Close(); }); }
public PickoutCoverViewModel() { PropertyChanged += PickOutCoverDialogViewModel_PropertyChanged; OKCommand.Subscribe(_ => { ExtractCover(); RequestClose.Invoke(new DialogResult(ButtonResult.OK)); }) .AddTo(disposables); CancelCommand.Subscribe(_ => { RequestClose.Invoke(new DialogResult(ButtonResult.Cancel)); }) .AddTo(disposables); }
public PackageManagerDialogViewModel() : base("Packages") { _packageManager = new PackageManager(this); AvailablePackages = new ObservableCollection <IPackageSearchMetadata>(); Dispatcher.UIThread.InvokeAsync(async() => { InvalidateInstalledPackages(); await DownloadCatalog(); }); InstallCommand = ReactiveCommand.Create(); InstallCommand.Subscribe(async _ => { await PackageManager.InstallPackage(selectedPackage.Identity.Id, selectedPackage.Identity.Version.ToFullString()); InvalidateInstalledPackages(); }); UninstallCommand = ReactiveCommand.Create(); UninstallCommand.Subscribe(async _ => { if (SelectedInstalledPackage != null) { await PackageManager.UninstallPackage(SelectedInstalledPackage.Model.Id, SelectedInstalledPackage.Model.Version.ToNormalizedString()); InvalidateInstalledPackages(); } }); OKCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.EnableInterface)); OKCommand.Subscribe(_ => { ShellViewModel.Instance.InvalidateCodeAnalysis(); Close(); }); EnableInterface = true; }
public PackageManagerDialogViewModel() : base("Packages") { AvailablePackages = new ObservableCollection <PackageReference>(); DownloadCatalog(); InstallCommand = ReactiveCommand.Create(); InstallCommand.Subscribe(async o => { EnableInterface = false; try { await SelectedPackageIndex.Synchronize(SelectedTag, this); //if (fullPackage.Install()) //{ // Status = "Package Installed Successfully."; //} //else //{ // Status = "An error occurred trying to install package."; //} } catch (Exception e) { Status = "An error occurred trying to install package. " + e.Message; } EnableInterface = true; }); OKCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.EnableInterface)); OKCommand.Subscribe(_ => { ShellViewModel.Instance.InvalidateCodeAnalysis(); Close(); }); EnableInterface = true; }
public AccountPanelViewModel(Config config) { Clients = config.Clients; var appRegistration = new ReactiveProperty<AppRegistration>(); var authClient = new ReactiveProperty<AuthenticationClient>(); Domain = new ReactiveProperty<string>(); var canExecuteAuthCommand = Domain.Select(x => !string.IsNullOrWhiteSpace(x)); AuthCommand = new ReactiveCommand(canExecuteAuthCommand); AuthCommand.Subscribe(async () => { authClient.Value = new AuthenticationClient(Domain.Value); appRegistration.Value = await authClient.Value.CreateApp("Mayodon Client", Scope.Read); System.Diagnostics.Process.Start(authClient.Value.OAuthUrl()); }); AuthCode = new ReactiveProperty<string>(); OKCommand = Observable.CombineLatest( appRegistration.Select(x => x != null), AuthCode.Select(x => !string.IsNullOrWhiteSpace(x)), (x, y) => x & y).ToReactiveCommand(); OKCommand.Subscribe(async () => { var auth = await authClient.Value.ConnectWithCode(AuthCode.Value); var client = new MastodonClient(appRegistration.Value, auth); var account = await client.GetCurrentUser(); config.Clients.Add(new Client() { App = appRegistration.Value, Auth = auth, Account = account }); config.Save(); Domain.Value = ""; AuthCode.Value = ""; }); }
public ExportDialogViewModel() { OKCommand.Subscribe(async _ => { await RunExport(); RequestClose.Invoke(new DialogResult(ButtonResult.OK)); }) .AddTo(_disposables); CancelCommand.Subscribe(_ => { RequestClose.Invoke(new DialogResult(ButtonResult.Cancel)); }) .AddTo(_disposables); ReferenceCommand.Subscribe(_ => { ShowOpenFileDialog(); }) .AddTo(_disposables); TextVerifier.Value = new Func <string, bool?>((s) => Directory.Exists(s)); }
public CustomDialogViewModel( IDialogService _dialogService, IRegionManager _regionManager ) { RegionManager = _regionManager; CustomDialogRegionManager.Value = RegionManager.CreateRegionManager(); OKCommand.Subscribe(Close).AddTo(DisposeCollection); RecursionCommand.Subscribe(() => { IDialogResult result = null; _dialogService.ShowDialog(nameof(CustomDialogView), new DialogParameters { { "Input", Input.Value } }, ret => result = ret); if (result != null) { Input.Value = result.Parameters.GetValue <string>("Input"); } }).AddTo(DisposeCollection); }
public CommandViewModel() { CanClose = new ReactiveProperty <bool>(false); AppDisplayName = new ReactiveProperty <string>(); Command = new ReactiveProperty <List <string> >(new List <string>()); IsAdmin = new ReactiveProperty <bool>(false); OKCommand = new[] { Command.Select(x => x.Where(y => !string.IsNullOrWhiteSpace(y)).Count() == 0), AppDisplayName.Select(x => string.IsNullOrWhiteSpace(x)) }.CombineLatestValuesAreAllFalse().ToReactiveCommand(); OKCommand.Subscribe(() => { UpdateAppInfo(); IsUpdate = true; CanClose.Value = true; }); CancelCommand = new ReactiveCommand(); CancelCommand.Subscribe(() => { IsUpdate = false; CanClose.Value = true; }); }
public SettingViewModel() { AppDisplayName = new ReactiveProperty <string>(); FilePath = new ReactiveProperty <string>(); Arguments = new ReactiveProperty <string>(); WorkDirectory = new ReactiveProperty <string>(); IsAdmin = new ReactiveProperty <bool>(); AppIcon = new ReactiveProperty <BitmapSource>(); CanClose = new ReactiveProperty <bool>(); OKCommand = new[] { AppDisplayName.Select(x => string.IsNullOrWhiteSpace(x)), FilePath.Select(x => string.IsNullOrWhiteSpace(x)) }.CombineLatestValuesAreAllFalse().ToReactiveCommand(); OKCommand.Subscribe(() => { if (HasChanges()) { if (!File.Exists(FilePath.Value) && !Directory.Exists(FilePath.Value)) { MessageBox.Show("ファイルが見つかりません。"); IsUpdate = true; CanClose.Value = false; return; } UpdateAppInfo(); IsUpdate = true; CanClose.Value = true; return; } //キャンセル扱い IsUpdate = false; CanClose.Value = true; }); CancelCommand = new ReactiveCommand(); CancelCommand.Subscribe(() => { IsUpdate = false; CanClose.Value = true;//キャンセルは常にtrue }); }
public AboutDialogViewModel() : base("About", true, false) { OKCommand = ReactiveCommand.Create(); OKCommand.Subscribe(o => { Close(); }); }
/// <summary> /// コンストラクタ /// </summary> public CameraCapturingViewModel() { OKCommand.Subscribe(OKInteraction); CancelCommand.Subscribe(CancelInteraction); }