コード例 #1
0
ファイル: ToolItem.cs プロジェクト: radtek/datawf
        public virtual void OnDraw(GraphContext context)
        {
            Style.Angle = Bar.ItemOrientation == Orientation.Horizontal ? 0 : 90;

            var dstate = !Sensitive ? CellDisplayState.Pressed : state == CellDisplayState.Default && Checked ? CellDisplayState.Selected : state;

            context.DrawCell(Style, null, Bound, Bound, dstate);

            object formatted = GetFormattedImage();

            if (DisplayStyle.HasFlag(ToolItemDisplayStyle.Image))
            {
                if (image != null)
                {
                    context.DrawImage(image, imageBound);
                }
                else if (glyph != GlyphType.None)
                {
                    context.DrawGlyph(glyph, imageBound, GlyphColor);
                }
            }
            if (DisplayStyle.HasFlag(ToolItemDisplayStyle.Text) && !string.IsNullOrEmpty(Text))
            {
                context.DrawText(text, textBound, Style, state);
            }
        }
コード例 #2
0
ファイル: ToolItem.cs プロジェクト: radtek/datawf
        public override void ApplyBound(Rectangle value)
        {
            base.ApplyBound(value);
            if (Count > 0)
            {
                return;
            }
            var halfIndent = Bar.Indent / 2D;

            value = value.Inflate(-halfIndent, -halfIndent);
            var imaged = DisplayStyle.HasFlag(ToolItemDisplayStyle.Image) && GetFormattedImage() != null;

            if (imaged)
            {
                imageBound.X = value.X + (Bar.MinItemWidth - imageBound.Width) / 2D;
                imageBound.Y = value.Y + (value.Height - imageBound.Height) / 2D;
            }
            if (DisplayStyle.HasFlag(ToolItemDisplayStyle.Text))
            {
                textBound.X = imaged ? imageBound.Right : value.X + 4D;
                textBound.Y = value.Y + (value.Height - textBound.Height) / 2D;
            }
            Bound = value;
            //Console.WriteLine($"ToolItem {Name} Bound:{value}");
        }
コード例 #3
0
ファイル: ToolItem.cs プロジェクト: radtek/datawf
        protected virtual internal void CheckSize(bool queue = true)
        {
            if (Bar == null)
            {
                return;
            }
            imageBound.Location = Point.Zero;
            if (DisplayStyle.HasFlag(ToolItemDisplayStyle.Image))
            {
                imageBound.Size = Image != null || Glyph != GlyphType.None ? new Size(Bar.MinItemHeight - 2, Bar.MinItemHeight - 2) : Size.Zero;
            }
            else
            {
                imageBound.Size = Size.Zero;
            }

            textBound.Location = new Point(imageBound.Right, 0);
            if (text != null && DisplayStyle.HasFlag(ToolItemDisplayStyle.Text))
            {
                textBound.Size   = text.GetSize();
                textBound.Width += 6;
            }
            else
            {
                textBound.Width = 0;
            }
            if (Bar.ItemOrientation == Orientation.Vertical)
            {
                textBound.Location = new Point(0, imageBound.Bottom);
                textBound.Size     = new Size(textBound.Height, textBound.Width);
            }

            width  = Math.Max(textBound.Right, Bar.MinItemWidth) + Bar.Indent;
            height = Math.Max(Math.Max(textBound.Height, textBound.Height), Bar.MinItemHeight) + Bar.Indent;
            if (Bar.ItemOrientation == Orientation.Vertical)
            {
                InvertSize();
            }
            if (queue)
            {
                Bar?.QueueForReallocate();
            }
        }
コード例 #4
0
ファイル: ToolItem.cs プロジェクト: radtek/datawf
 public object GetFormattedImage()
 {
     return(DisplayStyle.HasFlag(ToolItemDisplayStyle.Image)
                        ? image ?? (glyph != GlyphType.None ? (object)glyph : null)
                            : null);
 }