예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="partition">Partition where new element is to be created.</param>
        /// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
        public BarkerERDiagram(Partition partition, params PropertyAssignment[] propertyAssignments)
            : base(partition, propertyAssignments)
        {
            this.Name = ORMSolutions.ORMArchitect.Framework.Design.ResourceAccessor <BarkerERDiagram> .ResourceManager.GetString(NameResourceName);

            NodeToNodeClearance = new SizeD(1.75, 1.75);
        }
        /// <summary>
        /// Updates the tag of the given item with geometry data.
        /// </summary>
        /// <remarks>
        /// In case the tag already contains valid geometry data, it stays unchanged.
        /// </remarks>
        /// <param name="item">The item for which the tag is updated.</param>
        /// <param name="layout">The 2D-geometry for the item.</param>
        /// <param name="height">The height of the resulting solid figure.</param>
        /// <param name="insets">Insets that are added to the layout information to create a padding.</param>
        private void UpdateGeometry(IModelItem item, SizeD layout, double height, InsetsD?insets = null)
        {
            var nodeData = item.Tag as NodeData;

            if (nodeData != null && nodeData.Geometry != null)
            {
                return;
            }
            var inset    = insets ?? InsetsD.Empty;
            var geometry = new Geometry {
                Width  = layout.Width + inset.Left + inset.Right,
                Height = height,
                Depth  = layout.Height + inset.Top + inset.Bottom
            };

            if (nodeData != null)
            {
                nodeData.Geometry = geometry;
            }
            else
            {
                item.Tag = new NodeData {
                    Geometry = geometry
                };
            }
        }
예제 #3
0
 public RectangleD(PointD point, SizeD size)
 {
     _x = point.X;
     _y = point.Y;
     _width = size.Width;
     _height = size.Height;
 }
예제 #4
0
 /// <summary>
 /// ChangeRule: typeof(RingConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority;
 /// </summary>
 private static void RingConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e)
 {
     if (e.DomainProperty.Id == RingConstraint.RingTypeDomainPropertyId)
     {
         RingConstraint ringConstraint = (RingConstraint)e.ModelElement;
         if (!ringConstraint.IsDeleted)
         {
             foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(ringConstraint))
             {
                 RingConstraintShape ringConstraintShape = pel as RingConstraintShape;
                 if (ringConstraintShape != null)
                 {
                     foreach (LinkConnectsToNode connection in DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(ringConstraintShape, LinkConnectsToNode.NodesDomainRoleId))
                     {
                         BinaryLinkShape binaryLink = connection.Link as BinaryLinkShape;
                         if (binaryLink != null)
                         {
                             binaryLink.RecalculateRoute();
                         }
                     }
                     SizeD oldSize = ringConstraintShape.Size;
                     ringConstraintShape.AutoResize();
                     if (oldSize == ringConstraintShape.Size)
                     {
                         ringConstraintShape.InvalidateRequired(true);
                     }
                 }
             }
         }
     }
 }
예제 #5
0
        private void DrawSubdivision(Subdivision division)
        {
            // generate new random subdivision if desired
            if (division == null)
            {
                PointD offset = new PointD(OutputBox.Width * 0.2, OutputBox.Height * 0.2);
                SizeD  scale  = new SizeD(OutputBox.Width * 0.6, OutputBox.Height * 0.6);

                int      count  = MersenneTwister.Default.Next(4, 12);
                PointD[] points = new PointD[count];

                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = new PointD(
                        offset.X + MersenneTwister.Default.NextDouble() * scale.Width,
                        offset.Y + MersenneTwister.Default.NextDouble() * scale.Height);
                }

                // outer bounds for Voronoi pseudo-vertices
                double margin = 3 * FontSize;
                RectD  bounds = new RectD(margin, margin,
                                          OutputBox.Width - 2 * margin, OutputBox.Height - 2 * margin);

                var result = Voronoi.FindAll(points, bounds);
                division = result.ToVoronoiSubdivision().Source;
            }

            _division = division;
            _division.Validate();
            _nearestEdge = -1;

            _edges = DrawSubdivision(OutputBox, FontSize, division);
            OutputBox.Children.Add(VertexCircle);
        }
