/// <summary> /// Returns a value indicating whether this instance is equal to the specified <see cref="NntpGroup"/> value. /// </summary> /// <param name="other">A <see cref="NntpGroup"/> object to compare to this instance.</param> /// <returns>true if <paramref name="other" /> has the same value as this instance; otherwise, false.</returns> public bool Equals(NntpGroup other) { if ((object)other == null) { return(false); } bool equals = Name.Equals(other.Name) && ArticleCount.Equals(other.ArticleCount) && LowWaterMark.Equals(other.LowWaterMark) && HighWaterMark.Equals(other.HighWaterMark) && PostingStatus.Equals(other.PostingStatus) && OtherGroup.Equals(other.OtherGroup); if (!equals) { return(false); } // need to memoize the enumerables for comparison // otherwise they can not be used anymore after this call to equals if (!(ArticleNumbers is ICollection <long>)) { ArticleNumbers = ArticleNumbers.ToList(); } if (!(other.ArticleNumbers is ICollection <long>)) { other.ArticleNumbers = other.ArticleNumbers.ToList(); } return(ArticleNumbers.SequenceEqual(other.ArticleNumbers)); }
/// <summary> /// Returns the hash code for this instance. /// </summary> /// <returns>A 32-bit signed integer hash code.</returns> public override int GetHashCode() { unchecked { var hash = 17; hash *= 23 + Name.GetHashCode(); hash *= 23 + ArticleCount.GetHashCode(); hash *= 23 + LowWaterMark.GetHashCode(); hash *= 23 + HighWaterMark.GetHashCode(); hash *= 23 + PostingStatus.GetHashCode(); hash *= 23 + OtherGroup.GetHashCode(); hash *= 23 + ArticleNumbers.GetHashCode(); return(hash); } }
/// <summary> /// Returns a value indicating whether this instance is equal to the specified <see cref="NntpGroup"/> value. /// </summary> /// <param name="other">A <see cref="NntpGroup"/> object to compare to this instance.</param> /// <returns>true if <paramref name="other" /> has the same value as this instance; otherwise, false.</returns> public bool Equals(NntpGroup other) { if ((object)other == null) { return(false); } return (Name.Equals(other.Name) && ArticleCount.Equals(other.ArticleCount) && LowWaterMark.Equals(other.LowWaterMark) && HighWaterMark.Equals(other.HighWaterMark) && PostingStatus.Equals(other.PostingStatus) && OtherGroup.Equals(other.OtherGroup) && MultiSetComparer <int> .Instance.Equals(ArticleNumbers, other.ArticleNumbers)); }
public static void ChangeStatus(string id, string status) { var entities = FormulaHelper.GetEntities <OfficeAutoEntities>(); S_D_Posting model = entities.Set <S_D_Posting>().Find(id); if (model != null && !string.IsNullOrEmpty(status)) { PostingStatus enumStatus = (PostingStatus)Enum.Parse(typeof(PostingStatus), status); if (enumStatus.ToString() != string.Empty) { //model.Status = enumStatus.ToString(); //if (!string.IsNullOrEmpty(model.ExecutedSteps)) //{ // string[] arr = model.ExecutedSteps.Split(','); // arr.RemoveWhere(c => c == enumStatus.ToString()); // model.ExecutedSteps = string.Join(",", arr); //} entities.SaveChanges(); } } }
private bool CommonKeyDown(Keys KeyCode, FocusedControl Focused, ModifierState Modifier) { //リストのカーソル移動関係(上下キー、PageUp/Downに該当) if (Focused == FocusedControl.ListTab) { if (Modifier == (ModifierState.Ctrl | ModifierState.Shift) || Modifier == ModifierState.Ctrl || Modifier == ModifierState.None || Modifier == ModifierState.Shift) { if (KeyCode == Keys.J) { SendKeys.Send("{DOWN}"); return true; } else if (KeyCode == Keys.K) { SendKeys.Send("{UP}"); return true; } } if (Modifier == ModifierState.Shift || Modifier == ModifierState.None) { if (KeyCode == Keys.F) { SendKeys.Send("{PGDN}"); return true; } else if (KeyCode == Keys.B) { SendKeys.Send("{PGUP}"); return true; } } } //修飾キーなし switch (Modifier) { case ModifierState.None: //フォーカス関係なし switch (KeyCode) { case Keys.F1: OpenApplicationWebsite(); return true; case Keys.F3: MenuItemSearchNext_Click(null, null); return true; case Keys.F5: DoRefresh(); return true; case Keys.F6: GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 0, ""); return true; case Keys.F7: GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, ""); return true; } if (Focused != FocusedControl.StatusText) { //フォーカスStatusText以外 switch (KeyCode) { case Keys.Space: case Keys.ProcessKey: if (Focused == FocusedControl.ListTab) _anchorFlag = false; JumpUnreadMenuItem_Click(null, null); return true; case Keys.G: if (Focused == FocusedControl.ListTab) _anchorFlag = false; ShowRelatedStatusesMenuItem_Click(null, null); return true; } } if (Focused == FocusedControl.ListTab) { //フォーカスList switch (KeyCode) { case Keys.N: case Keys.Right: GoRelPost(true); return true; case Keys.P: case Keys.Left: GoRelPost(false); return true; case Keys.OemPeriod: GoAnchor(); return true; case Keys.I: if (this.StatusText.Enabled) this.StatusText.Focus(); return true; case Keys.Enter: MakeReplyOrDirectStatus(); return true; case Keys.R: DoRefresh(); return true; } //以下、アンカー初期化 _anchorFlag = false; switch (KeyCode) { case Keys.L: GoPost(true); return true; case Keys.H: GoPost(false); return true; case Keys.Z: case Keys.Oemcomma: MoveTop(); return true; case Keys.S: GoNextTab(true); return true; case Keys.A: GoNextTab(false); return true; case Keys.Oem4: // ] in_reply_to参照元へ戻る GoInReplyToPostTree(); return true; case Keys.Oem6: // [ in_reply_toへジャンプ GoBackInReplyToPostTree(); return true; case Keys.Escape: if (ListTab.SelectedTab != null) { MyCommon.TabUsageType tabtype = _statuses.Tabs[ListTab.SelectedTab.Text].TabType; if (tabtype == MyCommon.TabUsageType.Related || tabtype == MyCommon.TabUsageType.UserTimeline || tabtype == MyCommon.TabUsageType.PublicSearch) { TabPage relTp = ListTab.SelectedTab; RemoveSpecifiedTab(relTp.Text, false); SaveConfigsTabs(); return true; } } break; } } break; case ModifierState.Ctrl: //フォーカス関係なし switch (KeyCode) { case Keys.R: MakeReplyOrDirectStatus(false, true); return true; case Keys.D: doStatusDelete(); return true; case Keys.M: MakeReplyOrDirectStatus(false, false); return true; case Keys.S: FavoriteChange(true); return true; case Keys.I: doRepliedStatusOpen(); return true; case Keys.Q: doQuote(); return true; case Keys.B: ReadedStripMenuItem_Click(null, null); return true; case Keys.T: HashManageMenuItem_Click(null, null); return true; case Keys.L: UrlConvertAutoToolStripMenuItem_Click(null, null); return true; case Keys.Y: if (Focused != FocusedControl.PostBrowser) { MultiLineMenuItem_Click(null, null); return true; } break; case Keys.F: MenuItemSubSearch_Click(null, null); return true; case Keys.U: ShowUserTimeline(); return true; case Keys.H: // Webページを開く動作 if (_curList.SelectedIndices.Count > 0) OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices[0]).ScreenName); else if (_curList.SelectedIndices.Count == 0) OpenUriAsync("http://twitter.com/"); return true; case Keys.G: // Webページを開く動作 if (_curList.SelectedIndices.Count > 0) OpenUriAsync("http://twitter.com/" + GetCurTabPost(_curList.SelectedIndices[0]).ScreenName + "/favorites"); return true; case Keys.O: // Webページを開く動作 StatusOpenMenuItem_Click(null, null); return true; case Keys.E: // Webページを開く動作 OpenURLMenuItem_Click(null, null); return true; } //フォーカスList if (Focused == FocusedControl.ListTab) { switch (KeyCode) { case Keys.Home: case Keys.End: _colorize = true; return false; //スルーする case Keys.N: GoNextTab(true); return true; case Keys.P: GoNextTab(false); return true; case Keys.C: CopyStot(); return true; case Keys.D1: case Keys.D2: case Keys.D3: case Keys.D4: case Keys.D5: case Keys.D6: case Keys.D7: case Keys.D8: // タブダイレクト選択(Ctrl+1~8,Ctrl+9) int tabNo = KeyCode - Keys.D1; if (ListTab.TabPages.Count < tabNo) return false; ListTab.SelectedIndex = tabNo; ListTabSelect(ListTab.TabPages[tabNo]); return true; case Keys.D9: ListTab.SelectedIndex = ListTab.TabPages.Count - 1; ListTabSelect(ListTab.TabPages[ListTab.TabPages.Count - 1]); return true; } } else if (Focused == FocusedControl.StatusText) { //フォーカスStatusText switch (KeyCode) { case Keys.A: StatusText.SelectAll(); return true; case Keys.Up: case Keys.Down: if (!string.IsNullOrWhiteSpace(StatusText.Text)) { _history[_hisIdx] = new PostingStatus(StatusText.Text, _reply_to_id, _reply_to_name); } if (KeyCode == Keys.Up) { _hisIdx -= 1; if (_hisIdx < 0) _hisIdx = 0; } else { _hisIdx += 1; if (_hisIdx > _history.Count - 1) _hisIdx = _history.Count - 1; } StatusText.Text = _history[_hisIdx].status; _reply_to_id = _history[_hisIdx].inReplyToId; _reply_to_name = _history[_hisIdx].inReplyToName; StatusText.SelectionStart = StatusText.Text.Length; return true; case Keys.PageUp: case Keys.P: if (ListTab.SelectedIndex == 0) { ListTab.SelectedIndex = ListTab.TabCount - 1; } else { ListTab.SelectedIndex -= 1; } StatusText.Focus(); return true; case Keys.PageDown: case Keys.N: if (ListTab.SelectedIndex == ListTab.TabCount - 1) { ListTab.SelectedIndex = 0; } else { ListTab.SelectedIndex += 1; } StatusText.Focus(); return true; } } else { //フォーカスPostBrowserもしくは関係なし switch (KeyCode) { case Keys.A: PostBrowser.Document.ExecCommand("SelectAll", false, null); return true; case Keys.C: case Keys.Insert: string _selText = WebBrowser_GetSelectionText(ref PostBrowser); if (!string.IsNullOrEmpty(_selText)) { try { Clipboard.SetDataObject(_selText, false, 5, 100); } catch (Exception ex) { MessageBox.Show(ex.Message); } } return true; case Keys.Y: MultiLineMenuItem.Checked = !MultiLineMenuItem.Checked; MultiLineMenuItem_Click(null, null); return true; } } break; case ModifierState.Shift: //フォーカス関係なし switch (KeyCode) { case Keys.F3: MenuItemSearchPrev_Click(null, null); return true; case Keys.F5: DoRefreshMore(); return true; case Keys.F6: GetTimeline(MyCommon.WORKERTYPE.Reply, -1, 0, ""); return true; case Keys.F7: GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, -1, 0, ""); return true; } //フォーカスStatusText以外 if (Focused != FocusedControl.StatusText) { if (KeyCode == Keys.R) { DoRefreshMore(); return true; } } //フォーカスリスト if (Focused == FocusedControl.ListTab) { switch (KeyCode) { case Keys.H: GoTopEnd(true); return true; case Keys.L: GoTopEnd(false); return true; case Keys.M: GoMiddle(); return true; case Keys.G: GoLast(); return true; case Keys.Z: MoveMiddle(); return true; case Keys.Oem4: GoBackInReplyToPostTree(true, false); return true; case Keys.Oem6: GoBackInReplyToPostTree(true, true); return true; case Keys.N: case Keys.Right: // お気に入り前後ジャンプ(SHIFT+N←/P→) GoFav(true); return true; case Keys.P: case Keys.Left: // お気に入り前後ジャンプ(SHIFT+N←/P→) GoFav(false); return true; case Keys.Space: this.GoBackSelectPostChain(); return true; } } break; case ModifierState.Alt: switch (KeyCode) { case Keys.R: doReTweetOfficial(true); return true; case Keys.P: if (_curPost != null) { doShowUserStatus(_curPost.ScreenName, false); return true; } break; case Keys.Up: ScrollDownPostBrowser(false); return true; case Keys.Down: ScrollDownPostBrowser(true); return true; case Keys.PageUp: PageDownPostBrowser(false); return true; case Keys.PageDown: PageDownPostBrowser(true); return true; } if (Focused == FocusedControl.ListTab) { // 別タブの同じ書き込みへ(ALT+←/→) if (KeyCode == Keys.Right) { GoSamePostToAnotherTab(false); return true; } else if (KeyCode == Keys.Left) { GoSamePostToAnotherTab(true); return true; } } break; case ModifierState.Ctrl | ModifierState.Shift: switch (KeyCode) { case Keys.R: MakeReplyOrDirectStatus(false, true, true); return true; case Keys.C: CopyIdUri(); return true; case Keys.F: if (ListTab.SelectedTab != null) { if (_statuses.Tabs[ListTab.SelectedTab.Text].TabType == MyCommon.TabUsageType.PublicSearch) { ListTab.SelectedTab.Controls["panelSearch"].Controls["comboSearch"].Focus(); return true; } } break; case Keys.S: FavoriteChange(false); return true; case Keys.B: UnreadStripMenuItem_Click(null, null); return true; case Keys.T: HashToggleMenuItem_Click(null, null); return true; case Keys.P: ImageSelectMenuItem_Click(null, null); return true; case Keys.H: doMoveToRTHome(); return true; case Keys.O: FavorareMenuItem_Click(null, null); return true; } if (Focused == FocusedControl.StatusText) { int idx = 0; switch (KeyCode) { case Keys.Up: if (_curList != null && _curList.Items.Count != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] > 0) { idx = _curList.SelectedIndices[0] - 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); return true; } break; case Keys.Down: if (_curList != null && _curList.Items.Count != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] < _curList.Items.Count - 1) { idx = _curList.SelectedIndices[0] + 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); return true; } break; case Keys.Space: if (StatusText.SelectionStart > 0) { int endidx = StatusText.SelectionStart - 1; string startstr = ""; bool pressed = false; for (int i = StatusText.SelectionStart - 1; i >= 0; i--) { char c = StatusText.Text[i]; if (Char.IsLetterOrDigit(c) || c == '_') { continue; } if (c == '@') { pressed = true; startstr = StatusText.Text.Substring(i + 1, endidx - i); int cnt = AtIdSupl.ItemCount; ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr); if (AtIdSupl.ItemCount != cnt) _modifySettingAtId = true; } else if (c == '#') { pressed = true; startstr = StatusText.Text.Substring(i + 1, endidx - i); ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr); } else { break; } } return pressed; } break; } } else if (Focused == FocusedControl.ListTab) { DetailsListView lst = (DetailsListView)ListTab.SelectedTab.Tag; ColumnHeader col; switch (KeyCode) { case Keys.D1: case Keys.D2: case Keys.D3: case Keys.D4: case Keys.D5: case Keys.D6: case Keys.D7: case Keys.D8: // ソートダイレクト選択(Ctrl+Shift+1~8,Ctrl+Shift+9) int colNo = KeyCode - Keys.D1; if (lst.Columns.Count < colNo) return false; col = lst.Columns.Cast<ColumnHeader>().Where((x) => { return x.DisplayIndex == colNo; }).FirstOrDefault(); if (col == null) return false; MyList_ColumnClick(lst, new ColumnClickEventArgs(col.Index)); return true; case Keys.D9: col = lst.Columns.Cast<ColumnHeader>().OrderByDescending((x) => { return x.DisplayIndex; }).First(); MyList_ColumnClick(lst, new ColumnClickEventArgs(col.Index)); return true; } } break; case ModifierState.Ctrl | ModifierState.Alt: if (KeyCode == Keys.S) { FavoritesRetweetOriginal(); return true; } else if (KeyCode == Keys.R) { FavoritesRetweetUnofficial(); return true; } else if (KeyCode == Keys.H) { OpenUserAppointUrl(); return true; } break; case ModifierState.Alt | ModifierState.Shift: if (Focused == FocusedControl.PostBrowser) { if (KeyCode == Keys.R) doReTweetUnofficial(); else if (KeyCode == Keys.C) CopyUserId(); return true; } switch (KeyCode) { case Keys.T: if (!this.ExistCurrentPost) return false; doTranslation(_curPost.TextFromApi); return true; case Keys.R: doReTweetUnofficial(); return true; case Keys.C: CopyUserId(); return true; case Keys.Up: Thumbnail.ScrollThumbnail(false); return true; case Keys.Down: Thumbnail.ScrollThumbnail(true); return true; } if (Focused == FocusedControl.ListTab && KeyCode == Keys.Enter) { if (!this.SplitContainer3.Panel2Collapsed) { Thumbnail.OpenPicture(); } return true; } break; } return false; }
private async Task PostMessageAsyncInternal(IProgress<string> p, CancellationToken ct, PostingStatus status) { if (ct.IsCancellationRequested) return; if (!CheckAccountValid()) throw new WebApiException("Auth error. Check your account"); p.Report("Posting..."); var errMsg = ""; try { await Task.Run(async () => { if (status.mediaItems == null || status.mediaItems.Length == 0) { var err = this.tw.PostStatus(status.status, status.inReplyToId); if (!string.IsNullOrEmpty(err)) throw new WebApiException(err); } else { var service = ImageSelector.GetService(status.imageService); await service.PostStatusAsync(status.status, status.inReplyToId, status.mediaItems) .ConfigureAwait(false); } }); p.Report(Properties.Resources.PostWorker_RunWorkerCompletedText4); } catch (WebApiException ex) { // 処理は中断せずエラーの表示のみ行う errMsg = ex.Message; p.Report(errMsg); this._myStatusError = true; } finally { // 使い終わった MediaItem は破棄する if (status.mediaItems != null) { foreach (var disposableItem in status.mediaItems.OfType<IDisposable>()) { disposableItem.Dispose(); } } } if (ct.IsCancellationRequested) return; if (!string.IsNullOrEmpty(errMsg) && !errMsg.StartsWith("OK:", StringComparison.Ordinal) && !errMsg.StartsWith("Warn:", StringComparison.Ordinal)) { var ret = MessageBox.Show( string.Format( "{0} ---> [ " + errMsg + " ]" + Environment.NewLine + "\"" + status.status + "\"" + Environment.NewLine + "{1}", Properties.Resources.StatusUpdateFailed1, Properties.Resources.StatusUpdateFailed2), "Failed to update status", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question); if (ret == DialogResult.Retry) { await this.PostMessageAsync(status); } else { // 連投モードのときだけEnterイベントが起きないので強制的に背景色を戻す if (this.ToolStripFocusLockMenuItem.Checked) this.StatusText_Enter(this.StatusText, EventArgs.Empty); } return; } this._postTimestamps.Add(DateTime.Now); var oneHour = DateTime.Now - TimeSpan.FromHours(1); foreach (var i in MyCommon.CountDown(this._postTimestamps.Count - 1, 0)) { if (this._postTimestamps[i] < oneHour) this._postTimestamps.RemoveAt(i); } if (!this.HashMgr.IsPermanent && !string.IsNullOrEmpty(this.HashMgr.UseHash)) { this.HashMgr.ClearHashtag(); this.SetHashtagText(null); this.HashToggleMenuItem.Checked = false; this.HashToggleToolStripMenuItem.Checked = false; } this.SetMainWindowTitle(); if (this._cfgCommon.PostAndGet) { if (this._isActiveUserstream) this.RefreshTimeline(true); else await this.GetHomeTimelineAsync(); } }
private async Task PostMessageAsync(PostingStatus status) { await this.workerSemaphore.WaitAsync(); try { var progress = new Progress<string>(x => this.StatusLabel.Text = x); await this.PostMessageAsyncInternal(progress, this.workerCts.Token, status); } catch (WebApiException ex) { this._myStatusError = true; this.StatusLabel.Text = ex.Message; } finally { this.workerSemaphore.Release(); } }
private async void PostButton_Click(object sender, EventArgs e) { if (StatusText.Text.Trim().Length == 0) { if (!ImageSelector.Enabled) { this.DoRefresh(); return; } } if (this.ExistCurrentPost && StatusText.Text.Trim() == string.Format("RT @{0}: {1}", _curPost.ScreenName, _curPost.TextFromApi)) { DialogResult rtResult = MessageBox.Show(string.Format(Properties.Resources.PostButton_Click1, Environment.NewLine), "Retweet", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (rtResult) { case DialogResult.Yes: StatusText.Text = ""; await this.doReTweetOfficial(false); return; case DialogResult.Cancel: return; } } _history[_history.Count - 1] = new PostingStatus(StatusText.Text, _reply_to_id, _reply_to_name); if (this._cfgCommon.Nicoms) { StatusText.SelectionStart = StatusText.Text.Length; await UrlConvertAsync(MyCommon.UrlConverter.Nicoms); } //if (SettingDialog.UrlConvertAuto) //{ // StatusText.SelectionStart = StatusText.Text.Length; // UrlConvertAutoToolStripMenuItem_Click(null, null); //} //else if (SettingDialog.Nicoms) //{ // StatusText.SelectionStart = StatusText.Text.Length; // UrlConvert(UrlConverter.Nicoms); //} StatusText.SelectionStart = StatusText.Text.Length; CheckReplyTo(StatusText.Text); //整形によって増加する文字数を取得 int adjustCount = 0; string tmpStatus = StatusText.Text.Trim(); if (ToolStripMenuItemApiCommandEvasion.Checked) { // APIコマンド回避 if (Regex.IsMatch(tmpStatus, @"^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", RegexOptions.IgnoreCase) && tmpStatus.EndsWith(" .") == false) adjustCount += 2; } if (ToolStripMenuItemUrlMultibyteSplit.Checked) { // URLと全角文字の切り離し adjustCount += Regex.Matches(tmpStatus, @"https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+").Count; } bool isCutOff = false; bool isRemoveFooter = MyCommon.IsKeyDown(Keys.Shift); if (StatusText.Multiline && !this._cfgCommon.PostCtrlEnter) { //複数行でEnter投稿の場合、Ctrlも押されていたらフッタ付加しない isRemoveFooter = MyCommon.IsKeyDown(Keys.Control); } if (this._cfgCommon.PostShiftEnter) { isRemoveFooter = MyCommon.IsKeyDown(Keys.Control); } if (!isRemoveFooter && (StatusText.Text.Contains("RT @") || StatusText.Text.Contains("QT @"))) { isRemoveFooter = true; } if (GetRestStatusCount(false, !isRemoveFooter) - adjustCount < 0) { if (MessageBox.Show(Properties.Resources.PostLengthOverMessage1, Properties.Resources.PostLengthOverMessage2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { isCutOff = true; //if (!SettingDialog.UrlConvertAuto) UrlConvertAutoToolStripMenuItem_Click(null, null); if (GetRestStatusCount(false, !isRemoveFooter) - adjustCount < 0) { isRemoveFooter = true; } } else { return; } } string footer = ""; string header = ""; if (StatusText.Text.StartsWith("D ") || StatusText.Text.StartsWith("d ")) { //DM時は何もつけない footer = ""; } else { //ハッシュタグ if (HashMgr.IsNotAddToAtReply) { if (!string.IsNullOrEmpty(HashMgr.UseHash) && _reply_to_id == null && string.IsNullOrEmpty(_reply_to_name)) { if (HashMgr.IsHead) header = HashMgr.UseHash + " "; else footer = " " + HashMgr.UseHash; } } else { if (!string.IsNullOrEmpty(HashMgr.UseHash)) { if (HashMgr.IsHead) header = HashMgr.UseHash + " "; else footer = " " + HashMgr.UseHash; } } if (!isRemoveFooter) { if (this._cfgLocal.UseRecommendStatus) { // 推奨ステータスを使用する footer += this.recommendedStatusFooter; } else if (!string.IsNullOrEmpty(this._cfgLocal.StatusText)) { // テキストボックスに入力されている文字列を使用する footer += " " + this._cfgLocal.StatusText.Trim(); } } } var status = new PostingStatus(); status.status = header + StatusText.Text + footer; if (ToolStripMenuItemApiCommandEvasion.Checked) { // APIコマンド回避 if (Regex.IsMatch(status.status, @"^[+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]*(get|g|fav|follow|f|on|off|stop|quit|leave|l|whois|w|nudge|n|stats|invite|track|untrack|tracks|tracking|\*)([+\-\[\]\s\\.,*/(){}^~|='&%$#""<>?]+|$)", RegexOptions.IgnoreCase) && status.status.EndsWith(" .") == false) status.status += " ."; } if (ToolStripMenuItemUrlMultibyteSplit.Checked) { // URLと全角文字の切り離し Match mc2 = Regex.Match(status.status, @"https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+"); if (mc2.Success) status.status = Regex.Replace(status.status, @"https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+", "$& "); } if (IdeographicSpaceToSpaceToolStripMenuItem.Checked) { // 文中の全角スペースを半角スペース1個にする status.status = status.status.Replace(" ", " "); } if (isCutOff && status.status.Length > 140) { status.status = status.status.Substring(0, 140); string AtId = @"(@|@)[a-z0-9_/]+$"; string HashTag = @"(^|[^0-9A-Z&\/\?]+)(#|#)([0-9A-Z_]*[A-Z_]+)$"; string Url = @"https?:\/\/[a-z0-9!\*'\(\);:&=\+\$\/%#\[\]\-_\.,~?]+$"; //簡易判定 string pattern = string.Format("({0})|({1})|({2})", AtId, HashTag, Url); Match mc = Regex.Match(status.status, pattern, RegexOptions.IgnoreCase); if (mc.Success) { //さらに@ID、ハッシュタグ、URLと推測される文字列をカットする status.status = status.status.Substring(0, 140 - mc.Value.Length); } if (MessageBox.Show(status.status, "Post or Cancel?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) return; } status.inReplyToId = _reply_to_id; status.inReplyToName = _reply_to_name; if (ImageSelector.Visible) { //画像投稿 if (!ImageSelector.TryGetSelectedMedia(out status.imageService, out status.mediaItems)) return; } _reply_to_id = null; _reply_to_name = null; StatusText.Text = ""; _history.Add(new PostingStatus()); _hisIdx = _history.Count - 1; if (!ToolStripFocusLockMenuItem.Checked) ((Control)ListTab.SelectedTab.Tag).Focus(); urlUndoBuffer = null; UrlUndoToolStripMenuItem.Enabled = false; //Undoをできないように設定 //Google検索(試験実装) if (StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) && StatusText.Text.Trim().Length > 7) { string tmp = string.Format(Properties.Resources.SearchItem2Url, Uri.EscapeDataString(StatusText.Text.Substring(7))); await this.OpenUriInBrowserAsync(tmp); } await this.PostMessageAsync(status); }
private void InitializeShortcuts() { this.shortcutCommands = new[] { // リストのカーソル移動関係(上下キー、PageUp/Downに該当) ShortcutCommand.Create(Keys.J, Keys.Control | Keys.J, Keys.Shift | Keys.J, Keys.Control | Keys.Shift | Keys.J) .FocusedOn(FocusedControl.ListTab) .Do(() => SendKeys.Send("{DOWN}")), ShortcutCommand.Create(Keys.K, Keys.Control | Keys.K, Keys.Shift | Keys.K, Keys.Control | Keys.Shift | Keys.K) .FocusedOn(FocusedControl.ListTab) .Do(() => SendKeys.Send("{UP}")), ShortcutCommand.Create(Keys.F, Keys.Shift | Keys.F) .FocusedOn(FocusedControl.ListTab) .Do(() => SendKeys.Send("{PGDN}")), ShortcutCommand.Create(Keys.B, Keys.Shift | Keys.B) .FocusedOn(FocusedControl.ListTab) .Do(() => SendKeys.Send("{PGUP}")), ShortcutCommand.Create(Keys.F1) .Do(() => this.OpenApplicationWebsite()), ShortcutCommand.Create(Keys.F3) .Do(() => this.MenuItemSearchNext_Click(null, null)), ShortcutCommand.Create(Keys.F5) .Do(() => this.DoRefresh()), ShortcutCommand.Create(Keys.F6) .Do(() => this.GetReplyAsync()), ShortcutCommand.Create(Keys.F7) .Do(() => this.GetDirectMessagesAsync()), ShortcutCommand.Create(Keys.Space, Keys.ProcessKey) .NotFocusedOn(FocusedControl.StatusText) .Do(() => { this._anchorFlag = false; this.JumpUnreadMenuItem_Click(null, null); }), ShortcutCommand.Create(Keys.G) .NotFocusedOn(FocusedControl.StatusText) .Do(() => { this._anchorFlag = false; this.ShowRelatedStatusesMenuItem_Click(null, null); }), ShortcutCommand.Create(Keys.Right, Keys.N) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoRelPost(forward: true)), ShortcutCommand.Create(Keys.Left, Keys.P) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoRelPost(forward: false)), ShortcutCommand.Create(Keys.OemPeriod) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoAnchor()), ShortcutCommand.Create(Keys.I) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.StatusText.Enabled) .Do(() => this.StatusText.Focus()), ShortcutCommand.Create(Keys.Enter) .FocusedOn(FocusedControl.ListTab) .Do(() => this.MakeReplyOrDirectStatus()), ShortcutCommand.Create(Keys.R) .FocusedOn(FocusedControl.ListTab) .Do(() => this.DoRefresh()), ShortcutCommand.Create(Keys.L) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.GoPost(forward: true); }), ShortcutCommand.Create(Keys.H) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.GoPost(forward: false); }), ShortcutCommand.Create(Keys.Z, Keys.Oemcomma) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.MoveTop(); }), ShortcutCommand.Create(Keys.S) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.GoNextTab(forward: true); }), ShortcutCommand.Create(Keys.A) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.GoNextTab(forward: false); }), // ] in_reply_to参照元へ戻る ShortcutCommand.Create(Keys.Oem4) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; return this.GoInReplyToPostTree(); }), // [ in_reply_toへジャンプ ShortcutCommand.Create(Keys.Oem6) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; this.GoBackInReplyToPostTree(); }), ShortcutCommand.Create(Keys.Escape) .FocusedOn(FocusedControl.ListTab) .Do(() => { this._anchorFlag = false; if (ListTab.SelectedTab != null) { var tabtype = _statuses.Tabs[ListTab.SelectedTab.Text].TabType; if (tabtype == MyCommon.TabUsageType.Related || tabtype == MyCommon.TabUsageType.UserTimeline || tabtype == MyCommon.TabUsageType.PublicSearch || tabtype == MyCommon.TabUsageType.SearchResults) { var relTp = ListTab.SelectedTab; RemoveSpecifiedTab(relTp.Text, false); SaveConfigsTabs(); } } }), // 上下キー, PageUp/Downキー, Home/Endキー は既定の動作を残しつつアンカー初期化 ShortcutCommand.Create(Keys.Up, Keys.Down, Keys.PageUp, Keys.PageDown, Keys.Home, Keys.End) .FocusedOn(FocusedControl.ListTab) .Do(() => this._anchorFlag = false, preventDefault: false), // PreviewKeyDownEventArgs.IsInputKey を true にしてスクロールを発生させる ShortcutCommand.Create(Keys.Up, Keys.Down) .FocusedOn(FocusedControl.PostBrowser) .Do(() => { }), ShortcutCommand.Create(Keys.Control | Keys.R) .Do(() => this.MakeReplyOrDirectStatus(isAuto: false, isReply: true)), ShortcutCommand.Create(Keys.Control | Keys.D) .Do(() => this.doStatusDelete()), ShortcutCommand.Create(Keys.Control | Keys.M) .Do(() => this.MakeReplyOrDirectStatus(isAuto: false, isReply: false)), ShortcutCommand.Create(Keys.Control | Keys.S) .Do(() => this.FavoriteChange(FavAdd: true)), ShortcutCommand.Create(Keys.Control | Keys.I) .Do(() => this.doRepliedStatusOpen()), ShortcutCommand.Create(Keys.Control | Keys.Q) .Do(() => this.doQuoteOfficial()), ShortcutCommand.Create(Keys.Control | Keys.B) .Do(() => this.ReadedStripMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.T) .Do(() => this.HashManageMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.L) .Do(() => this.UrlConvertAutoToolStripMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Y) .NotFocusedOn(FocusedControl.PostBrowser) .Do(() => this.MultiLineMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.F) .Do(() => this.MenuItemSubSearch_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.U) .Do(() => this.ShowUserTimeline()), ShortcutCommand.Create(Keys.Control | Keys.H) .Do(() => this.MoveToHomeToolStripMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.G) .Do(() => this.MoveToFavToolStripMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.O) .Do(() => this.StatusOpenMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.E) .Do(() => this.OpenURLMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Home, Keys.Control | Keys.End) .FocusedOn(FocusedControl.ListTab) .Do(() => this._colorize = true, preventDefault: false), ShortcutCommand.Create(Keys.Control | Keys.N) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoNextTab(forward: true)), ShortcutCommand.Create(Keys.Control | Keys.P) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoNextTab(forward: false)), ShortcutCommand.Create(Keys.Control | Keys.C, Keys.Control | Keys.Insert) .FocusedOn(FocusedControl.ListTab) .Do(() => this.CopyStot()), // タブダイレクト選択(Ctrl+1~8,Ctrl+9) ShortcutCommand.Create(Keys.Control | Keys.D1) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 1) .Do(() => this.ListTab.SelectedIndex = 0), ShortcutCommand.Create(Keys.Control | Keys.D2) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 2) .Do(() => this.ListTab.SelectedIndex = 1), ShortcutCommand.Create(Keys.Control | Keys.D3) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 3) .Do(() => this.ListTab.SelectedIndex = 2), ShortcutCommand.Create(Keys.Control | Keys.D4) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 4) .Do(() => this.ListTab.SelectedIndex = 3), ShortcutCommand.Create(Keys.Control | Keys.D5) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 5) .Do(() => this.ListTab.SelectedIndex = 4), ShortcutCommand.Create(Keys.Control | Keys.D6) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 6) .Do(() => this.ListTab.SelectedIndex = 5), ShortcutCommand.Create(Keys.Control | Keys.D7) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 7) .Do(() => this.ListTab.SelectedIndex = 6), ShortcutCommand.Create(Keys.Control | Keys.D8) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => this.ListTab.TabPages.Count >= 8) .Do(() => this.ListTab.SelectedIndex = 7), ShortcutCommand.Create(Keys.Control | Keys.D9) .FocusedOn(FocusedControl.ListTab) .Do(() => this.ListTab.SelectedIndex = this.ListTab.TabPages.Count - 1), ShortcutCommand.Create(Keys.Control | Keys.A) .FocusedOn(FocusedControl.StatusText) .Do(() => this.StatusText.SelectAll()), ShortcutCommand.Create(Keys.Control | Keys.V) .FocusedOn(FocusedControl.StatusText) .Do(() => this.ProcClipboardFromStatusTextWhenCtrlPlusV()), ShortcutCommand.Create(Keys.Control | Keys.Up) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (!string.IsNullOrWhiteSpace(StatusText.Text)) { var inReplyToStatusId = this.inReplyTo?.Item1; var inReplyToScreenName = this.inReplyTo?.Item2; _history[_hisIdx] = new PostingStatus(StatusText.Text, inReplyToStatusId, inReplyToScreenName); } _hisIdx -= 1; if (_hisIdx < 0) _hisIdx = 0; var historyItem = this._history[this._hisIdx]; StatusText.Text = historyItem.status; StatusText.SelectionStart = StatusText.Text.Length; if (historyItem.inReplyToId != null) this.inReplyTo = Tuple.Create(historyItem.inReplyToId.Value, historyItem.inReplyToName); else this.inReplyTo = null; }), ShortcutCommand.Create(Keys.Control | Keys.Down) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (!string.IsNullOrWhiteSpace(StatusText.Text)) { var inReplyToStatusId = this.inReplyTo?.Item1; var inReplyToScreenName = this.inReplyTo?.Item2; _history[_hisIdx] = new PostingStatus(StatusText.Text, inReplyToStatusId, inReplyToScreenName); } _hisIdx += 1; if (_hisIdx > _history.Count - 1) _hisIdx = _history.Count - 1; var historyItem = this._history[this._hisIdx]; StatusText.Text = historyItem.status; StatusText.SelectionStart = StatusText.Text.Length; if (historyItem.inReplyToId != null) this.inReplyTo = Tuple.Create(historyItem.inReplyToId.Value, historyItem.inReplyToName); else this.inReplyTo = null; }), ShortcutCommand.Create(Keys.Control | Keys.PageUp, Keys.Control | Keys.P) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (ListTab.SelectedIndex == 0) { ListTab.SelectedIndex = ListTab.TabCount - 1; } else { ListTab.SelectedIndex -= 1; } StatusText.Focus(); }), ShortcutCommand.Create(Keys.Control | Keys.PageDown, Keys.Control | Keys.N) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (ListTab.SelectedIndex == ListTab.TabCount - 1) { ListTab.SelectedIndex = 0; } else { ListTab.SelectedIndex += 1; } StatusText.Focus(); }), ShortcutCommand.Create(Keys.Control | Keys.Y) .FocusedOn(FocusedControl.PostBrowser) .Do(() => { MultiLineMenuItem.Checked = !MultiLineMenuItem.Checked; MultiLineMenuItem_Click(null, null); }), ShortcutCommand.Create(Keys.Shift | Keys.F3) .Do(() => this.MenuItemSearchPrev_Click(null, null)), ShortcutCommand.Create(Keys.Shift | Keys.F5) .Do(() => this.DoRefreshMore()), ShortcutCommand.Create(Keys.Shift | Keys.F6) .Do(() => this.GetReplyAsync(loadMore: true)), ShortcutCommand.Create(Keys.Shift | Keys.F7) .Do(() => this.GetDirectMessagesAsync(loadMore: true)), ShortcutCommand.Create(Keys.Shift | Keys.R) .NotFocusedOn(FocusedControl.StatusText) .Do(() => this.DoRefreshMore()), ShortcutCommand.Create(Keys.Shift | Keys.H) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoTopEnd(GoTop: true)), ShortcutCommand.Create(Keys.Shift | Keys.L) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoTopEnd(GoTop: false)), ShortcutCommand.Create(Keys.Shift | Keys.M) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoMiddle()), ShortcutCommand.Create(Keys.Shift | Keys.G) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoLast()), ShortcutCommand.Create(Keys.Shift | Keys.Z) .FocusedOn(FocusedControl.ListTab) .Do(() => this.MoveMiddle()), ShortcutCommand.Create(Keys.Shift | Keys.Oem4) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoBackInReplyToPostTree(parallel: true, isForward: false)), ShortcutCommand.Create(Keys.Shift | Keys.Oem6) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoBackInReplyToPostTree(parallel: true, isForward: true)), // お気に入り前後ジャンプ(SHIFT+N←/P→) ShortcutCommand.Create(Keys.Shift | Keys.Right, Keys.Shift | Keys.N) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoFav(forward: true)), // お気に入り前後ジャンプ(SHIFT+N←/P→) ShortcutCommand.Create(Keys.Shift | Keys.Left, Keys.Shift | Keys.P) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoFav(forward: false)), ShortcutCommand.Create(Keys.Shift | Keys.Space) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoBackSelectPostChain()), ShortcutCommand.Create(Keys.Alt | Keys.R) .Do(() => this.doReTweetOfficial(isConfirm: true)), ShortcutCommand.Create(Keys.Alt | Keys.P) .OnlyWhen(() => this._curPost != null) .Do(() => this.doShowUserStatus(_curPost.ScreenName, ShowInputDialog: false)), ShortcutCommand.Create(Keys.Alt | Keys.Up) .Do(() => this.tweetDetailsView.ScrollDownPostBrowser(forward: false)), ShortcutCommand.Create(Keys.Alt | Keys.Down) .Do(() => this.tweetDetailsView.ScrollDownPostBrowser(forward: true)), ShortcutCommand.Create(Keys.Alt | Keys.PageUp) .Do(() => this.tweetDetailsView.PageDownPostBrowser(forward: false)), ShortcutCommand.Create(Keys.Alt | Keys.PageDown) .Do(() => this.tweetDetailsView.PageDownPostBrowser(forward: true)), // 別タブの同じ書き込みへ(ALT+←/→) ShortcutCommand.Create(Keys.Alt | Keys.Right) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoSamePostToAnotherTab(left: false)), ShortcutCommand.Create(Keys.Alt | Keys.Left) .FocusedOn(FocusedControl.ListTab) .Do(() => this.GoSamePostToAnotherTab(left: true)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.R) .Do(() => this.MakeReplyOrDirectStatus(isAuto: false, isReply: true, isAll: true)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.C, Keys.Control | Keys.Shift | Keys.Insert) .Do(() => this.CopyIdUri()), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.F) .OnlyWhen(() => this.ListTab.SelectedTab != null && this._statuses.Tabs[this.ListTab.SelectedTab.Text].TabType == MyCommon.TabUsageType.PublicSearch) .Do(() => this.ListTab.SelectedTab.Controls["panelSearch"].Controls["comboSearch"].Focus()), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.S) .Do(() => this.FavoriteChange(FavAdd: false)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.B) .Do(() => this.UnreadStripMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.T) .Do(() => this.HashToggleMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.P) .Do(() => this.ImageSelectMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.H) .Do(() => this.doMoveToRTHome()), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.O) .Do(() => this.FavorareMenuItem_Click(null, null)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.Up) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (_curList != null && _curList.VirtualListSize != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] > 0) { var idx = _curList.SelectedIndices[0] - 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); } }), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.Down) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (_curList != null && _curList.VirtualListSize != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] < _curList.VirtualListSize - 1) { var idx = _curList.SelectedIndices[0] + 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); } }), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.Space) .FocusedOn(FocusedControl.StatusText) .Do(() => { if (StatusText.SelectionStart > 0) { int endidx = StatusText.SelectionStart - 1; string startstr = ""; for (int i = StatusText.SelectionStart - 1; i >= 0; i--) { char c = StatusText.Text[i]; if (Char.IsLetterOrDigit(c) || c == '_') { continue; } if (c == '@') { startstr = StatusText.Text.Substring(i + 1, endidx - i); int cnt = AtIdSupl.ItemCount; ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr); if (AtIdSupl.ItemCount != cnt) ModifySettingAtId = true; } else if (c == '#') { startstr = StatusText.Text.Substring(i + 1, endidx - i); ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr); } else { break; } } } }), // ソートダイレクト選択(Ctrl+Shift+1~8,Ctrl+Shift+9) ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D1) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(0)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D2) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(1)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D3) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(2)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D4) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(3)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D5) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(4)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D6) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(5)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D7) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(6)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D8) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortColumnByDisplayIndex(7)), ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.D9) .FocusedOn(FocusedControl.ListTab) .Do(() => this.SetSortLastColumn()), ShortcutCommand.Create(Keys.Control | Keys.Alt | Keys.S) .Do(() => this.FavoritesRetweetOfficial()), ShortcutCommand.Create(Keys.Control | Keys.Alt | Keys.R) .Do(() => this.FavoritesRetweetUnofficial()), ShortcutCommand.Create(Keys.Control | Keys.Alt | Keys.H) .Do(() => this.OpenUserAppointUrl()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.R) .FocusedOn(FocusedControl.PostBrowser) .Do(() => this.doReTweetUnofficial()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.T) .OnlyWhen(() => this.ExistCurrentPost) .Do(() => this.tweetDetailsView.DoTranslation()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.R) .Do(() => this.doReTweetUnofficial()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.C, Keys.Alt | Keys.Shift | Keys.Insert) .Do(() => this.CopyUserId()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Up) .Do(() => this.tweetThumbnail1.ScrollUp()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Down) .Do(() => this.tweetThumbnail1.ScrollDown()), ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Enter) .FocusedOn(FocusedControl.ListTab) .OnlyWhen(() => !this.SplitContainer3.Panel2Collapsed) .Do(() => this.OpenThumbnailPicture(this.tweetThumbnail1.Thumbnail)), }; }
private async void PostButton_Click(object sender, EventArgs e) { if (StatusText.Text.Trim().Length == 0) { if (!ImageSelector.Enabled) { await this.DoRefresh(); return; } } if (this.ExistCurrentPost && StatusText.Text.Trim() == string.Format("RT @{0}: {1}", _curPost.ScreenName, _curPost.TextFromApi)) { DialogResult rtResult = MessageBox.Show(string.Format(Properties.Resources.PostButton_Click1, Environment.NewLine), "Retweet", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (rtResult) { case DialogResult.Yes: StatusText.Text = ""; await this.doReTweetOfficial(false); return; case DialogResult.Cancel: return; } } var inReplyToStatusId = this.inReplyTo?.Item1; var inReplyToScreenName = this.inReplyTo?.Item2; _history[_history.Count - 1] = new PostingStatus(StatusText.Text, inReplyToStatusId, inReplyToScreenName); if (this._cfgCommon.Nicoms) { StatusText.SelectionStart = StatusText.Text.Length; await UrlConvertAsync(MyCommon.UrlConverter.Nicoms); } //if (SettingDialog.UrlConvertAuto) //{ // StatusText.SelectionStart = StatusText.Text.Length; // UrlConvertAutoToolStripMenuItem_Click(null, null); //} //else if (SettingDialog.Nicoms) //{ // StatusText.SelectionStart = StatusText.Text.Length; // UrlConvert(UrlConverter.Nicoms); //} StatusText.SelectionStart = StatusText.Text.Length; CheckReplyTo(StatusText.Text); var statusText = this.FormatStatusText(this.StatusText.Text); if (this.GetRestStatusCount(statusText) < 0) { // 文字数制限を超えているが強制的に投稿するか var ret = MessageBox.Show(Properties.Resources.PostLengthOverMessage1, Properties.Resources.PostLengthOverMessage2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (ret != DialogResult.OK) return; } var status = new PostingStatus(); status.status = statusText; status.inReplyToId = this.inReplyTo?.Item1; status.inReplyToName = this.inReplyTo?.Item2; if (ImageSelector.Visible) { //画像投稿 if (!ImageSelector.TryGetSelectedMedia(out status.imageService, out status.mediaItems)) return; } this.inReplyTo = null; StatusText.Text = ""; _history.Add(new PostingStatus()); _hisIdx = _history.Count - 1; if (!ToolStripFocusLockMenuItem.Checked) ((Control)ListTab.SelectedTab.Tag).Focus(); urlUndoBuffer = null; UrlUndoToolStripMenuItem.Enabled = false; //Undoをできないように設定 //Google検索(試験実装) if (StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) && StatusText.Text.Trim().Length > 7) { string tmp = string.Format(Properties.Resources.SearchItem2Url, Uri.EscapeDataString(StatusText.Text.Substring(7))); await this.OpenUriInBrowserAsync(tmp); } await this.PostMessageAsync(status); }
private bool CommonKeyDown(Keys keyCode, FocusedControl focusedControl, ModifierState modifierState) { if (focusedControl == FocusedControl.ListTab) { // リストのカーソル移動関係(上下キー、PageUp/Downに該当) if (modifierState == (ModifierState.Ctrl | ModifierState.Shift) || modifierState == ModifierState.Ctrl || modifierState == ModifierState.None || modifierState == ModifierState.Shift) { switch (keyCode) { case Keys.J: SendKeys.Send("{DOWN}"); return true; case Keys.K: SendKeys.Send("{UP}"); return true; } } if (modifierState == ModifierState.Shift || modifierState == ModifierState.None) { switch (keyCode) { case Keys.F: SendKeys.Send("{PGDN}"); return true; case Keys.B: SendKeys.Send("{PGUP}"); return true; } } } switch (modifierState) { // 修飾キーなし case ModifierState.None: // フォーカス関係なし switch (keyCode) { case Keys.F1: OpenUriAsync(ApplicationHelpWebPageUrl); return true; case Keys.F3: TrySearchWordInTabToBottom(); return true; case Keys.F5: RefreshTab(); return true; case Keys.F6: GetTimeline(WorkerType.Reply); return true; case Keys.F7: GetTimeline(WorkerType.DirectMessegeRcv); return true; } if (focusedControl != FocusedControl.StatusText) { // フォーカスStatusText以外 switch (keyCode) { case Keys.Space: case Keys.ProcessKey: if (focusedControl == FocusedControl.ListTab) { _anchorFlag = false; } TrySearchAndFocusUnreadTweet(); return true; case Keys.G: if (focusedControl == FocusedControl.ListTab) { _anchorFlag = false; } AddRelatedStatusesTab(); return true; } } if (focusedControl == FocusedControl.ListTab) { // フォーカスList switch (keyCode) { case Keys.N: case Keys.Right: GoRelPost(true); return true; case Keys.P: case Keys.Left: GoRelPost(false); return true; case Keys.OemPeriod: GoAnchor(); return true; case Keys.I: if (StatusText.Enabled) { StatusText.Focus(); } return true; case Keys.Enter: // case Keys.Return: MakeReplyOrDirectStatus(); return true; case Keys.R: RefreshTab(); return true; } // 以下、アンカー初期化 _anchorFlag = false; switch (keyCode) { case Keys.L: GoSameUsersPost(true); return true; case Keys.H: GoSameUsersPost(false); return true; case Keys.Z: case Keys.Oemcomma: MoveTop(); return true; case Keys.S: GoNextTab(true); return true; case Keys.A: GoNextTab(false); return true; case Keys.Oem4: // ] in_reply_to参照元へ戻る GoInReplyToPostTree(); return true; case Keys.Oem6: // [ in_reply_toへジャンプ GoBackInReplyToPostTree(); return true; case Keys.Escape: if (ListTab.SelectedTab != null) { TabUsageType tabtype = _statuses.Tabs[ListTab.SelectedTab.Text].TabType; if (tabtype == TabUsageType.Related || tabtype == TabUsageType.UserTimeline || tabtype == TabUsageType.PublicSearch) { TabPage relTp = ListTab.SelectedTab; RemoveSpecifiedTab(relTp.Text, false); SaveConfigsTabs(); return true; } } break; } } break; case ModifierState.Ctrl: // フォーカス関係なし switch (keyCode) { case Keys.R: MakeReplyOrDirectStatus(false); return true; case Keys.D: DeleteSelected(); return true; case Keys.M: MakeReplyOrDirectStatus(false, false); return true; case Keys.S: ChangeSelectedFavStatus(true); return true; case Keys.I: OpenRepliedStatus(); return true; case Keys.Q: DoQuote(); return true; case Keys.B: ChangeSelectedTweetReadStateToRead(); return true; case Keys.T: ShowHashManageBox(); return true; case Keys.L: ConvertUrlByAutoSelectedService(); return true; case Keys.Y: if (focusedControl != FocusedControl.PostBrowser) { ChangeStatusTextMultilineState(MultiLineMenuItem.Checked); return true; } break; case Keys.F: TrySearchWordInTab(); return true; case Keys.U: ShowUserTimeline(); return true; case Keys.H: // Webページを開く動作 TryOpenCurListSelectedUserHome(); return true; case Keys.G: // Webページを開く動作 TryOpenCurListSelectedUserFavorites(); return true; case Keys.O: // Webページを開く動作 TryOpenSelectedTweetWebPage(); return true; case Keys.E: // Webページを開く動作 TryOpenUrlInCurrentTweet(); return true; } // フォーカスList if (focusedControl == FocusedControl.ListTab) { switch (keyCode) { case Keys.Home: case Keys.End: _colorize = true; // スルーする return false; case Keys.N: GoNextTab(true); return true; case Keys.P: GoNextTab(false); return true; case Keys.C: CopyStot(); return true; case Keys.D1: case Keys.D2: case Keys.D3: case Keys.D4: case Keys.D5: case Keys.D6: case Keys.D7: case Keys.D8: // タブダイレクト選択(Ctrl+1~8,Ctrl+9) int tabNo = keyCode - Keys.D1; if (ListTab.TabPages.Count < tabNo) { return false; } ListTabSelect(tabNo); return true; case Keys.D9: ListTabSelect(ListTab.TabPages.Count - 1); return true; } } else if (focusedControl == FocusedControl.StatusText) { // フォーカスStatusText switch (keyCode) { case Keys.A: StatusText.SelectAll(); return true; case Keys.Up: case Keys.Down: if (!string.IsNullOrEmpty(StatusText.Text.Trim())) { _postHistory[_postHistoryIndex] = new PostingStatus(StatusText.Text, _replyToId, _replyToName); } if (keyCode == Keys.Up) { _postHistoryIndex -= 1; if (_postHistoryIndex < 0) { _postHistoryIndex = 0; } } else { _postHistoryIndex += 1; if (_postHistoryIndex > _postHistory.Count - 1) { _postHistoryIndex = _postHistory.Count - 1; } } StatusText.Text = _postHistory[_postHistoryIndex].Status; _replyToId = _postHistory[_postHistoryIndex].InReplyToId; _replyToName = _postHistory[_postHistoryIndex].InReplyToName; StatusText.SelectionStart = StatusText.Text.Length; return true; case Keys.PageUp: case Keys.P: if (ListTab.SelectedIndex == 0) { ListTab.SelectedIndex = ListTab.TabCount - 1; } else { ListTab.SelectedIndex -= 1; } StatusText.Focus(); return true; case Keys.PageDown: case Keys.N: if (ListTab.SelectedIndex == ListTab.TabCount - 1) { ListTab.SelectedIndex = 0; } else { ListTab.SelectedIndex += 1; } StatusText.Focus(); return true; } } else { // フォーカスPostBrowserもしくは関係なし switch (keyCode) { case Keys.A: PostBrowser.Document.ExecCommand("SelectAll", false, null); return true; case Keys.C: case Keys.Insert: string selText = WebBrowser_GetSelectionText(PostBrowser); if (!string.IsNullOrEmpty(selText)) { CopyToClipboard(selText); } return true; case Keys.Y: MultiLineMenuItem.Checked = !MultiLineMenuItem.Checked; ChangeStatusTextMultilineState(MultiLineMenuItem.Checked); return true; } } break; case ModifierState.Shift: // フォーカス関係なし switch (keyCode) { case Keys.F3: TrySearchWordInTabToTop(); return true; case Keys.F5: RefreshTab(true); return true; case Keys.F6: GetTimeline(WorkerType.Reply, -1); return true; case Keys.F7: GetTimeline(WorkerType.DirectMessegeRcv); return true; } // フォーカスStatusText以外 if (focusedControl != FocusedControl.StatusText) { if (keyCode == Keys.R) { RefreshTab(true); return true; } } // フォーカスリスト if (focusedControl == FocusedControl.ListTab) { switch (keyCode) { case Keys.H: GoTopEnd(true); return true; case Keys.L: GoTopEnd(false); return true; case Keys.M: GoMiddle(); return true; case Keys.G: GoLast(); return true; case Keys.Z: MoveMiddle(); return true; case Keys.Oem4: GoBackInReplyToPostTree(true, false); return true; case Keys.Oem6: GoBackInReplyToPostTree(true); return true; case Keys.N: case Keys.Right: // お気に入り前後ジャンプ(SHIFT+N←/P→) GoFav(true); return true; case Keys.P: case Keys.Left: // お気に入り前後ジャンプ(SHIFT+N←/P→) GoFav(false); return true; case Keys.Space: GoBackSelectPostChain(); return true; } } break; case ModifierState.Alt: switch (keyCode) { case Keys.R: DoReTweetOfficial(true); return true; case Keys.P: if (_curPost != null) { ShowUserStatus(_curPost.ScreenName, false); return true; } break; case Keys.Up: ScrollDownPostBrowser(false); return true; case Keys.Down: ScrollDownPostBrowser(true); return true; case Keys.PageUp: PageDownPostBrowser(false); return true; case Keys.PageDown: PageDownPostBrowser(true); return true; } if (focusedControl == FocusedControl.ListTab) { // 別タブの同じ書き込みへ(ALT+←/→) if (keyCode == Keys.Right) { GoSamePostToAnotherTab(false); return true; } if (keyCode == Keys.Left) { GoSamePostToAnotherTab(true); return true; } } break; case ModifierState.Ctrl | ModifierState.Shift: switch (keyCode) { case Keys.R: MakeReplyOrDirectStatus(false, true, true); return true; case Keys.C: CopyIdUri(); return true; case Keys.F: if (ListTab.SelectedTab != null) { if (_statuses.Tabs[ListTab.SelectedTab.Text].TabType == TabUsageType.PublicSearch) { ListTab.SelectedTab.Controls["panelSearch"].Controls["comboSearch"].Focus(); return true; } } break; case Keys.S: ChangeSelectedFavStatus(false); return true; case Keys.B: ChangeSelectedTweetReadSateToUnread(); return true; case Keys.T: ChangeUseHashTagSetting(); return true; case Keys.P: ToggleImageSelectorView(); return true; case Keys.H: TryOpenSelectedRtUserHome(); return true; case Keys.O: OpenFavorarePageOfSelectedTweetUser(); return true; } if (focusedControl == FocusedControl.StatusText) { switch (keyCode) { case Keys.Up: { if (_curList != null && _curList.Items.Count != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] > 0) { int idx = _curList.SelectedIndices[0] - 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); return true; } } break; case Keys.Down: { if (_curList != null && _curList.Items.Count != 0 && _curList.SelectedIndices.Count > 0 && _curList.SelectedIndices[0] < _curList.Items.Count - 1) { int idx = _curList.SelectedIndices[0] + 1; SelectListItem(_curList, idx); _curList.EnsureVisible(idx); return true; } } break; case Keys.Space: if (StatusText.SelectionStart > 0) { int endidx = StatusText.SelectionStart - 1; bool pressed = false; for (int i = StatusText.SelectionStart - 1; i >= 0; i--) { char c = StatusText.Text[i]; if (char.IsLetterOrDigit(c) || c == '_') { continue; } string startstr; if (c == '@') { pressed = true; startstr = StatusText.Text.Substring(i + 1, endidx - i); int cnt = AtIdSupl.ItemCount; ShowSuplDialog(StatusText, AtIdSupl, startstr.Length + 1, startstr); if (AtIdSupl.ItemCount != cnt) { _modifySettingAtId = true; } } else if (c == '#') { pressed = true; startstr = StatusText.Text.Substring(i + 1, endidx - i); ShowSuplDialog(StatusText, HashSupl, startstr.Length + 1, startstr); } else { break; } } return pressed; } break; } } else if (focusedControl == FocusedControl.ListTab) { switch (keyCode) { case Keys.D1: case Keys.D2: case Keys.D3: case Keys.D4: case Keys.D5: case Keys.D6: case Keys.D7: case Keys.D8: { // ソートダイレクト選択(Ctrl+Shift+1~8,Ctrl+Shift+9) int colNo = keyCode - Keys.D1; var lst = (DetailsListView)ListTab.SelectedTab.Tag; if (lst.Columns.Count < colNo) { return false; } var col = lst.Columns.Cast<ColumnHeader>().FirstOrDefault(x => x.DisplayIndex == colNo); if (col == null) { return false; } MyList_ColumnClick(lst, new ColumnClickEventArgs(col.Index)); return true; } case Keys.D9: { var lst = (DetailsListView)ListTab.SelectedTab.Tag; var col = lst.Columns.Cast<ColumnHeader>().OrderByDescending(x => x.DisplayIndex).First(); MyList_ColumnClick(lst, new ColumnClickEventArgs(col.Index)); return true; } } } break; case ModifierState.Ctrl | ModifierState.Alt: switch (keyCode) { case Keys.S: FavoritesRetweetOriginal(); return true; case Keys.R: FavoritesRetweetUnofficial(); return true; case Keys.H: OpenUserAppointUrl(); return true; } break; case ModifierState.Alt | ModifierState.Shift: if (focusedControl == FocusedControl.PostBrowser) { if (keyCode == Keys.R) { DoReTweetUnofficial(); } else if (keyCode == Keys.C) { CopyUserId(); } return true; } switch (keyCode) { case Keys.T: if (!ExistCurrentPost) { return false; } DoTranslation(_curPost.TextFromApi); return true; case Keys.R: DoReTweetUnofficial(); return true; case Keys.C: CopyUserId(); return true; case Keys.Up: _thumbnail.ScrollThumbnail(false); return true; case Keys.Down: _thumbnail.ScrollThumbnail(true); return true; } if (focusedControl == FocusedControl.ListTab && keyCode == Keys.Enter) { if (!SplitContainer3.Panel2Collapsed) { _thumbnail.OpenPicture(); } return true; } break; } return false; }
public AddJournalEntriesViewModel AddJournal(AddJournalEntriesViewModel model, PostingStatus postingStatus = PostingStatus.Approved) { var journalDetails = model.journalDetails; //if (journalDetails.Count % 2 == 0) //{ var credit = journalDetails.Where(z => z.IsCreditor == true).Select(x => x.CreditorValue).Sum(); var debt = journalDetails.Where(z => z.IsCreditor == false).Select(x => x.DebtorValue).Sum(); if ((credit - debt) != 0) { throw new GeneralException((int)ErrorCodeEnum.JournalNotbalanced); } //} //else //{ //throw new GeneralException((int)ErrorCodeEnum.JournalNotbalanced); //} foreach (var item in model.journalDetails) { if (item.IsCreditor) { item.Amount = item.CreditorValue; } else { item.Amount = item.DebtorValue; } } DateTime CurrentDate = DateTime.Now; var entity = model.ToEntity(); entity.PostingStatus = postingStatus; #region translation entity.Description = ""; entity.CreationDate = CurrentDate; entity.Code = model.DocumentNumber; entity.Date = model.Date; entity.Language = Language.None; Journal JournalAr = new Journal(); JournalAr.Description = model.DescriptionAr; JournalAr.Language = Language.Arabic; JournalAr.CreationDate = CurrentDate; JournalAr.Date = model.Date; JournalAr.FirstModificationDate = model.Date; JournalAr.LastModificationDate = model.Date; Journal JournalEn = new Journal(); JournalEn.Description = model.DescriptionEn; JournalEn.Language = Language.English; JournalEn.CreationDate = CurrentDate; JournalEn.Date = model.Date; JournalEn.FirstModificationDate = model.Date; JournalEn.LastModificationDate = model.Date; entity.ChildTranslatedJournals.Add(JournalAr); entity.ChildTranslatedJournals.Add(JournalEn); #endregion entity = this._JournalsRepository.Add(entity); //#region Commit Changes //this._unitOfWork.Commit(); //#endregion #region Generate New Code long newCode = 1; try { ConditionFilter <Journal, long> condition = new ConditionFilter <Journal, long> { Query = (entityItem => entityItem.ParentKeyJournalId == null && string.IsNullOrEmpty(entityItem.Code) == false), Order = Order.Descending }; var z = this._JournalsRepository.Get(condition); var lastEntity = z.FirstOrDefault(); if (lastEntity != null) { try { newCode = long.Parse(lastEntity.Code) + 1; } catch { newCode = entity.Id; } } } catch { //entity.Code = entity.Id.ToString(); } entity.Code = newCode.ToString(); //entity = this._JournalsRepository.Update(entity); //this._unitOfWork.Commit(); #endregion #region Commit Changes this._unitOfWork.Commit(); #endregion //model.DocumentNumber = entity.Id.ToString(); model.DocumentNumber = entity.Code; if (entity.ReversedFromId.HasValue) { var existEntity = this._JournalsRepository.Get(entity.ReversedFromId.Value); existEntity.IsReversed = true; existEntity.ReversedToId = entity.Id; this._JournalsRepository.Update(existEntity); this._unitOfWork.Commit(); } //model = entity.ToModel(); return(model); }