Exemplo n.º 1
0
 /// <summary>
 /// エンジンから取得(設定)
 /// </summary>
 private void button2_Click(object sender, EventArgs e)
 {
     button2.Enabled = false;
     button3.Enabled = false;
     button4.Enabled = false;
     engineOptionsControl1.Enabled = false;
     ThreadPool.QueueUserWorkItem(new WaitCallback(arg => {
         try {
             using (USIDriver usi = new USIDriver(textBoxPath.Text)) {
                 usi.Start();
                 FormUtility.SafeInvoke(this, () => {
                     engineOptionsControl1.Clear();
                     foreach (var opt in usi.Options)
                     {
                         engineOptionsControl1.Add(
                             opt.Type, opt.Name, opt.Default,
                             opt.Min, opt.Max, opt.Var);
                     }
                 });
             }
         } catch (Exception ex) {
             logger.Warn("エンジンからの情報取得に失敗", ex);
             FormUtility.SafeInvoke(this, () => {
                 MessageBox.Show(this, "エンジンからの名前/作者取得に失敗しました。", "エラー");
             });
         } finally {
             FormUtility.SafeInvoke(this, () => {
                 button2.Enabled = true;
                 button3.Enabled = true;
                 button4.Enabled = true;
                 engineOptionsControl1.Enabled = true;
             });
         }
     }));
 }
Exemplo n.º 2
0
        /// <summary>
        /// エンジンへ送信してクリア
        /// </summary>
        private void button4_Click(object sender, EventArgs e)
        {
            button2.Enabled = false;
            button4.Enabled = false;
            button3.Enabled = false;
            engineOptionsControl1.Enabled = false;
            var list = engineOptionsControl1.ToList();

            ThreadPool.QueueUserWorkItem(new WaitCallback(arg => {
                try {
                    using (USIDriver usi = new USIDriver(textBoxPath.Text)) {
                        usi.Start();
                        foreach (var p in list)
                        {
                            usi.SendSetOption(p.Name, p.Value);
                        }
                    }
                } catch (Exception ex) {
                    logger.Warn("エンジンへの送信に失敗", ex);
                    FormUtility.SafeInvoke(this, () => {
                        MessageBox.Show(this, "エンジンへの送信に失敗しました。", "エラー");
                    });
                } finally {
                    FormUtility.SafeInvoke(this, () => {
                        button2.Enabled = true;
                        button4.Enabled = true;
                        button3.Enabled = true;
                        engineOptionsControl1.Enabled = true;
                        engineOptionsControl1.Clear();
                    });
                }
            }));
        }
Exemplo n.º 3
0
 /// <summary>
 /// エンジンから取得(エンジン名・作者名)
 /// </summary>
 private void buttonGetByEngine_Click(object sender, EventArgs e)
 {
     textBoxName.Enabled       = false;
     textBoxAuthor.Enabled     = false;
     buttonGetByEngine.Enabled = false;
     ThreadPool.QueueUserWorkItem(new WaitCallback(arg => {
         try {
             using (USIDriver usi = new USIDriver(textBoxPath.Text)) {
                 usi.Start();
                 FormUtility.SafeInvoke(this, () => {
                     textBoxName.Text   = usi.IdName;
                     textBoxAuthor.Text = usi.IdAuthor;
                 });
             }
         } catch (Exception ex) {
             logger.Warn("エンジンからの情報取得に失敗", ex);
             FormUtility.SafeInvoke(this, () => {
                 // 空なら仮でファイル名を設定
                 if (textBoxName.TextLength <= 0)
                 {
                     try {
                         textBoxName.Text = Path.GetFileNameWithoutExtension(textBoxPath.Text);
                     } catch (Exception ex2) {
                         logger.Warn("ファイル名の取得に失敗", ex2);
                     }
                 }
                 // エラーメッセージ
                 MessageBox.Show(this, "エンジンからの名前/作者取得に失敗しました。", "エラー");
             });
         } finally {
             FormUtility.SafeInvoke(this, () => {
                 buttonGetByEngine.Enabled = true;
                 textBoxAuthor.Enabled     = true;
                 textBoxName.Enabled       = true;
             });
         }
     }));
 }