コード例 #1
0
        /// <summary>
        /// 将 <paramref name="cell"/> 置于编辑状态。
        /// </summary>
        /// <param name="cell">要编辑的单元格。</param>
        /// <param name="rect">编辑器放置的位置。</param>
        public void BeginEdit(TreeListCell cell, Rectangle rect)
        {
            Guard.ArgumentNull(cell, "cell");

            if (IsEditing && cell == Cell)
            {
                return;
            }

            rect.Inflate(-1, -1);

            AcceptEdit();

            if (!cell.Column.Editable || cell.Column.Editor == null)
            {
                return;
            }

            editor = cell.Column.Editor;
            Cell   = cell;
            var control = (Control)editor;

            treelist.Controls.Add(control);

            IsEditing         = true;
            editor.Controller = this;
            editor.SetValue(cell.Value);
            editor.Show(rect);
        }
コード例 #2
0
        internal void Show(TreeListCell cell, Rectangle rect)
        {
            Initialize(cell);

            inner.Show(cell.Text, treelist, rect.X - 2, rect.Y + (rect.Height - size.Height - 2) / 2 + 1);
            IsShow = true;
        }
コード例 #3
0
        private void Initialize(TreeListCell cell)
        {
            if (inner != null)
            {
                inner.Dispose();
            }

            var font = cell.Column.Font ?? cell.Column.TreeList.Font;

            size         = TextRenderer.MeasureText(cell.Text, font);
            size.Height += 8;
            size.Width  += 6;

            inner = new ToolTip();
            inner.ToolTipTitle = "dfdsafafd";
            inner.OwnerDraw    = true;
            inner.Popup       += (o, e) =>
            {
                e.ToolTipSize = size;
            };

            inner.Draw += (o, e) =>
            {
                var flags = TextFormatFlags.VerticalCenter;
                var r     = e.Bounds;
                r.Offset(3, 0);
                using (var br = new LinearGradientBrush(e.Bounds, Color.White, Color.LightGray, 90))
                {
                    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                }

                e.DrawBorder();
                TextRenderer.DrawText(e.Graphics, cell.Text, font, r, Color.Black, flags);
            };
        }
コード例 #4
0
        protected internal void RaiseAfterCellEditedEvent(TreeListCell cell, bool enterKey)
        {
            var e = new TreeListAfterCellEditedEventArgs {
                Cell = cell, EnterKey = enterKey
            };

            OnAfterCellEdited(e);
        }
コード例 #5
0
        protected internal void RaiseCellDataBoundEvent(TreeListCell cell, object data, object value)
        {
            var e = new TreeListCellDataBoundEventArgs {
                Cell = cell, ItemData = data, Value = value
            };

            OnCellDataBound(e);
        }
コード例 #6
0
        protected internal void RaiseAfterCellCheckChangeEvent(TreeListCell cell)
        {
            var e = new TreeListCellEventArgs {
                Cell = cell
            };

            OnAfterCellCheckChange(e);
        }
コード例 #7
0
        protected internal void RaiseCellClickEvent(TreeListCell cell)
        {
            var e = new TreeListCellEventArgs {
                Cell = cell
            };

            OnCellClick(e);
        }
コード例 #8
0
        protected internal bool RaiseBeforeCellEditingEvent(TreeListCell cell)
        {
            var e = new TreeListBeforeCellEditingEventArgs {
                Cell = cell
            };

            OnBeforeCellEditing(e);
            return(e.Cancel);
        }
コード例 #9
0
        protected internal bool RaiseBeforeCellCheckChangeEvent(TreeListCell cell)
        {
            var e = new TreeListCellCancelEventArgs {
                Cell = cell
            };

            OnBeforeCellCheckChange(e);
            return(e.Cancel);
        }
コード例 #10
0
        protected internal bool RaiseAfterCellUpdatedEvent(TreeListCell cell, object oldValue, object newValue, bool enterKey)
        {
            var e = new TreeListAfterCellUpdatedEventArgs {
                Cell = cell, OldValue = oldValue, NewValue = newValue, EnterKey = enterKey
            };

            OnAfterCellUpdated(e);
            return(e.EnterKey);
        }
コード例 #11
0
        protected internal bool RaiseBeforeCellUpdatingEvent(TreeListCell cell, object oldValue, ref object newValue)
        {
            var e = new TreeListBeforeCellUpdatingEventArgs {
                Cell = cell, OldValue = oldValue, NewValue = newValue
            };

            OnBeforeCellUpdating(e);
            newValue = e.NewValue;
            return(e.Cancel);
        }
コード例 #12
0
        private string GetDrawingText(TreeListCell cell, out bool isNullText)
        {
            var cellText = cell.Text;

            if (string.IsNullOrEmpty(cellText) && !string.IsNullOrEmpty(cell.NullText))
            {
                isNullText = true;
                return(cell.NullText);
            }

            isNullText = false;
            return(cellText);
        }