예제 #6
0
        /// <summary>
        /// Pulled directly from Reflector disassembly
        /// </summary>
        private LineSegment[] CalculateSegments(IGeometryHost geometryHost, DiagramHitTestInfo hitTestInfo)
        {
            IBinaryLinkGeometryData data1       = geometryHost as IBinaryLinkGeometryData;
            EdgePointCollection     collection1 = data1.GeometryEdgePointsNoJumps;

            LineSegment[] segmentArray1 = new LineSegment[collection1.Count - 1];
            Pen           pen1          = geometryHost.GeometryStyleSet.GetPen(this.GetOutlinePenId(geometryHost));

            if (pen1 != null)
            {
                for (int num1 = 0; num1 < (collection1.Count - 1); num1++)
                {
                    RectangleD ed1 = GeometryHelpers.RectangleDFrom2Pts(collection1[num1].Point, collection1[num1 + 1].Point);
                    // In DSL Tools v8.2, GetHitTestTolerance is an instance method, but in DSL Tools v9.0, it is a static method.
                    // We call it without a qualifier here so that it will compile against both versions.
                    SizeD ed2 = GetHitTestTolerance(hitTestInfo);
                    if (ed1.Height < ed2.Height)
                    {
                        ed1.Inflate(0, (pen1.Width / 2f) + ed2.Height);
                    }
                    else if (ed1.Width < ed2.Width)
                    {
                        ed1.Inflate((pen1.Width / 2f) + ed2.Width, 0);
                    }
                    segmentArray1[num1] = new LineSegment(collection1[num1].Point, collection1[num1 + 1].Point, num1, num1 + 1, num1 == 0, (num1 + 1) == (collection1.Count - 1), ed1);
                }
            }
            return(segmentArray1);
        }
            public static SizeD SizeD(JProperty prop)
            {
                if (prop.Value is JValue)
                {
                    string text   = (string)((JValue)prop.Value).Value;
                    var    values = text.Split(',');
                    if (values.Length != 2)
                    {
                        throw new Exception("Parsing Error");
                    }

                    return(new SizeD(double.Parse(values[0]), double.Parse(values[1])));
                }
                else
                {
                    var size = new SizeD();
                    foreach (var pr in ((JObject)prop.Value).Properties())
                    {
                        switch (prop.Name)
                        {
                        case "Width":
                            size.Width = pr.Value.ToObject <int>();
                            break;

                        case "Height":
                            size.Height = pr.Value.ToObject <int>();
                            break;
                        }
                    }
                    return(size);
                }
            }
        public IIcon CreateLineUpIcon(IList <IIcon> icons, SizeD innerIconSize, double gap)
        {
            var icon = new LineUpIcon(icons, innerIconSize, gap);

            Clear();
            return(icon);
        }
        public void Scale(double factor)
        {
            var mid = MiddlePoint;

            Size        = new SizeD(Size.Width * factor, Size.Height * factor);
            MiddlePoint = mid;
        }
        private void UpdateSize(SizeD newSize)
        {
            Size = newSize;
            TableShape parent = (TableShape)ParentShape;

            parent.Size = new SizeD(newSize.Width, parent.Size.Height + newSize.Height);
        }
예제 #11
0
        protected static new void DrawDecorator(DiagramPaintEventArgs e, IGeometryHost geometryHost, float rotation, PointD centerRight, LinkDecorator decorator)
        {
            SizeD size = LinkShapeGeometry.SizeDecorator;
#endif
            double offsetBy = 0d;
            bool   doOffset = false;
            ILinkDecoratorSettings settings = decorator as ILinkDecoratorSettings;
            if (settings != null)
            {
                size     = settings.DecoratorSize;
                offsetBy = settings.OffsetBy;
                doOffset = !VGConstants.FuzzZero(offsetBy, VGConstants.FuzzDistance);
            }
            Graphics   g              = e.Graphics;
            RectangleD boundingRect   = new RectangleD(centerRight.X - size.Width, centerRight.Y - (size.Height / 2), size.Width, size.Height);
            Matrix     rotationMatrix = g.Transform;
            float      offsetX        = 0f;
            float      offsetY        = 0f;
            if (doOffset)
            {
                double rotationRadians = rotation * Math.PI / 180;
                offsetX = (float)(offsetBy * Math.Cos(rotationRadians));
                offsetY = (float)(offsetBy * Math.Sin(rotationRadians));
                rotationMatrix.Translate(offsetX, offsetY);
            }
            rotationMatrix.RotateAt(rotation, PointD.ToPointF(centerRight));
            g.Transform = rotationMatrix;
            decorator.DoPaintShape(boundingRect, geometryHost, e);
            rotationMatrix.RotateAt(-rotation, PointD.ToPointF(centerRight));
            if (doOffset)
            {
                rotationMatrix.Translate(-offsetX, -offsetY);
            }
            g.Transform = rotationMatrix;
        }
예제 #12
0
        /// <summary>
        /// Maintain center position on resize
        /// </summary>
        public override void AutoResize()
        {
            SizeD contentSize = ContentSize;

            if (!contentSize.IsEmpty)
            {
                RectangleD oldBounds = (RectangleD)AbsoluteBounds;
                if (!(oldBounds.IsEmpty ||
                      Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.ContainsKey(ORMBaseShape.PlaceAllChildShapes)))
                {
                    SizeD  oldSize  = oldBounds.Size;
                    double xDelta   = contentSize.Width - oldSize.Width;
                    double yDelta   = contentSize.Height - oldSize.Height;
                    bool   xChanged = !VGConstants.FuzzZero(xDelta, VGConstants.FuzzDistance);
                    bool   yChanged = !VGConstants.FuzzZero(yDelta, VGConstants.FuzzDistance);
                    if (xChanged || yChanged)
                    {
                        PointD location = oldBounds.Location;
                        location.Offset(xChanged ? -xDelta / 2 : 0d, yChanged ? -yDelta / 2 : 0d);
                        AbsoluteBounds = new RectangleD(location, contentSize);
                        return;
                    }
                }
                Size = contentSize;
            }
        }
