Beispiel #1
0
        /// <summary>
        /// Handles it-click to freeze first col.
        /// </summary>
        /// <param name="sender"><c><see cref="it_freeze1"/></c></param>
        /// <param name="e"></param>
        /// <remarks>Fired by
        /// <list type="bullet">
        /// <item>2daOps|Freeze 1st col <c>[F5]</c></item>
        /// </list></remarks>
        void opsclick_Freeze1stCol(object sender, EventArgs e)
        {
            Table.Select();

            it_freeze2.Checked = false;

            if (it_freeze1.Checked = !it_freeze1.Checked)
            {
                Col col = Table.Cols[FROZEN_COL_First];
                if (col.UserSized)
                {
                    col.UserSized = false;
                    Table.Colwidth(FROZEN_COL_First);
                }
                Table.FrozenCount = YataGrid.FreezeFirst;
            }
            else
            {
                Table.FrozenCount = YataGrid.FreezeId;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Overrides the <c>MouseUp</c> handler on this <c>YataPanelCols</c>.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
#if Clicks
            logfile.Log("YataPanelCols.OnMouseUp() e.Button= " + e.Button);
#endif
            Cursor        = Cursors.Default;
            IsCursorSplit = false;

            if (IsGrab)
            {
#if Clicks
                logfile.Log(". clear IsGrab");
#endif
                IsGrab = false;
                if (ModifierKeys == Keys.None &&
                    e.Button == MouseButtons.Left &&
                    e.X != _grabPos)
                {
#if Clicks
                    logfile.Log(". . do col-width adjust");
#endif
                    Col col = _grid.Cols[_grabCol];
                    col.UserSized = true;

                    int w = col.width() + e.X - _grabPos;
                    if (w < YataGrid._wId)
                    {
                        w = YataGrid._wId;
                    }

                    col.width(w, true);
                    _grid.InitScroll();
                    _grid.Invalidator(YataGrid.INVALID_GRID | YataGrid.INVALID_COLS);
                }
            }
            _grid.Select();
        }
Beispiel #3
0
        /// <summary>
        /// Resets the width of a specified col based on the cells in rows
        /// <paramref name="r"/> to <paramref name="r"/> +
        /// <paramref name="range"/>.
        /// </summary>
        /// <param name="c">col</param>
        /// <param name="r">first row to consider as changed (default -1 if
        /// deleting rows and/or no extant text-widths have changed; ie, no
        /// text-widths need to be re-measured)</param>
        /// <param name="range">range of rows to consider as changed (default 0
        /// for a single row)</param>
        internal void Colwidth(int c, int r = -1, int range = 0)
        {
            Col col = Cols[c];

            int colwidth = col._widthtext + _padHoriSort;
            int widthtext;

            if (r != -1)             // re-calc '_widthtext' regardless of what happens below ->
            {
                string text;

                int rend = r + range;
                for (; r <= rend; ++r)
                {
                    if ((text = this[r, c].text) == gs.Stars)                    // bingo.
                    {
                        widthtext = _wStars;
                    }
                    else
                    {
                        widthtext = YataGraphics.MeasureWidth(text, Font);
                    }

                    this[r, c]._widthtext = widthtext;

                    if (widthtext > colwidth)
                    {
                        colwidth = widthtext;
                    }
                }
            }

            if (!col.UserSized)                 // ie. don't resize a col that user has adjusted. If it needs to
            {                                   // be forced (eg. on reload) unflag UserSized on all cols first.
                int totalwidth = col.width();

                if ((colwidth += _padHori * 2) > totalwidth)
                {
                    col.width(colwidth);
                }
                else if (colwidth < totalwidth)                 // recalc width on the entire col
                {
                    if (c == 0 || _wId > colwidth)
                    {
                        colwidth = _wId;
                    }

                    for (r = 0; r != RowCount; ++r)
                    {
                        widthtext = this[r, c]._widthtext + _padHori * 2;

                        if (widthtext > colwidth)
                        {
                            colwidth = widthtext;
                        }
                    }
                    col.width(colwidth, true);
                }

                if (range == 0 && totalwidth != colwidth)                       // if range >0 let Calibrate() handle multiple
                {                                                               // cols or at least the scrollers and do the UI-update
                    InitScroll();
                    Invalidator(INVALID_GRID | INVALID_COLS);
                }
            }

            if (Propanel != null && Propanel.Visible)
            {
                Propanel.widthValcol();                 // TODO: Re-calc the 'c' col only.
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates a col.
        /// </summary>
        /// <param name="selc"></param>
        /// <seealso cref="CreateCols()"><c>CreateCols()</c></seealso>
        internal void CreateCol(int selc)
        {
            --selc;                               // the Field-count is 1 less than the col-count

            int fieldsLength = Fields.Length + 1; // create a new Fields array ->
            var fields       = new string[fieldsLength];

            for (int i = 0; i != fieldsLength; ++i)
            {
                if (i < selc)
                {
                    fields[i] = Fields[i];
                }
                else if (i == selc)
                {
                    fields[i] = InputDialog._colabel;

                    var col = new Col();
                    col.text       = InputDialog._colabel;
                    col._widthtext = YataGraphics.MeasureWidth(col.text, _f.FontAccent);
                    col.width(col._widthtext + _padHori * 2 + _padHoriSort);
                    col.selected = true;

                    Cols.Insert(i + 1, col);
                    ++ColCount;

                    for (int r = 0; r != RowCount; ++r)
                    {
                        var cells = new Cell[ColCount];                         // create a new Cells array in each row ->
                        for (int c = 0; c != ColCount; ++c)
                        {
                            if (c < selc + 1)
                            {
                                cells[c] = this[r, c];
                            }
                            else if (c == selc + 1)
                            {
                                cells[c]            = new Cell(r, c, gs.Stars);
                                cells[c].selected   = true;
                                cells[c]._widthtext = _wStars;
                            }
                            else                             // (c > selc + 1)
                            {
                                cells[c]    = this[r, c - 1];
                                cells[c].x += 1;
                            }
                        }
                        Rows[r]._cells  = cells;
                        Rows[r].Length += 1;
                    }
                }
                else                 // (i > selc)
                {
                    fields[i] = Fields[i - 1];
                }
            }
            Fields = fields;

            int w = _wStars + _padHori * 2;

            if (w > Cols[++selc].width())
            {
                Cols[selc].width(w);
            }

            InitScroll();
            EnsureDisplayedCol(selc);

            _f.EnableCelleditOperations();

            if (!Changed)
            {
                Changed = true;
            }
        }