コード例 #13
0
 protected virtual TreeListDecorationRenderer CreateDecorationRenderer(TreeListCell cell)
 {
     if (cell.Column.Index == 0)
     {
         return(new TreeListIdentityDecorationRenderer());
     }
     else if (cell.Column.DataType == TreeListCellDataType.Boolean)
     {
         return(new TreeListBooleanDecorationRenderer());
     }
     else
     {
         return(new TreeListDefaultDecorationRenderer());
     }
 }
コード例 #14
0
        /// <summary>
        /// 根据 <see cref="TreeListCell"/> 的值绘制进度条。
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cell"></param>
        /// <param name="rect"></param>
        private void DrawProgressValueBar(Graphics graphics, TreeListCell cell, Rectangle rect)
        {
            if (Application.RenderWithVisualStyles)
            {
                var element = VisualStyleElement.ProgressBar.Chunk.Normal;
                if (VisualStyleRenderer.IsElementDefined(element))
                {
                    new VisualStyleRenderer(element).DrawBackground(graphics, rect);
                    return;
                }
            }

            rect.Inflate(-1, -1);
            graphics.FillRectangle(SystemBrushes.Highlight, rect);
        }
コード例 #15
0
        /// <summary>
        /// 绘制进度条的背景。
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cell"></param>
        /// <param name="rect"></param>
        private void DrawProgressBackground(Graphics graphics, TreeListCell cell, Rectangle rect)
        {
            if (Application.RenderWithVisualStyles)
            {
                var element = VisualStyleElement.ProgressBar.Bar.Normal;
                if (VisualStyleRenderer.IsElementDefined(element))
                {
                    new VisualStyleRenderer(element).DrawBackground(graphics, rect);
                    return;
                }
            }

            graphics.FillRectangle(SystemBrushes.Window, rect);
            ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.Flat);
        }
コード例 #16
0
        internal override void Update(TreeList treelist, TreeListItem parent, int level)
        {
            if (statInfo != null)
            {
                for (var i = Cells.Count; i < treelist.Columns.Count; i++)
                {
                    var cell = new TreeListCell();
                    cell.Value = GetStatPropertyValue(treelist.Columns[i].DataKey);

                    Cells.Add(cell);
                }
            }

            base.Update(treelist, parent, level);
        }
コード例 #17
0
        /// <summary>
        /// 绘制子项的文本。
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cell"></param>
        /// <param name="rect"></param>
        /// <param name="state"></param>
        protected virtual void DrawCellText(Graphics graphics, TreeListCell cell, Rectangle rect, DrawState state)
        {
            var item      = cell.Item;
            var column    = cell.Column;
            var treeList  = item.TreeList;
            var foreColor = state == DrawState.Selected && treeList.Focused ? SystemColors.Window :
                            (!column.CellForeColor.IsEmpty ? column.CellForeColor : (!column.ForeColor.IsEmpty ? column.ForeColor :
                                                                                     (!item.ForeColor.IsEmpty ? item.ForeColor : treeList.ForeColor)));
            var font = column.CellFont ?? column.Font ?? item.Font ?? treeList.Font;

            var text = GetDrawingText(cell, out bool isNullText);

            if (isNullText && !(state == DrawState.Selected && treeList.Focused))
            {
                foreColor = Color.DarkGray;
            }

            if (item.Highlight)
            {
                foreColor = Color.White;
            }
            else if (state == DrawState.Hot)
            {
                foreColor = SystemColors.HotTrack;
            }

            var flags = TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.PreserveGraphicsClipping;

            if (cell.Column.TreeList.ColumnHorizontalCenter || cell.Column.TextAlign == HorizontalAlignment.Center)
            {
                flags |= TextFormatFlags.HorizontalCenter;
            }
            else if (cell.Column.TextAlign == HorizontalAlignment.Right)
            {
                flags |= TextFormatFlags.Right;
            }

            //graphics.DrawString(text, font, new SolidBrush(foreColor), rect, sf);
            TextRenderer.DrawText(graphics, text, font, rect, foreColor, flags);
        }
コード例 #18
0
        /// <summary>
        /// 绘制验证失败的标识。
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cell"></param>
        /// <param name="rect"></param>
        protected virtual void DrawInvalidate(Graphics graphics, TreeListCell cell, Rectangle rect)
        {
            var img = Properties.Resources.error;

            graphics.DrawImage(img, rect.Left + rect.Width - img.Width, rect.Top + (rect.Height - img.Height) / 2);
        }
コード例 #19
0
 internal TreeListCellRenderEventArgs(TreeListCell item, Graphics graphics, Rectangle rect)
     : base(graphics, rect)
 {
     Cell = item;
 }