Beispiel #1
0
        /// <summary>コントロール取得&イベントハンドラ設定</summary>
        /// <param name="ctrl">コントロール</param>
        /// <param name="prefixAndEvtHndHt">プレフィックスとイベント ハンドラのディクショナリ</param>
        /// <param name="controlHt">コントロールのディクショナリ</param>
        internal static void GetCtrlAndSetClickEventHandler2(
            Control ctrl, Dictionary <string, object> prefixAndEvtHndHt, Dictionary <string, Control> controlHt)
        {
            // ループ
            foreach (string prefix in prefixAndEvtHndHt.Keys)
            {
                object eventHandler = prefixAndEvtHndHt[prefix];

                #region チェック処理

                // コントロール指定が無い場合
                if (ctrl == null)
                {
                    // 何もしないで戻る。
                    return;
                }

                // プレフィックス指定が無い場合
                if (prefix == null || prefix == "")
                {
                    // 何もしないで戻る。
                    return;
                }

                #endregion

                #region コントロール取得&イベントハンドラ設定

                // コントロールのIDチェック
                if (ctrl.ID == null)
                {
                    // コントロールID無し
                }
                else
                {
                    // コントロールID有り

                    // コントロールのID長確認
                    if (prefix.Length <= ctrl.ID.Length)
                    {
                        // 指定のプレフィックス
                        if (prefix == ctrl.ID.Substring(0, prefix.Length))
                        {
                            // イベントハンドラを設定する。
                            if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_BUTTON))
                            {
                                // BUTTON
                                Button button = FxCmnFunction.CastByAsOperator <Button>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                button.Click += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LINK_BUTTON))
                            {
                                // LINK BUTTON
                                LinkButton linkButton = FxCmnFunction.CastByAsOperator <LinkButton>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                linkButton.Click += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_BUTTON))
                            {
                                // IMAGE BUTTON
                                ImageButton imageButton = FxCmnFunction.CastByAsOperator <ImageButton>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                imageButton.Click += (ImageClickEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_MAP))
                            {
                                // IMAGE MAP
                                ImageMap imageMap = FxCmnFunction.CastByAsOperator <ImageMap>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                imageMap.Click += (ImageMapEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            //else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_COMMAND))
                            //{
                            //    // COMMAND
                            //    Command command = FxCmnFunction.CastByAsOperator<Command>(ctrl, prefix);

                            //    // ハンドラをキャストして設定
                            //    command.Click += (EventHandler)eventHandler;

                            //    // ディクショナリに格納
                            //    controlHt[ctrl.ID] = ctrl;
                            //    break;
                            //}
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_DROP_DOWN_LIST))
                            {
                                // DROP DOWN LIST
                                DropDownList dropDownList = FxCmnFunction.CastByAsOperator <DropDownList>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                dropDownList.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LIST_BOX))
                            {
                                // LIST BOX
                                ListBox listBox = FxCmnFunction.CastByAsOperator <ListBox>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                listBox.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIO_BUTTON))
                            {
                                // RADIO BUTTON
                                RadioButton radioButton = FxCmnFunction.CastByAsOperator <RadioButton>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                radioButton.CheckedChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }

                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIOBUTTONLIST))
                            {
                                // RADIOBUTTONLIST
                                RadioButtonList radioButtonlist = FxCmnFunction.CastByAsOperator <RadioButtonList>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                radioButtonlist.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }

                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_CHECKBOXLIST))
                            {
                                // CHECKBOXLIST
                                CheckBoxList checkboxlist = FxCmnFunction.CastByAsOperator <CheckBoxList>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                checkboxlist.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_REPEATER))
                            {
                                // REPEATER
                                Repeater repeater = FxCmnFunction.CastByAsOperator <Repeater>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                repeater.ItemCommand += (RepeaterCommandEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_GRIDVIEW))
                            {
                                // GRIDVIEW
                                GridView gridView = FxCmnFunction.CastByAsOperator <GridView>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                object[] eventHandlers = ((object[])eventHandler);

                                // 全コマンド
                                gridView.RowCommand += (GridViewCommandEventHandler)eventHandlers[0];
                                // 選択
                                gridView.SelectedIndexChanged += (EventHandler)eventHandlers[1];
                                // 編集(更新)
                                gridView.RowUpdating += (GridViewUpdateEventHandler)eventHandlers[2];
                                // 編集(削除)
                                gridView.RowDeleting += (GridViewDeleteEventHandler)eventHandlers[3];
                                // ページング
                                gridView.PageIndexChanging += (GridViewPageEventHandler)eventHandlers[4];
                                // ソーティング
                                gridView.Sorting += (GridViewSortEventHandler)eventHandlers[5];

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LISTVIEW))
                            {
                                // LISTVIEW
                                ListView listView = FxCmnFunction.CastByAsOperator <ListView>(ctrl, prefix);

                                // ハンドラをキャストして設定
                                object[] eventHandlers = ((object[])eventHandler);

                                // Delete
                                listView.ItemDeleting += (EventHandler <ListViewDeleteEventArgs>)eventHandlers[0];
                                //Update
                                listView.ItemUpdating += (EventHandler <ListViewUpdateEventArgs>)eventHandlers[1];
                                // Paging
                                listView.PagePropertiesChanged += (EventHandler)eventHandlers[2];
                                //Sorting event handler
                                listView.Sorting += (EventHandler <ListViewSortEventArgs>)eventHandlers[3];
                                //ItemCommand event handler
                                listView.ItemCommand += (EventHandler <ListViewCommandEventArgs>)eventHandlers[5];
                                FxCmnFunction.AddControlToDic(ctrl, controlHt);
                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                FxCmnFunction.AddControlToDic(ctrl, controlHt);
                            }
                        }
                    }
                }

                #endregion
            }

            #region 再帰

            // 子コントロールがある場合、
            if (ctrl.HasControls())
            {
                // 子コントロール毎に
                foreach (Control childCtrl in ctrl.Controls)
                {
                    // 再帰する。
                    FxCmnFunction.GetCtrlAndSetClickEventHandler2(childCtrl, prefixAndEvtHndHt, controlHt);
                }
            }

            #endregion
        }
