コード例 #1
0
ファイル: RowCreatorDialog.cs プロジェクト: kevL/yata
        /// <summary>
        /// Overrides the <c>FormClosing</c> handler.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (!(e.Cancel = _cancel))
            {
                if (rb_StartAdd.Checked)
                {
                    _strt = StrtType.Add;
                }
                else                 // rb_StartInsert.Checked
                {
                    _strt = StrtType.Insert;
                }

                if (rb_StopCount.Checked)
                {
                    _stop = StopType.Count;
                }
                else                 // rb_StopFinish.Checked
                {
                    _stop = StopType.Finish;
                }

                int result;
                if (Int32.TryParse(tb_StopCount.Text, out result) &&
                    result > 0)
                {
                    _count = tb_StopCount.Text;
                }
                else
                {
                    _count = "1";
                }

                base.OnFormClosing(e);
            }
            else
            {
                _cancel = false;
            }
        }
コード例 #2
0
ファイル: RowCreatorDialog.cs プロジェクト: kevL/yata
        /// <summary>
        /// cTor.
        /// </summary>
        /// <param name="f">the <c><see cref="Yata"/></c></param>
        /// <param name="r">the currently selected row-id</param>
        /// <param name="copyfillenabled"><c>true</c> if at least one
        /// <c><see cref="Row"/></c> has been copied into
        /// <c><see cref="Yata"/>._copyr</c></param>
        internal RowCreatorDialog(Yata f, int r, bool copyfillenabled)
        {
            _f = f;

            InitializeComponent();
            Initialize(YataDialog.METRIC_LOC, true);

            if (r != -1)
            {
                _strt = StrtType.Insert;
                _stop = StopType.Count;
            }
            else
            {
                _strt = StrtType.Add;

                rb_FillSelected.Enabled   = false;
                la_FillSelected.ForeColor = SystemColors.GrayText;
            }

            if (!copyfillenabled)
            {
                rb_FillCopied.Enabled   = false;
                la_FillCopied.ForeColor = SystemColors.GrayText;
            }


            _init = true;

            switch (_strt)
            {
            case StrtType.Add:
                rb_StartAdd.Checked     =
                    tb_StartAdd.Enabled = true;

                rb_StartInsert.Checked     =
                    tb_StartInsert.Enabled = false;
                break;

            case StrtType.Insert:
                rb_StartAdd.Checked     =
                    tb_StartAdd.Enabled = false;

                rb_StartInsert.Checked     =
                    tb_StartInsert.Enabled = true;
                break;
            }

            switch (_stop)
            {
            case StopType.non:
                rb_StopFinish.Checked     =
                    tb_StopFinish.Enabled = _strt == StrtType.Add;

                rb_StopCount.Checked     =
                    tb_StopCount.Enabled = _strt == StrtType.Insert;
                break;

            case StopType.Finish:
                rb_StopFinish.Checked     =
                    tb_StopFinish.Enabled = true;

                rb_StopCount.Checked     =
                    tb_StopCount.Enabled = false;
                break;

            case StopType.Count:
                rb_StopFinish.Checked     =
                    tb_StopFinish.Enabled = false;

                rb_StopCount.Checked     =
                    tb_StopCount.Enabled = true;
                break;
            }

            tb_StartAdd.Text    = Yata.Table.Rows.Count.ToString(CultureInfo.InvariantCulture);
            tb_StartInsert.Text = (r + 1).ToString(CultureInfo.InvariantCulture);

            int     result = Int32.Parse(_count, CultureInfo.InvariantCulture);         // shall be valid and greater than 0.
            Control tb;

            if (rb_StartAdd.Checked)                                                                                            // readonly - shall be valid.
            {
                tb             = tb_StartAdd;
                bu_Accept.Text = ADD;
            }
            else             // rb_StartInsert.Checked									// shall be valid.
            {
                tb             = tb_StartInsert;
                bu_Accept.Text = INSERT;
            }

            tb_StopFinish.Text = (Int32.Parse(tb.Text, CultureInfo.InvariantCulture) + result - 1).ToString(CultureInfo.InvariantCulture);
            tb_StopCount.Text  = _count;

            _init = false;

            tb_StartAdd.BackColor = Colors.TextboxReadonly;

            if (rb_StartInsert.Checked)
            {
                tb_StartInsert.BackColor = Colors.TextboxSelected;
            }
            else
            {
                tb_StartInsert.BackColor = Colors.TextboxBackground;
            }

            if (rb_StopFinish.Checked)
            {
                tb_StopFinish.BackColor = Colors.TextboxSelected;
                tb_StopCount.BackColor  = Colors.TextboxBackground;
            }
            else             // rb_StopCount.Checked
            {
                tb_StopFinish.BackColor = Colors.TextboxBackground;
                tb_StopCount.BackColor  = Colors.TextboxSelected;
            }

            bu_Accept.Select();
        }