예제 #13
0
        /// <summary>
        /// Creates the transformation function that determines the position of a
        /// source pixel, given the position of a target pixel.
        /// </summary>
        /// <param name="targetMapRectangle">The requested target rectangle.</param>
        /// <param name="targetSize">The requested target size.</param>
        /// <param name="sourceBoundingBox">The source bounding box corresponding to the target map rectangle..</param>
        /// <param name="sourceSize">The source size corresponding to the target size.</param>
        /// <returns>Position of source pixel</returns>
        protected virtual Func <PointD, PointD> GetTransformFunction(MapRectangle targetMapRectangle, Size targetSize, IBoundingBox sourceBoundingBox, Size sourceSize)
        {
            return(target =>
            {
                // knowing the map rectangle, we can compute the logical coordinate corresponding to the position of the target pixel
                var pLogicalTarget = new Location(
                    targetMapRectangle.Left + (targetMapRectangle.Right - targetMapRectangle.Left) * (target.X / (targetSize.Width - 1)),
                    targetMapRectangle.Top - (targetMapRectangle.Top - targetMapRectangle.Bottom) * (target.Y / (targetSize.Height - 1))
                    );

                // transform this logical coordinate into the source CRS
                var pLogicalSource = TargetToSourceTransformation.Transform(pLogicalTarget);

                // knowing the source bounding box and its configured orientation, we can now
                // turn the logical source coordinate into the logical offsets (left and top)
                var sourceOffset = new SizeD(

                    new[] { ContentAlignment.TopLeft, ContentAlignment.BottomLeft }.Contains(SourceMapService.MinAlignment)
                        ? pLogicalSource.X - sourceBoundingBox.MinX
                        : sourceBoundingBox.MaxX - pLogicalSource.X,

                    new[] { ContentAlignment.BottomLeft, ContentAlignment.BottomRight }.Contains(SourceMapService.MinAlignment)
                        ? sourceBoundingBox.MaxY - pLogicalSource.Y
                        : pLogicalSource.Y - sourceBoundingBox.MinY
                    );

                // and finally, we an turn the logical offsets into the pixel position
                return new PointD(
                    sourceSize.Width * sourceOffset.Width / sourceBoundingBox.Size().Width,
                    sourceSize.Height * sourceOffset.Height / sourceBoundingBox.Size().Height
                    );
            });
        }
예제 #14
0
        private SizeD CalculateNewSize(SizeD delta)
        {
            var newWidth  = Math.Max(MinimumSize.Width, initialRenderSize.Width + delta.Width);
            var newHeight = Math.Max(MinimumSize.Height, initialRenderSize.Height + delta.Height);

            return(new SizeD(newWidth, newHeight));
        }
예제 #15
0
 public RectangleD(PointD location, SizeD size)
 {
     x = location.X;
     y = location.Y;
     width = size.Width;
     height = size.Height;
 }
예제 #16
0
        internal void InvalidateImage(DiagramClientView diagramClientView)
        {
            m_diagramClientView = diagramClientView;
            if (m_diagramClientView != null)
            {
                SizeD diagramSize       = this.Diagram.Size;
                Size  deviceDiagramSize = this.DiagramClientView.WorldToDevice(diagramSize);
                Size  maxImageSize      = this.MaximumImageSize;

                m_imageScale = Math.Min(
                    (double)maxImageSize.Width / deviceDiagramSize.Width,
                    (double)maxImageSize.Height / deviceDiagramSize.Height);

                this.ImageSize = new Size(
                    (int)(deviceDiagramSize.Width * m_imageScale),
                    (int)(deviceDiagramSize.Height * m_imageScale));

                using (Graphics g = Graphics.FromImage(this.DiagramImage))
                {
                    g.Clear(Color.White);

                    MethodInfo drawMethod = typeof(Microsoft.VisualStudio.Modeling.Diagrams.Diagram).GetMethod("DrawDiagram", BindingFlags.NonPublic | BindingFlags.Instance);
                    drawMethod.Invoke(Diagram, new object[] {
                        g,
                        new Rectangle(0, 0, ImageSize.Width, ImageSize.Height), // fit the image
                        new PointD(0, 0),                                       // from origin
                        (float)(m_imageScale * DiagramClientView.ZoomFactor),   // fit the whole diagram
                        null                                                    // don't need selection etc
                    });
                }
            }
            this.Invalidate();
        }
예제 #17
0
 /// <summary>
 /// Move the name label above the parent shape
 /// </summary>
 public override void PlaceAsChildOf(NodeShape parent, bool createdDuringViewFixup)
 {
     AutoResize();
     if (createdDuringViewFixup)
     {
         SizeD      size         = Size;
         RectangleD parentBounds = ParentShape.AbsoluteBoundingBox;
         // Place slightly to the right and aligned with the top
         // of the shape. This will place the cardinality shape
         // below any value ranges.
         // For a fact type shape with a role cardinality, we want
         // to align with the top of the current roles shape field,
         // not the top of the shape itself.
         double        top = 0d;
         FactTypeShape factTypeShape;
         ShapeField    rolesField;
         if (ModelElement is UnaryRoleCardinalityConstraint &&
             null != (factTypeShape = parent as FactTypeShape) &&
             null != (rolesField = FactTypeShape.RolesField))
         {
             top = rolesField.GetBounds(factTypeShape).Top;
         }
         Location = new PointD(parentBounds.Width + .06, top);
     }
 }
        ////////////////////////////////////////////////////////////////////
        // Draw image of a flower and clip it
        ////////////////////////////////////////////////////////////////////

        private void DrawFlower
        (
            PdfDocument Document,
            PdfContents Contents
        )
        {
            // define local image resources
            PdfImage Image1 = new PdfImage(Document, "flower.jpg");

            // image size will be limited to 1.4" by 1.4"
            SizeD ImageSize = Image1.ImageSize(1.4, 1.4);

            // save graphics state
            Contents.SaveGraphicsState();

            // translate coordinate origin to the center of the picture
            Contents.Translate(3.36, 5.7);

            // clipping path
            Contents.DrawOval(-ImageSize.Width / 2, -ImageSize.Height / 2, ImageSize.Width, ImageSize.Height, PaintOp.ClipPathEor);

            // draw image
            Contents.DrawImage(Image1, -ImageSize.Width / 2, -ImageSize.Height / 2, ImageSize.Width, ImageSize.Height);

            // restore graphics state
            Contents.RestoreGraphicsState();
            return;
        }
예제 #19
0
 /// <summary>デフォルトコンストラクタ。</summary>
 public VirtualPie()
 {
     StartAngle = 0;
     SweepAngle = 0;
     Radius     = new SizeD();
     Center     = new PointD();
 }
