示例#1
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     Visual.Render (context, availableSize);
 }
示例#2
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Subtract another box from this one horizontally.
 /// </summary>
 public VBox HSub(VBox other)
 {
     return new VBox (Width - other.Width, Height);
 }
示例#3
0
文件: Visual.cs 项目: johtela/NOP
            /// <summary>
            /// Draw the stack into the specified context.
            /// </summary>
            protected override void Draw(GraphicsContext context, VBox availableSize)
            {
                var stack = GetSize (context);

                Items.Foreach (visual =>
                {
                    if (availableSize.IsEmpty)
                        return;

                    var inner = visual.GetSize (context);
                    var outer = Direction == VisualDirection.Horizontal ?
                        new VBox (inner.Width, stack.Height) :
                        new VBox (stack.Width, inner.Height);
                    var st = context.Graphics.Save ();
                    context.Graphics.TranslateTransform (DeltaX (outer.Width, inner.Width),
                        DeltaY (outer.Height, inner.Height));
                    visual.Render (context, outer);
                    context.Graphics.Restore (st);

                    if (Direction == VisualDirection.Horizontal)
                    {
                        context.Graphics.TranslateTransform (outer.Width, 0);
                        availableSize = availableSize.HSub (outer);
                    }
                    else
                    {
                        context.Graphics.TranslateTransform (0, outer.Height);
                        availableSize = availableSize.VSub (outer);
                    }
                });
            }
示例#4
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     throw new NotImplementedException ();
 }
示例#5
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Returns the horizontal intersection with another box. This means that the
 /// width of the result is the minimum of the box widths.
 /// </summary>
 public VBox HMin(VBox other)
 {
     return new VBox (Math.Min (Width, other.Width), Height);
 }
示例#6
0
文件: Visual.cs 项目: johtela/NOP
 /// <summary>
 /// Draw the visual into specified context using the available size.
 /// </summary>
 /// <param name="context">The graphics context which used in drawing.</param>
 /// <param name='availableSize'>The available size into which the visual should
 /// fit.</param>
 protected abstract void Draw(GraphicsContext context, VBox availableSize);
示例#7
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
 }
示例#8
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Subtract another box from this one vertically.
 /// </summary>
 public VBox VSub(VBox other)
 {
     return new VBox (Width, Height - other.Height);
 }
示例#9
0
文件: Visual.cs 项目: johtela/NOP
            protected override void Draw(GraphicsContext context, VBox availableSize)
            {
                var box = GetSize (context);

                if (context.FocusedExpr == SExpr)
                {
                    context.Graphics.FillRectangle (Brushes.RoyalBlue, 0, 0, box.Width, box.Height);
                    context = new GraphicsContext (context,
                        new VisualStyle (context.Style, brush: Brushes.White));
                }
                var hitRect = new HitRect (box.AsRectF (context.Graphics.Transform), SExpr);
                GraphicsContext.HitRects = hitRect | GraphicsContext.HitRects;
                SExpr.Depiction.Draw (context, availableSize);
            }
示例#10
0
文件: Visual.cs 项目: johtela/NOP
            protected override void Draw(GraphicsContext context, VBox availableSize)
            {
                var box = Visual.GetSize (context);
                base.Draw (context, availableSize);

                switch (Kind)
                {
                    case FrameKind.Rectangle:
                        context.Graphics.DrawRectangle (context.Style.Pen,
                            0, 0, box.Width - 1, box.Height - 1);
                        break;
                    case FrameKind.Ellipse:
                        context.Graphics.DrawEllipse (context.Style.Pen,
                            0, 0, box.Width - 1, box.Height - 1);
                        break;
                    case FrameKind.RoundRectangle:
                        DrawRoundedRectangle(context.Graphics, context.Style.Pen,
                            new RectangleF(0, 0, box.Width - 1, box.Height - 1), 10);
                        break;
                }
            }
示例#11
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     base.Draw (context, availableSize);
     var state = context.Graphics.Save ();
     context.Graphics.ResetTransform ();
     context.Graphics.DrawLine (context.Style.Pen, Position, Target.Position);
     context.Graphics.Restore (state);
 }
示例#12
0
文件: Visual.cs 项目: johtela/NOP
 private PointF GetAnchorPosition(Matrix matrix, VBox box)
 {
     var anchor = new PointF[1];
     switch (HorizAlign)
     {
         case HAlign.Left:
             anchor[0].X = 0;
             break;
         case HAlign.Center:
             anchor[0].X = box.Width / 2;
             break;
         case HAlign.Right:
             anchor[0].X = box.Width;
             break;
     }
     switch (VertAlign)
     {
         case VAlign.Top:
             anchor[0].Y = 0;
             break;
         case VAlign.Center:
             anchor[0].Y = box.Height / 2;
             break;
         case VAlign.Bottom:
             anchor[0].Y = box.Height;
             break;
     }
     matrix.TransformPoints (anchor);
     return anchor[0];
 }
示例#13
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     Position = GetAnchorPosition (context.Graphics.Transform, Visual.GetSize (context));
     base.Draw (context, availableSize);
 }
示例#14
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Add another box to vertically to this one.
 /// </summary>
 public VBox VAdd(VBox other)
 {
     return new VBox (Width, Height + other.Height);
 }
示例#15
0
文件: Visual.cs 项目: johtela/NOP
 /// <summary>
 /// Draw the label into the specified context.
 /// </summary>
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     context.Graphics.DrawString (Text, context.Style.Font, context.Style.TextBrush,
         new PointF (0, 0));
 }
示例#16
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Returns the vertical intersection with another box. This means that the
 /// height of the result is the minimum of the box heights.
 /// </summary>
 public VBox VMin(VBox other)
 {
     return new VBox (Width, Math.Min (Height, other.Height));
 }
示例#17
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     var st = context.Graphics.Save ();
     context.Graphics.TranslateTransform (Left, Top);
     base.Draw (context, availableSize);
     context.Graphics.Restore (st);
 }
示例#18
0
文件: VBox.cs 项目: johtela/NOP
 /// <summary>
 /// Add another box to horizontally to this one.
 /// </summary>
 public VBox HAdd(VBox other)
 {
     return new VBox (Width + other.Width, Height);
 }
示例#19
0
文件: Visual.cs 项目: johtela/NOP
 protected override void Draw(GraphicsContext context, VBox availableSize)
 {
     if (Direction == VisualDirection.Horizontal)
     {
         var y = availableSize.Height / 2;
         context.Graphics.DrawLine (context.Style.Pen, 0, y, availableSize.Width, y);
     }
     else
     {
         var x = availableSize.Width / 2;
         context.Graphics.DrawLine (context.Style.Pen, x, 0, x, availableSize.Height);
     }
 }
示例#20
0
 private void CalculateNewSize()
 {
     if (_visual != null)
     {
         _size = _visual.GetSize (new GraphicsContext (Graphics.FromHwnd (Handle)));
         Width = Convert.ToInt32 (_size.Width);
         Height = Convert.ToInt32 (_size.Height);
     }
     Invalidate ();
 }
示例#21
0
文件: Visual.cs 项目: johtela/NOP
 public void Render(GraphicsContext context, VBox availableSize)
 {
     Draw (context, availableSize);
 }