Exemple #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
        }
Exemple #2
0
        /// <summary>コントロール取得&イベントハンドラ設定(下位互換)</summary>
        /// <param name="ctrl">コントロール</param>
        /// <param name="prefix">プレフィックス</param>
        /// <param name="eventHandler">イベント ハンドラ</param>
        /// <param name="controlHt">コントロールのディクショナリ</param>
        internal static void GetCtrlAndSetClickEventHandler(
            Control ctrl, string prefix, object eventHandler, Dictionary <string, Control> controlHt)
        {
            #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;

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

                            button.Click += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LINK_BUTTON))
                        {
                            // LINK BUTTON
                            LinkButton linkButton = null;

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

                            linkButton.Click += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_BUTTON))
                        {
                            // IMAGE BUTTON
                            ImageButton imageButton = null;

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

                            imageButton.Click += (ImageClickEventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_IMAGE_MAP))
                        {
                            // IMAGE MAP
                            ImageMap imageMap = null;

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

                            imageMap.Click += (ImageMapEventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        //else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_COMMAND))
                        //{
                        //    // COMMAND
                        //    Command command = null;

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

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

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

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

                            dropDownList.SelectedIndexChanged += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LIST_BOX))
                        {
                            // LIST BOX
                            ListBox listBox = null;

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

                            listBox.SelectedIndexChanged += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIO_BUTTON))
                        {
                            // RADIO BUTTON
                            RadioButton radioButton = null;

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

                            radioButton.CheckedChanged += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_REPEATER))
                        {
                            // REPEATER
                            Repeater repeater = null;

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

                            repeater.ItemCommand += (RepeaterCommandEventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                        else if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_GRIDVIEW))
                        {
                            // GRIDVIEW
                            GridView gridView = null;

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

                            // キャスト
                            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.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                    }
                }
            }

            #endregion

            #region 再帰

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

            #endregion
        }