How to use HTML Converter for C#.
2016/01/01
The software can be download here.
I’m Sorry. I had mistaken. It seems that web browser was not run properly. I repaired it right now. Please re-download it. – 2015/12/23
Run HTML Converter.
Read a source code in the following ways:
1) Copy and paste to textbox.
2) Read file by “Open” button.
When “convert” button clicked, the source code is mark up to HTML.
Click “To clipboad” button.
Paste to your blog editor that is stated HTML mode.
☟
Return the editor that is nomal mode. Complated!
The following is an example.
using System; |
using System.Drawing; |
using System.Windows.Forms; |
using System.IO; |
using System.Text; |
class HTMLBrowser : Form{ |
private WebBrowser wb; |
private string text; |
public HTMLBrowser(string text){ |
this.StartPosition = FormStartPosition.CenterScreen; |
this.Width = 600; |
this.Height = 550; |
this.Text = “HTML Converter”; |
this.ShowInTaskbar = false; |
this.text = text; |
this.Shown += new EventHandler(this.showForm); |
this.setComponents(); |
} |
public void run(){ |
string fname = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); |
fname = fname + “\\index.html”; |
string savetext = “<!DOCTYPE html><html><body>” + text + “</body></html>”; |
Encoding sjisEnc = Encoding.GetEncoding(“UTF-8”); |
StreamWriter file = new StreamWriter(fname, false, sjisEnc); |
file.Write(savetext); |
file.Close(); |
} |
public void showForm(object sender, EventArgs e){ |
wb.Refresh(); |
} |
private void copyBtn_Click(object sender, EventArgs e){ |
Clipboard.SetText(text); |
} |
private void closeBtn_Click(object sender, EventArgs e){ |
this.Close(); |
} |
private void setComponents(){ |
Panel mainPane = new Panel(){ |
Padding = new Padding(5), |
Dock = DockStyle.Fill, |
Parent=this, |
}; |
Panel btnPane = new Panel(){ |
Dock = DockStyle.Bottom, |
Size = new Size(80, 60), |
Parent=this, |
}; |
wb = new WebBrowser(){ |
Dock = DockStyle.Fill, |
Name = “webBrowser1”, |
//BorderStyle = BorderStyle.FixedSingle, |
Parent=mainPane, |
}; |
string fname = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); |
fname = fname + “\\index.html”; |
wb.Navigate(fname); |
Button copyBtn = new Button(){ |
Text = “To Clipboad”, |
Size = new Size(130, 30), |
Location = new Point(300, 10), |
Parent=btnPane, |
}; |
copyBtn.Click += new EventHandler(this.copyBtn_Click); |
Button closeBtn = new Button(){ |
Text = “Close”, |
Size = new Size(130, 30), |
Location = new Point(440, 10), |
Parent=btnPane, |
}; |
closeBtn.Click += new EventHandler(this.closeBtn_Click); |
} |
} |
スポンサーリンク