public override void EijirouWeb_Click(object sender, EventArgs e) { string text = null; if (textBoxModify.Focused && textBoxModify.SelectionLength > 0) { text = textBoxModify.SelectedText; } else if (textBoxOriginal.Focused && textBoxOriginal.SelectionLength > 0) { text = textBoxOriginal.SelectedText; } if (text != null) { TranslateBrowser browser = TranslateBrowser.Create(new WebTranslate.EijirouTranslate(text), this); } if (text != null) { string url = WebTranslate.EijirouTranslate.GetUrl(text); if (url != null) { System.Diagnostics.Process.Start(url); } } }
void TranslateBrowser_FormClosed(object sender, FormClosedEventArgs e) { // とりあえずこのタイミングで破棄 lock (instance.sync) { instance = null; } }
static public TranslateBrowser Create(WebTranslate.TranslateBase trans, System.Windows.Forms.IWin32Window parent) { if (instance != null) { instance.translate(trans); return(instance); } TranslateBrowser browser = new TranslateBrowser(trans); //browser.Show( parent ); browser.Show(); // 親よりも後ろに配置できる return(browser); }
void TranslateBrowser_Shown(object sender, EventArgs e) { // とりあえずこのタイミングでシングル化 if (instance != null) { // この場合はassertでもいいが lock (instance.sync) { instance = this; } } else { lock (this.sync) { instance = this; } } }
public override void Eijirou_Click(object sender, EventArgs e) { string text = null; if (textBoxModify.Focused && textBoxModify.SelectionLength > 0) { text = textBoxModify.SelectedText; } else if (textBoxOriginal.Focused && textBoxOriginal.SelectionLength > 0) { text = textBoxOriginal.SelectedText; } if (text != null) { TranslateBrowser browser = TranslateBrowser.Create(new WebTranslate.EijirouTranslate(text), this); } }