예제 #20
0
        /// <summary>ビュー座標系に変換された図形をグラフィクスに描き出します。(IVirtualShapeの実装)</summary>
        /// <param name="g"></param>
        public override void RenderToView(Graphics g)
        {
            PointD c = ParentGraphics.FromGlobalToView(Center);
            SizeD  s = DoesGlobalScale ? new SizeD(Math.Abs(ParentGraphics.ViewScale.W * Radius.W), Math.Abs(ParentGraphics.ViewScale.H * Radius.H)) : Radius;

            if (s.W == 0 || s.H == 0)
            {
                return;
            }

            PointD p          = c - s;
            float  startAngle = (float)StartAngle,
                   sweepAngle = (float)SweepAngle;

            if (ParentGraphics.ViewScale.W < 0)
            {
                startAngle = 180 - startAngle;
                sweepAngle = -sweepAngle;
            }
            if (ParentGraphics.ViewScale.H < 0)
            {
                startAngle = -startAngle;
                sweepAngle = -sweepAngle;
            }


            g.FillPie(ShapeFill, (float)p.X, (float)p.Y, (float)(2.0 * s.W), (float)(2.0 * s.H), startAngle, sweepAngle);
            g.DrawPie(ShapeBorder, new RectangleF(p, 2 * s), startAngle, sweepAngle);
        }
예제 #21
0
        public static void AjustarAoConteudo(Simbolo simbolo)
        {
            var compartimento = PresentationViewsSubject.GetPresentation(simbolo)
                                .FirstOrDefault() as SimboloCompartment;

            if (compartimento == null)
            {
                return;
            }

            var tamanhos = new List <SizeD>();

            foreach (var nocao in simbolo.Nocoes)
            {
                tamanhos.Add(DisplayText.ObterTamanho(compartimento, nocao));
            }

            foreach (var impacto in simbolo.Impactos)
            {
                tamanhos.Add(DisplayText.ObterTamanho(compartimento, impacto));
            }

            var maiorLargura = tamanhos.Max(s => s.Width);
            var novoSize     = new SizeD(maiorLargura, compartimento.Size.Height);

            compartimento.Size = novoSize;
        }
        private void UpdateSize(SizeD newSize)
        {
            Size = newSize;
            BarkerEntityShape parent = (BarkerEntityShape)ParentShape;

            parent.Size = new SizeD(newSize.Width, parent.Size.Height + newSize.Height);
        }
 /// <summary>
 /// Sets the size of this item and propagates it to the hosted shape element if allowed.
 /// </summary>
 /// <param name="newSize">Size to apply.</param>
 /// <remarks>
 /// This function needs to be called withing a modeling transaction.
 /// </remarks>
 public virtual void SetSize(SizeD newSize)
 {
     if (this.ShapeElement.Size != newSize)
     {
         this.ShapeElement.SetSize(newSize);
     }
 }
예제 #24
0
 public RectangleD(PointD location, SizeD size)
 {
     X      = location.X;
     Y      = location.Y;
     Width  = size.Width;
     Height = size.Height;
 }
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public ChoreographyNodeStyle()
 {
     Type               = ChoreographyType.Task;
     MessageOutline     = BpmnConstants.ChoreographyDefaultMessageOutline;
     MinimumSize        = new SizeD(30, 30);
     LoopCharacteristic = LoopCharacteristic.None;
     SubState           = SubState.None;
 }
예제 #26
0
 public MeasureInfo(RenderObject renderObject, SizeD size, UnitTypeEnum resolvedUnit)
 {
     _renderedAreas           = new UnitRectangle[1];
     _renderedAreas[0].X      = new Unit(0, resolvedUnit);
     _renderedAreas[0].Y      = new Unit(0, resolvedUnit);
     _renderedAreas[0].Width  = new Unit(size.Width, resolvedUnit);
     _renderedAreas[0].Height = new Unit(size.Height, resolvedUnit);
 }
        private void UpdateSize(SizeD newSize)
        {
            Size = newSize;
            TableShape parent = (TableShape)ParentShape;

            // When need to use this method to make sure the name textbox grows correctly
            parent.UpdateSize(new SizeD(newSize.Width, parent.Size.Height + newSize.Height));
        }
예제 #28
0
 /// <summary>全体像を表示するようビュー座標を変更する。</summary>
 /// <param name="padding"></param>
 public void MoveViewToPerspective(SizeD padding)
 {
     if (VirtualGraphics == null)
     {
         return;
     }
     VirtualGraphics.MoveViewToPerspective(this.CreateGraphics(), padding);
 }
