Skip to content

Instantly share code, notes, and snippets.

@hareno
Created August 31, 2012 11:20
Show Gist options
  • Save hareno/3551613 to your computer and use it in GitHub Desktop.
Save hareno/3551613 to your computer and use it in GitHub Desktop.
#light
open System
open System.Windows.Forms
open System.Drawing
//GUI部分
let mainForm = new Form(Width = 600, Height = 300, Text = "Window For Button") //#1
let myTextBox0 = new TextBox(Location = new Point(30,50))
let myTextBox1 = new TextBox(Location = new Point(150,50))
let myLabel0 = new Label(Text = "Input1", Location = new Point(30, 35))
let myLabel1 = new Label(Text = "Input2", Location = new Point(150, 35))
let largetextbox = new TextBox(Location = new Point(350, 50), Height = 150, Width = 200, Multiline = true, ScrollBars = ScrollBars.Vertical)
let myLabeltextbox = new Label(Text = "Output here.", Location = new Point(350, 35))
let returnbutton = new Button(Location = new Point(180,150), Text = "Enter", AutoSize = true)
let changeBoxText (target_box:TextBox) text =
target_box.Text <- text
let create_frame id =
"<iframe src=\"http://ext.nicovideo.jp/thumb/" + id +
"\" class=\"nicovideo\" scrolling=\"no\" frameborder=\"0\" height=\"176\" width=\"312\">"
let get_frame (target_box: TextBox) () =
if target_box.Text <> ""
then create_frame target_box.Text
else ""
let get_prevframe = get_frame myTextBox0
let get_nextframe = get_frame myTextBox1
let changetextlarge = changeBoxText largetextbox
let table_head =
"<table style=\"text-align: center; width: 100%;\" border=\"0\"><tfoot><tr> \
<td colspan=\"2\" style=\"border: none; background-color: #333; color: #fff; font-size: 0.6em; text-align: center;\">by name - \
<a href=\"http://dic.nicovideo.jp/a/template%3A%E5%8B%95%E7%94%BB%E8%A8%98%E4%BA%8B%E3%83%8A%E3%83%93%E3%82%B2%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88\">動画記事ナビ</a></td> \
</tr></tfoot><tbody> \
<tr><th style=\"border: none; width: 50%; background-color: #333; color: #fff;\">- \
 ←</th><th style=\"border: none; width: 50%; background-color: #333; color: #fff;\">→ -</th></tr> \
<tr><td style=\"border-color: #333;\">"
let table_middle =
"</td> \
<td style=\"border-color: #333;\">"
let table_tail = "</td></tr></tbody></table>"
let html_text () = table_head + get_prevframe() + table_middle + get_nextframe() + table_tail
returnbutton.Click.AddHandler(fun sender _-> changetextlarge (html_text()))
//追加
mainForm.Controls.Add(myTextBox0)
mainForm.Controls.Add(myTextBox1)
mainForm.Controls.Add(myLabel0)
mainForm.Controls.Add(myLabel1)
mainForm.Controls.Add(largetextbox)
mainForm.Controls.Add(myLabeltextbox)
mainForm.Controls.Add(returnbutton)
//mainloop
[<STAThread>]
System.Windows.Forms.Application.Run(mainForm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment