public InputDataViewModel(InputCoreViewModel parent, InputData info, Action<InputData> removeHandler) { this.Parent = parent; this.Model = info; this._removeHandler = removeHandler; }
public PostSucceededEvent(InputData data) { this._body = data.Text; }
public PostResult(InputData succeededs, InputData faileds, IEnumerable<Exception> throwns) { Succeededs = succeededs; Faileds = faileds; Exceptions = throwns; }
private void SendCore(InputData data) { data.Send() .Subscribe(r => { if (r.Succeededs != null) { InputModel.InputCore.LastPostedData = r.Succeededs; BackstageModel.RegisterEvent(new PostSucceededEvent(r.Succeededs)); } if (r.Faileds != null) { var message = this.AnalyzeFailedReason(r.Exceptions) ?? InputAreaResources.MsgTweetFailedReasonUnknown; var ed = r.Exceptions .Guard() .SelectMany(ex => EnumerableEx.Generate( ex, e => e != null, e => e.InnerException, e => e)) .Where(e => e != null) .Select(e => e.ToString()) .JoinString(Environment.NewLine); if (Setting.ShowMessageOnTweetFailed.Value) { var resp = _parent.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions { Title = InputAreaResources.MsgTweetFailedTitle, MainIcon = VistaTaskDialogIcon.Error, MainInstruction = InputAreaResources.MsgTweetFailedInst, Content = InputAreaResources.MsgTweetFailedContentFormat.SafeFormat(message), ExpandedInfo = ed, FooterText = InputAreaResources.MsgTweetFailedFooter, FooterIcon = VistaTaskDialogIcon.Information, VerificationText = Resources.MsgDoNotShowAgain, CommonButtons = TaskDialogCommonButtons.RetryCancel })); Setting.ShowMessageOnTweetFailed.Value = !resp.Response.VerificationChecked.GetValueOrDefault(); if (resp.Response.Result == TaskDialogSimpleResult.Retry) { this.SendCore(r.Faileds); return; } } else { BackstageModel.RegisterEvent(new PostFailedEvent(r.Faileds, message)); } // Send to draft InputModel.InputCore.Drafts.Add(r.Faileds); } }); }
private void SendCore(InputData data) { data.Send() .Subscribe(r => { if (r.Succeededs != null) { InputModel.InputCore.LastPostedData = r.Succeededs; BackstageModel.RegisterEvent(new PostSucceededEvent(r.Succeededs)); } if (r.Faileds != null) { var message = this.AnalyzeFailedReason(r.Exceptions) ?? "原因を特定できませんでした。"; if (Setting.ShowMessageOnTweetFailed.Value) { var resp = _parent.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions { Title = "ツイートの失敗", MainIcon = VistaTaskDialogIcon.Error, MainInstruction = "ツイートに失敗しました。", Content = "エラー: " + message + Environment.NewLine + "もう一度投稿しますか?", FooterText = "再試行しない場合は、ツイートしようとした内容は下書きとして保存されます。", FooterIcon = VistaTaskDialogIcon.Information, VerificationText = "次回から表示しない", CommonButtons = TaskDialogCommonButtons.RetryCancel })); Setting.ShowMessageOnTweetFailed.Value = !resp.Response.VerificationChecked.GetValueOrDefault(); if (resp.Response.Result == TaskDialogSimpleResult.Retry) { this.SendCore(r.Faileds); return; } } else { BackstageModel.RegisterEvent(new PostFailedEvent(r.Faileds, message)); } // Send to draft InputModel.InputCore.Drafts.Add(r.Faileds); } }); }
public ImageDescriptionViewModel(InputData data, byte[] image) { _data = data; ByteArray = image; }
public PostFailedEvent(InputData data, string reason) { this._post = data.Text; this._reason = reason; }
internal InputCoreModel() { CurrentInputData = new InputData(String.Empty); _bindingHashtags.ListenCollectionChanged() .Subscribe(_ => { if (_currentFocusTabModel != null) { _currentFocusTabModel.BindingHashtags = _bindingHashtags.ToArray(); } }); }
public void ClearInput(string text, bool sendDraftIfChanged) { var current = _inputData; _inputData = new InputData(text); if (current.IsChanged && sendDraftIfChanged) { // if text is not changed, send to draft _drafts.Add(current); } _inputData.BoundTags = BindingHashtags.ToArray(); RaisePropertyChanged(() => CurrentInputData); }
private void SetDirectMessage(IEnumerable<TwitterAccount> infos, [NotNull] TwitterUser recipient, bool focusToInputArea) { if (recipient == null) throw new ArgumentNullException("recipient"); CurrentInputData = new InputData(String.Empty) { Accounts = infos, MessageRecipient = recipient }; // because text is always empty, setting cursor position can be skipped. if (focusToInputArea) { FocusRequest.SafeInvoke(); } }
private void SetText(IEnumerable<TwitterAccount> infos, string body, TwitterStatus inReplyTo, CursorPosition cursor, bool focusToInputArea) { CurrentInputData = new InputData(body) { Accounts = infos, InReplyTo = inReplyTo, }; SetCursorRequest.SafeInvoke(cursor ?? CursorPosition.End); if (focusToInputArea) { FocusRequest.SafeInvoke(); } }
private InputData Clone() { var newdata = new InputData(_initText) { _accounts = _accounts == null ? null : _accounts.ToArray(), _amendTweets = _amendTweets.ToDictionary(p => p.Key, p => p.Value), _boundTags = _boundTags, _geoInfo = _geoInfo, _inReplyTo = _inReplyTo, _initText = _initText, _messageRecipient = _messageRecipient, _text = _text }; foreach (var image in _attachedImages) { newdata.AttachedImages.Add(image); } return newdata; }