Example #1
0
 void Clear()
 {
     Rows.Clear();
     Cols.Clear();
     Vals.Clear();
     Rows.Add(0);
 }
Example #2
0
        /// <summary>
        /// 使用DataTable来填充
        /// </summary>
        /// <param name="dt"></param>
        public void FillBy(DataTable dt)
        {
            Cols.Clear();
            Rows.Clear();
            var regCardNum = new Regex(msRegCardNum, RegexOptions.IgnoreCase);
            var bInitCols  = true;

            foreach (DataRow dataRow in dt.Rows)
            {
                var row = new RowType();
                foreach (DataColumn dataColumn in dt.Columns)
                {
                    var sCol = dataColumn.ColumnName;
                    if (!CheckValid(sCol))
                    {
                        continue;
                    }

                    var sCell = dataRow[sCol].ToString();
                    if (regCardNum.IsMatch(sCol))
                    {
                        //chage to base64 string
                        var    sTemp   = MyCrypt.Encode(sCell, 0x21); //简单加一加密码
                        byte[] bytes   = Encoding.ASCII.GetBytes(sTemp ?? string.Empty);
                        string sBase64 = Convert.ToBase64String(bytes);
                        sCell = sBase64;
                    }
                    if (bInitCols)
                    {
                        Cols.Add(sCol);
                    }
                    row.Add(sCell);
                }
                bInitCols = false;
                Rows.Add(row);
            }

            //没有记录集的话,也要输出列名
            if (0 == dt.Rows.Count)
            {
                foreach (DataColumn dataColumn in dt.Columns)
                {
                    var sCol = dataColumn.ColumnName;
                    if (!CheckValid(sCol))
                    {
                        continue;
                    }
                    Cols.Add(sCol);
                }
            }
        }
Example #3
0
 public void Reset()
 {
     IsReady = false;
     Cols.Clear();
     Rows.Clear();
 }
Example #4
0
        /// <summary>
        /// Initializes a loaded, reloaded, or created
        /// <c><see cref="YataGrid"/></c>.
        /// </summary>
        /// <param name="changed"></param>
        /// <param name="reload"></param>
        internal void Init(bool changed = false, bool reload = false)
        {
            if (reload)
            {
                _init = true;

                _scrollVert.Value     =
                    _scrollHori.Value = 0;

                _sortcol = 0;
                _sortdir = SORT_ASC;

                RangeSelect = 0;

                FrozenCount = YataGrid.FreezeId;

                Cols.Clear();
                Rows.Clear();

                Controls.Remove(_panelCols);
                Controls.Remove(_panelRows);
                Controls.Remove(FrozenPanel);

//				_panelCols  .Dispose(); // breaks the frozen-labels
//				_panelRows  .Dispose();
//				_panelFrozen.Dispose();
            }
            else
            {
                switch (Path.GetFileNameWithoutExtension(Fullpath).ToUpperInvariant())
                {
                case "CRAFTING":
                    Info = InfoType.INFO_CRAFT;
                    break;

                case "SPELLS":
                    Info = InfoType.INFO_SPELL;
                    break;

                case "FEAT":
                    Info = InfoType.INFO_FEAT;
                    break;

                case "CLASSES":
                    Info = InfoType.INFO_CLASS;
                    break;
                }

                if (!Groped && Info != InfoType.INFO_NONE)
                {
                    Groped = true;
                    foreach (var dir in Settings._pathall)
                    {
                        _f.GropeLabels(dir);
                    }
                }
            }

            Changed = changed;

            _panelCols = new YataPanelCols(this);
            _panelRows = new YataPanelRows(this);

            CreateCols();
            CreateRows();

            FrozenPanel = new YataPanelFrozen(this, Cols[0].width());
            initFrozenLabels();

            metricStaticHeads(_f);

            Controls.Add(FrozenPanel);
            Controls.Add(_panelRows);
            Controls.Add(_panelCols);


            _scrollVert.LargeChange     =
                _scrollHori.LargeChange = HeightRow;
            InitScroll();

            Select();
            _init = false;
        }