public void IsDefault_Test(MyCommon.TabUsageType tabType, bool expected) { Assert.Equal(expected, tabType.IsDefault()); }
public void IsInnerStorage_Test(MyCommon.TabUsageType tabType, bool expected) { Assert.Equal(expected, tabType.IsInnerStorage()); }
/// <summary> /// 指定された短縮URLサービスを使用してURLを短縮します /// </summary> /// <param name="shortenerType">使用する短縮URLサービス</param> /// <param name="srcUri">短縮するURL</param> /// <returns>短縮されたURL</returns> public Task<Uri> ShortenUrlAsync(MyCommon.UrlConverter shortenerType, Uri srcUri) { // 既に短縮されている状態のURLであれば短縮しない if (ShortUrlHosts.Contains(srcUri.Host)) return Task.FromResult(srcUri); switch (shortenerType) { case MyCommon.UrlConverter.TinyUrl: return this.ShortenByTinyUrlAsync(srcUri); case MyCommon.UrlConverter.Isgd: return this.ShortenByIsgdAsync(srcUri); case MyCommon.UrlConverter.Twurl: return this.ShortenByTwurlAsync(srcUri); case MyCommon.UrlConverter.Bitly: return this.ShortenByBitlyAsync(srcUri, "bit.ly"); case MyCommon.UrlConverter.Jmp: return this.ShortenByBitlyAsync(srcUri, "j.mp"); case MyCommon.UrlConverter.Uxnu: return this.ShortenByUxnuAsync(srcUri); default: throw new ArgumentException("Unknown shortener.", "shortenerType"); } }
public string GetTimelineApi(bool read, MyCommon.WORKERTYPE gType, bool more, bool startup) { if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return ""; if (MyCommon._endingFlag) return ""; HttpStatusCode res; var content = ""; var count = SettingCommon.Instance.CountApi; if (gType == MyCommon.WORKERTYPE.Reply) count = SettingCommon.Instance.CountApiReply; if (SettingCommon.Instance.UseAdditionalCount) { if (more && SettingCommon.Instance.MoreCountApi != 0) { count = SettingCommon.Instance.MoreCountApi; } else if (startup && SettingCommon.Instance.FirstCountApi != 0 && gType == MyCommon.WORKERTYPE.Timeline) { count = SettingCommon.Instance.FirstCountApi; } } try { if (gType == MyCommon.WORKERTYPE.Timeline) { if (more) { res = twCon.HomeTimeline(count, this.minHomeTimeline, null, ref content); } else { res = twCon.HomeTimeline(count, null, null, ref content); } } else { if (more) { res = twCon.Mentions(count, this.minMentions, null, ref content); } else { res = twCon.Mentions(count, null, null, ref content); } } } catch(Exception ex) { return "Err:" + ex.Message; } var err = this.CheckStatusCode(res, content); if (err != null) return err; if (gType == MyCommon.WORKERTYPE.Timeline) { return CreatePostsFromJson(content, gType, null, read, ref this.minHomeTimeline); } else { return CreatePostsFromJson(content, gType, null, read, ref this.minMentions); } }
private string CreateDirectMessagesFromJson(string content, MyCommon.WORKERTYPE gType, bool read) { List<TwitterDataModel.Directmessage> item; try { if (gType == MyCommon.WORKERTYPE.UserStream) { var itm = MyCommon.CreateDataFromJson<List<TwitterDataModel.DirectmessageEvent>>(content); item = new List<TwitterDataModel.Directmessage>(); foreach (var dat in itm) { item.Add(dat.Directmessage); } } else { item = MyCommon.CreateDataFromJson<List<TwitterDataModel.Directmessage>>(content); } } catch(SerializationException ex) { MyCommon.TraceOut(ex.Message + Environment.NewLine + content); return "Json Parse Error(DataContractJsonSerializer)"; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); return "Invalid Json!"; } foreach (var message in item) { var post = new PostClass(); try { post.StatusId = message.Id; if (gType != MyCommon.WORKERTYPE.UserStream) { if (gType == MyCommon.WORKERTYPE.DirectMessegeRcv) { if (minDirectmessage > post.StatusId) minDirectmessage = post.StatusId; } else { if (minDirectmessageSent > post.StatusId) minDirectmessageSent = post.StatusId; } } //二重取得回避 lock (LockObj) { if (TabInformations.GetInstance().GetTabByType(MyCommon.TabUsageType.DirectMessage).Contains(post.StatusId)) continue; } //sender_id //recipient_id post.CreatedAt = MyCommon.DateTimeParse(message.CreatedAt); //本文 post.TextFromApi = message.Text; //HTMLに整形 post.Text = CreateHtmlAnchor(post.TextFromApi, post.ReplyToList, post.Media); post.TextFromApi = HttpUtility.HtmlDecode(post.TextFromApi); post.TextFromApi = post.TextFromApi.Replace("<3", "?"); post.IsFav = false; //以下、ユーザー情報 TwitterDataModel.User user; if (gType == MyCommon.WORKERTYPE.UserStream) { if (twCon.AuthenticatedUsername.Equals(message.Recipient.ScreenName, StringComparison.CurrentCultureIgnoreCase)) { user = message.Sender; post.IsMe = false; post.IsOwl = true; } else { user = message.Recipient; post.IsMe = true; post.IsOwl = false; } } else { if (gType == MyCommon.WORKERTYPE.DirectMessegeRcv) { user = message.Sender; post.IsMe = false; post.IsOwl = true; } else { user = message.Recipient; post.IsMe = true; post.IsOwl = false; } } post.UserId = user.Id; post.ScreenName = user.ScreenName; post.Nickname = user.Name.Trim(); post.ImageUrl = user.ProfileImageUrl; post.IsProtect = user.Protected; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); MessageBox.Show("Parse Error(CreateDirectMessagesFromJson)"); continue; } post.IsRead = read; if (post.IsMe && !read && _readOwnPost) post.IsRead = true; post.IsReply = false; post.IsExcludeReply = false; post.IsDm = true; TabInformations.GetInstance().AddPost(post); } return string.Empty; }
/// <summary> /// OAuth認証ヘッダの署名作成 /// </summary> /// <param name="tokenSecret">アクセストークン秘密鍵</param> /// <param name="method">HTTPメソッド文字列</param> /// <param name="uri">アクセス先Uri</param> /// <param name="parameter">クエリ、もしくはPOSTデータ</param> /// <returns>署名文字列</returns> public static string CreateSignature(string consumerSecret, string tokenSecret, string method, Uri uri, Dictionary <string, string> parameter) { // パラメタをソート済みディクショナリに詰替(OAuthの仕様) SortedDictionary <string, string> sorted = new SortedDictionary <string, string>(parameter); // URLエンコード済みのクエリ形式文字列に変換 string paramString = MyCommon.BuildQueryString(sorted); // アクセス先URLの整形 string url = string.Format("{0}://{1}{2}", uri.Scheme, uri.Host, uri.AbsolutePath); // 署名のベース文字列生成(&区切り)。クエリ形式文字列は再エンコードする string signatureBase = string.Format("{0}&{1}&{2}", method, MyCommon.UrlEncode(url), MyCommon.UrlEncode(paramString)); // 署名鍵の文字列をコンシューマー秘密鍵とアクセストークン秘密鍵から生成(&区切り。アクセストークン秘密鍵なくても&残すこと) string key = MyCommon.UrlEncode(consumerSecret) + "&"; if (!string.IsNullOrEmpty(tokenSecret)) { key += MyCommon.UrlEncode(tokenSecret); } // 鍵生成&署名生成 using (HMACSHA1 hmac = new HMACSHA1(Encoding.ASCII.GetBytes(key))) { byte[] hash = hmac.ComputeHash(Encoding.ASCII.GetBytes(signatureBase)); return(Convert.ToBase64String(hash)); } }
public static StreamMessageScrubGeo ParseJson(string json) => MyCommon.CreateDataFromJson <StreamMessageScrubGeo>(json);
private void ApplyEventNotifyFlag(bool rootEnabled, MyCommon.EVENTTYPE eventnotifyflag, MyCommon.EVENTTYPE isMyeventnotifyflag) { MyCommon.EVENTTYPE evt = eventnotifyflag; MyCommon.EVENTTYPE myevt = isMyeventnotifyflag; CheckEventNotify.Checked = rootEnabled; foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable()) { if ((evt & tbl.Type) != 0) { if ((myevt & tbl.Type) != 0) { tbl.CheckBox.CheckState = CheckState.Checked; } else { tbl.CheckBox.CheckState = CheckState.Indeterminate; } } else { tbl.CheckBox.CheckState = CheckState.Unchecked; } tbl.CheckBox.Enabled = rootEnabled; } }
/// <exception cref="SerializationException"/> public static TwitterList[] ParseJsonArray(string json) { return(MyCommon.CreateDataFromJson <TwitterList[]>(json)); }
public override async Task <ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { var match = Tumblr.UrlPatternRegex.Match(url); if (!match.Success) { return(null); } // 参照: http://www.tumblr.com/docs/en/api/v2#photo-posts var host = match.Groups["host"].Value; var postId = match.Groups["postId"].Value; var param = new Dictionary <string, string> { { "api_key", ApplicationSettings.TumblrConsumerKey }, { "id", match.Groups["postId"].Value }, }; var apiUrl = string.Format("https://api.tumblr.com/v2/blog/{0}/posts?", host) + MyCommon.BuildQueryString(param); using (var response = await this.http.GetAsync(apiUrl, token).ConfigureAwait(false)) { var jsonBytes = await response.Content.ReadAsByteArrayAsync() .ConfigureAwait(false); var thumbs = ParsePhotoPostJson(jsonBytes); return(thumbs.FirstOrDefault()); } }
public static TwitterFriendship ParseJson(string json) => MyCommon.CreateDataFromJson <TwitterFriendship>(json);
/// <summary> /// 保存 /// </summary> public void Save(string text) { //CBLL.FileRegist cbll = new ERM.CBLL.FileRegist(); if (!String.IsNullOrEmpty(text)) { if (!MyCommon.IsMatchCode(text)) { TXMessageBoxExtensions.Info("包含非法字符,不能保存!"); return; } //for (int i = 0; i < NewNode.Parent.Nodes.Count; i++) //{ // string newtext = NewNode.Parent.Nodes[i].Text.Trim().Substring(NewNode.Parent.Nodes[i].Text.Trim().LastIndexOf("]") + 1); // if (text.Trim().Equals(newtext)) // { // TXMessageBoxExtensions.Info("重命名失败,同一层级下节点名字不能重复!"); // return; // } //} try { if (NewNode.ImageIndex == 3) { BLL.T_CellAndEFile_BLL cellAndFile_bll = new BLL.T_CellAndEFile_BLL(); MDL.T_CellAndEFile cellMDL = cellAndFile_bll.Find(NewNode.Name, Globals.ProjectNO); cellMDL.title = text; cellAndFile_bll.Update(cellMDL); //cbll.UpdateAttachmentTitle(OpeartPath((TreeNodeEx)(NewNode.Parent)), Globals.ProjectNO, OldTitle, text); } else { BLL.T_FileList_BLL fileList_bll = new BLL.T_FileList_BLL(); MDL.T_FileList fileMDL1 = fileList_bll.Find(NewNode.Name, Globals.ProjectNO); fileMDL1.wjtm = text; fileMDL1.gdwj = text; fileList_bll.Update(fileMDL1); //string OldPath = OpeartPath((TreeNodeEx)NewNode); //string NewPath = OldPath.Substring(0, OldPath.LastIndexOf("\\") + 1) + text; //cbll.UpdateFinal_fileTitle(NewPath, Globals.ProjectNO, OldPath); //cbll.UpdateCell_TempletTitle(NewPath, Globals.ProjectNO, OldPath, text); //cbll.UpdateAttachmentFilePath(NewPath, OldPath, Globals.ProjectNO); } NewNode.Text = text; TXMessageBoxExtensions.Info("修改成功!"); this.Close(); } catch { TXMessageBoxExtensions.Info("重命名失败!"); } } else { TXMessageBoxExtensions.Info("名称不能为空!"); return; } }
/// <exception cref="SerializationException"/> public static TwitterSearchResult ParseJson(string json) { return(MyCommon.CreateDataFromJson <TwitterSearchResult>(json)); }
public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null) { //重複チェック foreach (TabPage tb in ListTab.TabPages) { if (tb.Text == tabName) return false; } //新規タブ名チェック if (tabName == Properties.Resources.AddNewTabText1) return false; //タブタイプ重複チェック if (!startup) { if (tabType == MyCommon.TabUsageType.DirectMessage || tabType == MyCommon.TabUsageType.Favorites || tabType == MyCommon.TabUsageType.Home || tabType == MyCommon.TabUsageType.Mentions || tabType == MyCommon.TabUsageType.Related) { if (_statuses.GetTabByType(tabType) != null) return false; } } TabPage _tabPage = new TabPage(); DetailsListView _listCustom = new DetailsListView(); ColumnHeader _colHd1 = new ColumnHeader(); //アイコン ColumnHeader _colHd2 = new ColumnHeader(); //ニックネーム ColumnHeader _colHd3 = new ColumnHeader(); //本文 ColumnHeader _colHd4 = new ColumnHeader(); //日付 ColumnHeader _colHd5 = new ColumnHeader(); //ユーザID ColumnHeader _colHd6 = new ColumnHeader(); //未読 ColumnHeader _colHd7 = new ColumnHeader(); //マーク&プロテクト ColumnHeader _colHd8 = new ColumnHeader(); //ソース int cnt = ListTab.TabPages.Count; ///ToDo:Create and set controls follow tabtypes this.SplitContainer1.Panel1.SuspendLayout(); this.SplitContainer1.Panel2.SuspendLayout(); this.SplitContainer1.SuspendLayout(); this.ListTab.SuspendLayout(); this.SuspendLayout(); _tabPage.SuspendLayout(); /// UserTimeline関連 Label label = null; if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) { label = new Label(); label.Dock = DockStyle.Top; label.Name = "labelUser"; if (tabType == MyCommon.TabUsageType.Lists) { label.Text = listInfo.ToString(); } else { label.Text = _statuses.Tabs[tabName].User + "'s Timeline"; } label.TextAlign = ContentAlignment.MiddleLeft; using (ComboBox tmpComboBox = new ComboBox()) { label.Height = tmpComboBox.Height; } _tabPage.Controls.Add(label); } /// 検索関連の準備 Panel pnl = null; if (tabType == MyCommon.TabUsageType.PublicSearch) { pnl = new Panel(); Label lbl = new Label(); ComboBox cmb = new ComboBox(); Button btn = new Button(); ComboBox cmbLang = new ComboBox(); pnl.SuspendLayout(); pnl.Controls.Add(cmb); pnl.Controls.Add(cmbLang); pnl.Controls.Add(btn); pnl.Controls.Add(lbl); pnl.Name = "panelSearch"; pnl.Dock = DockStyle.Top; pnl.Height = cmb.Height; pnl.Enter += SearchControls_Enter; pnl.Leave += SearchControls_Leave; cmb.Text = ""; cmb.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmb.Dock = DockStyle.Fill; cmb.Name = "comboSearch"; cmb.DropDownStyle = ComboBoxStyle.DropDown; cmb.ImeMode = ImeMode.NoControl; cmb.TabStop = false; cmb.AutoCompleteMode = AutoCompleteMode.None; cmb.KeyDown += SearchComboBox_KeyDown; if (_statuses.ContainsTab(tabName)) { cmb.Items.Add(_statuses.Tabs[tabName].SearchWords); cmb.Text = _statuses.Tabs[tabName].SearchWords; } cmbLang.Text = ""; cmbLang.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmbLang.Dock = DockStyle.Right; cmbLang.Width = 50; cmbLang.Name = "comboLang"; cmbLang.DropDownStyle = ComboBoxStyle.DropDownList; cmbLang.TabStop = false; cmbLang.Items.Add(""); cmbLang.Items.Add("ja"); cmbLang.Items.Add("en"); cmbLang.Items.Add("ar"); cmbLang.Items.Add("da"); cmbLang.Items.Add("nl"); cmbLang.Items.Add("fa"); cmbLang.Items.Add("fi"); cmbLang.Items.Add("fr"); cmbLang.Items.Add("de"); cmbLang.Items.Add("hu"); cmbLang.Items.Add("is"); cmbLang.Items.Add("it"); cmbLang.Items.Add("no"); cmbLang.Items.Add("pl"); cmbLang.Items.Add("pt"); cmbLang.Items.Add("ru"); cmbLang.Items.Add("es"); cmbLang.Items.Add("sv"); cmbLang.Items.Add("th"); if (_statuses.ContainsTab(tabName)) cmbLang.Text = _statuses.Tabs[tabName].SearchLang; lbl.Text = "Search(C-S-f)"; lbl.Name = "label1"; lbl.Dock = DockStyle.Left; lbl.Width = 90; lbl.Height = cmb.Height; lbl.TextAlign = ContentAlignment.MiddleLeft; btn.Text = "Search"; btn.Name = "buttonSearch"; btn.UseVisualStyleBackColor = true; btn.Dock = DockStyle.Right; btn.TabStop = false; btn.Click += SearchButton_Click; } this.ListTab.Controls.Add(_tabPage); _tabPage.Controls.Add(_listCustom); if (tabType == MyCommon.TabUsageType.PublicSearch) _tabPage.Controls.Add(pnl); if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) _tabPage.Controls.Add(label); _tabPage.Location = new Point(4, 4); _tabPage.Name = "CTab" + cnt.ToString(); _tabPage.Size = new Size(380, 260); _tabPage.TabIndex = 2 + cnt; _tabPage.Text = tabName; _tabPage.UseVisualStyleBackColor = true; _listCustom.AllowColumnReorder = true; if (!_iconCol) { _listCustom.Columns.AddRange(new ColumnHeader[] {_colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8}); } else { _listCustom.Columns.AddRange(new ColumnHeader[] {_colHd1, _colHd3}); } _listCustom.ContextMenuStrip = this.ContextMenuOperate; _listCustom.Dock = DockStyle.Fill; _listCustom.FullRowSelect = true; _listCustom.HideSelection = false; _listCustom.Location = new Point(0, 0); _listCustom.Margin = new Padding(0); _listCustom.Name = "CList" + Environment.TickCount.ToString(); _listCustom.ShowItemToolTips = true; _listCustom.Size = new Size(380, 260); _listCustom.UseCompatibleStateImageBehavior = false; _listCustom.View = View.Details; _listCustom.OwnerDraw = true; _listCustom.VirtualMode = true; _listCustom.Font = _fntReaded; _listCustom.BackColor = _clListBackcolor; _listCustom.GridLines = SettingDialog.ShowGrid; _listCustom.AllowDrop = true; _listCustom.SelectedIndexChanged += MyList_SelectedIndexChanged; _listCustom.MouseDoubleClick += MyList_MouseDoubleClick; _listCustom.ColumnClick += MyList_ColumnClick; _listCustom.DrawColumnHeader += MyList_DrawColumnHeader; _listCustom.DragDrop += TweenMain_DragDrop; _listCustom.DragOver += TweenMain_DragOver; _listCustom.DrawItem += MyList_DrawItem; _listCustom.MouseClick += MyList_MouseClick; _listCustom.ColumnReordered += MyList_ColumnReordered; _listCustom.ColumnWidthChanged += MyList_ColumnWidthChanged; _listCustom.CacheVirtualItems += MyList_CacheVirtualItems; _listCustom.RetrieveVirtualItem += MyList_RetrieveVirtualItem; _listCustom.DrawSubItem += MyList_DrawSubItem; _listCustom.HScrolled += MyList_HScrolled; InitColumnText(); _colHd1.Text = ColumnText[0]; _colHd1.Width = 48; _colHd2.Text = ColumnText[1]; _colHd2.Width = 80; _colHd3.Text = ColumnText[2]; _colHd3.Width = 300; _colHd4.Text = ColumnText[3]; _colHd4.Width = 50; _colHd5.Text = ColumnText[4]; _colHd5.Width = 50; _colHd6.Text = ColumnText[5]; _colHd6.Width = 16; _colHd7.Text = ColumnText[6]; _colHd7.Width = 16; _colHd8.Text = ColumnText[7]; _colHd8.Width = 50; if (_statuses.IsDistributableTab(tabName)) TabDialog.AddTab(tabName); _listCustom.SmallImageList = new ImageList(); if (_iconSz > 0) { _listCustom.SmallImageList.ImageSize = new Size(_iconSz, _iconSz); } else { _listCustom.SmallImageList.ImageSize = new Size(1, 1); } int[] dispOrder = new int[8]; if (!startup) { for (int i = 0; i < _curList.Columns.Count; i++) { for (int j = 0; j < _curList.Columns.Count; j++) { if (_curList.Columns[j].DisplayIndex == i) { dispOrder[i] = j; break; } } } for (int i = 0; i < _curList.Columns.Count; i++) { _listCustom.Columns[i].Width = _curList.Columns[i].Width; _listCustom.Columns[dispOrder[i]].DisplayIndex = i; } } else { if (_iconCol) { _listCustom.Columns[0].Width = _cfgLocal.Width1; _listCustom.Columns[1].Width = _cfgLocal.Width3; _listCustom.Columns[0].DisplayIndex = 0; _listCustom.Columns[1].DisplayIndex = 1; } else { for (int i = 0; i <= 7; i++) { if (_cfgLocal.DisplayIndex1 == i) dispOrder[i] = 0; else if (_cfgLocal.DisplayIndex2 == i) dispOrder[i] = 1; else if (_cfgLocal.DisplayIndex3 == i) dispOrder[i] = 2; else if (_cfgLocal.DisplayIndex4 == i) dispOrder[i] = 3; else if (_cfgLocal.DisplayIndex5 == i) dispOrder[i] = 4; else if (_cfgLocal.DisplayIndex6 == i) dispOrder[i] = 5; else if (_cfgLocal.DisplayIndex7 == i) dispOrder[i] = 6; else if (_cfgLocal.DisplayIndex8 == i) dispOrder[i] = 7; } _listCustom.Columns[0].Width = _cfgLocal.Width1; _listCustom.Columns[1].Width = _cfgLocal.Width2; _listCustom.Columns[2].Width = _cfgLocal.Width3; _listCustom.Columns[3].Width = _cfgLocal.Width4; _listCustom.Columns[4].Width = _cfgLocal.Width5; _listCustom.Columns[5].Width = _cfgLocal.Width6; _listCustom.Columns[6].Width = _cfgLocal.Width7; _listCustom.Columns[7].Width = _cfgLocal.Width8; for (int i = 0; i <= 7; i++) { _listCustom.Columns[dispOrder[i]].DisplayIndex = i; } } } if (tabType == MyCommon.TabUsageType.PublicSearch) pnl.ResumeLayout(false); _tabPage.ResumeLayout(false); this.SplitContainer1.Panel1.ResumeLayout(false); this.SplitContainer1.Panel2.ResumeLayout(false); this.SplitContainer1.ResumeLayout(false); this.ListTab.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); _tabPage.Tag = _listCustom; return true; }
} // Nullable public static StreamMessageDelete ParseJson(string json) => MyCommon.CreateDataFromJson <StreamMessageDelete>(json);
private bool IsEventNotifyAsEventType(MyCommon.EVENTTYPE type) { return SettingDialog.EventNotifyEnabled && (type & SettingDialog.EventNotifyFlag) != 0 || type == MyCommon.EVENTTYPE.None; }
public static TwitterUploadMediaInit ParseJson(string json) => MyCommon.CreateDataFromJson <TwitterUploadMediaInit>(json);
public string GetFavoritesApi(bool read, MyCommon.WORKERTYPE gType, bool more) { if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty; if (MyCommon._endingFlag) return string.Empty; HttpStatusCode res; var content = string.Empty; var count = AppendSettingDialog.Instance.CountApi; if (AppendSettingDialog.Instance.UseAdditionalCount && AppendSettingDialog.Instance.FavoritesCountApi != 0) { count = AppendSettingDialog.Instance.FavoritesCountApi; } // 前ページ取得の場合はページカウンタをインクリメント、それ以外の場合はページカウンタリセット if (more) { page_++; } else { page_ = 1; } try { res = twCon.Favorites(count, page_, ref content); } catch(Exception ex) { return "Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")"; } switch (res) { case HttpStatusCode.OK: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid; break; case HttpStatusCode.Unauthorized: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid; return Properties.Resources.Unauthorized; case HttpStatusCode.BadRequest: return "Err:API Limits?"; default: return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")"; } var serializer = new DataContractJsonSerializer(typeof(List<TwitterDataModel.Status>)); List<TwitterDataModel.Status> item; try { item = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content); } catch(SerializationException ex) { MyCommon.TraceOut(ex.Message + Environment.NewLine + content); return "Json Parse Error(DataContractJsonSerializer)"; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); return "Invalid Json!"; } foreach (var status in item) { var post = new PostClass(); TwitterDataModel.Entities entities; try { post.StatusId = status.Id; //二重取得回避 lock (LockObj) { if (TabInformations.GetInstance().GetTabByType(MyCommon.TabUsageType.Favorites).Contains(post.StatusId)) continue; } //Retweet判定 if (status.RetweetedStatus != null) { var retweeted = status.RetweetedStatus; post.CreatedAt = MyCommon.DateTimeParse(retweeted.CreatedAt); //Id post.RetweetedId = post.StatusId; //本文 post.TextFromApi = retweeted.Text; entities = retweeted.Entities; //Source取得(htmlの場合は、中身を取り出し) post.Source = retweeted.Source; //Reply先 long inReplyToStatusId; long.TryParse(retweeted.InReplyToStatusId, out inReplyToStatusId); post.InReplyToStatusId = inReplyToStatusId; post.InReplyToUser = retweeted.InReplyToScreenName; long inReplyToUserId; long.TryParse(retweeted.InReplyToUserId, out inReplyToUserId); post.InReplyToUserId = inReplyToUserId; post.IsFav = true; //以下、ユーザー情報 var user = retweeted.User; post.UserId = user.Id; post.ScreenName = user.ScreenName; post.Nickname = user.Name.Trim(); post.ImageUrl = user.ProfileImageUrl; post.IsProtect = user.Protected; //Retweetした人 post.RetweetedBy = status.User.ScreenName; post.IsMe = post.RetweetedBy.ToLower().Equals(_uname); } else { post.CreatedAt = MyCommon.DateTimeParse(status.CreatedAt); //本文 post.TextFromApi = status.Text; entities = status.Entities; //Source取得(htmlの場合は、中身を取り出し) post.Source = status.Source; long inReplyToStatusId; long.TryParse(status.InReplyToStatusId, out inReplyToStatusId); post.InReplyToStatusId = inReplyToStatusId; post.InReplyToUser = status.InReplyToScreenName; long inReplyToUserId; long.TryParse(status.InReplyToUserId, out inReplyToUserId); post.InReplyToUserId = inReplyToUserId; post.IsFav = true; //以下、ユーザー情報 var user = status.User; post.UserId = user.Id; post.ScreenName = user.ScreenName; post.Nickname = user.Name.Trim(); post.ImageUrl = user.ProfileImageUrl; post.IsProtect = user.Protected; post.IsMe = post.ScreenName.ToLower().Equals(_uname); } //HTMLに整形 string textFromApi = post.TextFromApi; post.Text = CreateHtmlAnchor(ref textFromApi, post.ReplyToList, entities, post.Media); post.TextFromApi = textFromApi; post.TextFromApi = this.ReplaceTextFromApi(post.TextFromApi, entities); post.TextFromApi = HttpUtility.HtmlDecode(post.TextFromApi); post.TextFromApi = post.TextFromApi.Replace("<3", "?"); //Source整形 CreateSource(ref post); post.IsRead = read; post.IsReply = post.ReplyToList.Contains(_uname); post.IsExcludeReply = false; if (post.IsMe) { post.IsOwl = false; } else { if (followerId.Count > 0) post.IsOwl = !followerId.Contains(post.UserId); } post.IsDm = false; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); continue; } TabInformations.GetInstance().AddPost(post); } return string.Empty; }
void setSpecialObjPlane(soloItem item) { specialItem = item; if (m_uplane != null) { m_uplane.Destroy(); } string str = "right,error,overdate"; if (btnList.Count == 0) { foreach (var number in MyCommon.RandomRepeat(3)) { btnList.Add(str.Split(',')[number]); } } m_uplane = new UPlane(); //定义UI m_uplane.SetAnchored(AnchoredPosition.center); //定义位置远点 m_uplane.rect = new Rect(65, 0, 1620, 1080 / 6 * 5); //定义显示框的位置的大小 m_uplane.gameObejct.AddComponent <ToggleGroup>(); //副节点 m_uplane.color = new Color(0.9f, 0.9f, 0.9f); m_uplane.LoadImage(""); UText m_utext = new UText(); m_utext.SetAnchored(AnchoredPosition.center); m_utext.text = "请选择正确物品"; m_utext.rect = new Rect(100, -375, 500, 100); m_utext.baseText.fontSize = 55; m_utext.baseText.color = Color.white; m_utext.SetParent(m_uplane); for (int i = 0; i < btnList.Count; i++) { UPageButton btn = new UPageButton(); btn.SetParent(m_uplane); btn.name = btnList[i]; btn.SetAnchored(AnchoredPosition.center); btn.rect = new Rect(-540 + i * 500 + 50, 9, 500, 300); btn.LoadSprite("check_anesthetic_3"); btn.LoadPressSprite("check_anesthetic_3_h"); btn.onClick.AddListener(() => { OnImageButtonClick(btn); }); UText m_datetext_1 = new UText(); m_datetext_1.SetAnchored(AnchoredPosition.center); m_datetext_1.SetParent(m_uplane); m_datetext_1.rect = new Rect(-300 + i * 500 + 50, 240, 500, 300); m_datetext_1.baseText.fontSize = 23; m_datetext_1.baseText.color = new Color(0f, 0f, 0f); m_datetext_1.rectTransform.localEulerAngles = new Vector3(0f, 0f, 5.6f); m_datetext_1.baseText.raycastTarget = false; UText m_type_1 = new UText(); m_type_1.SetAnchored(AnchoredPosition.center); m_type_1.SetParent(m_uplane); m_type_1.rect = new Rect(-300 + i * 500 + 50, 200, 500, 300); m_type_1.baseText.color = new Color(0f, 0f, 0f); m_type_1.rectTransform.localEulerAngles = new Vector3(0f, 0f, 5.6f); m_type_1.baseText.fontSize = 23; m_type_1.baseText.raycastTarget = false; if (btnList[i] == "right") { m_datetext_1.text = "有效日期: " + (DateTime.Now.Year + 2).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; m_type_1.text = "规格:16Fr "; } else { if (btnList[i] == "error") { m_datetext_1.text = "有效日期: " + (DateTime.Now.Year + 2).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; m_type_1.text = "规格:8Fr\0\0\0\0\0\0\0\0"; } else { m_type_1.text = "规格:16Fr\r\r\r\r\r\r "; m_datetext_1.text = "有效日期: " + (DateTime.Now.Year - 1).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; } } } UFinishButton OkButton = new UFinishButton("确定", new Rect(23, 363, 180, 70), AnchoredPosition.center); OkButton.SetParent(m_uplane); OkButton.baseButton.onClick.AddListener(specialItemChoose); m_uplane.transform.SetAsLastSibling(); List <UPageBase> list = m_uplane.GetChildren(); foreach (UPageBase upb in list) { UToogleItem tmp = null; try { tmp = (UToogleItem)upb; } catch { continue; } if (tmp != null) { upb.gameObejct.GetComponent <Toggle>().isOn = false; } } m_uplane.gameObejct.SetActive(true); UPageBase.FindPage("ChooseGoodsUI/ChooseItems/chooseItemFinishButton").gameObejct.SetActive(false); //GameObject.Find("Canvas").transform.Find("ChooseItems/UPageButton").gameObject.SetActive(false); }
private string CreatePostsFromPhoenixSearch(string content, MyCommon.WORKERTYPE gType, TabClass tab, bool read, int count, ref long minimumId, ref string nextPageQuery) { TwitterDataModel.SearchResult items; try { items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content); } catch(SerializationException ex) { MyCommon.TraceOut(ex.Message + Environment.NewLine + content); return "Json Parse Error(DataContractJsonSerializer)"; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); return "Invalid Json!"; } nextPageQuery = items.NextPage; foreach (var status in items.Statuses) { PostClass post = null; post = CreatePostsFromStatusData(status); if (post == null) continue; if (minimumId > post.StatusId) minimumId = post.StatusId; //二重取得回避 lock (LockObj) { if (tab == null) { if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue; } else { if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue; } } post.IsRead = read; if (post.IsMe && !read && _readOwnPost) post.IsRead = true; if (tab != null) post.RelTabName = tab.TabName; //非同期アイコン取得&StatusDictionaryに追加 TabInformations.GetInstance().AddPost(post); } return string.IsNullOrEmpty(items.ErrMsg) ? string.Empty : "Err:" + items.ErrMsg; }
/// <exception cref="SerializationException"/> public static TwitterIds ParseJson(string json) { return(MyCommon.CreateDataFromJson <TwitterIds>(json)); }
public bool AddTab(string TabName, MyCommon.TabUsageType TabType, ListElement List) { if (_tabs.ContainsKey(TabName)) return false; var tb = new TabClass(TabName, TabType, List); _tabs.Add(TabName, tb); tb.SortMode = this.SortMode; tb.SortOrder = this.SortOrder; return true; }
/// <exception cref="SerializationException"/> public static TwitterConfiguration ParseJson(string json) { return(MyCommon.CreateDataFromJson <TwitterConfiguration>(json)); }
public bool IsSupportedFileType(MyCommon.UploadFileType type) { return type == MyCommon.UploadFileType.Picture; }
private void ChangeListViewIconSize(MyCommon.IconSizes iconSize) { if (this._cfgCommon.IconSize == iconSize) return; var oldIconCol = _iconCol; this._cfgCommon.IconSize = iconSize; ApplyListViewIconSize(iconSize); if (_iconCol != oldIconCol) { foreach (TabPage tp in ListTab.TabPages) { ResetColumns((DetailsListView)tp.Tag); } } if (_curList != null) _curList.Refresh(); _modifySettingCommon = true; }
public string GetDirectMessageApi(bool read, MyCommon.WORKERTYPE gType, bool more) { if (MyCommon._endingFlag) return ""; if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return ""; if (this.AccessLevel == TwitterApiAccessLevel.Read || this.AccessLevel == TwitterApiAccessLevel.ReadWrite) { return "Auth Err:try to re-authorization."; } HttpStatusCode res; var content = ""; try { if (gType == MyCommon.WORKERTYPE.DirectMessegeRcv) { if (more) { res = twCon.DirectMessages(20, minDirectmessage, null, ref content); } else { res = twCon.DirectMessages(20, null, null, ref content); } } else { if (more) { res = twCon.DirectMessagesSent(20, minDirectmessageSent, null, ref content); } else { res = twCon.DirectMessagesSent(20, null, null, ref content); } } } catch(Exception ex) { return "Err:" + ex.Message; } var err = this.CheckStatusCode(res, content); if (err != null) return err; return CreateDirectMessagesFromJson(content, gType, read); }
private bool IsEventNotifyAsEventType(MyCommon.EVENTTYPE type) { return this._cfgCommon.EventNotifyEnabled && (type & this._cfgCommon.EventNotifyFlag) != 0 || type == MyCommon.EVENTTYPE.None; }
public void IsDistributable_Test(MyCommon.TabUsageType tabType, bool expected) { Assert.Equal(expected, tabType.IsDistributable()); }
private void ApplyListViewIconSize(MyCommon.IconSizes iconSz) { // アイコンサイズの再設定 _iconCol = false; switch (iconSz) { case MyCommon.IconSizes.IconNone: _iconSz = 0; break; case MyCommon.IconSizes.Icon16: _iconSz = 16; break; case MyCommon.IconSizes.Icon24: _iconSz = 26; break; case MyCommon.IconSizes.Icon48: _iconSz = 48; break; case MyCommon.IconSizes.Icon48_2: _iconSz = 48; _iconCol = true; break; } if (_iconSz > 0) { // ディスプレイの DPI 設定を考慮したサイズを設定する _listViewImageList.ImageSize = new Size( 1, (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Height)); } else { _listViewImageList.ImageSize = new Size(1, 1); } }
private bool UrlConvert(MyCommon.UrlConverter Converter_Type) { //t.coで投稿時自動短縮する場合は、外部サービスでの短縮禁止 //if (SettingDialog.UrlConvertAuto && SettingDialog.ShortenTco) return; //Converter_Type=Nicomsの場合は、nicovideoのみ短縮する //参考資料 RFC3986 Uniform Resource Identifier (URI): Generic Syntax //Appendix A. Collected ABNF for URI //http://www.ietf.org/rfc/rfc3986.txt string result = ""; const string nico = @"^https?://[a-z]+\.(nicovideo|niconicommons|nicolive)\.jp/[a-z]+/[a-z0-9]+$"; if (StatusText.SelectionLength > 0) { string tmp = StatusText.SelectedText; // httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない if (tmp.StartsWith("http")) { // 文字列が選択されている場合はその文字列について処理 //nico.ms使用、nicovideoにマッチしたら変換 if (SettingDialog.Nicoms && Regex.IsMatch(tmp, nico)) { result = nicoms.Shorten(tmp); } else if (Converter_Type != MyCommon.UrlConverter.Nicoms) { //短縮URL変換 日本語を含むかもしれないのでURLエンコードする result = ShortUrl.Make(Converter_Type, tmp); if (result.Equals("Can't convert")) { StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":"); return false; } } else { return true; } if (!string.IsNullOrEmpty(result)) { urlUndo undotmp = new urlUndo(); StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length); StatusText.SelectedText = result; //undoバッファにセット undotmp.Before = tmp; undotmp.After = result; if (urlUndoBuffer == null) { urlUndoBuffer = new List<urlUndo>(); UrlUndoToolStripMenuItem.Enabled = true; } urlUndoBuffer.Add(undotmp); } } } else { const string url = @"(?<before>(?:[^\""':!=]|^|\:))" + @"(?<url>(?<protocol>https?://)" + @"(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + @"(?<path>/[a-z0-9!*//();:&=+$/%#\-_.,~@]*[a-z0-9)=#/]?)?" + @"(?<query>\?[a-z0-9!*//();:&=+$/%#\-_.,~@?]*[a-z0-9_&=#/])?)"; // 正規表現にマッチしたURL文字列をtinyurl化 foreach (Match mt in Regex.Matches(StatusText.Text, url, RegexOptions.IgnoreCase)) { if (StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal) == -1) continue; string tmp = mt.Result("${url}"); if (tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase)) tmp = "http://" + tmp; urlUndo undotmp = new urlUndo(); //選んだURLを選択(?) StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length); //nico.ms使用、nicovideoにマッチしたら変換 if (SettingDialog.Nicoms && Regex.IsMatch(tmp, nico)) { result = nicoms.Shorten(tmp); } else if (Converter_Type != MyCommon.UrlConverter.Nicoms) { //短縮URL変換 日本語を含むかもしれないのでURLエンコードする result = ShortUrl.Make(Converter_Type, tmp); if (result.Equals("Can't convert")) { StatusLabel.Text = result.Insert(0, Converter_Type.ToString() + ":"); continue; } } else { continue; } if (!string.IsNullOrEmpty(result)) { StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length); StatusText.SelectedText = result; //undoバッファにセット undotmp.Before = mt.Result("${url}"); undotmp.After = result; if (urlUndoBuffer == null) { urlUndoBuffer = new List<urlUndo>(); UrlUndoToolStripMenuItem.Enabled = true; } urlUndoBuffer.Add(undotmp); } } } return true; }
public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null) { //重複チェック foreach (TabPage tb in ListTab.TabPages) { if (tb.Text == tabName) return false; } //新規タブ名チェック if (tabName == Properties.Resources.AddNewTabText1) return false; //タブタイプ重複チェック if (!startup) { if (tabType == MyCommon.TabUsageType.DirectMessage || tabType == MyCommon.TabUsageType.Favorites || tabType == MyCommon.TabUsageType.Home || tabType == MyCommon.TabUsageType.Mentions || tabType == MyCommon.TabUsageType.Related) { if (_statuses.GetTabByType(tabType) != null) return false; } } TabPage _tabPage = new TabPage(); DetailsListView _listCustom = new DetailsListView(); int cnt = ListTab.TabPages.Count; ///ToDo:Create and set controls follow tabtypes using (ControlTransaction.Update(_listCustom)) using (ControlTransaction.Layout(this.SplitContainer1.Panel1, false)) using (ControlTransaction.Layout(this.SplitContainer1.Panel2, false)) using (ControlTransaction.Layout(this.SplitContainer1, false)) using (ControlTransaction.Layout(this.ListTab, false)) using (ControlTransaction.Layout(this)) using (ControlTransaction.Layout(_tabPage, false)) { /// UserTimeline関連 Label label = null; if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) { label = new Label(); label.Dock = DockStyle.Top; label.Name = "labelUser"; if (tabType == MyCommon.TabUsageType.Lists) { label.Text = listInfo.ToString(); } else { label.Text = _statuses.Tabs[tabName].User + "'s Timeline"; } label.TextAlign = ContentAlignment.MiddleLeft; using (ComboBox tmpComboBox = new ComboBox()) { label.Height = tmpComboBox.Height; } _tabPage.Controls.Add(label); } /// 検索関連の準備 Panel pnl = null; if (tabType == MyCommon.TabUsageType.PublicSearch) { pnl = new Panel(); Label lbl = new Label(); ComboBox cmb = new ComboBox(); Button btn = new Button(); ComboBox cmbLang = new ComboBox(); pnl.SuspendLayout(); pnl.Controls.Add(cmb); pnl.Controls.Add(cmbLang); pnl.Controls.Add(btn); pnl.Controls.Add(lbl); pnl.Name = "panelSearch"; pnl.Dock = DockStyle.Top; pnl.Height = cmb.Height; pnl.Enter += SearchControls_Enter; pnl.Leave += SearchControls_Leave; cmb.Text = ""; cmb.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmb.Dock = DockStyle.Fill; cmb.Name = "comboSearch"; cmb.DropDownStyle = ComboBoxStyle.DropDown; cmb.ImeMode = ImeMode.NoControl; cmb.TabStop = false; cmb.AutoCompleteMode = AutoCompleteMode.None; cmb.KeyDown += SearchComboBox_KeyDown; if (_statuses.ContainsTab(tabName)) { cmb.Items.Add(_statuses.Tabs[tabName].SearchWords); cmb.Text = _statuses.Tabs[tabName].SearchWords; } cmbLang.Text = ""; cmbLang.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmbLang.Dock = DockStyle.Right; cmbLang.Width = 50; cmbLang.Name = "comboLang"; cmbLang.DropDownStyle = ComboBoxStyle.DropDownList; cmbLang.TabStop = false; cmbLang.Items.Add(""); cmbLang.Items.Add("ja"); cmbLang.Items.Add("en"); cmbLang.Items.Add("ar"); cmbLang.Items.Add("da"); cmbLang.Items.Add("nl"); cmbLang.Items.Add("fa"); cmbLang.Items.Add("fi"); cmbLang.Items.Add("fr"); cmbLang.Items.Add("de"); cmbLang.Items.Add("hu"); cmbLang.Items.Add("is"); cmbLang.Items.Add("it"); cmbLang.Items.Add("no"); cmbLang.Items.Add("pl"); cmbLang.Items.Add("pt"); cmbLang.Items.Add("ru"); cmbLang.Items.Add("es"); cmbLang.Items.Add("sv"); cmbLang.Items.Add("th"); if (_statuses.ContainsTab(tabName)) cmbLang.Text = _statuses.Tabs[tabName].SearchLang; lbl.Text = "Search(C-S-f)"; lbl.Name = "label1"; lbl.Dock = DockStyle.Left; lbl.Width = 90; lbl.Height = cmb.Height; lbl.TextAlign = ContentAlignment.MiddleLeft; btn.Text = "Search"; btn.Name = "buttonSearch"; btn.UseVisualStyleBackColor = true; btn.Dock = DockStyle.Right; btn.TabStop = false; btn.Click += SearchButton_Click; } this.ListTab.Controls.Add(_tabPage); _tabPage.Controls.Add(_listCustom); if (tabType == MyCommon.TabUsageType.PublicSearch) _tabPage.Controls.Add(pnl); if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) _tabPage.Controls.Add(label); _tabPage.Location = new Point(4, 4); _tabPage.Name = "CTab" + cnt.ToString(); _tabPage.Size = new Size(380, 260); _tabPage.TabIndex = 2 + cnt; _tabPage.Text = tabName; _tabPage.UseVisualStyleBackColor = true; _listCustom.AllowColumnReorder = true; _listCustom.ContextMenuStrip = this.ContextMenuOperate; _listCustom.ColumnHeaderContextMenuStrip = this.ContextMenuColumnHeader; _listCustom.Dock = DockStyle.Fill; _listCustom.FullRowSelect = true; _listCustom.HideSelection = false; _listCustom.Location = new Point(0, 0); _listCustom.Margin = new Padding(0); _listCustom.Name = "CList" + Environment.TickCount.ToString(); _listCustom.ShowItemToolTips = true; _listCustom.Size = new Size(380, 260); _listCustom.UseCompatibleStateImageBehavior = false; _listCustom.View = View.Details; _listCustom.OwnerDraw = true; _listCustom.VirtualMode = true; _listCustom.Font = _fntReaded; _listCustom.BackColor = _clListBackcolor; _listCustom.GridLines = this._cfgCommon.ShowGrid; _listCustom.AllowDrop = true; _listCustom.SmallImageList = _listViewImageList; InitColumns(_listCustom, startup); _listCustom.SelectedIndexChanged += MyList_SelectedIndexChanged; _listCustom.MouseDoubleClick += MyList_MouseDoubleClick; _listCustom.ColumnClick += MyList_ColumnClick; _listCustom.DrawColumnHeader += MyList_DrawColumnHeader; _listCustom.DragDrop += TweenMain_DragDrop; _listCustom.DragEnter += TweenMain_DragEnter; _listCustom.DragOver += TweenMain_DragOver; _listCustom.DrawItem += MyList_DrawItem; _listCustom.MouseClick += MyList_MouseClick; _listCustom.ColumnReordered += MyList_ColumnReordered; _listCustom.ColumnWidthChanged += MyList_ColumnWidthChanged; _listCustom.CacheVirtualItems += MyList_CacheVirtualItems; _listCustom.RetrieveVirtualItem += MyList_RetrieveVirtualItem; _listCustom.DrawSubItem += MyList_DrawSubItem; _listCustom.HScrolled += MyList_HScrolled; if (tabType == MyCommon.TabUsageType.PublicSearch) pnl.ResumeLayout(false); } _tabPage.Tag = _listCustom; return true; }
private void GetTimeline(MyCommon.WORKERTYPE WkType, int fromPage, int toPage, string tabName) { if (!this.IsNetworkAvailable()) return; //非同期実行引数設定 GetWorkerArg args = new GetWorkerArg(); args.page = fromPage; args.endPage = toPage; args.type = WkType; args.tName = tabName; if (!lastTime.ContainsKey(WkType)) lastTime.Add(WkType, new DateTime()); double period = DateTime.Now.Subtract(lastTime[WkType]).TotalSeconds; if (period > 1 || period < -1) { lastTime[WkType] = DateTime.Now; RunAsync(args); } //Timeline取得モードの場合はReplyも同時に取得 //if (!SettingDialog.UseAPI && // !_initial && // WkType == MyCommon.WORKERTYPE.Timeline && // SettingDialog.CheckReply) //{ // //TimerReply.Enabled = false; // _mentionCounter = SettingDialog.ReplyPeriodInt; // GetWorkerArg _args = new GetWorkerArg(); // _args.page = fromPage; // _args.endPage = toPage; // _args.type = MyCommon.WORKERTYPE.Reply; // RunAsync(_args); //} }
private async Task<bool> UrlConvertAsync(MyCommon.UrlConverter Converter_Type) { //t.coで投稿時自動短縮する場合は、外部サービスでの短縮禁止 //if (SettingDialog.UrlConvertAuto && SettingDialog.ShortenTco) return; //Converter_Type=Nicomsの場合は、nicovideoのみ短縮する //参考資料 RFC3986 Uniform Resource Identifier (URI): Generic Syntax //Appendix A. Collected ABNF for URI //http://www.ietf.org/rfc/rfc3986.txt string result = ""; const string nico = @"^https?://[a-z]+\.(nicovideo|niconicommons|nicolive)\.jp/[a-z]+/[a-z0-9]+$"; if (StatusText.SelectionLength > 0) { string tmp = StatusText.SelectedText; // httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない if (tmp.StartsWith("http")) { // 文字列が選択されている場合はその文字列について処理 //nico.ms使用、nicovideoにマッチしたら変換 if (this._cfgCommon.Nicoms && Regex.IsMatch(tmp, nico)) { result = nicoms.Shorten(tmp); } else if (Converter_Type != MyCommon.UrlConverter.Nicoms) { //短縮URL変換 日本語を含むかもしれないのでURLエンコードする try { var srcUri = new Uri(MyCommon.urlEncodeMultibyteChar(tmp)); var resultUri = await ShortUrl.Instance.ShortenUrlAsync(Converter_Type, srcUri); result = resultUri.ToString(); } catch (WebApiException e) { this.StatusLabel.Text = Converter_Type + ":" + e.Message; return false; } catch (UriFormatException e) { this.StatusLabel.Text = Converter_Type + ":" + e.Message; return false; } } else { return true; } if (!string.IsNullOrEmpty(result)) { urlUndo undotmp = new urlUndo(); StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length); StatusText.SelectedText = result; //undoバッファにセット undotmp.Before = tmp; undotmp.After = result; if (urlUndoBuffer == null) { urlUndoBuffer = new List<urlUndo>(); UrlUndoToolStripMenuItem.Enabled = true; } urlUndoBuffer.Add(undotmp); } } } else { const string url = @"(?<before>(?:[^\""':!=]|^|\:))" + @"(?<url>(?<protocol>https?://)" + @"(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + @"(?<path>/[a-z0-9!*//();:&=+$/%#\-_.,~@]*[a-z0-9)=#/]?)?" + @"(?<query>\?[a-z0-9!*//();:&=+$/%#\-_.,~@?]*[a-z0-9_&=#/])?)"; // 正規表現にマッチしたURL文字列をtinyurl化 foreach (Match mt in Regex.Matches(StatusText.Text, url, RegexOptions.IgnoreCase)) { if (StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal) == -1) continue; string tmp = mt.Result("${url}"); if (tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase)) tmp = "http://" + tmp; urlUndo undotmp = new urlUndo(); //選んだURLを選択(?) StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length); //nico.ms使用、nicovideoにマッチしたら変換 if (this._cfgCommon.Nicoms && Regex.IsMatch(tmp, nico)) { result = nicoms.Shorten(tmp); } else if (Converter_Type != MyCommon.UrlConverter.Nicoms) { //短縮URL変換 日本語を含むかもしれないのでURLエンコードする try { var srcUri = new Uri(MyCommon.urlEncodeMultibyteChar(tmp)); var resultUri = await ShortUrl.Instance.ShortenUrlAsync(Converter_Type, srcUri); result = resultUri.ToString(); } catch (HttpRequestException e) { // 例外のメッセージが「Response status code does not indicate success: 500 (Internal Server Error).」 // のように長いので「:」が含まれていればそれ以降のみを抽出する var message = e.Message.Split(new[] { ':' }, count: 2).Last(); this.StatusLabel.Text = Converter_Type + ":" + message; continue; } catch (WebApiException e) { this.StatusLabel.Text = Converter_Type + ":" + e.Message; continue; } catch (UriFormatException e) { this.StatusLabel.Text = Converter_Type + ":" + e.Message; continue; } } else { continue; } if (!string.IsNullOrEmpty(result)) { StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length); StatusText.SelectedText = result; //undoバッファにセット undotmp.Before = mt.Result("${url}"); undotmp.After = result; if (urlUndoBuffer == null) { urlUndoBuffer = new List<urlUndo>(); UrlUndoToolStripMenuItem.Enabled = true; } urlUndoBuffer.Add(undotmp); } } } return true; }
private void GetEventNotifyFlag(ref MyCommon.EVENTTYPE eventnotifyflag, ref MyCommon.EVENTTYPE isMyeventnotifyflag) { MyCommon.EVENTTYPE evt = MyCommon.EVENTTYPE.None; MyCommon.EVENTTYPE myevt = MyCommon.EVENTTYPE.None; foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable()) { switch (tbl.CheckBox.CheckState) { case CheckState.Checked: evt = evt | tbl.Type; myevt = myevt | tbl.Type; break; case CheckState.Indeterminate: evt = evt | tbl.Type; break; case CheckState.Unchecked: break; } } eventnotifyflag = evt; isMyeventnotifyflag = myevt; }
/// <summary> /// 指定された短縮URLサービスを使用してURLを短縮します /// </summary> /// <param name="shortenerType">使用する短縮URLサービス</param> /// <param name="srcUri">短縮するURL</param> /// <returns>短縮されたURL</returns> public async Task<Uri> ShortenUrlAsync(MyCommon.UrlConverter shortenerType, Uri srcUri) { // 既に短縮されている状態のURLであれば短縮しない if (ShortUrlHosts.Contains(srcUri.Host)) return srcUri; try { switch (shortenerType) { case MyCommon.UrlConverter.TinyUrl: return await this.ShortenByTinyUrlAsync(srcUri) .ConfigureAwait(false); case MyCommon.UrlConverter.Isgd: return await this.ShortenByIsgdAsync(srcUri) .ConfigureAwait(false); case MyCommon.UrlConverter.Twurl: return await this.ShortenByTwurlAsync(srcUri) .ConfigureAwait(false); case MyCommon.UrlConverter.Bitly: return await this.ShortenByBitlyAsync(srcUri, "bit.ly") .ConfigureAwait(false); case MyCommon.UrlConverter.Jmp: return await this.ShortenByBitlyAsync(srcUri, "j.mp") .ConfigureAwait(false); case MyCommon.UrlConverter.Uxnu: return await this.ShortenByUxnuAsync(srcUri) .ConfigureAwait(false); default: throw new ArgumentException("Unknown shortener.", "shortenerType"); } } catch (OperationCanceledException) { // 短縮 URL の API がタイムアウトした場合 return srcUri; } }
public string GetDirectMessageApi(bool read, MyCommon.WORKERTYPE gType, bool more) { if (MyCommon._endingFlag) return string.Empty; if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty; if (MyCommon.TwitterApiInfo.AccessLevel != ApiAccessLevel.None) { if (!MyCommon.TwitterApiInfo.IsDirectMessagePermission) return "Auth Err:try to re-authorization."; } HttpStatusCode res = HttpStatusCode.BadRequest; var content = string.Empty; try { if (gType == MyCommon.WORKERTYPE.DirectMessegeRcv) { if (more) { res = twCon.DirectMessages(20, minDirectmessage, 0, ref content); } else { res = twCon.DirectMessages(20, 0, 0, ref content); } } else { if (more) { res = twCon.DirectMessagesSent(20, minDirectmessageSent, 0, ref content); } else { res = twCon.DirectMessagesSent(20, 0, 0, ref content); } } } catch(Exception ex) { return "Err:" + ex.Message; } switch (res) { case HttpStatusCode.OK: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid; break; case HttpStatusCode.Unauthorized: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid; return Properties.Resources.Unauthorized; case HttpStatusCode.BadRequest: return "Err:API Limits?"; default: return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")"; } return CreateDirectMessagesFromJson(content, gType, read); }
public TabClass GetTabByType(MyCommon.TabUsageType tabType) { //Home,Mentions,DM,Favは1つに制限する //その他のタイプを指定されたら、最初に合致したものを返す //合致しなければnullを返す lock (LockObj) { foreach (var tab in _tabs.Values) { if (tab.TabType == tabType) return tab; } return null; } }
public string GetTimelineApi(bool read, MyCommon.WORKERTYPE gType, bool more, bool startup) { if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty; if (MyCommon._endingFlag) return string.Empty; HttpStatusCode res; var content = string.Empty; var count = AppendSettingDialog.Instance.CountApi; if (gType == MyCommon.WORKERTYPE.Reply) count = AppendSettingDialog.Instance.CountApiReply; if (AppendSettingDialog.Instance.UseAdditionalCount) { if (more && AppendSettingDialog.Instance.MoreCountApi != 0) { count = AppendSettingDialog.Instance.MoreCountApi; } else if (startup && AppendSettingDialog.Instance.FirstCountApi != 0 && gType == MyCommon.WORKERTYPE.Timeline) { count = AppendSettingDialog.Instance.FirstCountApi; } } try { if (gType == MyCommon.WORKERTYPE.Timeline) { if (more) { res = twCon.HomeTimeline(count, this.minHomeTimeline, 0, ref content); } else { res = twCon.HomeTimeline(count, 0, 0, ref content); } } else { if (more) { res = twCon.Mentions(count, this.minMentions, 0, ref content); } else { res = twCon.Mentions(count, 0, 0, ref content); } } } catch(Exception ex) { return "Err:" + ex.Message; } switch (res) { case HttpStatusCode.OK: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid; break; case HttpStatusCode.Unauthorized: Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid; return Properties.Resources.Unauthorized; case HttpStatusCode.BadRequest: return "Err:API Limits?"; default: return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")"; } if (gType == MyCommon.WORKERTYPE.Timeline) { return CreatePostsFromJson(content, gType, null, read, count, ref this.minHomeTimeline); } else { return CreatePostsFromJson(content, gType, null, read, count, ref this.minMentions); } }
public List<TabClass> GetTabsByType(MyCommon.TabUsageType tabType) { //合致したタブをListで返す //合致しなければ空のListを返す lock (LockObj) { var tbs = new List<TabClass>(); foreach (var tb in _tabs.Values) { if ((tabType & tb.TabType) == tb.TabType) tbs.Add(tb); } return tbs; } }
private string CreatePostsFromJson(string content, MyCommon.WORKERTYPE gType, TabClass tab, bool read, int count, ref long minimumId) { List<TwitterDataModel.Status> items; try { items = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content); } catch(SerializationException ex) { MyCommon.TraceOut(ex.Message + Environment.NewLine + content); return "Json Parse Error(DataContractJsonSerializer)";; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); return "Invalid Json!"; } foreach (var status in items) { PostClass post = null; post = CreatePostsFromStatusData(status); if (post == null) continue; if (minimumId > post.StatusId) minimumId = post.StatusId; //二重取得回避 lock (LockObj) { if (tab == null) { if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue; } else { if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue; } } //RT禁止ユーザーによるもの if (post.RetweetedId > 0 && this.noRTId.Contains(post.RetweetedByUserId)) continue; post.IsRead = read; if (post.IsMe && !read && _readOwnPost) post.IsRead = true; if (tab != null) post.RelTabName = tab.TabName; //非同期アイコン取得&StatusDictionaryに追加 TabInformations.GetInstance().AddPost(post); } return string.Empty; }
public TabClass(string TabName, MyCommon.TabUsageType TabType, ListElement list) : this() { this.TabName = TabName; this.TabType = TabType; this.ListInfo = list; }
public EventTypeTableElement(string name, MyCommon.EVENTTYPE type) { this.Name = name; this.Type = type; }
/// <exception cref="SerializationException"/> public static TwitterDirectMessage ParseJson(string json) { return(MyCommon.CreateDataFromJson <TwitterDirectMessage>(json)); }