コード例 #1
0
        // <イベントの説明>
        // TextBox1からTextBox2にフォーカスを移動したときのイベントの発生順序。
        // http://homepage1.nifty.com/rucio/main/dotnet/shokyu/standard23.htm

        // マウス、またはFocusメソッドでフォーカスを移動する場合
        // -----------------------------------------------------
        // TextBox1.LostFocus → TextBox1.Leave
        // → TextBox1.Validating → TextBox1.Validated
        // → TextBox2.Enter → TextBox2.GotFocus

        // その他の方法でフォーカスを移動する場合
        // -----------------------------------------------------
        // TextBox1.Leave → TextBox1.Validating → TextBox1.Validated
        // → TextBox2.Enter → TextBox1.LostFocus → TextBox2.GotFocus

        // ★共通する法則★
        // -----------------------------------------------------
        // TextBox1.Leave → TextBox1.Validating → TextBox1.Validated → TextBox2.Enter
        // TextBox1.Enter → TextBox1.Leave → TextBox1.Validating → TextBox1.Validated

        #region 初期化処理(Layout)

        /// <summary>初期化処理</summary>
        private void WinCustomMaskedTextBox_Layout(object sender, EventArgs e)
        {
            if (!RcFxCmnFunction.IsDesignMode())
            {
                // デザイン・モードでは無い場合。
                if (base.Text == "" &&
                    this.CheckType.IsNumeric &&
                    this.EditInitialValue == EditInitialValue.Zero)
                {
                    // 「0」初期化
                    base.Text = "0";
                    this.ReEdit();
                }
            }
        }
コード例 #2
0
        /// <summary>動的に追加したコントロールをLstUserControlに追加する</summary>
        /// <param name="sender">object</param>
        /// <param name="e">ControlEventArgs</param>
        private void groupBox_ControlAdded(object sender, ControlEventArgs e)
        {
            // UOC_イベントハンドラ内で追加/削除すると例外が発生するのでBeginInvokeで書く。
            this.BeginInvoke(
                (MethodInvoker <Control>)((x) =>
            {
                // UserControlの追加処理
                if (x is UserControl)
                {
                    // コントロール検索&イベントハンドラ設定(ルートから1回だけ行う)
                    RcFxCmnFunction.GetCtrlAndSetClickEventHandler2(
                        x, this.CreatePrefixAndEvtHndHt(), this.ControlHt);       // Base
                    RcMyCmnFunction.GetCtrlAndSetClickEventHandler2(
                        x, this.MyCreatePrefixAndEvtHndHt(), this.ControlHt);     // MyBase

                    // UserControlのLstUserControlへの追加(は再帰的に行う)
                    this.AddToLstUserControl(x);
                }
            }),
                new object[] { e.Control });
        }
コード例 #3
0
        /// <summary>Form_Loadのイベントハンドラ</summary>
        private void Form_Load(object sender, EventArgs e)
        {
            try
            {
                #region ウィンドウ数・インスタンス管理

                //lock (_lock)
                //{

                // ウィンドウ数管理

                // - 全Form型
                ++BaseControllerWin._intWindowsCount;

                // - 当該Form型
                if (BaseControllerWin._dicWindowsCount.ContainsKey(this.GetType()))
                {
                    // 初回以降(インクリメント)
                    int i = BaseControllerWin._dicWindowsCount[this.GetType()];
                    BaseControllerWin._dicWindowsCount[this.GetType()] = ++i;
                }
                else
                {
                    // 初回(初期化)
                    BaseControllerWin._dicWindowsCount[this.GetType()] = 1;
                }

                // ウィンドウ インスタンス管理
                if (BaseControllerWin._windowInstances.ContainsKey(this.GetType()))
                {
                    // 初回以降(インクリメント)
                    List <Form> list = BaseControllerWin._windowInstances[this.GetType()];

                    list.Add(this);
                    BaseControllerWin._windowInstances[this.GetType()] = list;
                }
                else
                {
                    // 初回(初期化)
                    List <Form> list = new List <Form>();

                    list.Add(this);
                    BaseControllerWin._windowInstances[this.GetType()] = list;
                }

                //}

                #endregion

                #region コントロールの初期化
                if (!this.IsInitializedEvent)
                {
                    // ユーザ コントロールの検索&取得
                    this.GetUserControl(this);

                    // コントロール検索&取得&イベントハンドラ設定
                    RcFxCmnFunction.GetCtrlAndSetClickEventHandler2(
                        this, this.CreatePrefixAndEvtHndHt(), this.ControlHt);
                }
                #endregion

                #region 画面の初期処理

                this.UOC_CMNFormInit();
                this.UOC_FormInit();
                this.UOC_CMNAfterFormInit();

                #endregion
            }
            catch (BusinessApplicationException baEx)
            {
                // アプリケーション例外発生時の処理は派生クラスに記述する。
                this.UOC_ABEND(baEx, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // アプリケーション例外はリスローしない。
            }
            catch (BusinessSystemException bsEx)
            {
                // システム例外発生時の処理は派生クラスに記述する。
                this.UOC_ABEND(bsEx, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // システム例外はリスローする。
                throw;
            }
            //catch (System.Threading.ThreadAbortException taEx)
            //{
            //    // スレッド中断エラーの場合は何もしない
            //    Exception ex = taEx; // ← 警告を出さないため
            //}
            catch (Exception ex)
            {
                // 一般的な例外発生時の処理は派生クラスに記述する
                this.UOC_ABEND(ex, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // 一般的な例外はリスローする。
                throw;
            }
            finally
            {
                // 初回のみ実行
                this._isInitializedEvent = true;

                // Finally節のUOCメソッド
                this.UOC_Finally(new RcFxEventArgs(
                                     FxLiteral.EVENT_FORM_LOAD, "", sender, e));
            }
        }
コード例 #4
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 コントロール取得&イベントハンドラ設定

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

                // コントロールのName長確認
                if (prefix.Length <= ctrl.Name.Length)
                {
                    // 指定のプレフィックス
                    if (prefix == ctrl.Name.Substring(0, prefix.Length))
                    {
                        // イベントハンドラを設定する。
                        if (prefix == GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX))
                        {
                            // CHECK BOX
                            CheckBox checkBox = RcFxCmnFunction.CastByAsOperator <CheckBox>(ctrl, prefix);

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

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.Name, ctrl);
                            ControlHt[ctrl.Name] = ctrl; // 2009/08/10-この行
                        }
                    }
                }
            }

            #endregion

            #region 再起

            // 子コントロールがある場合、
            if (ctrl.Controls.Count != 0)
            {
                // 子コントロール毎に
                foreach (Control childCtrl in ctrl.Controls)
                {
                    // 再起する。
                    RcMyCmnFunction.GetCtrlAndSetClickEventHandler(childCtrl, prefix, eventHandler, ControlHt);
                }
            }

            #endregion
        }
