Ejemplo n.º 1
0
        private Shape CreateShapeFromLine(string line)
        {
            string[] lineSplit = SplitCurrentLine();
            Shape    shape     = null;

            switch (lineSplit[0])
            {
            case "rectangle":
                shape = new BaseShape(lineSplit[0], RectangleStategy.Instance());
                break;

            case "ellipse":
                shape = new BaseShape(lineSplit[0], EllipseStrategy.Instance());
                break;

            case "group":
                shape = new ShapeComposite();
                break;

            case "ornament":
                shape = new ShapeDecorator();
                break;
            }

            return(shape);
        }
Ejemplo n.º 2
0
        private void OrnamentButton_Click(object sender, EventArgs e)
        {
            DecoratorForm decoratorForm = new DecoratorForm();
            Shape         selectedShape = shapeList.FirstOrDefault(s => s.selected);

            if (selectedShape == null)
            {
                return;
            }

            decoratorForm.ShowDialog();

            if (decoratorForm.DialogResult == DialogResult.OK)
            {
                string ornamentText = decoratorForm.Ornament;

                ShapeDecorator ornament = new ShapeDecorator(selectedShape.x + 50, selectedShape.y, 50, 50, selectedShape, ornamentText, decoratorForm.position);

                MacroCommand macroCommand = new MacroCommand();
                macroCommand.Add(new CustomCommand(
                                     () => shapeList.Remove(selectedShape),
                                     () => shapeList.Add(selectedShape)));
                macroCommand.Add(new AddShapeCommand(shapeList, ornament));

                history.Add(macroCommand);

                Invalidate();
            }
        }
Ejemplo n.º 3
0
        public override void Visit(ShapeDecorator shapeDecorator)
        {
            string[] lineSplit = SplitCurrentLine();
            string   text      = lineSplit[2];

            ShapeDecorator.OrnamentPosition position;
            Enum.TryParse(lineSplit[1], out position);

            currentLine = streamReader.ReadLine();
            Shape shape = CreateShapeFromLine(currentLine);

            shape.Accept(this);
            shapeDecorator.decoratedShape = shape;
            shapeDecorator.ornament       = text;
            shapeDecorator.position       = position;
        }
Ejemplo n.º 4
0
        //public override void OnClick(DiagramPointEventArgs e)
        //{

        //    base.OnClick(e);

        //    //if (this.ModelElement is ModelElement me)
        //    //{
        //    //    using (Transaction t = this.Store.TransactionManager.BeginTransaction("automated model"))
        //    //    {
        //    //        ModelElementBase.ShowMenuPropertyHandler.Instance.NotifyValueChange(me);
        //    //        //t.Commit();
        //    //    }
        //    //}

        //}

        protected override void InitializeDecorators(IList <ShapeField> shapeFields, IList <Decorator> decorators)
        {
            base.InitializeDecorators(shapeFields, decorators);

            ShapeField field;

            double   y    = 0.25;
            ShowMenu menu = new ShowMenu("ShowMenu");
            //ShowMenu menu = (ShowMenu)DslDiagrams::ShapeElement.FindShapeField(shapeFields, "ShowMenu");
            Decorator decoratorMenu = new ShapeDecorator(menu, ShapeDecoratorPosition.OuterTopRight, new PointD(0, y));

            decorators.Add(decoratorMenu);

            //y += 0.23;
            ////field = DslDiagrams::ShapeElement.FindShapeField(shapeFields, "SelectWithChildren");
            //field = new SelectParentChildren("SelectWithChildren");
            ////shapeFields.Add(field);
            //Decorator decorator = new ShapeDecorator(field, ShapeDecoratorPosition.OuterTopRight, new PointD(0, y));
            //decorators.Add(decorator);
            //menu.AddSubMenu(decorator);
        }
Ejemplo n.º 5
0
 public override void Visit(ShapeDecorator shapeDecorator)
 {
     shapeDecorator.decoratedShape.Accept(this);
 }
Ejemplo n.º 6
0
        public override void Visit(ShapeDecorator shapeDecorator)
        {
            WriteToFile(shapeDecorator, true);

            shapeDecorator.decoratedShape.Accept(this);
        }
Ejemplo n.º 7
0
 public Shape(ShapeDecorator component)
 {
     this.m_component = component;
 }
Ejemplo n.º 8
0
 public virtual void Visit(ShapeDecorator shapeDecorator)
 {
 }