예제 #1
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 ();
 }
예제 #2
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Add another box to vertically to this one.
 /// </summary>
 public VBox VAdd(VBox other)
 {
     return new VBox (Width, Height + other.Height);
 }
예제 #3
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     var st = context.Graphics.Save ();
     context.Graphics.TranslateTransform (Left, Top);
     var box = base.Draw (context, availableSize);
     context.Graphics.Restore (st);
     return new VBox (box.Width + Left + Right, box.Height + Top + Bottom);
 }
예제 #4
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return GetSize (context);
 }
예제 #5
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            private IEnumerable<Tuple<int, VBox>> WrapToLines(GraphicsContext context, 
				VBox availableSize)
            {
                var remaining = availableSize;
                var line = VBox.Empty;

                for (int i = 0; i < Items.Length; i++)
                {
                    if (remaining.IsEmpty)
                        yield break;
                    var item = Items[i].GetSize (context);
                    if (Direction == VisualDirection.Horizontal)
                    {
                        if (line.HAdd(item).Width >= availableSize.Width)
                        {
                            yield return Tuple.Create (i, line.HMin (availableSize));
                            remaining = remaining.VSub (line);
                            line = item;
                        }
                        else
                            line = line.HAdd (item).VMax (item);
                    }
                    else
                    {
                        if (line.VAdd(item).Height >= availableSize.Height)
                        {
                            yield return Tuple.Create (i, line.VMin (availableSize));
                            remaining = remaining.HSub (line);
                            line = item;
                        }
                        else
                            line = line.VAdd (item).HMax (item);
                    }
                }
                if (!line.IsEmpty)
                    yield return Tuple.Create (Items.Length, line);
            }
예제 #6
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return _size.Value;
 }
예제 #7
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return GetChild ().Draw (context, availableSize);
 }
예제 #8
0
 /// <summary>
 /// Add another box to horizontally to this one.
 /// </summary>
 public VBox HAdd(VBox other)
 {
     return(new VBox(Width + other.Width, Height));
 }
예제 #9
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox 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);
         return new VBox (availableSize.Width, 8f);
     }
     else
     {
         var x = availableSize.Width / 2;
         context.Graphics.DrawLine (context.Style.Pen, x, 0, x, availableSize.Height);
         return new VBox (8f, availableSize.Width);
     }
 }
예제 #10
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Draw the pile into the specified context.
 /// </summary>
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     foreach (var pair in Items)
     {
         var inner = pair.Item2.GetSize (context);
         var outer = Direction == VisualDirection.Horizontal ?
             new VBox (0f, availableSize.Height) :
             new VBox (availableSize.Width, 0f);
         var dx = DeltaX (outer.Width, inner.Width);
         var dy = DeltaY (outer.Height, inner.Height);
         if (Direction == VisualDirection.Horizontal)
         {
             dx += availableSize.Width * pair.Item1;
             outer = new VBox (inner.Width, outer.Height);
         }
         else
         {
             dy += availableSize.Height * pair.Item1;
             outer = new VBox (outer.Width, inner.Height);
         }
         var gs = context.Graphics.Save ();
         context.Graphics.TranslateTransform (dx, dy);
         pair.Item2.Render (context, outer);
         context.Graphics.Restore (gs);
     }
     return availableSize;
 }
예제 #11
0
 /// <summary>
 /// Subtract another box from this one vertically.
 /// </summary>
 public VBox VSub(VBox other)
 {
     return(new VBox(Width, Height - other.Height));
 }
예제 #12
0
 /// <summary>
 /// Add another box to vertically to this one.
 /// </summary>
 public VBox VAdd(VBox other)
 {
     return(new VBox(Width, Height + other.Height));
 }
예제 #13
0
 /// <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));
 }
예제 #14
0
 /// <summary>
 /// Subtract another box from this one horizontally.
 /// </summary>
 public VBox HSub(VBox other)
 {
     return(new VBox(Width - other.Width, Height));
 }
예제 #15
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Subtract another box from this one vertically.
 /// </summary>
 public VBox VSub(VBox other)
 {
     return new VBox (Width, Height - other.Height);
 }
예제 #16
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Returns the horizontal union with another box. This means that the
 /// width of the result is the maximum of the box widths.
 /// </summary>
 public VBox HMax(VBox other)
 {
     return new VBox (Math.Max (Width, other.Width), Height);
 }
예제 #17
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create an empty visual.
 /// </summary>
 public static Visual Empty(VBox size)
 {
     return new _Empty (size);
 }
예제 #18
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return new VBox (Paint (context, availableSize.AsSizeF));
 }
예제 #19
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            /// <summary>
            /// Draw the stack into the specified context.
            /// </summary>
            protected override VBox Draw(GraphicsContext context, VBox availableSize)
            {
                var stack = GetSize (context);
                var gs1 = context.Graphics.Save ();
                var remainingSize = availableSize;

                foreach (var visual in Items)
                {
                    if (remainingSize.IsEmpty)
                        return stack.HMin (availableSize).VMin (availableSize);

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

                    if (Direction == VisualDirection.Horizontal)
                    {
                        context.Graphics.TranslateTransform (outer.Width, 0);
                        remainingSize = remainingSize.HSub (outer);
                    }
                    else
                    {
                        context.Graphics.TranslateTransform (0, outer.Height);
                        remainingSize = remainingSize.VSub (outer);
                    }
                }
                context.Graphics.Restore (gs1);
                return stack;
            }
