Ejemplo n.º 1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            // 重複チェックを行う
            if (engineList.Engines.Any(
                    x => !object.ReferenceEquals(x, engine) &&
                    x.Name == textBoxName.Text &&
                    x.Path == textBoxPath.Text))
            {
                MessageBox.Show(this, "名前・パスが同じエンジンは複数登録できません。", "エラー");
                DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }
            // エンジンの存在チェックを行う
            string path = USIDriver.NormalizeEnginePath(textBoxPath.Text);

            if (!File.Exists(path))
            {
                MessageBox.Show(this, path + " が存在しません。", "エラー");
                DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }
            // コントロールからEngineへ
            engine.Name        = textBoxName.Text;
            engine.Author      = textBoxAuthor.Text;
            engine.Path        = textBoxPath.Text;
            engine.USIPonder   = checkBoxUSIPonder.Checked;
            engine.USIHash     = (int)numericUpDownHash.Value;
            engine.ByoyomiHack = checkBox1.Checked;
            engine.Options     = engineOptionsControl1.ToList();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// リストビューアイテムにアイコンを設定
        /// </summary>
        private void SetIconToListViewItem(ListViewItem item)
        {
            string path = "";

            try {
                path = USIDriver.NormalizeEnginePath(((Engine)item.Tag).Path);
                if (File.Exists(path))
                {
                    Icon icon = GetIcon(path);
                    FormUtility.SafeInvoke(listView1, () => {
                        item.ImageIndex = imageList1.Images.Add(icon.ToBitmap(), Color.Transparent);
                        if (0 <= item.Index)
                        {
                            listView1.RedrawItems(item.Index, item.Index, false);
                        }
                    });
                }
                else
                {
                    logger.Debug("アイコンの読み込みに失敗: " + path);
                }
            } catch (Exception e) {
                logger.Warn("アイコンの読み込みに失敗: " + path, e);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// エンジンのパスが変更されたら活性非活性を調整
 /// </summary>
 private void textBoxPath_TextChanged(object sender, EventArgs e)
 {
     try {
         string path = USIDriver.NormalizeEnginePath(textBoxPath.Text);
         buttonGetByEngine.Enabled = File.Exists(path);
         UpdateEnables();
     } catch {
         // 入力は色々あり得るので黙殺
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// ...
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            string path = USIDriver.NormalizeEnginePath(textBoxPath.Text);
            string dir  = Path.GetDirectoryName(path);

            if (Directory.Exists(dir))
            {
                openFileDialog1.InitialDirectory = dir;
                openFileDialog1.FileName         = Path.GetFileName(path);
            }
            else
            {
                openFileDialog1.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; // 適当
            }
            if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                textBoxPath.Text = openFileDialog1.FileName;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// エンジンが存在するかチェック
        /// </summary>
        public bool EngineExists(string name, string path)
        {
            var engine = Select(name, path);

            return(engine != null && File.Exists(USIDriver.NormalizeEnginePath(engine.Path)));
        }