Exemplo n.º 1
0
        public void LaunchForm_AsBody()
        {
            ((Form1_Shogiable)this.OwnerForm).Delegate_Form1_Load = (MainGui_Csharp shogiGui, object sender, EventArgs e) =>
            {
                //
                // ボタンのプロパティを外部ファイルから設定
                //
                foreach (WidgetsLoader widgetsLoader in this.WidgetLoaders)
                {
                    widgetsLoader.Step1_ReadFile();//shogiGui.Shape_PnlTaikyoku
                }

                foreach (WidgetsLoader widgetsLoader in this.WidgetLoaders)
                {
                    widgetsLoader.Step2_Compile_AllWidget(shogiGui);
                }

                foreach (WidgetsLoader widgetsLoader in this.WidgetLoaders)
                {
                    widgetsLoader.Step3_SetEvent(shogiGui);
                }
            };

            this.ReadStyle_ToForm((Form1_Shogiable)this.OwnerForm);

            //
            // FIXME: [初期配置]を1回やっておかないと、[コマ送り]ボタン等で不具合が出てしまう。
            //
            {
                Util_Function_Csharp.Perform_SyokiHaichi(
                    ((Form1_Shogiable)this.OwnerForm).Uc_Form1Main.MainGui
                    );
            }


            Application.Run(this.OwnerForm);
        }
Exemplo n.º 2
0
        /// <summary>
        /// シングルトン。
        /// </summary>
        /// <returns></returns>
        public static Event_CsharpImpl GetInstance()
        {
            if (null == Event_CsharpImpl.instance)
            {
                Event_CsharpImpl ins = new Event_CsharpImpl();
                Event_CsharpImpl.instance = ins;

                //
                // [成る]ボタンのイベント。
                //
                ins.delegate_BtnNaru = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    shogibanGui2.SetNaruFlag(true);
                    ins.After_NaruNaranai_ButtonPushed(
                        shogibanGui2
                        , btnKoma_Selected
                        );
                };

                //
                // [成らない]ボタンのイベント。
                //
                ins.delegate_BtnNaranai = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    shogibanGui2.SetNaruFlag(false);
                    ins.After_NaruNaranai_ButtonPushed(
                        shogibanGui2
                        , btnKoma_Selected
                        );
                };

                //
                // [クリアー]ボタンのイベント。
                //
                ins.delegate_BtnClear = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    Util_Lua_Csharp.ShogiGui = shogibanGui2;
                    Util_Lua_Csharp.Perform("click_clearButton");
                };

                //
                // [再生]ボタンのイベント。
                //
                ins.delegate_BtnPlay = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    Util_Lua_Csharp.ShogiGui = shogibanGui2;
                    Util_Lua_Csharp.Perform("click_playButton");
                };

                //
                // [コマ送り]ボタンのイベント。
                //
                ins.delegate_BtnForward = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp mainGui3         = (MainGui_Csharp)obj_shogiGui2;

                    string restText = Util_Function_Csharp.ReadLine_FromTextbox();
                    Util_Functions_Server.Komaokuri_Srv(
                        ref restText,
                        mainGui3.Link_Server.Model_Taikyoku,
                        mainGui3.Model_Manual);
                    Util_Function_Csharp.Komaokuri_Gui(restText, mainGui3);
                    Util_Menace.Menace(mainGui3);// メナス
                };

                //
                // [巻き戻し]ボタンのイベント。
                //
                ins.delegate_BtnBackward = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    Finger movedKoma;
                    Finger foodKoma;//取られた駒
                    string fugoJStr;

                    if (!Util_Functions_Server.Makimodosi_Srv(out movedKoma, out foodKoma, out fugoJStr, shogibanGui2.Link_Server.Model_Taikyoku))
                    {
                        goto gt_EndBlock;
                    }

                    Util_Function_Csharp.Makimodosi_Gui(shogibanGui2, movedKoma, foodKoma, fugoJStr, Util_Function_Csharp.ReadLine_FromTextbox());
                    Util_Menace.Menace(shogibanGui2);//メナス

