public async Task ShowThumbnailAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(0, thumbbox.scrollBar.Maximum); Assert.False(thumbbox.scrollBar.Enabled); Assert.Equal(1, thumbbox.pictureBox.Count); Assert.NotNull(thumbbox.pictureBox[0].Image); Assert.IsAssignableFrom <ThumbnailInfo>(thumbbox.pictureBox[0].Tag); var thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[0].Tag; Assert.Equal("http://foo.example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("http://img.example.com/abcd.png", thumbinfo.ThumbnailUrl); Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0])); } }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) { return(null); } using (var client = new OTWebClient()) using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(client.DownloadData(apiUrl), XmlDictionaryReaderQuotas.Max)) { var xElm = XElement.Load(jsonReader); var thumbUrlElm = xElm.XPathSelectElement("/response/post/thumb_url"); if (thumbUrlElm == null) { return(null); } var textElm = xElm.XPathSelectElement("/response/post/text"); return(new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbUrlElm.Value, TooltipText = textElm == null ? null : textElm.Value, }); } }
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, }; try { 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(); } } catch (HttpRequestException) { } // たまに api.tumblr.com が名前解決できない return null; }
public override async Task <ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { // ツイートに位置情報が付与されている場合は何もしない if (post.PostGeo != null) { return(null); } var location = await this.FetchCheckinLocation(url, token) .ConfigureAwait(false); if (location == null) { location = await this.FetchCheckinLocationLegacy(url, token) .ConfigureAwait(false); } if (location != null) { var map = MapThumb.GetDefaultInstance(); return(await map.GetThumbnailInfoAsync(new PostClass.StatusGeo(location.Longitude, location.Latitude)) .ConfigureAwait(false)); } return(null); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) { return(null); } var xdoc = this.FetchContentInfoApi(apiUrl); if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value == "ok") { var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150"); if (thumbUrlElm != null) { var descElm = xdoc.XPathSelectElement("/rsp/content/description"); return(new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbUrlElm.Attribute("url").Value, TooltipText = descElm == null ? null : descElm.Value, }); } } return(null); }
public void EnqueueRemovePost_SetIsDeletedTest() { var tab = new PublicSearchTabModel("search") { UnreadManage = true, }; var post = new PostClass { StatusId = 100L, IsRead = false }; tab.AddPostQueue(post); tab.AddSubmit(); Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); tab.EnqueueRemovePost(100L, setIsDeleted: true); // この時点ではタブからの削除は行われないが、PostClass.IsDeleted は true にセットされる Assert.Equal(1, tab.AllCount); Assert.Equal(1, tab.UnreadCount); Assert.True(post.IsDeleted); var removedIds = tab.RemoveSubmit(); Assert.Equal(0, tab.AllCount); Assert.Equal(0, tab.UnreadCount); Assert.Equal(new[] { 100L }, removedIds.AsEnumerable()); }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { // 前処理で動画用URLが準備されていればそれを使う var mediaInfo = post.Media.FirstOrDefault(x => x.Url == url); if (mediaInfo.VideoUrl != null) { return new ThumbnailInfo { ImageUrl = mediaInfo.VideoUrl, ThumbnailUrl = url, IsPlayable = true, }; } // amp.twimg.com のメタデータからサムネイル用URLを取得する var thumbInfo = await base.GetThumbnailInfoAsync(url, post, token) .ConfigureAwait(false); if (thumbInfo != null) { thumbInfo.IsPlayable = true; return thumbInfo; } return null; }
public void CloneTest() { var post = new PostClass(); var clonePost = post.Clone(); TestUtils.CheckDeepCloning(post, clonePost); }
public void ShowThumbnailAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new Dictionary <string, string> { { "http://foo.example.com/abcd", "http://foo.example.com/abcd" }, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(0)); Assert.That(thumbbox.scrollBar.Enabled, Is.False); Assert.That(thumbbox.pictureBox.Count, Is.EqualTo(1)); Assert.That(thumbbox.pictureBox[0].ImageLocation, Is.EqualTo("dot.gif")); var thumbinfo = thumbbox.pictureBox[0].Tag as ThumbnailInfo; Assert.That(thumbinfo, Is.Not.Null); Assert.That(thumbinfo.ImageUrl, Is.EqualTo("http://foo.example.com/abcd")); Assert.That(thumbinfo.ThumbnailUrl, Is.EqualTo("dot.gif")); Assert.That(thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0]), Is.EqualTo("")); } }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) return null; using (var client = new OTWebClient()) using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(client.DownloadData(apiUrl), XmlDictionaryReaderQuotas.Max)) { var xElm = XElement.Load(jsonReader); var thumbUrlElm = xElm.XPathSelectElement("/response/post/thumb_url"); if (thumbUrlElm == null) { return null; } var textElm = xElm.XPathSelectElement("/response/post/text"); return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbUrlElm.Value, TooltipText = textElm == null ? null : textElm.Value, }; } }
public NewPostForm(RiverClass[] rivers) { this.InitializeComponent(); this.post = (PostClass)null; this.comboBox1.DataSource = (object)((IEnumerable <RiverClass>)rivers).OrderBy <RiverClass, string>((Func <RiverClass, string>)(x => x.Name)).ToList <RiverClass>(); this.comboBox1.DisplayMember = "Name"; }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { var match = Tinami.UrlPatternRegex.Match(url); if (!match.Success) return null; var contentId = match.Groups["ContentId"].Value; try { var xdoc = await this.FetchContentInfoApiAsync(contentId, token) .ConfigureAwait(false); if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value != "ok") return null; var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150"); if (thumbUrlElm == null) return null; var descElm = xdoc.XPathSelectElement("/rsp/content/description"); return new ThumbnailInfo { MediaPageUrl = url, ThumbnailImageUrl = thumbUrlElm.Attribute("url").Value, TooltipText = descElm == null ? null : descElm.Value, }; } catch (HttpRequestException) { } return null; }
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 List<ThumbnailInfo> GetThumbnails(PostClass post) { var thumbnails = new List<ThumbnailInfo>(); if (post.Media != null) { foreach (var media in post.Media) { var thumbInfo = ThumbnailGenerator.GetThumbnailInfo(media.Value, post); if (thumbInfo != null) { thumbnails.Add(thumbInfo); } } } if (post.PostGeo != null && !(post.PostGeo.Lat == 0 && post.PostGeo.Lng == 0)) { var map = MapThumb.GetDefaultInstance(); thumbnails.Add(new ThumbnailInfo() { ImageUrl = map.CreateMapLinkUrl(post.PostGeo.Lat, post.PostGeo.Lng), ThumbnailUrl = map.CreateStaticMapUrl(post.PostGeo.Lat, post.PostGeo.Lng), TooltipText = null, }); } return thumbnails; }
public static async Task <IEnumerable <ThumbnailInfo> > GetThumbnailsAsync(PostClass post, CancellationToken token) { var thumbnails = new List <ThumbnailInfo>(); var expandedUrls = Enumerable.Concat( post.GetExpandedUrls(), post.Media.Select(x => x.Url)); foreach (var expandedUrl in expandedUrls) { var thumbInfo = await ThumbnailGenerator.GetThumbnailInfoAsync(expandedUrl, post, token) .ConfigureAwait(false); if (thumbInfo != null) { thumbnails.Add(thumbInfo); } token.ThrowIfCancellationRequested(); } if (post.PostGeo != null) { var map = MapThumb.GetDefaultInstance(); var thumb = await map.GetThumbnailInfoAsync(post.PostGeo.Value) .ConfigureAwait(false); thumbnails.Add(thumb); } return(thumbnails); }
public static List <ThumbnailInfo> GetThumbnails(PostClass post) { var thumbnails = new List <ThumbnailInfo>(); if (post.Media != null) { foreach (var media in post.Media) { var thumbInfo = ThumbnailGenerator.GetThumbnailInfo(media.Value, post); if (thumbInfo != null) { thumbnails.Add(thumbInfo); } } } if (post.PostGeo != null && !(post.PostGeo.Lat == 0 && post.PostGeo.Lng == 0)) { var map = MapThumb.GetDefaultInstance(); thumbnails.Add(new ThumbnailInfo() { ImageUrl = map.CreateMapLinkUrl(post.PostGeo.Lat, post.PostGeo.Lng), ThumbnailUrl = map.CreateStaticMapUrl(post.PostGeo.Lat, post.PostGeo.Lng), TooltipText = null, }); } return(thumbnails); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) return null; var xdoc = this.FetchContentInfoApi(apiUrl); if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value == "ok") { var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150"); if (thumbUrlElm != null) { var descElm = xdoc.XPathSelectElement("/rsp/content/description"); return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbUrlElm.Attribute("url").Value, TooltipText = descElm == null ? null : descElm.Value, }; } } return null; }
public override async Task <ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { // 前処理で動画用URLが準備されていればそれを使う var mediaInfo = post.Media.FirstOrDefault(x => x.Url == url); if (mediaInfo?.VideoUrl != null) { return(new ThumbnailInfo { MediaPageUrl = mediaInfo.VideoUrl, ThumbnailImageUrl = url, TooltipText = mediaInfo.AltText, IsPlayable = true, }); } // amp.twimg.com のメタデータからサムネイル用URLを取得する var thumbInfo = await base.GetThumbnailInfoAsync(url, post, token) .ConfigureAwait(false); if (thumbInfo != null) { thumbInfo.IsPlayable = true; return(thumbInfo); } return(null); }
public static async Task <IEnumerable <ThumbnailInfo> > GetThumbnailsAsync(PostClass post, CancellationToken token) { var thumbnails = new List <ThumbnailInfo>(); if (post.Media != null) { foreach (var media in post.Media) { var thumbInfo = await ThumbnailGenerator.GetThumbnailInfoAsync(media, post, token) .ConfigureAwait(false); if (thumbInfo != null) { thumbnails.Add(thumbInfo); } token.ThrowIfCancellationRequested(); } } if (post.PostGeo != null && !(post.PostGeo.Lat == 0 && post.PostGeo.Lng == 0)) { var map = MapThumb.GetDefaultInstance(); thumbnails.Add(new ThumbnailInfo() { ImageUrl = map.CreateMapLinkUrl(post.PostGeo.Lat, post.PostGeo.Lng), ThumbnailUrl = map.CreateStaticMapUrl(post.PostGeo.Lat, post.PostGeo.Lng), TooltipText = null, }); } return(thumbnails); }
private void tSBDelete_Click(object sender, EventArgs e) { try { if (this.dgvPostList.SelectedRows.Count < 1) { return; } this.post = new PostClass() { Id = (int)this.dgvPostList.SelectedRows[0].Cells[0].Value, Status = (byte)2 }; this.dgvPostList.Rows.RemoveAt(this.dgvPostList.SelectedRows[0].Index); // ISSUE: reference to a compiler-generated field if (this.GetChangePost == null) { return; } // ISSUE: reference to a compiler-generated field this.GetChangePost((object)this, e); } catch (Exception ex) { int num = (int)MessageBox.Show(ex.ToString()); } }
private void tSBEditing_Click(object sender, EventArgs e) { try { if (this.dgvPostList.SelectedRows.Count < 1) { return; } this.post = new PostClass() { Id = (int)this.dgvPostList.SelectedRows[0].Cells[0].Value, NumberControl = (int)this.dgvPostList.SelectedRows[0].Cells[2].Value, NameObject = (string)this.dgvPostList.SelectedRows[0].Cells[3].Value, NameObserve = (string)this.dgvPostList.SelectedRows[0].Cells[4].Value, Distance = (double)this.dgvPostList.SelectedRows[0].Cells[5].Value, Administer = (string)this.dgvPostList.SelectedRows[0].Cells[6].Value, NumberFolds = (int)this.dgvPostList.SelectedRows[0].Cells[7].Value, LocationFold = (string)this.dgvPostList.SelectedRows[0].Cells[8].Value, Vertical = (string)this.dgvPostList.SelectedRows[0].Cells[9].Value, Horizantal = (string)this.dgvPostList.SelectedRows[0].Cells[10].Value, Date = (int)this.dgvPostList.SelectedRows[0].Cells[11].Value, Status = (byte)1, River_Id = (int)this.dgvPostList.SelectedRows[0].Cells[13].Value }; NewPostForm newPostForm = new NewPostForm(this.post, this.rivers.ToArray()); newPostForm.GetPost += new EventHandler(this.GetPost); int num = (int)newPostForm.ShowDialog(); } catch (Exception ex) { int num = (int)MessageBox.Show(ex.ToString()); } }
public void EmptyRuleTest() { var filter = new PostFilterRule { }; var post = new PostClass { ScreenName = "hogehoge" }; Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post)); }
public override async Task <ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { if (!this.regex.IsMatch(url)) { return(null); } try { var content = await this.FetchImageUrlAsync(url, token) .ConfigureAwait(false); var thumbnailUrl = this.GetThumbnailUrl(content); if (string.IsNullOrEmpty(thumbnailUrl)) { return(null); } return(new ThumbnailInfo { ImageUrl = url, ThumbnailUrl = thumbnailUrl, TooltipText = null, }); } catch (HttpRequestException) { } return(null); }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { // ツイートに位置情報が付与されている場合は何もしない if (post.PostGeo != null) return null; var location = await this.FetchCheckinLocation(url, token) .ConfigureAwait(false); if (location == null) { location = await this.FetchCheckinLocationLegacy(url, token) .ConfigureAwait(false); } if (location != null) { var map = MapThumb.GetDefaultInstance(); return await map.GetThumbnailInfoAsync(new PostClass.StatusGeo(location.Longitude, location.Latitude)) .ConfigureAwait(false); } return null; }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) return null; var xdoc = XDocument.Load(apiUrl); var thumbUrlElm = xdoc.XPathSelectElement("/oembed/thumbnail_url"); if (thumbUrlElm != null) { var titleElm = xdoc.XPathSelectElement("/oembed/title"); var durationElm = xdoc.XPathSelectElement("/oembed/duration"); var tooltipText = ""; if (titleElm != null && durationElm != null) { var duration = int.Parse(durationElm.Value); var minute = duration / 60; var second = duration % 60; tooltipText = string.Format("{0} ({1:00}:{2:00})", titleElm.Value, minute, second); } return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbUrlElm.Value, TooltipText = tooltipText, }; } return null; }
public override Task <ThumbnailInfo?> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { return(Task.Run <ThumbnailInfo?>(() => { if (GetApiConnection == null) { return null; } if (!url.StartsWith(@"https://ton.twitter.com/1.1/ton/data/", StringComparison.Ordinal)) { return null; } var largeUrl = url + ":large"; return new TonTwitterCom.Thumbnail { MediaPageUrl = largeUrl, ThumbnailImageUrl = url, TooltipText = null, FullSizeImageUrl = largeUrl, }; }, token)); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var match = this.regex.Match(url); if (!match.Success) { return(null); } if (!AppendSettingDialog.Instance.IsPreviewFoursquare) { return(null); } if (post.PostGeo.Lat != 0 | post.PostGeo.Lng != 0) { return(null); } var tipsText = ""; var mapUrl = OpenTween.Foursquare.GetInstance.GetMapsUri(url, ref tipsText); if (mapUrl == null) { return(null); } return(new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = mapUrl, TooltipText = tipsText, }); }
public async Task GetThumbnailInfoAsync_GeoLocatedTweetTest() { var handler = new HttpMessageHandlerMock(); using (var http = new HttpClient(handler)) { var service = new FoursquareCheckin(http); handler.Enqueue(x => { // このリクエストは実行されないはず Assert.True(false); return(new HttpResponseMessage(HttpStatusCode.NotFound)); }); // 既にジオタグが付いているツイートに対しては何もしない var post = new PostClass { PostGeo = new PostClass.StatusGeo(134.04693603515625, 34.35067978344854), }; await service.GetThumbnailInfoAsync( "https://www.swarmapp.com/c/xxxxxxxx", post, CancellationToken.None); Assert.Equal(1, handler.QueueCount); } }
public void IsMuted_MuteTabRules_NotInHomeTimelineTest() { this.tabinfo.MuteUserIds = new HashSet <long> { }; this.tabinfo.AddTab("Mute", MyCommon.TabUsageType.Mute, null); var muteTab = this.tabinfo.Tabs["Mute"]; muteTab.AddFilter(new PostFilterRule { FilterName = "foo", MoveMatches = true, }); // ミュートタブによるミュートは Recent 以外のタブも対象とする var post = new PostClass { UserId = 12345L, ScreenName = "foo", Text = "hogehoge", RelTabName = "Search", }; Assert.True(this.tabinfo.IsMuted(post)); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { lock (this.LockObj) { if (this.UrlRegex == null) { return(null); } foreach (var regex in this.UrlRegex) { if (regex.IsMatch(url)) { return(new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = this.ApiBase + "redirect?size=large&uri=" + Uri.EscapeDataString(url), TooltipText = null, }); } } } return(null); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var pageUrl = this.ReplaceUrl(url); if (pageUrl == null) { return(null); } var content = this.FetchImageUrl(pageUrl); var thumbnailUrl = this.GetThumbnailUrl(content); if (string.IsNullOrEmpty(thumbnailUrl)) { return(null); } return(new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbnailUrl, TooltipText = null, }); }
private void GetPost(object sender, EventArgs e) { try { this.post = (sender as NewPostForm).post; if (this.post == null) { return; } if ((int)this.post.Status == 0) { // ISSUE: reference to a compiler-generated field if (this.GetChangePost != null) { // ISSUE: reference to a compiler-generated field this.GetChangePost((object)this, e); } //this.post.Id = Form1.StaticId; if (this.post.Id < 0) { return; } this.post.Status = (byte)4; this.dgvPostList.Rows.Add((object)this.post.Id, (object)(this.dgvPostList.RowCount + 1), (object)this.post.NumberControl, (object)this.post.NameObject, (object)this.post.NameObserve, (object)this.post.Distance, (object)this.post.Administer, (object)this.post.NumberFolds, (object)this.post.LocationFold, (object)this.post.Vertical, (object)this.post.Horizantal, (object)this.post.Date, (object)this.post.Status, (object)this.post.River_Id); } else { this.post.Status = (byte)1; // ISSUE: reference to a compiler-generated field if (this.GetChangePost != null) { // ISSUE: reference to a compiler-generated field this.GetChangePost((object)this, e); } this.post.Status = (byte)4; if (Form1.StaticId < 0) { return; } this.dgvPostList.SelectedRows[0].Cells[2].Value = (object)this.post.NumberControl; this.dgvPostList.SelectedRows[0].Cells[3].Value = (object)this.post.NameObject; this.dgvPostList.SelectedRows[0].Cells[4].Value = (object)this.post.NameObserve; this.dgvPostList.SelectedRows[0].Cells[5].Value = (object)this.post.Distance; this.dgvPostList.SelectedRows[0].Cells[6].Value = (object)this.post.Administer; this.dgvPostList.SelectedRows[0].Cells[7].Value = (object)this.post.NumberFolds; this.dgvPostList.SelectedRows[0].Cells[8].Value = (object)this.post.LocationFold; this.dgvPostList.SelectedRows[0].Cells[9].Value = (object)this.post.Vertical; this.dgvPostList.SelectedRows[0].Cells[10].Value = (object)this.post.Horizantal; this.dgvPostList.SelectedRows[0].Cells[11].Value = (object)this.post.Date; this.dgvPostList.SelectedRows[0].Cells[12].Value = (object)this.post.Status; this.dgvPostList.SelectedRows[0].Cells[13].Value = (object)this.post.River_Id; } this.post = (PostClass)null; } catch (Exception ex) { int num = (int)MessageBox.Show(ex.ToString()); } }
public Task ShowThumbnailAsync(PostClass post) { this.CancelAsync(); this.scrollBar.Enabled = false; this.cancelTokenSource = new CancellationTokenSource(); var cancelToken = this.cancelTokenSource.Token; this.task = Task.Factory.StartNew(() => ThumbnailGenerator.GetThumbnails(post), cancelToken) .ContinueWith( /* await使いたい */ t => { var thumbnails = t.Result; this.SetThumbnailCount(thumbnails.Count); if (thumbnails.Count == 0) { return; } for (int i = 0; i < thumbnails.Count; i++) { var thumb = thumbnails[i]; var picbox = this.pictureBox[i]; picbox.Tag = thumb; picbox.LoadAsync(thumb.ThumbnailUrl); var tooltipText = thumb.TooltipText; if (!string.IsNullOrEmpty(tooltipText)) { this.toolTip.SetToolTip(picbox, tooltipText); } cancelToken.ThrowIfCancellationRequested(); } this.pictureBox[0].Visible = true; this.scrollBar.Maximum = thumbnails.Count - 1; if (thumbnails.Count > 1) { this.scrollBar.Enabled = true; } if (this.ThumbnailLoading != null) { this.ThumbnailLoading(this, new EventArgs()); } }, cancelToken, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext() ); return(this.task); }
/// <summary> /// 菜单拖拽 /// </summary> /// <param name="PostClass">{dropOID:'拖拽节点OID',targetOID:'目标节点OID',dropPosition:'拖拽位置(参照目标节点)"before"之前,"after"之后,"append"之内'}</param> /// <returns>true/false</returns> public bool PostDrop(PostClass PostClass) { dynamic param = Common.NewtonJsonHelper.Deserialize <dynamic>(PostClass.PostData, null); string dropOID = param.dropOID.ToString(); string targetOID = param.targetOID.ToString(); string dropPosition = param.dropPosition.ToString(); return(_service.DropWithTree(dropOID, targetOID, dropPosition)); }
/// <summary> /// 根据用户名和邮箱找回密码 /// </summary> /// <param name="UserName"></param> /// <param name="Email"></param> /// <returns></returns> public object PostSendEmailSave(PostClass PostClass) { dynamic d = Common.NewtonJsonHelper.Deserialize <object>(PostClass.PostData.ToString(), null); string UserName = Convert.ToString(d.UserName); string Email = Convert.ToString(d.Email);; string Random = Convert.ToString(d.Random);; return(_authBll.PostSendEmailSave(UserName, Email, Random)); }
public ActionResult <PostClass> Put(int id, [FromBody] PostUpdateRequestClass request) { PostClass post = _context.Posts.First(p => p.Id == id); post.Text = request.Text; post.Heading = request.Heading; _context.SaveChanges(); return(post); }
public void Delete(int id) { PostClass post = new PostClass { Id = id }; _context.Posts.Remove(post); _context.SaveChanges(); }
public override void AddPostQueue(PostClass post) { if (TabInformations.GetInstance().IsMuted(post, isHomeTimeline: false)) return; this.internalPosts.TryAdd(post.StatusId, post); base.AddPostQueue(post); }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { // ツイートに位置情報が付与されている場合は何もしない if (post.PostGeo.Lat != 0 || post.PostGeo.Lng != 0) return null; var match = UrlPatternRegex.Match(url); if (!match.Success) return null; var checkinIdGroup = match.Groups["checkin_id"]; var signatureGroup = match.Groups["signature"]; try { // Foursquare のベニュー情報を取得 // 参照: https://developer.foursquare.com/docs/venues/venues var query = new Dictionary<string, string> { {"client_id", ApplicationSettings.FoursquareClientId}, {"client_secret", ApplicationSettings.FoursquareClientSecret}, {"v", "20140419"}, // https://developer.foursquare.com/overview/versioning }; if (signatureGroup.Success) query["signature"] = signatureGroup.Value; var apiUrl = new Uri(ApiBase + "/checkins/" + checkinIdGroup.Value + "?" + MyCommon.BuildQueryString(query)); using (var response = await this.http.GetAsync(apiUrl, token).ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); var jsonBytes = await response.Content.ReadAsByteArrayAsync() .ConfigureAwait(false); var location = ParseIntoLocation(jsonBytes); if (location == null) return null; var map = MapThumb.GetDefaultInstance(); return new ThumbnailInfo { ImageUrl = map.CreateMapLinkUrl(location.Latitude, location.Longitude), ThumbnailUrl = map.CreateStaticMapUrl(location.Latitude, location.Longitude), TooltipText = null, }; } } catch (HttpRequestException) { } return null; }
public async new Task ShowThumbnailAsync(PostClass post, CancellationToken cancelToken) { var loadTasks = new List <Task>(); Invoke((MethodInvoker)(() => { this.scrollBar.Enabled = false; this.scrollBar.Visible = false; })); if (post.ExpandedUrls.Length == 0 && post.Media.Count == 0 && post.PostGeo == null) { this.SetThumbnailCount(0); return; } var thumbnails = (await this.GetThumbailInfoAsync(post, cancelToken)) .ToArray(); cancelToken.ThrowIfCancellationRequested(); this.SetThumbnailCount(thumbnails.Length); if (thumbnails.Length == 0) { return; } for (int i = 0; i < thumbnails.Length; i++) { var thumb = thumbnails[i]; var picbox = this.pictureBox[i]; picbox.Tag = thumb; picbox.Dock = DockStyle.Fill; //picbox.ContextMenuStrip = this.ContextMenuStrip; //FullSizeImageUrlが使える場合は,ThumbnailUrlを置き換える if (thumb.FullSizeImageUrl != null) { thumb.ThumbnailImageUrl = thumb.FullSizeImageUrl; } var loadTask = picbox.SetImageFromTask(() => thumb.LoadThumbnailImageAsync(cancelToken)); loadTasks.Add(loadTask); var tooltipText = thumb.TooltipText; if (!string.IsNullOrEmpty(tooltipText)) { this.toolTip.SetToolTip(picbox, tooltipText); picbox.AccessibleDescription = tooltipText; } cancelToken.ThrowIfCancellationRequested(); } await Task.WhenAll(loadTasks); }
public ActionResult <PostClass> Post([FromBody] PostCreateRequestClass request) { PostClass post = new PostClass { Heading = request.Heading, Text = request.Text }; _context.Posts.Add(post); _context.SaveChanges(); return(post); }
/// <summary> /// 更新图片 /// </summary> /// <param name="PostClass"></param> /// <returns></returns> //public object PhotoUpdate(PostClass PostClass) //{ // string name = Tools.SessionHelper.GetSession<Base_UserInfo>(Tools.SessionHelper.SessinoName.CurUser).UserName; // bool res = false; // dynamic dy = Common.NewtonJsonHelper.Deserialize<dynamic>(PostClass.PostData.ToString(), null); // foreach (var item in dy) // { // object s = item; // } // string imgData = dy.dataUrl; // string imgUrl = dy.imgUrl; // string imgName = dy.dataName; // Base_UserInfo UserInfo = _userInfoBll.FindBy(t => t.UserName == name).ToList<Base_UserInfo>().FirstOrDefault(); // if (UserInfo != null) // { // string photo = Tools.ImgHelper.ImgUpload(imgData, imgUrl, imgName); // UserInfo.BusinessImg = photo; // res = _userInfoBll.SaveOrUpdate(UserInfo); // } // return res; //} /// <summary> /// 上传图片获取图片路径 /// </summary> /// <param name="PostClass"></param> /// <returns>图片路径</returns> public object UploadPhoto(PostClass PostClass) { dynamic dy = Common.NewtonJsonHelper.Deserialize <dynamic>(PostClass.PostData.ToString(), null); string imgData = dy.dataUrl; string imgUrl = dy.imgUrl; string imgName = dy.dataName; string ImgUrl = Tools.ImgHelper.ImgUpload(imgData, imgUrl, imgName); return(ImgUrl); }
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(PostClass.StatusGeo geo) { var thumb = new ThumbnailInfo { MediaPageUrl = this.CreateMapLinkUrl(geo.Latitude, geo.Longitude), ThumbnailImageUrl = this.CreateStaticMapUrl(geo.Latitude, geo.Longitude), TooltipText = null, }; return Task.FromResult(thumb); }
//フィルタに合致したら追加 public MyCommon.HITRESULT AddFiltered(PostClass post, bool immediately = false) { if (this.IsInnerStorageTabType) return MyCommon.HITRESULT.None; var rslt = MyCommon.HITRESULT.None; //全フィルタ評価(優先順位あり) lock (this.lockObjFilters) { foreach (var ft in _filters) { try { switch (ft.ExecFilter(post)) //フィルタクラスでヒット判定 { case MyCommon.HITRESULT.None: break; case MyCommon.HITRESULT.Copy: if (rslt != MyCommon.HITRESULT.CopyAndMark) rslt = MyCommon.HITRESULT.Copy; break; case MyCommon.HITRESULT.CopyAndMark: rslt = MyCommon.HITRESULT.CopyAndMark; break; case MyCommon.HITRESULT.Move: rslt = MyCommon.HITRESULT.Move; break; case MyCommon.HITRESULT.Exclude: rslt = MyCommon.HITRESULT.Exclude; goto exit_for; } } catch (NullReferenceException) { // ExecFilterでNullRef出る場合あり。暫定対応 MyCommon.TraceOut("ExecFilterでNullRef: " + ft); rslt = MyCommon.HITRESULT.None; } } exit_for: ; } if (this.TabType != MyCommon.TabUsageType.Mute && rslt != MyCommon.HITRESULT.None && rslt != MyCommon.HITRESULT.Exclude) { if (immediately) this.AddPostImmediately(post.StatusId, post.IsRead); else this.AddPostQueue(post); } return rslt; //マーク付けは呼び出し元で行うこと }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var thumbnailUrl = this.ReplaceUrl(url); if (thumbnailUrl == null) return null; return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbnailUrl, TooltipText = null, }; }
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(PostClass.StatusGeo geo) { var size = new Size(SettingCommon.Instance.MapThumbnailWidth, SettingCommon.Instance.MapThumbnailHeight); var zoom = SettingCommon.Instance.MapThumbnailZoom; var thumb = new OSMThumbnailInfo(geo.Latitude, geo.Longitude, zoom, size) { MediaPageUrl = this.CreateMapLinkUrl(geo.Latitude, geo.Longitude), }; return Task.FromResult((ThumbnailInfo)thumb); }
public static ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { foreach (var generator in ThumbnailGenerator.Services) { var result = generator.GetThumbnailInfo(url, post); if (result != null) { return result; } } return null; }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var thumb = base.GetThumbnailInfo(url, post); if (thumb == null) return null; return new Pixiv.Thumbnail { ImageUrl = thumb.ImageUrl, ThumbnailUrl = thumb.ThumbnailUrl, TooltipText = thumb.TooltipText, FullSizeImageUrl = thumb.FullSizeImageUrl, }; }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var match = this.regex.Match(url); if (!match.Success) return null; return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = "http://images.bcphotoshare.com/storages/" + RadixConvert.ToInt32(match.Result("${1}"), 36) + "/thumb180.jpg", TooltipText = null, }; }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var http = new HttpVarious(); var TargetUrl = url; var tmp = http.GetRedirectTo(TargetUrl); while (!TargetUrl.Equals(tmp)) { TargetUrl = tmp; tmp = http.GetRedirectTo(TargetUrl); } var apiUrl = base.ReplaceUrl(url); if (apiUrl == null) return null; var src = ""; string imgurl = null; string errmsg; if (http.GetData(apiUrl, null, out src, 0, out errmsg, "")) { var xdoc = new XmlDocument(); try { xdoc.LoadXml(src); var type = xdoc.SelectSingleNode("/tumblr/posts/post").Attributes["type"].Value; if (type == "photo") { imgurl = xdoc.SelectSingleNode("/tumblr/posts/post/photo-url").InnerText; } else { errmsg = "PostType:" + type; return null; } } catch (Exception) { return null; } return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = imgurl, TooltipText = null, }; } return null; }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { var thumb = await base.GetThumbnailInfoAsync(url, post, token) .ConfigureAwait(false); if (thumb == null) return null; return new Pixiv.Thumbnail { MediaPageUrl = thumb.MediaPageUrl, ThumbnailImageUrl = thumb.ThumbnailImageUrl, TooltipText = thumb.TooltipText, FullSizeImageUrl = thumb.FullSizeImageUrl, }; }
public void NullTest() { var filter = new PostFilterRule { FilterName = null, FilterSource = null, ExFilterName = null, ExFilterSource = null, }; var post = new PostClass { ScreenName = "hogehoge" }; Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post)); Assert.Throws<ArgumentNullException>(() => filter.FilterBody = null); Assert.Throws<ArgumentNullException>(() => filter.ExFilterBody = null); }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { var thumb = await base.GetThumbnailInfoAsync(url, post, token) .ConfigureAwait(false); if (thumb == null) return null; var media = post.Media.FirstOrDefault(x => x.Url == url); if (media != null) { thumb.TooltipText = media.AltText; } return thumb; }
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { return Task.Run(() => { var thumbnailUrl = this.ReplaceUrl(url); if (thumbnailUrl == null) return null; return new ThumbnailInfo { MediaPageUrl = url, ThumbnailImageUrl = thumbnailUrl, TooltipText = null, FullSizeImageUrl = ReplaceUrl(url, this.fullsize_replacement) }; }, token); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { if (InitializeOAuthToken == null) return null; if (!url.StartsWith(@"https://ton.twitter.com/1.1/ton/data/")) return null; return new TonTwitterCom.Thumbnail { ImageUrl = url, ThumbnailUrl = url, TooltipText = null, FullSizeImageUrl = url, }; }
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { return Task.Run(() => { var match = Tumblr.UrlPatternRegex.Match(url); if (!match.Success) return null; var apiUrl = match.Result("${base}api/read?id=${postID}"); var http = new HttpVarious(); var src = ""; string imgurl = null; string errmsg; if (http.GetData(apiUrl, null, out src, 0, out errmsg, "")) { var xdoc = new XmlDocument(); try { xdoc.LoadXml(src); var type = xdoc.SelectSingleNode("/tumblr/posts/post").Attributes["type"].Value; if (type == "photo") { imgurl = xdoc.SelectSingleNode("/tumblr/posts/post/photo-url").InnerText; } else { errmsg = "PostType:" + type; return null; } } catch (Exception) { return null; } return new ThumbnailInfo { ImageUrl = url, ThumbnailUrl = imgurl, TooltipText = null, }; } return null; }, token); }
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post) { var pageUrl = this.ReplaceUrl(url); if (pageUrl == null) return null; var content = this.FetchImageUrl(pageUrl); var thumbnailUrl = this.GetThumbnailUrl(content); if (string.IsNullOrEmpty(thumbnailUrl)) return null; return new ThumbnailInfo() { ImageUrl = url, ThumbnailUrl = thumbnailUrl, TooltipText = null, }; }
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { return Task.Run(() => { var match = PhotoShareShortlink.UrlPatternRegex.Match(url); if (!match.Success) return null; return new ThumbnailInfo { ImageUrl = url, ThumbnailUrl = "http://images.bcphotoshare.com/storages/" + RadixConvert.ToInt32(match.Result("${1}"), 36) + "/thumb180.jpg", TooltipText = null, }; }, token); }
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token) { var match = Vimeo.UrlPatternRegex.Match(url); if (!match.Success) return null; try { var apiUrl = "http://vimeo.com/api/oembed.xml?url=" + Uri.EscapeDataString(url); var xmlStr = await this.http.GetStringAsync(apiUrl) .ConfigureAwait(false); var xdoc = XDocument.Parse(xmlStr); var thumbUrlElm = xdoc.XPathSelectElement("/oembed/thumbnail_url"); if (thumbUrlElm == null) return null; var titleElm = xdoc.XPathSelectElement("/oembed/title"); var durationElm = xdoc.XPathSelectElement("/oembed/duration"); var tooltipText = ""; if (titleElm != null && durationElm != null) { var duration = int.Parse(durationElm.Value); var minute = duration / 60; var second = duration % 60; tooltipText = string.Format("{0} ({1:00}:{2:00})", titleElm.Value, minute, second); } return new ThumbnailInfo { MediaPageUrl = url, ThumbnailImageUrl = thumbUrlElm.Value, TooltipText = tooltipText, IsPlayable = true, }; } catch (HttpRequestException) { } return null; }