Beispiel #2
0
        /// <summary>コントロール取得&イベントハンドラ設定</summary>
        /// <param name="ctrl">コントロール</param>
        /// <param name="prefixAndEvtHndHt">プレフィックスとイベント ハンドラのディクショナリ</param>
        /// <param name="controlHt">コントロールのディクショナリ</param>
        internal static void GetCtrlAndSetClickEventHandler2(
            Control ctrl, Dictionary <string, object> prefixAndEvtHndHt, Dictionary <string, Control> controlHt)
        {
            // ループ
            foreach (string prefix in prefixAndEvtHndHt.Keys)
            {
                object eventHandler = prefixAndEvtHndHt[prefix];

                #region チェック処理

                // コントロール指定が無い場合
                if (ctrl == null)
                {
                    // 何もしないで戻る。
                    return;
                }

                // プレフィックス指定が無い場合
                if (prefix == null || prefix == "")
                {
                    // 何もしないで戻る。
                    return;
                }

                #endregion

                #region コントロール取得&イベントハンドラ設定

                // コントロールのIDチェック
                if (ctrl.ID == null)
                {
                    // コントロールID無し
                }
                else
                {
                    // コントロールID有り

                    // コントロールのID長確認
                    if (prefix.Length <= ctrl.ID.Length)
                    {
                        // 指定のプレフィックス
                        if (prefix == ctrl.ID.Substring(0, prefix.Length))
                        {
                            // イベントハンドラを設定する。
                            if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_BUTTON))
                            {
                                // BUTTON
                                Button button = null;

                                if (ctrl is Button)
                                {
                                    // キャストできる
                                    button = (Button)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                button.Click += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LINK_BUTTON))
                            {
                                // LINK BUTTON
                                LinkButton linkButton = null;

                                if (ctrl is LinkButton)
                                {
                                    // キャストできる
                                    linkButton = (LinkButton)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                linkButton.Click += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_BUTTON))
                            {
                                // IMAGE BUTTON
                                ImageButton imageButton = null;

                                if (ctrl is ImageButton)
                                {
                                    // キャストできる
                                    imageButton = (ImageButton)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                imageButton.Click += (ImageClickEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_MAP))
                            {
                                // IMAGE MAP
                                ImageMap imageMap = null;

                                if (ctrl is ImageMap)
                                {
                                    // キャストできる
                                    imageMap = (ImageMap)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                imageMap.Click += (ImageMapEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            //else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_COMMAND))
                            //{
                            //    // COMMAND
                            //    Command command = null;

                            //    if (ctrl is Command)
                            //    {
                            //        // キャストできる
                            //        command = (Command)ctrl;
                            //    }
                            //    else
                            //    {
                            //        // キャストできない
                            //        throw new FrameworkException(
                            //            FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                            //            String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                            //            prefix, ctrl.GetType().ToString()));
                            //    }

                            //    command.Click += (EventHandler)eventHandler;

                            //    // ディクショナリに格納
                            //    controlHt[ctrl.ID] = ctrl;
                            //    break;
                            //}
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_DROP_DOWN_LIST))
                            {
                                // DROP DOWN LIST
                                DropDownList dropDownList = null;

                                if (ctrl is DropDownList)
                                {
                                    // キャストできる
                                    dropDownList = (DropDownList)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                dropDownList.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LIST_BOX))
                            {
                                // LIST BOX
                                ListBox listBox = null;

                                if (ctrl is ListBox)
                                {
                                    // キャストできる
                                    listBox = (ListBox)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                listBox.SelectedIndexChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIO_BUTTON))
                            {
                                // RADIO BUTTON
                                RadioButton radioButton = null;

                                if (ctrl is RadioButton)
                                {
                                    // キャストできる
                                    radioButton = (RadioButton)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                radioButton.CheckedChanged += (EventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_REPEATER))
                            {
                                // REPEATER
                                Repeater repeater = null;

                                if (ctrl is Repeater)
                                {
                                    // キャストできる
                                    repeater = (Repeater)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                repeater.ItemCommand += (RepeaterCommandEventHandler)eventHandler;

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                            else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_GRIDVIEW))
                            {
                                // GRIDVIEW
                                GridView gridView = null;

                                if (ctrl is GridView)
                                {
                                    // キャストできる
                                    gridView = (GridView)ctrl;
                                }
                                else
                                {
                                    // キャストできない
                                    throw new FrameworkException(
                                              FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                              String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                                            prefix, ctrl.GetType().ToString()));
                                }

                                // キャスト
                                object[] eventHandlers = ((object[])eventHandler);

                                // 全コマンド
                                gridView.RowCommand += (GridViewCommandEventHandler)eventHandlers[0];
                                // 選択
                                gridView.SelectedIndexChanged += (EventHandler)eventHandlers[1];
                                // 編集(更新)
                                gridView.RowUpdating += (GridViewUpdateEventHandler)eventHandlers[2];
                                // 編集(削除)
                                gridView.RowDeleting += (GridViewDeleteEventHandler)eventHandlers[3];
                                // ページング
                                gridView.PageIndexChanging += (GridViewPageEventHandler)eventHandlers[4];
                                // ソーティング
                                gridView.Sorting += (GridViewSortEventHandler)eventHandlers[5];

                                // ディクショナリに格納
                                controlHt[ctrl.ID] = ctrl;
                                break;
                            }
                        }
                    }
                }

                #endregion
            }

            #region 再帰

            // 子コントロールがある場合、
            if (ctrl.HasControls())
            {
                // 子コントロール毎に
                foreach (Control childCtrl in ctrl.Controls)
                {
                    // 再帰する。
                    FxCmnFunction.GetCtrlAndSetClickEventHandler2(childCtrl, prefixAndEvtHndHt, controlHt);
                }
            }

            #endregion
        }