gt_EndBlock:
                    ;
                };

                //
                // [ログ出せ]ボタンのイベント。
                //
                ins.delegate_BtnLogdase = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;

                    shogibanGui2.Logdase();
                };

                //
                // [壁置く]ボタンのイベント。
                //
                ins.delegate_BtnKabeOku = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    UserWidget     widget           = shogibanGui2.GetWidget("BtnKabeOku");

                    // [壁置く]←→[駒動かす]切替
                    switch (widget.Text)
                    {
                    case "壁置く":
                        widget.Text = "駒動かす";
                        break;

                    default:
                        widget.Text = "壁置く";
                        break;
                    }

                    shogibanGui2.RepaintRequest.SetFlag_RefreshRequest();
                };

                //
                // [出力切替]ボタンのイベント。
                //
                ins.delegate_BtnSyuturyokuKirikae = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    switch (shogibanGui2.SyuturyokuKirikae)
                    {
                    case SyuturyokuKirikae.Japanese:
                        shogibanGui2.SetSyuturyokuKirikae(SyuturyokuKirikae.Sfen);
                        break;

                    case SyuturyokuKirikae.Sfen:
                        shogibanGui2.SetSyuturyokuKirikae(SyuturyokuKirikae.Html);
                        break;

                    case SyuturyokuKirikae.Html:
                        shogibanGui2.SetSyuturyokuKirikae(SyuturyokuKirikae.Japanese);
                        break;
                    }

                    shogibanGui2.RepaintRequest.SyuturyokuRequest = RepaintRequestGedanTxt.Kifu;
                };

                //
                // [各種符号]ボタンのイベント。
                //
                ins.delegate_BtnKakusyuFugo = (
                    object obj_shogiGui2
                    , object userWidget2     // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    UserWidget     userWidget       = (UserWidget)userWidget2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;
                    UserWidget     widget           = shogibanGui2.GetWidget(userWidget.Name);

                    shogibanGui2.RepaintRequest.SetNyuryokuTextTail(widget.Fugo);
                };

                //
                // [全消]ボタンのイベント。
                //
                ins.delegate_BtnZenkesi = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    shogibanGui2.RepaintRequest.NyuryokuText = "";
                };

                //
                // [ここから採譜]ボタンのイベント。
                //
                ins.delegate_BtnKokokaraSaifu = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    UtilKifuTree282.SetStartpos_KokokaraSaifu(shogibanGui2.Link_Server.Model_Taikyoku.Kifu, shogibanGui2.Link_Server.Model_Taikyoku.Kifu.CurNode.Value.KyokumenConst.KaisiPside);
                    shogibanGui2.RepaintRequest.SyuturyokuRequest = RepaintRequestGedanTxt.Kifu;
                };

                //
                // [初期配置]ボタンのイベント。
                //
                ins.delegate_BtnSyokihaichi = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp shogibanGui2     = (MainGui_Csharp)obj_shogiGui2;

                    Util_Function_Csharp.Perform_SyokiHaichi(shogibanGui2);
                };

                //
                // [向き]ボタンのイベント。
                //
                ins.delegate_BtnMuki = (
                    object obj_shogiGui2
                    , object userWidget2 // UerWidget
                    , object btnKoma_Selected2
                    ) =>
                {
                    Shape_BtnKoma  btnKoma_Selected = (Shape_BtnKoma)btnKoma_Selected2;
                    MainGui_Csharp mainGui3         = (MainGui_Csharp)obj_shogiGui2;

                    Shape_BtnKoma movedKoma = mainGui3.Shape_PnlTaikyoku.Btn_MovedKoma();

                    RO_Star koma;
                    Finger  figKoma = Fingers.Error_1;

                    if (null != movedKoma)
                    {
                        //>>>>> 移動直後の駒があるとき
                        koma    = Util_Starlightable.AsKoma(mainGui3.Model_Manual.GuiSkyConst.StarlightIndexOf(movedKoma.Finger).Now);
                        figKoma = movedKoma.Finger;
                    }
                    else if (null != btnKoma_Selected)
                    {
                        //>>>>> 選択されている駒があるとき
                        koma    = Util_Starlightable.AsKoma(mainGui3.Model_Manual.GuiSkyConst.StarlightIndexOf(btnKoma_Selected.Koma).Now);
                        figKoma = btnKoma_Selected.Koma;
                    }
                    else
                    {
                        koma = null;
                    }

                    if (null != koma)
                    {
                        KifuNode modifyNode = new KifuNodeImpl(
                            mainGui3.Link_Server.Model_Taikyoku.Kifu.CurNode.Key,//現在の局面を流用
                            new KyokumenWrapper(
                                SkyConst.NewInstance_OverwriteOrAdd_Light(
                                    mainGui3.Model_Manual.GuiSkyConst,
                                    -1,//そのまま
                                    figKoma,
                                    new RO_Starlight(
                                        new RO_Star(
                                            Conv_Playerside.Reverse(koma.Pside),//向きを逆さにします。
                                            koma.Masu,
                                            koma.Komasyurui
                                            )
                                        )
                                    )
                                )
                            );
                        // ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                        // ここで局面データを変更します。
                        // ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                        string jsaFugoStr;
                        Util_Functions_Server.SetCurNode_Srv(
                            mainGui3.Link_Server.Model_Taikyoku,
                            mainGui3.Model_Manual,
                            modifyNode, out jsaFugoStr);
                        mainGui3.RepaintRequest.SetFlag_RefreshRequest();
                    }
                };
            }
            return(Event_CsharpImpl.instance);
        }