(How to)Windows Live Writer插入Latex公式
生活随笔
收集整理的這篇文章主要介紹了
(How to)Windows Live Writer插入Latex公式
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、首先構建出如下窗體:
????
private void InitializeComponent() {this.buttonOK = new System.Windows.Forms.Button();this.textBoxLaTeX = new System.Windows.Forms.TextBox();this.label1 = new System.Windows.Forms.Label();this.SuspendLayout();...}2、在buttonOK_Click事件中構造要插入的代碼:
public partial class LaTeXInput : Form {// Constructorpublic LaTeXInput() {InitializeComponent();}// public propertiespublic string ResultHTML {get { return m_result_gchart_html; }}// data membersstring m_result_gchart_html = "";private void buttonOK_Click(object sender, EventArgs e) {// get original latex string, and encode itstring raw_latex = textBoxLaTeX.Text;string encoded_str = HttpUtility.UrlEncode(raw_latex);string gchart_url = "http://chart.googleapis.com/chart?cht=tx&chl=" + encoded_str;m_result_gchart_html = String.Format("<p><img src=\"{0}\" /></p>", gchart_url);this.DialogResult = DialogResult.OK;} }3、根據Windows Live Writer插件編寫規范編寫自己的插件類:
[WriterPluginAttribute("24E0269C-D61B-11E0-A846-6D254824019B","LaTeX Chart",Description = "A simple LaTeX render plugin for Windows Live Writer",HasEditableOptions = false,ImagePath = "formula_icon.jpg",PublisherUrl = "http://liselsia.org")][InsertableContentSourceAttribute("LaTeX Chart")]public class LaTeXPlugin : ContentSource {public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content) {LaTeXInput input_form = new LaTeXInput();if (DialogResult.OK == input_form.ShowDialog()) {content = input_form.ResultHTML;}input_form.Dispose();return DialogResult.OK;} }注:只要改動第二個ref傳入的content參數,就能直接改變最終在Live Writer里要加入的HTML代碼。而為了彈出如下的一個輸入LaTeX的對話框,又需要添加一個Windows Form窗口,同時加上System.Windows.Forms.dll的.NET庫的引用。然后以上述代碼所示的input_form.ShowDialog()的方式彈出模態對話框(modal dialog)。
項目地址:https://code.google.com/p/wlwlatex/
SVN:http://wlwlatex.googlecode.com/svn/trunk/
轉載于:https://www.cnblogs.com/Ymete/archive/2012/12/28/2837494.html
總結
以上是生活随笔為你收集整理的(How to)Windows Live Writer插入Latex公式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 被音乐毒害的孩纸
- 下一篇: ngx_pagespeed加速nginx