Exemplo n.º 1
0
        public override void CreateShape(EntityType type)
        {
            {
                state        = State.CreatingShape;
                shapeType    = type;
                newShapeType = type;

                switch (type)
                {
                case EntityType.Class:
                case EntityType.Delegate:
                case EntityType.Enum:
                case EntityType.Interface:
                case EntityType.Structure:
                    shapeOutline = TypeShape.GetOutline(Style.CurrentStyle);
                    break;

                case EntityType.Package:
                    shapeOutline = PackageShape.GetOutline(Style.CurrentStyle);
                    break;

                case EntityType.Comment:
                    shapeOutline = CommentShape.GetOutline(Style.CurrentStyle);
                    break;
                }
                shapeOutline.Location = new Point((int)mouseLocation.X, (int)mouseLocation.Y);
                Redraw();
            }
        }
Exemplo n.º 2
0
        public override void CreateShape(EntityType type, Point?where = null)
        {
            base.CreateShape(type);

            switch (type)
            {
            case EntityType.Class:
            case EntityType.Delegate:
            case EntityType.Enum:
            case EntityType.Interface:
            case EntityType.Structure:
                shapeOutline = TypeShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.Package:
                shapeOutline = PackageShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.Comment:
                shapeOutline = CommentShape.GetOutline(Style.CurrentStyle);
                break;
            }

            //shapeOutline.Location = new Point((int) mouseLocation.X, (int) mouseLocation.Y);
            shapeOutline.Location = where ?? new Point((int)mouseLocation.X, (int)mouseLocation.Y);
            Redraw();
        }
Exemplo n.º 3
0
        public override void CreateShape(EntityType type, Point?where = null)
        {
            state        = State.CreatingShape;
            shapeType    = type;
            newShapeType = type;

            switch (type)
            {
            case EntityType.Actor:
                shapeOutline = ActorShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.UseCase:
                shapeOutline = UseCaseShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.Comment:
                shapeOutline = CommentShape.GetOutline(Style.CurrentStyle);
                break;

            case EntityType.SystemBoundary:
                shapeOutline = SystemBoundaryShape.GetOutline(Style.CurrentStyle);
                break;
            }
            shapeOutline.Location = where ?? new Point((int)mouseLocation.X, (int)mouseLocation.Y);
            Redraw();
        }
Exemplo n.º 4
0
        private void CreateCommentRelationship()
        {
            CommentShape        shape1 = first as CommentShape;
            CommentShape        shape2 = second as CommentShape;
            Func <Relationship> _connectionFactory;

            if (shape1 != null)
            {
                _connectionFactory = () => diagram.AddCommentRelationship(shape1.Comment, second.Entity);
            }
            else if (shape2 != null)
            {
                _connectionFactory = () => diagram.AddCommentRelationship(shape2.Comment, first.Entity);
            }
            else
            {
                MessageBox.Show(Strings.ErrorCannotCreateRelationship);
                return;
            }

            var command = new AddConnectionCommand(diagram, _connectionFactory);

            command.Execute();
            diagram.TrackCommand(command);
        }
Exemplo n.º 5
0
 private void mnuEditComment_Click(object sender, EventArgs e)
 {
     if (Diagram != null)
     {
         CommentShape commentShape = Diagram.TopSelectedElement as CommentShape;
         if (commentShape != null)
         {
             commentShape.EditText();
         }
     }
 }