예제 #29
0
        /// <summary>
        /// This method ensures that the role in the related fact type is closest (spatially) to the related object shape.
        /// </summary>
        /// <param name="shape">The shape that was most recently placed on the diagram</param>
        protected override void PostShapePlacement(LayoutShape shape)
        {
            FactTypeShape factShape;
            LayoutShape   parentShape;

            if (shape.Pinned || null == (parentShape = shape.Parent) || null == (factShape = shape.Shape as FactTypeShape))
            {
                return;
            }

            NodeShape    objectShape   = parentShape.Shape;
            ModelElement objectElement = parentShape.Shape.ModelElement;
            FactType     factElement;

            if (null != (factElement = objectElement as FactType))
            {
                Objectification objectification = factElement.Objectification;
                if (objectification != null)
                {
                    objectElement = objectification.NestingType;
                }
            }
            factElement = factShape.ModelElement as FactType;
            LinkedElementCollection <RoleBase> roles = factShape.DisplayedRoleOrder;

            // set the index at which the role will be closest to otherLayoutShape
            int         targetIndex = 0;
            LayoutShape objectLayoutShape;
            PointD      objectShapeLocation = myLayoutShapes.TryGetValue(objectShape, out objectLayoutShape) ? objectLayoutShape.TargetLocation : objectShape.Location;
            SizeD       objectShapeSize     = objectShape.Size;

            objectShapeLocation.Offset(objectShapeSize.Width / 2, objectShapeSize.Height / 2);
            if (objectShapeLocation.X > shape.TargetLocation.X + (factShape.Size.Width / 2))
            {
                targetIndex = roles.Count - 1;
            }

            // find actual index
            bool haveEditableOrder = false;
            int  roleCount         = roles.Count;

            for (int i = 0; i < roleCount; ++i)
            {
                if (roles[i].Role.RolePlayer == objectElement)
                {
                    if (i == targetIndex)
                    {
                        if (!haveEditableOrder)
                        {
                            haveEditableOrder = true;
                            roles             = factShape.GetEditableDisplayRoleOrder();
                        }
                        roles.Move(i, targetIndex);
                        break;
                    }
                }
            }
        }
예제 #30
0
        /// <summary>ビュー座標系に変換された図形をグラフィクスに描き出します。(IVirtualShapeの実装)</summary>
        /// <param name="g"></param>
        public override void RenderToView(Graphics g)
        {
            PointD c = ParentGraphics.FromGlobalToView(Center);
            SizeD  s = DoesGlobalScale ? new SizeD(Math.Abs(ParentGraphics.ViewScale.W * Radius.W), Math.Abs(ParentGraphics.ViewScale.H * Radius.H)) : Radius;
            PointD p = c - s;

            g.FillEllipse(ShapeFill, new RectangleF(p, 2 * s));
            g.DrawEllipse(ShapeBorder, new RectangleF(p, 2 * s));
        }
예제 #31
0
        protected BaseLayout(WordCloudInput wordCloud)
        {
            var size = new SizeD(wordCloud.Width, wordCloud.Height);

            Surface   = new RectangleD(new PointD(0, 0), size);
            QuadTree  = new QuadTree <LayoutItem>(Surface);
            Center    = new PointD(Surface.X + size.Width / 2, Surface.Y + size.Height / 2);
            WordCloud = wordCloud;
        }
예제 #32
0
        /// <summary>
        /// Sizes to object to the size of the contents.
        /// The default implementation uses the ContentSize
        /// if it is set and does not do any margin adjustments.
        /// </summary>
        public virtual void AutoResize()
        {
            SizeD contentSize = ContentSize;

            if (!contentSize.IsEmpty)
            {
                Size = contentSize;
            }
        }
예제 #33
0
파일: TreeNode.cs 프로젝트: EFanZh/EFanZh
        private double MeasureNode(DrawTreeContext context)
        {
            double borderThickness = context.BorderPen == null ? 0.0 : context.BorderPen.Width;

            nodeSize = new SizeD((context.NodeHorizontalPadding + borderThickness) * 2.0 + context.Graphics.MeasureString(Label, context.LabelFont, PointF.Empty, stringFormat).Width,
                                 (context.NodeVerticalPadding + borderThickness) * 2.0 + context.LabelHeight);

            return nodeSize.Width;
        }
예제 #34
0
 internal static SizeD ScreenToWorld(SizeD screenSize, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(screenRect.Width) > double.Epsilon) && (Math.Abs(screenRect.Height) > double.Epsilon))
     {
         var ed = new SizeD(0.0, 0.0)
                      {
                          Width = ((screenSize.Width/screenRect.Width)*worldRect.Width),
                          Height = ((screenSize.Height/screenRect.Height)*worldRect.Height)
                      };
         return ed;
     }
     return SizeD.Empty;
 }
예제 #35
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="Origin">Origin (left-bottom)</param>
        /// <param name="Size">Size</param>
        /// <param name="PP">Paint operator</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawRectangle(
			PointD		Origin,
			SizeD		Size,
			PaintOp		PP
			)
        {
            DrawRectangle(Origin.X, Origin.Y, Size.Width, Size.Height, PP);
            return;
        }
예제 #36
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Calculates chart size to preserve aspect ratio and sets position.
        /// </summary>
        /// <param name="InputSize">Chart display area</param>
        /// <param name="Alignment">Content alignment</param>
        /// <returns>Adjusted chart size and position within area.</returns>
        /// <remarks>
        /// Calculates best fit to preserve aspect ratio and adjust
        /// position according to content alignment argument.
        /// </remarks>
        ////////////////////////////////////////////////////////////////////
        public PdfRectangle ImageSizePosition(
			SizeD				InputSize,
			ContentAlignment	Alignment
			)
        {
            return(ImageSizePos.ImageArea(WidthPix, HeightPix, 0.0, 0.0, InputSize.Width, InputSize.Height, Alignment));
        }
예제 #37
0
 public CarModelData(string name, SizeD size, double speed, double acceleration, double deceleration)
     : base(name, size, speed, acceleration, deceleration)
 {
 }
예제 #38
0
 public RectangleAA2(Vector2 location, SizeD size)
 {
     _location = location;
     _size = size;
 }
예제 #39
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="partition">Partition where new element is to be created.</param>
		/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
		public BarkerERDiagram(Partition partition, params PropertyAssignment[] propertyAssignments)
			: base(partition, propertyAssignments)
		{
			this.Name = ORMSolutions.ORMArchitect.Framework.Design.ResourceAccessor<BarkerERDiagram>.ResourceManager.GetString(NameResourceName);
			NodeToNodeClearance = new SizeD(1.75, 1.75);
		}
