private Preview_OpenGraph CreateOpenGraph() { Preview_AdvancedOpenGraph _aog = m_mrPreviewsGetAdv.preview; Preview_OpenGraph _og = new Preview_OpenGraph(); _og.description = _aog.description; _og.provider_name = _aog.provider_name; _og.provider_url = _aog.provider_url; _og.provider_display = _aog.provider_display; _og.url = _aog.url; _og.title = _aog.title; if (!cbNoThumbnail.Checked) { if (_aog.images.Count != 0) { _og.thumbnail_url = _aog.images[m_currentPreviewImageIndex].url; _og.thumbnail_width = _aog.images[m_currentPreviewImageIndex].width; _og.thumbnail_height = _aog.images[m_currentPreviewImageIndex].height; } } _og.type = _aog.type; return(_og); }
private void btnSend_Click(object sender, EventArgs e) { if (!Main.Current.CheckNetworkStatus()) { return; } //[1] 有Preview if (m_mrPreviewsGetAdv != null) { try { Preview_OpenGraph _openGraph = CreateOpenGraph(); string _og = JsonConvert.SerializeObject(_openGraph); if (DoRealPost(_og)) { MyParent.SetDialogResult_Yes_AndClose(); } return; } catch (Exception _e) { MessageBox.Show(_e.Message); return; } } //[2] 單純文字 if (MyParent.pureTextBox.Text.Trim().Equals(string.Empty)) { MessageBox.Show(I18n.L.T("TextEmpty"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (DoRealPost("")) { MyParent.SetDialogResult_Yes_AndClose(); } } }
private void SetHTML() { // if (m_post.preview.url == null) // PostType.Link 目前不支援 { MyParent.CanEdit = true; } StringBuilder _sb = new StringBuilder(); _sb.Append("<font face='微軟正黑體, Helvetica, Arial, Verdana, sans-serif' color='#eef'><p>[Text]</p></font>"); string _htmlMainAndComment = _sb.ToString(); string _content = HttpUtility.HtmlEncode(Post.content); _content = _content.Replace(Environment.NewLine, "<BR>"); _content = _content.Replace("\n", "<BR>"); _content = _content.Replace("\r", "<BR>"); _htmlMainAndComment = _htmlMainAndComment.Replace("[Text]", _content); _htmlMainAndComment += MyParent.GenCommentHTML(Post); _htmlMainAndComment = HtmlUtility.MakeLink(_htmlMainAndComment, m_clickableURL); if (Post.preview.url != null) { Preview_OpenGraph _p = Post.preview; StringBuilder _s = new StringBuilder(); _s.Append("<table width=\"99%\" border=\"0\">"); _s.Append(" <tr>"); _s.Append(" <td><font face='微軟正黑體, Helvetica, Arial, Verdana, sans-serif' size='5pt'><b><a style=\"text-decoration:none\" href=\"[PriviewLink]\" target=\"_blank\">[PriviewTitle]</a></b></font></td>"); _s.Append(" </tr>"); _s.Append(" <tr>"); _s.Append(" <td><font size='2.75pt'>[PriviewLink2]</font></td>"); _s.Append(" </tr>"); _s.Append("</table>"); _htmlMainAndComment += _s.ToString(); _htmlMainAndComment = _htmlMainAndComment.Replace("[PreviewPic]", _p.thumbnail_url); _htmlMainAndComment = _htmlMainAndComment.Replace("[PriviewTitle]", _p.title); _htmlMainAndComment = _htmlMainAndComment.Replace("[PriviewLink]", _p.url); _htmlMainAndComment = _htmlMainAndComment.Replace("[PriviewLink2]", StringUtility.ExtractDomainNameFromURL(_p.url)); _htmlMainAndComment = _htmlMainAndComment.Replace("[PriviewText]", _p.description); if (!m_clickableURL.Contains(_p.url)) { m_clickableURL.Add(_p.url); } } string _minimaxJS = Properties.Resources.minmax; _minimaxJS = "<script type=\"text/javascript\">" + _minimaxJS + "</script>"; string _wfPreviewWin = Properties.Resources.WFPreviewWin; _wfPreviewWin = "<style type=\"text/css\">" + _wfPreviewWin + "</style>"; webBrowser.DocumentText = "<html>" + _minimaxJS + "<style type=\"text/css\">img {height: auto; max-width: 95%;}</style>" + "<body bgcolor=\"rgb(243, 242, 238)\"><font face='微軟正黑體, Helvetica, Arial, Verdana, sans-serif'>" + HtmlUtility.TrimScript(_htmlMainAndComment + m_post.soul) + "</font></body></html>"; }