Ejemplo n.º 1
0
 private void 削除DToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (0 < listView1.SelectedItems.Count)
     {
         ListViewItem item   = listView1.SelectedItems[0];
         Engine       engine = (Engine)item.Tag;
         if (MessageBox.Show(this, engine.Name + "を削除します。よろしいですか?", "確認",
                             MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
         {
             if (engineList.Engines.Remove(engine))
             {
                 listView1.Items.Remove(item);
                 // 書き込み
                 ConfigSerializer.Serialize(engineList);
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 読み込み処理
        /// </summary>
        private void OnThread(object arg)
        {
            lock (syncObject) {
                try {
                    // Engine.xmlの読み込み
                    try {
                        engineList = ConfigSerializer.Deserialize <EngineList>();
                        engineList.Engines.Sort();
                    } catch (Exception ex) {
                        logger.Warn("Engine.xmlの読み込みに失敗。", ex);
                        ConfigLoadFailed(this, new ConfigLoadFailedEventArgs {
                            ConfigFileName = "Engine.xml", ToBeQuit = true
                        });
                        return;
                    }
                    // ShogiBoard.xmlの読み込み
                    try {
                        config = ConfigSerializer.Deserialize <Config>();
                        config.Ready();
                    } catch (Exception ex) {
                        logger.Warn("ShogiBoard.xmlの読み込みに失敗。", ex);
                        ConfigLoadFailed(this, new ConfigLoadFailedEventArgs {
                            ConfigFileName = "ShogiBoard.xml", ToBeQuit = true
                        });
                        return;
                    }
                    // ShogiBoard.Volatile.xmlの読み込み
                    try {
                        volatileConfig = ConfigSerializer.Deserialize <VolatileConfig>();
                    } catch (Exception ex) {
                        logger.Warn("ShogiBoard.Volatile.xmlの読み込みに失敗。", ex);
                        ConfigLoadFailed(this, new ConfigLoadFailedEventArgs {
                            ConfigFileName = "ShogiBoard.Volatile.xml", ToBeQuit = false
                        });
                        volatileConfig = new VolatileConfig(); // 初期値にしてしまう
                    }
                    volatileConfig.Ready();
                } catch (Exception ex) {
                    logger.Warn("ShogiBoard.Volatile.xmlの読み込みに失敗。", ex);
                }

                Monitor.PulseAll(syncObject);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 設定ボタン
        /// </summary>
        private void buttonEngineConfig_Click(object sender, EventArgs e)
        {
            Engine engine = comboBoxEngine.SelectedItem as Engine;

            if (engine != null)
            {
                using (EngineForm form = new EngineForm(engine, engineList)) {
                    if (form.ShowDialog(this) == DialogResult.OK)
                    {
                        // 保存
                        ConfigSerializer.Serialize(engineList);
                        // 表示を更新
                        comboBoxEngine.BeginUpdate();
                        comboBoxEngine.Items.Clear();
                        comboBoxEngine.Items.AddRange(engineList.Engines.ToArray());
                        comboBoxEngine.SelectedItem = engine;
                        comboBoxEngine.EndUpdate();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            {
                Engine engine = engineSelectControl1.SelectedItem;
                if (engine == null)
                {
                    volatileConfig.GameEngine1Name = null;
                    volatileConfig.GameEngine1Path = null;
                }
                else
                {
                    // 念のため存在チェック
                    string path = ShogiCore.USI.USIDriver.NormalizeEnginePath(engine.Path);
                    if (!System.IO.File.Exists(path))
                    {
                        MessageBox.Show(this, path + " が存在しません。", "エラー");
                        DialogResult = System.Windows.Forms.DialogResult.None;
                        return;
                    }
                    volatileConfig.GameEngine1Name = engine.Name;
                    volatileConfig.GameEngine1Path = engine.Path;
                }
            }
            {
                Engine engine = engineSelectControl2.SelectedItem;
                if (engine == null)
                {
                    volatileConfig.GameEngine2Name = null;
                    volatileConfig.GameEngine2Path = null;
                }
                else
                {
                    // 念のため存在チェック
                    string path = ShogiCore.USI.USIDriver.NormalizeEnginePath(engine.Path);
                    if (!System.IO.File.Exists(path))
                    {
                        MessageBox.Show(this, path + " が存在しません。", "エラー");
                        DialogResult = System.Windows.Forms.DialogResult.None;
                        return;
                    }
                    volatileConfig.GameEngine2Name = engine.Name;
                    volatileConfig.GameEngine2Path = engine.Path;
                }
            }
            volatileConfig.GameEngineTimeControls[0] = engineTimeOptionControl1.TimeControl;
            volatileConfig.GameEngineTimeControls[1] = engineTimeOptionControl2.TimeControl;
            volatileConfig.GameEngineDepths[0]       = engineTimeOptionControl1.Depth;
            volatileConfig.GameEngineDepths[1]       = engineTimeOptionControl2.Depth;
            volatileConfig.GameEngineNodes[0]        = engineTimeOptionControl1.Nodes;
            volatileConfig.GameEngineNodes[1]        = engineTimeOptionControl2.Nodes;
            if (radioButton1.Checked)
            {
                volatileConfig.GameTimeIndex = 0;
            }
            else if (radioButton2.Checked)
            {
                volatileConfig.GameTimeIndex = 1;
            }
            else if (radioButton3.Checked)
            {
                volatileConfig.GameTimeIndex = 2;
            }
            //else if (radioButton4.Checked) volatileConfig.GameTimeIndex = VolatileConfig.GameTimeIndexDepth;
            //else if (radioButton7.Checked) volatileConfig.GameTimeIndex = VolatileConfig.GameTimeIndexNodes;
            else
            {
                volatileConfig.GameTimeIndex = 0;
            }
            volatileConfig.GameTimes[0].TimeASeconds   = gameTimePickerControl1.TimeASeconds;
            volatileConfig.GameTimes[1].TimeASeconds   = gameTimePickerControl2.TimeASeconds;
            volatileConfig.GameTimes[2].TimeASeconds   = gameTimePickerControl3.TimeASeconds;
            volatileConfig.GameTimes[0].TimeBSeconds   = gameTimePickerControl1.TimeBSeconds;
            volatileConfig.GameTimes[1].TimeBSeconds   = gameTimePickerControl2.TimeBSeconds;
            volatileConfig.GameTimes[2].TimeBSeconds   = gameTimePickerControl3.TimeBSeconds;
            volatileConfig.GameTimes[0].IncTimeSeconds = gameTimePickerControl1.IncTimeSeconds;
            volatileConfig.GameTimes[1].IncTimeSeconds = gameTimePickerControl2.IncTimeSeconds;
            volatileConfig.GameTimes[2].IncTimeSeconds = gameTimePickerControl3.IncTimeSeconds;
            volatileConfig.GameTimeUpType     = comboBox1.SelectedIndex;
            volatileConfig.GameCount          = (int)numericUpDown1.Value;
            volatileConfig.GameEndByMoveCount = checkBox2.Checked;
            volatileConfig.GameEndMoveCount   = (int)numericUpDown3.Value;
            if (radioButton5.Checked)
            {
                volatileConfig.GameStartPosType = 0;
            }
            else
            {
                volatileConfig.GameStartPosType = 1;
            }
            volatileConfig.GameStartPosNotationPath       = textBox1.Text;
            volatileConfig.GameStartPosNotationShuffle    = checkBox1.Checked;
            volatileConfig.GameStartPosNotationStartCount = (int)numericUpDown2.Value;
            volatileConfig.GameEngineRestart = checkBoxRestart.Checked;

            // 保存
            ConfigSerializer.Serialize(volatileConfig);
        }
Ejemplo n.º 5
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            // フォームからコンフィグへ
            // エンジン
            Engine engine = engineSelectControl1.SelectedItem;

            if (engine == null)
            {
                volatileConfig.NetworkGameEngineName = null;
                volatileConfig.NetworkGameEnginePath = null;
            }
            else
            {
                // 念のため存在チェック
                string path = ShogiCore.USI.USIDriver.NormalizeEnginePath(engine.Path);
                if (!System.IO.File.Exists(path))
                {
                    MessageBox.Show(this, path + " が存在しません。", "エラー");
                    DialogResult = System.Windows.Forms.DialogResult.None;
                    return;
                }
                volatileConfig.NetworkGameEngineName = engine.Name;
                volatileConfig.NetworkGameEnginePath = engine.Path;
            }
            // 接続先
            if (radioButton1.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 0;
            }
            else if (radioButton2.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 1;
            }
            else if (radioButton3.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 2;
            }
            else if (radioButton4.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 3;
            }
            else if (radioButton5.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 4;
            }
            else if (radioButton6.Checked)
            {
                volatileConfig.NetworkGameConnectionIndex = 5;
            }
            else
            {
                volatileConfig.NetworkGameConnectionIndex = 0;
            }
            networkGameConnectionControl1.WriteToConfig(config.NetworkGameConnections[0]);
            networkGameConnectionControl2.WriteToConfig(config.NetworkGameConnections[1]);
            networkGameConnectionControl3.WriteToConfig(config.NetworkGameConnections[2]);
            networkGameConnectionControl4.WriteToConfig(config.NetworkGameConnections[3]);
            networkGameConnectionControl5.WriteToConfig(config.NetworkGameConnections[4]);
            networkGameConnectionControl6.WriteToConfig(config.NetworkGameConnections[5]);
            volatileConfig.NetworkGameCount = (int)numericUpDown1.Value;
            // 保存
            ConfigSerializer.Serialize(config);
            ConfigSerializer.Serialize(volatileConfig);
        }