예제 #40
0
        /// <summary>
        /// Resizes the parent of this item if this is required.
        /// </summary>
        /// <remarks>
        /// This function needs to be called withing a modeling transaction.
        /// </remarks>
        public virtual void ResizeParentIfRequired()
        {
            if (this.Parent != null && !this.IsRelativeChildShape)
            {
                RectangleD bounds = this.Bounds;
                SizeD parentSize = this.Parent.Size;

                SizeD size = new SizeD(
                    Math.Max(parentSize.Width, bounds.Right),
                    Math.Max(parentSize.Height, bounds.Bottom));

                if (parentSize.Width < size.Width || parentSize.Height < size.Height)
                {
                    this.Parent.SetSize(
                        new SizeD(this.Parent.Size.Width + (size.Width - parentSize.Width) + 3.0,
                                  this.Parent.Size.Height + (size.Height - parentSize.Height) + 3.0));
                }
            }
        }
예제 #41
0
		/// <summary></summary>
		public RectangleD(PointD location, SizeD size)
			{
			_Location = location;
			_Size = size;
			}
예제 #42
0
		/// <summary></summary>
		public RectangleD(PointD leftTop, PointD rightBottom)
			{
			_Location = leftTop;
			_Size = rightBottom - leftTop;
			}
예제 #43
0
 public void Scale(double factor)
 {
     var mid = MiddlePoint;
     Size = new SizeD(Size.Width * factor, Size.Height * factor);
     MiddlePoint = mid;
 }
예제 #44
0
 protected Vehicle(int id, VehicleModelData modeldata)
 {
     acceleration = modeldata.Acceleration;
     deceleration = modeldata.Deceleration;
     drawlock = new object();
     this.id = id;
     this.modeldata = modeldata;
     name = modeldata.Name;
     size = modeldata.Size;
     solidbrush =
         new SolidBrush(Color.FromArgb(Randomizer.Next(0, 256), Randomizer.Next(0, 256), Randomizer.Next(0, 256)));
     type = GetType().Name;
 }
예제 #45
0
        /// <summary>
        /// Sets the size of this item and propagates it to the hosted shape element if allowed.
        /// </summary>
        /// <param name="newWidth">Size to apply.</param>
        /// <remarks>
        /// This function needs to be called withing a modeling transaction.
        /// </remarks>
        public virtual void SetSize(SizeD newSize)
        {
            SizeD oldSize = this.Size;
            this.Size = newSize;

            UpdateAbsoluteLocation();
            ResizeParentIfRequired();

            // for children: we need to change position if they are left of right side of this shape
            foreach(NodeShape shape in this.RelativeChildren )
            {
                if (shape.MovementBehaviour == ShapeMovementBehaviour.PositionRelativeToParent)
                {
                    PointD newPosition = new PointD(shape.Location.X, shape.Location.Y);
                    if (newPosition.X >= oldSize.Width)
                        newPosition.X += this.Size.Width - oldSize.Width;
                    if (newPosition.Y >= oldSize.Height)
                        newPosition.Y += this.Size.Height - oldSize.Height;

                    shape.SetLocationOnParentChange(newPosition);
                }
                else if (shape.MovementBehaviour == ShapeMovementBehaviour.PositionOnEdgeOfParent)
                {
                    if (newSize.Width != oldSize.Width && shape.PlacementSide == PortPlacement.Right)
                        shape.SetLocationOnParentChange(shape.Location);
                    else if (newSize.Height != oldSize.Height && shape.PlacementSide == PortPlacement.Bottom)
                        shape.SetLocationOnParentChange(shape.Location);
                }
            }

            if (this.IsRelativeChildShape)
                if (this.MovementBehaviour == ShapeMovementBehaviour.PositionOnEdgeOfParent)
                {
                    // size of this element changed, need to reposition it on the edge of the parent element
                    this.SetLocationOnParentChange(this.Location);
                }
        }
예제 #46
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw Rounded Rectangle
        /// </summary>
        /// <param name="Origin">Origin (left-bottom)</param>
        /// <param name="Size">Size</param>
        /// <param name="Radius">Radius</param>
        /// <param name="PP">Paint operator</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawRoundedRectangle(
			PointD		Origin,
			SizeD		Size,
			Double		Radius,
			PaintOp		PP
			)
        {
            DrawRoundedRectangle(Origin.X, Origin.Y, Size.Width, Size.Height, Radius, PP);
            return;
        }
