private void btnAttachFromUrl_Click_1(object sender, RoutedEventArgs e) { if (_d == null) { return; } InpDialog dlg = new InpDialog(); dlg.ShowDialog(); string URL = dlg.Answer; if (URL == null) { return; } Attachment a = new Attachment(); if (AttachmentManager.ProcessAttachCmd(null, URL, ref a) != null) { a.Discussion = _d; a.Person = getFreshPerson(); insertMedia(a); } }
//attachment from URL, with dialog box private void btnAttachFromUrl_Click_1(object sender, RoutedEventArgs e) { var ap = DataContext as ArgPoint; if (ap == null) { return; } var dlg = new InpDialog(); dlg.ShowDialog(); string URL = dlg.Answer; if (URL == null) { return; } var a = new Attachment(); var imgSrc = AttachmentManager.ProcessAttachCmd(ap, URL, ref a); if (imgSrc != null) { a.Person = ap.Person; ap.ChangesPending = true; UISharedRTClient.Instance.clienRt.SendStatsEvent( AttachmentToEvent(a, false), ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); UpdateOrderedMedia(); BeginAttachmentNumberInjection(); } }
private void AvatarPointDown(bool name) { if (name) { var inpDlg = new InpDialog("Name", "<User>"); inpDlg.ShowDialog(); if (inpDlg.Answer != null) { SessionInfo.Get().person.Name = inpDlg.Answer; CommitAvaNameChanges(SessionInfo.Get().person); //refresh avatar var pers = SessionInfo.Get().person; avatar.DataContext = null; avatar.DataContext = pers; } } else { SetNewAvatar(); } sharedClient.clienRt.SendAvaNameChanged(); }
//if Url!=null, uses it. otherwice asks for URL private static Attachment AttachFromYoutube(ArgPoint Point, string Url) { string URLToUse = Url; if (URLToUse == null) { InpDialog dlg = new InpDialog(); dlg.ShowDialog(); URLToUse = dlg.Answer; if (URLToUse == null || !URLToUse.StartsWith("http://")) return null; } BusyWndSingleton.Show("Processing Youtube attachment..."); Attachment res = new Attachment(); try { YouTubeInfo videoInfo = YouTubeProvider.LoadVideo(URLToUse); if (videoInfo == null) return null; res.Format = (int) AttachmentFormat.Youtube; res.VideoEmbedURL = videoInfo.EmbedUrl; res.VideoThumbURL = videoInfo.ThumbNailUrl; res.VideoLinkURL = videoInfo.LinkUrl; res.Link = videoInfo.LinkUrl; res.Title = videoInfo.VideoTitle; res.Name = URLToUse; res.Thumb = ImageToBytes(GetYoutubeThumb(videoInfo.ThumbNailUrl), new JpegBitmapEncoder()); if (Point != null) Point.Attachment.Add(res); ///PublicBoardCtx.Get().SaveChanges(); } finally { BusyWndSingleton.Hide(); } return res; }
//if URL==null, shows URL input dialog. else uses provided URL, no dialog private static Attachment AttachPdfFromURL(ArgPoint Point, string Url) { string UrlToUse = Url; if (UrlToUse == null) { InpDialog dlg = new InpDialog(); dlg.ShowDialog(); UrlToUse = dlg.Answer; UrlToUse = UrlToUse.ToLower(); if (UrlToUse == null || !UrlToUse.StartsWith("http://") || UrlToUse.EndsWith(".pdf")) return null; } string tmpFile = DownloadPdfFromUrl(UrlToUse); if (tmpFile == null) return null; Attachment res = new Attachment(); res.Name = UrlToUse; res.Format = (int) AttachmentFormat.Pdf; res.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(tmpFile)); res.Title = ""; res.Thumb = TryCreatePdfThumb(tmpFile); res.Link = Url; if (Point != null) Point.Attachment.Add(res); ///PublicBoardCtx.Get().SaveChanges(); return res; }
//if URL==null, shows URL input dialog. else uses provided URL, no dialog private static Attachment AttachFromURL(ArgPoint Point, string Url) { string UrlToUse = Url; if (UrlToUse == null) { InpDialog dlg = new InpDialog(); dlg.ShowDialog(); UrlToUse = dlg.Answer; if (UrlToUse == null || !UrlToUse.StartsWith("http://")) return null; } string tmpFile = DownloadImageFromURL(UrlToUse); if (tmpFile == null) return null; Attachment res = new Attachment(); res.Name = UrlToUse; res.Format = (int) AttachmentFormat.Jpg; //all downloads are jpg res.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(tmpFile)); res.Title = ""; res.Link = Url; if (Point != null) Point.Attachment.Add(res); //PublicBoardCtx.Get().SaveChanges(); return res; }
private void btnAttachFromUrl_Click_1(object sender, RoutedEventArgs e) { if (_d == null) return; InpDialog dlg = new InpDialog(); dlg.ShowDialog(); string URL = dlg.Answer; if (URL == null) return; Attachment a = new Attachment(); if (AttachmentManager.ProcessAttachCmd(null, URL, ref a) != null) { a.Discussion = _d; a.Person = getFreshPerson(); insertMedia(a); } }
//attachment from URL, with dialog box private void btnAttachFromUrl_Click_1(object sender, RoutedEventArgs e) { var ap = DataContext as ArgPoint; if (ap == null) return; var dlg = new InpDialog(); dlg.ShowDialog(); string URL = dlg.Answer; if (URL == null) return; var a = new Attachment(); var imgSrc = AttachmentManager.ProcessAttachCmd(ap, URL, ref a); if (imgSrc != null) { a.Person = ap.Person; ap.ChangesPending = true; UISharedRTClient.Instance.clienRt.SendStatsEvent( AttachmentToEvent(a, false), ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); UpdateOrderedMedia(); BeginAttachmentNumberInjection(); } }