private void SubmitImpl() { _redditService.AddComment(((dynamic)_replyTargetThing.Data).Name, ReplyBody); var theComment = new Thing { Kind = "t2", Data = new Comment { Author = string.IsNullOrWhiteSpace(CommentingAs) ? "self" : CommentingAs, Body = ReplyBody, Likes = true, Ups = 1, ParentId = ((dynamic)_replyTargetThing.Data).Name, Replies = new Listing { Data = new ListingData { Children = new List <Thing>() } }, Created = DateTime.Now, CreatedUTC = DateTime.UtcNow } }; _convertIntoUIReply(theComment); Cancel.Execute(null); }
private Task GameServerClient_Closed(Exception exception) { PlatformSpecific.PlatformManager.Instance.ShowMessage($"{Resources.LostConnection}: {exception?.Message}", PlatformSpecific.MessageType.Warning); Cancel.Execute(null); return(Task.CompletedTask); }
public async Task Init() { try { IsProgress = true; _gamesHostInfo = await _gameServerClient.GetGamesHostInfoAsync(_cancellationTokenSource.Token); await ReloadGamesAsync(); await ReloadUsersAsync(); _avatar = (await UploadAvatar(Human, CancellationToken.None))?.Item1; } catch (Exception exc) { PlatformSpecific.PlatformManager.Instance.ShowMessage(exc.ToString(), PlatformSpecific.MessageType.Warning, true); Cancel.Execute(null); } }
private async void SaveAction() { ModelsShared.Models.port port = new ModelsShared.Models.port { CityID = this.CityID, Code = this.Code, PortType = this.PortType, Id = this.Id, Name = this.Name, CityName = CityCollection.SelectedItem.CityName }; var res = await Collection.Add(port); if (res != null) { MessageBoxButton btn = MessageBoxButton.OK; var result = ModernDialog.ShowMessage("Data Saved?", "Message Dialog", btn); Cancel.Execute(null); } }
private async void SaveAction() { var list = new List <string>(); foreach (var i in Ports) { list.Add(i.Name); } this.RouteView = list; var item = new ModelsShared.Models.ship { Description = this.Description, Name = this.Name, Id = this.Id, Route = this.Route }; var result = await MainVM.ShipCollection.Add(item); if (result == null) { ResourcesBase.ShowMessageError("Data Tidak Tersimpan"); } else { Cancel.Execute(null); } }
public PullRequestCreationViewModel( IModelServiceFactory modelServiceFactory, IPullRequestService service, INotificationService notifications, IMessageDraftStore draftStore, IGitService gitService, IScheduler timerScheduler) { Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(notifications, nameof(notifications)); Guard.ArgumentNotNull(draftStore, nameof(draftStore)); Guard.ArgumentNotNull(gitService, nameof(gitService)); Guard.ArgumentNotNull(timerScheduler, nameof(timerScheduler)); this.service = service; this.modelServiceFactory = modelServiceFactory; this.draftStore = draftStore; this.gitService = gitService; this.timerScheduler = timerScheduler; this.WhenAnyValue(x => x.Branches) .WhereNotNull() .Where(_ => TargetBranch != null) .Subscribe(x => { if (!x.Any(t => t.Equals(TargetBranch))) { TargetBranch = GitHubRepository.IsFork ? GitHubRepository.Parent.DefaultBranch : GitHubRepository.DefaultBranch; } }); SetupValidators(); var whenAnyValidationResultChanges = this.WhenAny( x => x.TitleValidator.ValidationResult, x => x.BranchValidator.ValidationResult, x => x.IsBusy, (x, y, z) => (x.Value?.IsValid ?? false) && (y.Value?.IsValid ?? false) && !z.Value); this.WhenAny(x => x.BranchValidator.ValidationResult, x => x.GetValue()) .WhereNotNull() .Where(x => !x.IsValid && x.DisplayValidationError) .Subscribe(x => notifications.ShowError(BranchValidator.ValidationResult.Message)); CreatePullRequest = ReactiveCommand.CreateFromObservable( () => service .CreatePullRequest(modelService, activeLocalRepo, TargetBranch.Repository, SourceBranch, TargetBranch, PRTitle, Description ?? String.Empty) .Catch <IPullRequestModel, Exception>(ex => { log.Error(ex, "Error creating pull request"); //TODO:Will need a uniform solution to HTTP exception message handling var apiException = ex as ApiValidationException; var error = apiException?.ApiError?.Errors?.FirstOrDefault(); notifications.ShowError(error?.Message ?? ex.Message); return(Observable.Empty <IPullRequestModel>()); }), whenAnyValidationResultChanges); CreatePullRequest.Subscribe(pr => { notifications.ShowMessage(String.Format(CultureInfo.CurrentCulture, Resources.PRCreatedUpstream, SourceBranch.DisplayName, TargetBranch.Repository.Owner + "/" + TargetBranch.Repository.Name + "#" + pr.Number, TargetBranch.Repository.CloneUrl.ToRepositoryUrl().Append("pull/" + pr.Number))); NavigateTo("/pulls?refresh=true"); Cancel.Execute(); draftStore.DeleteDraft(GetDraftKey(), string.Empty).Forget(); Close(); }); Cancel = ReactiveCommand.Create(() => { }); Cancel.Subscribe(_ => { Close(); draftStore.DeleteDraft(GetDraftKey(), string.Empty).Forget(); }); isExecuting = CreatePullRequest.IsExecuting.ToProperty(this, x => x.IsExecuting); this.WhenAnyValue(x => x.Initialized, x => x.GitHubRepository, x => x.IsExecuting) .Select(x => !(x.Item1 && x.Item2 != null && !x.Item3)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => IsBusy = x); }
public ViewModel() { Add = new DelegateCommand(() => Collection.Add(new ImageModel() { Text = NewText, Uri = new Uri(NewUri) })); Delete = new DelegateCommand <ImageModel>(item => Collection.Remove(item)); Load = new DelegateCommand(() => { var open = new Microsoft.Win32.OpenFileDialog(); if (open.ShowDialog() ?? false) { var file = new FileInfo(open.FileName); if (file.Exists) { if (Model == null) { Model = new ImageCollectionModel(); } Model.Load(file); } Cancel.Execute(); } }); Save = new DelegateCommand(() => { var save = new Microsoft.Win32.SaveFileDialog(); if (save.ShowDialog() ?? false) { var file = new FileInfo(save.FileName); if (!file.Exists) { if (Model == null) { Model = new ImageCollectionModel(); } Model.Collection.Clear(); Model.Collection.AddRange(Collection); Model.Save(file); } } }); Cancel = new DelegateCommand(() => { Collection.Clear(); if (Model != null) { foreach (var item in Model.Collection) { Collection.Add(item); } } }); Browse = new DelegateCommand(() => { var open = new Microsoft.Win32.OpenFileDialog(); if (open.ShowDialog() ?? false) { NewUri = open.FileName; } }); }
public NodeEditor() { InitializeComponent(); this.Resize += NodeEditor_Resize; NeutralHoveredPressedButton ok = new NeutralHoveredPressedButton(() => okButton.ClientRectangle, (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Neutral), (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Hovered), (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Pressed), () => Invalidate(true), () => m_ok(), () => "Ok", Fonts.Default); ok.RegisterCallbacks(null, okButton); NeutralHoveredPressedButton cancel = new NeutralHoveredPressedButton(() => cancelButton.ClientRectangle, (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Neutral), (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Hovered), (area, graphics) => ButtonDrawer.DrawButton(area.Round(), graphics, ButtonDrawer.ButtonState.Pressed), () => Invalidate(true), () => Cancel.Execute(), () => "Cancel", Fonts.Default); cancel.RegisterCallbacks(null, cancelButton); }
private void CancelBase_Executed(object arg) { Closed?.Invoke(); Cancel.Execute(null); }