예제 #47
0
        /// <summary>
        /// Corret link shapes placement.
        /// </summary>
        /// <param name="sizeOld"></param>
        /// <param name="sizeNew"></param>
        internal void CorrectLinkShapesOnSizeChanged(SizeD sizeOld, SizeD sizeNew)
        {
            // List<LinkShape> shapesToLayout = new List<LinkShape>();

            double widthChange = (sizeNew.Width - sizeOld.Width);
            double heightChange = (sizeNew.Height - sizeOld.Height);

            double widthFactor = sizeNew.Width / sizeOld.Width;
            double heightFactor = sizeNew.Height / sizeOld.Height;
   
            foreach (SourceAnchor anchor in this.SourceAnchors)
            {
                if (anchor.FromShape == null)
                    continue;

                if (anchor.IsDeleted || anchor.IsDeleting)
                    continue;

                NodeShape shape = anchor.FromShape;
                LinkShape linkShape = anchor.LinkShape;

                double newLeft = (anchor.AbsoluteLocation.X - shape.AbsoluteLocation.X) * widthFactor + shape.AbsoluteLocation.X;
                double newTop = (anchor.AbsoluteLocation.Y - shape.AbsoluteLocation.Y) * heightFactor + shape.AbsoluteLocation.Y;

                if (linkShape.LinkPlacementStart == LinkPlacement.Bottom)
                {
                    anchor.AbsoluteLocation = new PointD(newLeft, anchor.AbsoluteLocation.Y + heightChange);
                }
                else if (linkShape.LinkPlacementStart == LinkPlacement.Top)
                {
                    anchor.AbsoluteLocation = new PointD(newLeft, anchor.AbsoluteLocation.Y);
                }
                else if (linkShape.LinkPlacementStart == LinkPlacement.Right)
                {
                    anchor.AbsoluteLocation = new PointD(anchor.AbsoluteLocation.X + widthChange, newTop);
                }
                else if (linkShape.LinkPlacementStart == LinkPlacement.Left)
                {
                    anchor.AbsoluteLocation = new PointD(anchor.AbsoluteLocation.X, newTop);
                }

                //if (!shapesToLayout.Contains(anchor.LinkShape))
                //    shapesToLayout.Add(anchor.LinkShape);
            }

            foreach (TargetAnchor anchor in this.TargetAnchors)
            {
                if (anchor.ToShape == null)
                    continue;

                if (anchor.IsDeleted || anchor.IsDeleting)
                    continue;

                NodeShape shape = anchor.ToShape;
                LinkShape linkShape = anchor.LinkShape;

                double newLeft = (anchor.AbsoluteLocation.X - shape.AbsoluteLocation.X) * widthFactor + shape.AbsoluteLocation.X;
                double newTop = (anchor.AbsoluteLocation.Y - shape.AbsoluteLocation.Y) * heightFactor + shape.AbsoluteLocation.Y;

                if (linkShape.LinkPlacementEnd == LinkPlacement.Bottom)
                {
                    anchor.AbsoluteLocation = new PointD(newLeft, anchor.AbsoluteLocation.Y + heightChange);
                }
                else if (linkShape.LinkPlacementEnd == LinkPlacement.Top)
                {
                    anchor.AbsoluteLocation = new PointD(newLeft, anchor.AbsoluteLocation.Y);
                }
                else if (linkShape.LinkPlacementEnd == LinkPlacement.Right)
                {
                    anchor.AbsoluteLocation = new PointD(anchor.AbsoluteLocation.X + widthChange, newTop);
                }
                else if (linkShape.LinkPlacementEnd == LinkPlacement.Left)
                {
                    anchor.AbsoluteLocation = new PointD(anchor.AbsoluteLocation.X, newTop);
                }

                //if (!shapesToLayout.Contains(anchor.LinkShape))
                //   shapesToLayout.Add(anchor.LinkShape);
            }

            //foreach (LinkShape s in shapesToLayout)
            //    s.Layout(FixedGeometryPoints.SourceAndTarget);
        }
		/// <summary>定義されたプロパティに従ってVirtualShapeを更新する。GeometricObjectDataBaseの実装。</summary>
		/// <returns>全てのプロパティが妥当であり、VirtualShapeの更新に成功したときはtrue。</returns>
		public override bool UpdateVirtualShape()
			{
			VirtualPolygon polygon = (VirtualPolygon)VirtualShape;
			polygon.Visible = true;

			bool validOX = true, validOY = true, validR = true, validP = true, validLeft = true, validRight = true;
			double xOffset, yOffset;
			double[] CenterXList = new double[PointNum + 2],
				CenterYList = new double[PointNum + 2],
				CenterRadiusList = new double[PointNum + 2],
				CenterPhaseList = new double[PointNum + 2],
				LeftWingWidthList = new double[PointNum + 2],
				RightWingWidthList = new double[PointNum + 2];


			// 検証
			ValidateFormula( XOffset, XOffset_LastValid, out xOffset, out validOX );
			ValidateFormula( YOffset, YOffset_LastValid, out yOffset, out validOY );
			ValidateFormula( CenterRadius, PointNum, CenterRadius_LastValid, CenterRadiusList, out validR );
			ValidateFormula( CenterPhase, PointNum, CenterPhase_LastValid, CenterPhaseList, out validP );
			ValidateFormula( LeftWingWidth, PointNum, LeftWingWidth_LastValid, LeftWingWidthList, out validLeft );
			ValidateFormula( RightWingWidth, PointNum, RightWingWidth_LastValid, RightWingWidthList, out validRight );

			// CenterX,CenterYの作成
			for( int i = 0 ; i < PointNum + 2 ; i++ )
				{
				CenterXList[i] = CenterRadiusList[i] * Math.Cos( CenterPhaseList[i] );
				CenterYList[i] = CenterRadiusList[i] * Math.Sin( CenterPhaseList[i] );
				}

			// IsValidの評価
			IsValid = validOX && validOY && validR && validP && validLeft && validRight;
			if( validOX ) XOffset_LastValid = XOffset;
			if( validOY ) YOffset_LastValid = YOffset;
			if( validR ) CenterRadius_LastValid = CenterRadius;
			if( validP ) CenterPhase_LastValid = CenterPhase;
			if( validLeft ) LeftWingWidth_LastValid = LeftWingWidth;
			if( validRight ) RightWingWidth_LastValid = RightWingWidth;

			// VirtualPolygonに頂点を反映
			int j;
			double normalAngle;
			SizeD normalVector;
			polygon.Vertices = new PointD[2 * PointNum];
			for( int i = 0 ; i < PointNum ; i++ )
				{
				j = 2 * PointNum - i - 1;
				normalAngle = Math.Atan2( CenterYList[i + 2] - CenterYList[i], CenterXList[i + 2] - CenterXList[i] ) + Math.PI / 2;
				normalVector = new SizeD( Math.Cos( normalAngle ), Math.Sin( normalAngle ) );
				polygon.Vertices[i] = new PointD( CenterXList[i + 1] + xOffset, CenterYList[i + 1] + yOffset ) + LeftWingWidthList[i + 1] * normalVector;
				polygon.Vertices[j] = new PointD( CenterXList[i + 1] + xOffset, CenterYList[i + 1] + yOffset ) - RightWingWidthList[i + 1] * normalVector;
				}

			base.RefreshRenderSetting();
			return IsValid;
			}