Exemplo n.º 6
0
        internal override void Init(DiagramElement element)
        {
            shape = ( CommentShape )element;

            txtComment.BackColor = Style.CurrentStyle.CommentBackColor;
            txtComment.ForeColor = Style.CurrentStyle.CommentTextColor;
            txtComment.Text      = shape.Comment.Text;

            Font font = Style.CurrentStyle.CommentFont;

            txtComment.Font = new Font(font.FontFamily, font.SizeInPoints * shape.Diagram.Zoom, font.Style);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Create a new shape object used to Create the escher records.
 /// </summary>
 /// <param name="hssfShape">The simple shape this Is based on.</param>
 /// <param name="shapeId">The shape id.</param>
 /// <returns></returns>
 public static AbstractShape CreateShape(HSSFShape hssfShape, int shapeId)
 {
     AbstractShape shape;
     if (hssfShape is HSSFComment)
     {
         shape = new CommentShape((HSSFComment)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFTextbox)
     {
         shape = new TextboxShape((HSSFTextbox)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFPolygon)
     {
         shape = new PolygonShape((HSSFPolygon)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFSimpleShape)
     {
         HSSFSimpleShape simpleShape = (HSSFSimpleShape)hssfShape;
         switch (simpleShape.ShapeType)
         {
             case HSSFSimpleShape.OBJECT_TYPE_PICTURE:
                 shape = new PictureShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_LINE:
                 shape = new LineShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_OVAL:
             case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE:
                 shape = new SimpleFilledShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX:
                 shape = new ComboboxShape(simpleShape, shapeId);
                 break;
             default:
                 throw new ArgumentException("Do not know how to handle this type of shape");
         }
     }
     else
     {
         throw new ArgumentException("Unknown shape type");
     }
     EscherSpRecord sp = shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID);
     if (hssfShape.Parent!= null)
         sp.Flags=sp.Flags | EscherSpRecord.FLAG_CHILD;
     return shape;
 }
Exemplo n.º 8
0
        private void CreateCommentRelationship()
        {
            CommentShape shape1 = first as CommentShape;
            CommentShape shape2 = second as CommentShape;

            if (shape1 != null)
            {
                diagram.AddCommentRelationship(shape1.Comment, second.Entity);
            }
            else if (shape2 != null)
            {
                diagram.AddCommentRelationship(shape2.Comment, first.Entity);
            }
            else
            {
                MessageBox.Show(Strings.ErrorCannotCreateRelationship);
            }
        }
Exemplo n.º 9
0
        public void TestShapeId()
        {
            HSSFClientAnchor          anchor = new HSSFClientAnchor();
            AbstractShape             shape;
            CommonObjectDataSubRecord cmo;

            shape = new TextboxShape(new HSSFTextbox(null, anchor), 1025);
            cmo   = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(1, cmo.ObjectId);

            shape = new PictureShape(new HSSFPicture(null, anchor), 1026);
            cmo   = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(2, cmo.ObjectId);

            shape = new CommentShape(new HSSFComment(null, anchor), 1027);
            cmo   = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(1027, cmo.ObjectId);
        }
Exemplo n.º 10
0
        internal void Relocate(CommentShape shape)
        {
            Diagram diagram = shape.Diagram;

            if (diagram != null)
            {
                Rectangle absolute = shape.GetTextRectangle( );
                // The following lines are required because of a .NET bug:
                // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=380085
                if (!MonoHelper.IsRunningOnMono)
                {
                    absolute.X     -= 3;
                    absolute.Width += 3;
                }

                SetBounds(( int )(absolute.X * diagram.Zoom) - diagram.Offset.X + ParentLocation.X, ( int )(absolute.Y * diagram.Zoom) - diagram.Offset.Y + ParentLocation.Y, ( int )(absolute.Width * diagram.Zoom), ( int )(absolute.Height * diagram.Zoom));
            }
        }
Exemplo n.º 11
0
        private void ConvertShapes(HSSFShapeContainer parent, EscherContainerRecord escherParent, Hashtable shapeToObj)
        {
            if (escherParent == null)
            {
                throw new ArgumentException("Parent record required");
            }

            IList shapes = parent.Children;

            for (IEnumerator iterator = shapes.GetEnumerator(); iterator.MoveNext();)
            {
                HSSFShape shape = (HSSFShape)iterator.Current;
                if (shape is HSSFShapeGroup)
                {
                    ConvertGroup((HSSFShapeGroup)shape, escherParent, shapeToObj);
                }
                else
                {
                    AbstractShape shapeModel = AbstractShape.CreateShape(
                        shape,
                        drawingManager.AllocateShapeId(drawingGroupId));
                    shapeToObj[FindClientData(shapeModel.SpContainer)] = shapeModel.ObjRecord;
                    if (shapeModel is TextboxShape)
                    {
                        EscherRecord escherTextbox = ((TextboxShape)shapeModel).EscherTextbox;
                        shapeToObj[escherTextbox] = ((TextboxShape)shapeModel).TextObjectRecord;
                        //                    escherParent.AddChildRecord(escherTextbox);

                        if (shapeModel is CommentShape)
                        {
                            CommentShape comment = (CommentShape)shapeModel;
                            tailRec.Add(comment.NoteRecord);
                        }
                    }
                    escherParent.AddChildRecord(shapeModel.SpContainer);
                }
            }
            //        drawingManager.newCluster( (short)1 );
            //        drawingManager.newCluster( (short)2 );
        }
Exemplo n.º 12
0
        public void TestResultEqualsToAbstractShape()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment;
            HSSFRow     row     = sh.CreateRow(0) as HSSFRow;
            HSSFCell    cell    = row.CreateCell(0) as HSSFCell;

            cell.CellComment = (comment);

            CommentShape commentShape = HSSFTestModelHelper.CreateCommentShape(1025, comment);

            Assert.AreEqual(comment.GetEscherContainer().ChildRecords.Count, 5);
            Assert.AreEqual(commentShape.SpContainer.ChildRecords.Count, 5);

            //sp record
            byte[] expected = commentShape.SpContainer.GetChild(0).Serialize();
            byte[] actual   = comment.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(2).Serialize();
            actual   = comment.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(3).Serialize();
            actual   = comment.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(4).Serialize();
            actual   = comment.GetEscherContainer().GetChild(4).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj      = comment.GetObjRecord();
            ObjRecord objShape = commentShape.ObjRecord;

            expected = obj.Serialize();
            actual   = objShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            //assertArrayEquals(expected, actual);


            TextObjectRecord tor      = comment.GetTextObjectRecord();
            TextObjectRecord torShape = commentShape.TextObjectRecord;

            expected = tor.Serialize();
            actual   = torShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            NoteRecord note      = comment.NoteRecord;
            NoteRecord noteShape = commentShape.NoteRecord;

            expected = note.Serialize();
            actual   = noteShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            wb.Close();
        }