コード例 #5
0
        /// <summary>Form_Loadのイベントハンドラ</summary>
        private void Form_Load(object sender, EventArgs e)
        {
            try
            {
                #region ウィンドウ数・インスタンス管理

                //lock (_lock)
                //{

                // ウィンドウ数管理

                // 全Form型
                ++BaseControllerWin._intWindowsCount;

                // 当該Form型
                if (BaseControllerWin._dicWindowsCount.ContainsKey(this.GetType()))
                {
                    // 初回以降(インクリメント)
                    int i = BaseControllerWin._dicWindowsCount[this.GetType()];
                    BaseControllerWin._dicWindowsCount[this.GetType()] = ++i;
                }
                else
                {
                    // 初回(初期化)
                    BaseControllerWin._dicWindowsCount[this.GetType()] = 1;
                }

                // ・・・

                // ウィンドウ インスタンス管理
                if (BaseControllerWin._windowInstances.ContainsKey(this.GetType()))
                {
                    // 初回以降(インクリメント)
                    List <Form> list = BaseControllerWin._windowInstances[this.GetType()];

                    list.Add(this);
                    BaseControllerWin._windowInstances[this.GetType()] = list;
                }
                else
                {
                    // 初回(初期化)
                    List <Form> list = new List <Form>();

                    list.Add(this);
                    BaseControllerWin._windowInstances[this.GetType()] = list;
                }

                //}

                #endregion

                // ユーザ コントロールの初期化
                this.GetUserControl(this);

                #region コントロール取得処理

                #region 旧処理
                //// BUTTON
                //RcFxCmnFunction.GetCtrlAndSetClickEventHandler(
                //    this, GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_BUTTON),
                //    new System.EventHandler(this.Button_Click), this.ControlHt);

                //// PICTURE BOX
                //RcFxCmnFunction.GetCtrlAndSetClickEventHandler(
                //    this, GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_PICTURE_BOX),
                //    new System.EventHandler(this.Button_Click), this.ControlHt);

                //// COMBO BOX
                //RcFxCmnFunction.GetCtrlAndSetClickEventHandler(
                //    this, GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_COMBO_BOX),
                //    new System.EventHandler(this.List_SelectedIndexChanged), this.ControlHt);

                //// LIST BOX
                //RcFxCmnFunction.GetCtrlAndSetClickEventHandler(
                //    this, GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LIST_BOX),
                //    new System.EventHandler(this.List_SelectedIndexChanged), this.ControlHt);

                //// RADIO BUTTON
                //RcFxCmnFunction.GetCtrlAndSetClickEventHandler(
                //    this, GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIO_BUTTON),
                //    new System.EventHandler(this.Check_CheckedChanged), this.ControlHt);
                #endregion

                // コントロール検索&イベントハンドラ設定
                RcFxCmnFunction.GetCtrlAndSetClickEventHandler2(
                    this, this.CreatePrefixAndEvtHndHt(), this.ControlHt);

                #endregion

                #region 画面の初期処理

                this.UOC_CMNFormInit();
                this.UOC_FormInit();
                this.UOC_CMNAfterFormInit();

                #endregion
            }
            catch (BusinessApplicationException baEx)
            {
                // アプリケーション例外発生時の処理は派生クラスに記述する。
                this.UOC_ABEND(baEx, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // アプリケーション例外はリスローしない。
            }
            catch (BusinessSystemException bsEx)
            {
                // システム例外発生時の処理は派生クラスに記述する。
                this.UOC_ABEND(bsEx, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // システム例外はリスローする。
                throw;
            }
            //catch (System.Threading.ThreadAbortException taEx)
            //{
            //    // スレッド中断エラーの場合は何もしない
            //    Exception ex = taEx; // ← 警告を出さないため
            //}
            catch (Exception ex)
            {
                // 一般的な例外発生時の処理は派生クラスに記述する
                this.UOC_ABEND(ex, new RcFxEventArgs(
                                   FxLiteral.EVENT_FORM_LOAD, "", sender, e));

                // 一般的な例外はリスローする。
                throw;
            }
            finally
            {
                // Finally節のUOCメソッド
                this.UOC_Finally(new RcFxEventArgs(
                                     FxLiteral.EVENT_FORM_LOAD, "", sender, e));
            }
        }