예제 #49
0
 internal static SizeD WorldToScreen(SizeD worldSize, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(worldRect.Width) > double.Epsilon) && (Math.Abs(worldRect.Height) > double.Epsilon))
     {
         var ed = new SizeD(0.0, 0.0)
                      {
                          Width = ((worldSize.Width/worldRect.Width)*screenRect.Width),
                          Height = ((worldSize.Height/worldRect.Height)*screenRect.Height)
                      };
         return ed;
     }
     return worldSize;
 }
예제 #50
0
 /// <summary>
 /// Translates a given System.DrawingX.PointD by a specified System.DrawingX.SizeD.
 /// </summary>
 /// <param name="pt">The System.DrawingX.PointD to translate.</param>
 /// <param name="sz">The System.DrawingX.SizeD that specifies the numbers to add to the coordinates of pt.</param>
 /// <returns>The translated System.DrawingD.PointF.</returns>
 public static PointD Add(PointD pt, SizeD sz)
 {
     return new PointD(pt.X + sz.Width, pt.Y + sz.Height);
 }
예제 #51
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Calculate best fit to preserve aspect ratio
        /// </summary>
        /// <param name="ImageWidthPix">Image width in pixels.</param>
        /// <param name="ImageHeightPix">Image height in pixels.</param>
        /// <param name="DrawAreaWidth">Drawing area width.</param>
        /// <param name="DrawAreaHeight">Drawing area height.</param>
        /// <returns>Image size in user units.</returns>
        ////////////////////////////////////////////////////////////////////
        public static SizeD ImageSize(
			Int32		ImageWidthPix,
			Int32		ImageHeightPix,
			Double		DrawAreaWidth,
			Double		DrawAreaHeight
			)
        {
            SizeD OutputSize = new SizeD();
            OutputSize.Height = DrawAreaWidth * ImageHeightPix / ImageWidthPix;
            if(OutputSize.Height <= DrawAreaHeight)
            {
            OutputSize.Width = DrawAreaWidth;
            }
            else
            {
            OutputSize.Width = DrawAreaHeight * ImageWidthPix / ImageHeightPix;
            OutputSize.Height = DrawAreaHeight;
            }
            return(OutputSize);
        }
예제 #52
0
		/// <summary>デフォルトコンストラクタ。</summary>
		public VirtualRectangle()
			{
			Location = new PointD();
			Size = new SizeD();
			}
예제 #53
0
 public Rectangle2(Vector2 location, SizeD size, Angle? rotation = null)
     : this(location.X, location.Y, size.Width, size.Height, rotation ?? Angle.Zero)
 {
 }
예제 #54
0
		/// <summary>コピーコンストラクタ。</summary>
		/// <param name="previous"></param>
		public VirtualRectangle(VirtualRectangle previous)
			: base( previous )
			{
			Location = previous.Location;
			Size = previous.Size;
			}
예제 #55
0
파일: RectangleD.cs 프로젝트: EFanZh/EFanZh
 public RectangleD(PointD location, SizeD size)
 {
     this.location = location;
     this.size = size;
 }
예제 #56
0
		/// <summary>デフォルトコンストラクタ。</summary>
		public VirtualEllipse()
			{
			Center = new PointD();
			Radius = new SizeD();
			}
예제 #57
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Calculates chart size to preserve aspect ratio.
        /// </summary>
        /// <param name="InputSize">Chart display area.</param>
        /// <returns>Adjusted chart display area.</returns>
        /// <remarks>
        /// Calculates best fit to preserve aspect ratio.
        /// </remarks>
        ////////////////////////////////////////////////////////////////////
        public SizeD ImageSize(
			SizeD InputSize
			)
        {
            return(ImageSizePos.ImageSize(WidthPix, HeightPix, InputSize.Width, InputSize.Height));
        }
예제 #58
0
		/// <summary>コピーコンストラクタ。</summary>
		/// <param name="previous"></param>
		public VirtualEllipse(VirtualEllipse previous)
			: base( previous )
			{
			Center = previous.Center;
			Radius = previous.Radius;
			}
예제 #59
0
		/// <summary>デフォルトコンストラクタ。</summary>
		public VirtualPie()
			{
			StartAngle = 0;
			SweepAngle = 0;
			Radius = new SizeD();
			Center = new PointD();
			}
예제 #60
0
 /// <summary>Translates a <see cref="T:EGIS.ShapeFileLib.PointD"></see> by the negative of a specified size.</summary>
 /// <returns>The translated <see cref="T:EGIS.ShapeFileLib.PointD"></see>.</returns>
 /// <param name="sz">The <see cref="T:EGIS.ShapeFileLib.SizeD"></see> that specifies the numbers to subtract from the coordinates of pt.</param>
 /// <param name="pt">The <see cref="T:EGIS.ShapeFileLib.PointD"></see> to translate.</param>
 public static PointD Subtract(PointD pt, SizeD sz)
 {
     return new PointD(pt.X - sz.Width, pt.Y - sz.Height);
 }