예제 #20
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 public _Empty(VBox size)
 {
     _size = size;
 }
예제 #21
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return Visual.Draw (new GraphicsContext(context, GetStyle (context.Style)), availableSize);
 }
예제 #22
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            protected override VBox Draw(GraphicsContext context, VBox availableSize)
            {
                var gs1 = context.Graphics.Save ();
                var i = 0;
                var totalSize = VBox.Empty;

                foreach (var line in WrapToLines (context, availableSize))
                {
                    var gs2 = context.Graphics.Save ();
                    while (i < line.Item1)
                    {
                        var visual = Items[i++];
                        var itemBox = visual.GetSize (context);
                        var outer = Direction == VisualDirection.Horizontal ?
                            new VBox (itemBox.Width, line.Item2.Height) :
                            new VBox (line.Item2.Width, itemBox.Height);
                        var gs3 = context.Graphics.Save ();
                        context.Graphics.TranslateTransform (DeltaX (outer.Width, itemBox.Width),
                            DeltaY (outer.Height, itemBox.Height));
                        visual.Render (context, outer);
                        context.Graphics.Restore (gs3);

                        if (Direction == VisualDirection.Horizontal)
                            context.Graphics.TranslateTransform (outer.Width, 0f);
                        else
                            context.Graphics.TranslateTransform (0f, outer.Height);
                    }
                    context.Graphics.Restore (gs2);
                    if (Direction == VisualDirection.Horizontal)
                    {
                        totalSize = totalSize.VAdd (line.Item2).HMax (line.Item2);
                        context.Graphics.TranslateTransform (0f, line.Item2.Height);
                    }
                    else
                    {
                        totalSize = totalSize.HAdd (line.Item2).VMax (line.Item2);
                        context.Graphics.TranslateTransform (line.Item2.Width, 0f);
                    }
                }
                context.Graphics.Restore (gs1);
                return totalSize;
            }
예제 #23
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     return Visual.Draw (context, availableSize);
 }
예제 #24
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            protected override VBox Draw(GraphicsContext context, VBox availableSize)
            {
                var box = Visual.GetSize (context);

                switch (Kind)
                {
                    case FrameKind.Rectangle:
                        if (Filled)
                            context.Graphics.FillRectangle (context.Style.Brush,
                                0, 0, box.Width, box.Height);
                        else
                            context.Graphics.DrawRectangle (context.Style.Pen,
                                0, 0, box.Width, box.Height);
                        break;
                    case FrameKind.Ellipse:
                        if (Filled)
                            context.Graphics.FillEllipse (context.Style.Brush,
                                0, 0, box.Width, box.Height);
                        else
                            context.Graphics.DrawEllipse (context.Style.Pen,
                                0, 0, box.Width, box.Height);
                        break;
                    case FrameKind.RoundRectangle:
                        if (Filled)
                            DrawRoundedRectangle (context.Graphics, null, context.Style.Brush,
                                new RectangleF (0, 0, box.Width, box.Height), 10);
                        else
                            DrawRoundedRectangle (context.Graphics, context.Style.Pen, null,
                            new RectangleF(0, 0, box.Width, box.Height), 10);
                        break;
                }
                return base.Draw (context, availableSize);
            }
예제 #25
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 public void Render(GraphicsContext context, VBox availableSize)
 {
     Draw (context, availableSize);
 }
예제 #26
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Draw the label into the specified context.
 /// </summary>
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     context.Graphics.DrawString (Text, context.Style.Font, context.Style.TextBrush,
         new PointF (0, 0));
     return CalculateSize (context);
 }
예제 #27
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <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 VBox Draw(GraphicsContext context, VBox availableSize);
예제 #28
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Subtract another box from this one horizontally.
 /// </summary>
 public VBox HSub(VBox other)
 {
     return new VBox (Width - other.Width, Height);
 }
예제 #29
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     Position = GetAnchorPosition (context.Graphics.Transform, Visual.GetSize (context));
     return base.Draw (context, availableSize);
 }
예제 #30
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <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));
 }
예제 #31
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 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];
 }
예제 #32
0
파일: VBox.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Add another box to horizontally to this one.
 /// </summary>
 public VBox HAdd(VBox other)
 {
     return new VBox (Width + other.Width, Height);
 }
예제 #33
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     var box = base.Draw (context, availableSize);
     SetClickRegion (box.AsRectF (context.Graphics.Transform));
     return box;
 }
예제 #34
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 protected override VBox Draw(GraphicsContext context, VBox availableSize)
 {
     var box = base.Draw (context, availableSize);
     var state = context.Graphics.Save ();
     context.Graphics.ResetTransform ();
     if (Kind == ConnectorKind.Line)
         context.Graphics.DrawLine (context.Style.Pen, Position, Target.Position);
     else
     {
         var p1 = Position;
         var p4 = Target.Position;
         PointF p2, p3;
         if (Direction == VisualDirection.Horizontal)
         {
             var xcenter = (p1.X + p4.X) / 2f;
             p2 = new PointF (xcenter, p1.Y);
             p3 = new PointF (xcenter, p4.Y);
         }
         else
         {
             var ycenter = (p1.Y + p4.Y) / 2f;
             p2 = new PointF (p1.X, ycenter);
             p3 = new PointF (p4.X, ycenter);
         }
         context.Graphics.DrawBezier (context.Style.Pen, p1, p2, p3, p4);
     }
     context.Graphics.Restore (state);
     return box;
 }
예제 #35
0
 /// <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)));
 }