예제 #1
0
        public override void Trigger(object sender, MouseEventArgs e, Invoker invoker)
        {
            if (MainForm.selected1 == null)
            {
                Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);
                if (foundSymbol == null)
                {
                }
                else if (foundSymbol.type == "Class")
                {
                    MainForm.selected1 = foundSymbol as ClassSymbol;
                }
            }
            else if (MainForm.moveToLocation == MainForm.defaultLocation)
            {
                MainForm.moveToLocation = e.Location;
            }

            if (MainForm.selected1 != null && MainForm.moveToLocation != MainForm.defaultLocation)
            {
                for (int i = 0; i < TargetDrawing._RelationShipLines.Count; i++)
                {
                    if (TargetDrawing._RelationShipLines[i].Location1 == MainForm.selected1.Location || TargetDrawing._RelationShipLines[i].Location2 == MainForm.selected1.Location)
                    {
                        MoveLineCommand moveCommand = new MoveLineCommand(TargetDrawing._RelationShipLines[i], MainForm.selected1.Location, MainForm.moveToLocation, TargetDrawing);
                        invoker.EnqueueCommandForExecution(moveCommand);
                    }
                }
                MoveClassCommand moveClass = new MoveClassCommand(MainForm.selected1, MainForm.moveToLocation, TargetDrawing);
                invoker.EnqueueCommandForExecution(moveClass);
                MainForm.selected1      = null;
                MainForm.moveToLocation = MainForm.defaultLocation;
            }
        }
예제 #2
0
        public override void Execute()
        {
            StreamReader reader = new StreamReader(_filename);

            TargetDrawing?.LoadFromStream(reader.BaseStream);
            reader.Close();
        }
        public override bool Execute()
        {
            if (string.IsNullOrWhiteSpace(_treeType) || TargetDrawing == null)
            {
                return(false);
            }

            var treeSize = new Size()
            {
                Width  = Convert.ToInt16(Math.Round(NormalWidth * _scale, 0)),
                Height = Convert.ToInt16(Math.Round(NormalHeight * _scale, 0))
            };
            var treeLocation = new Point(_location.X - treeSize.Width / 2, _location.Y - treeSize.Height / 2);

            var extrinsicState = new ClassDiagramExtrinsicState()
            {
                TreeType = _treeType,
                Location = treeLocation,
                Size     = treeSize
            };

            _treeAdded = ClassDiagramFactory.Instance.GetTree(extrinsicState);
            TargetDrawing.Add(_treeAdded);

            return(true);
        }
예제 #4
0
 public override void Trigger(object sender, MouseEventArgs e, Invoker invoker)
 {
     if (MainForm.selected1 == null)
     {
         Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);
         if (foundSymbol != null && foundSymbol.type == "Class")
         {
             MainForm.selected1 = foundSymbol as ClassSymbol;
             foundSymbol        = null;
         }
     }
     else if (MainForm.selected2 == null)
     {
         Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);
         if (foundSymbol != null && foundSymbol.type == "Class")
         {
             MainForm.selected2 = foundSymbol as ClassSymbol;
             foundSymbol        = null;
         }
     }
     if (MainForm.selected1 != null && MainForm.selected2 != null)
     {
         AddCommand addCommand = new AddCommand(MainForm._SelectedTool, MainForm.selected1.Location, MainForm.selected2.Location, TargetDrawing);
         MainForm.selected1 = null;
         MainForm.selected2 = null;
         invoker.EnqueueCommandForExecution(addCommand);
     }
 }
예제 #5
0
        public override void Trigger(object sender, MouseEventArgs e, Invoker invoker)
        {
            Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);

            if (foundSymbol == null)
            {
            }
            else if (foundSymbol.type == "Class")
            {
                ClassSymbol classSymbol = foundSymbol as ClassSymbol;
                for (int i = 0; i < TargetDrawing._RelationShipLines.Count; i++)
                {
                    if (TargetDrawing._RelationShipLines[i].Location1 == classSymbol.Location || TargetDrawing._RelationShipLines[i].Location2 == classSymbol.Location)
                    {
                        DeleteCommand deleteLineCommand = new DeleteCommand(TargetDrawing._RelationShipLines[i], TargetDrawing);
                        invoker.EnqueueCommandForExecution(deleteLineCommand);
                    }
                }
                DeleteCommand command = new DeleteCommand(classSymbol, TargetDrawing);
                invoker.EnqueueCommandForExecution(command);
            }
            else if (foundSymbol.type == "Binary" || foundSymbol.type == "Aggregation" || foundSymbol.type == "Composition" || foundSymbol.type == "Generalization" || foundSymbol.type == "Dependency")
            {
                Relationship  line    = foundSymbol as Relationship;
                DeleteCommand command = new DeleteCommand(line, TargetDrawing);
                invoker.EnqueueCommandForExecution(command);
            }
        }
        public override bool Execute()
        {
            if (string.IsNullOrWhiteSpace(assocationType) || TargetDrawing == null)
            {
                return(false);
            }

            var assocationSize = new Size()
            {
                Width  = WIDTH,
                Height = HEIGHT
            };
            var assocationLocation = new Point(location.X - assocationSize.Width / 2, location.Y - assocationSize.Height / 2);

            var extrinsicState = new AssociationExtrinsicState()
            {
                AssocationType = assocationType,
                Location       = assocationLocation,
                Size           = assocationSize
            };

            assocationAdded = AssociationFactory.Instance.GetAssocation(extrinsicState);
            TargetDrawing.Add(assocationAdded);

            return(true);
        }
예제 #7
0
        public override void Trigger(object sender, MouseEventArgs e, Invoker invoker)
        {
            Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);

            if (foundSymbol == null)
            {
            }
            else if (foundSymbol.type == "Class")
            {
                ClassSymbol foundClass      = foundSymbol as ClassSymbol;
                EditClass   editClassWindow = new EditClass(foundClass, TargetDrawing, invoker);
                editClassWindow.Show();
            }
            else if (foundSymbol.type == "Binary")
            {
                BinaryRelationship foundBinary      = foundSymbol as BinaryRelationship;
                EditBinary         editBinaryWindow = new EditBinary(foundBinary, TargetDrawing, invoker);
                editBinaryWindow.Show();
            }
            else
            {
                Relationship foundLine      = foundSymbol as Relationship;
                EditLine     editLineWindow = new EditLine(foundLine, invoker, TargetDrawing);
                editLineWindow.Show();
            }
        }
예제 #8
0
파일: CmdAdd.cs 프로젝트: ironLink21/oo_hw3
        public override void Execute()
        {
            if (string.IsNullOrWhiteSpace(_starType) || TargetDrawing == null)
            {
                return;
            }

            Size starSize = new Size()
            {
                Width  = Convert.ToInt16(Math.Round(NormalWidth * _scale, 0)),
                Height = Convert.ToInt16(Math.Round(NormalHeight * _scale, 0))
            };

            Point starLocation = new Point(_location.X - starSize.Width / 2, _location.Y - starSize.Height / 2);

            StarExtrinsicState extrinsicState = new StarExtrinsicState()
            {
                StarType = _starType,
                Location = starLocation,
                Size     = starSize
            };

            var star = TargetDrawing.Factory.GetStar(extrinsicState);

            TargetDrawing.Add(star);
        }
예제 #9
0
        public override void Execute()
        {
            StreamWriter writer = new StreamWriter(_filename);

            TargetDrawing?.SaveToStream(writer.BaseStream);
            writer.Close();
        }
예제 #10
0
        public override bool Execute()
        {
            StreamWriter writer = new StreamWriter(filename);

            TargetDrawing?.SaveToStream(writer.BaseStream);
            writer.Close();

            return(true);
        }
예제 #11
0
파일: CmdAdd.cs 프로젝트: ironLink21/oo_hw3
        public override void Undo()
        {
            if (TargetDrawing == null)
            {
                return;
            }

            TargetDrawing.RemoveLastStar();
        }
예제 #12
0
 public override void Undo()
 {
     if (deletedStars != null)
     {
         foreach (Star item in deletedStars)
         {
             TargetDrawing.Add(item);
         }
     }
 }
예제 #13
0
        public override void Undo()
        {
            var star = TargetDrawing?.FindStarAtPosition(_newLocation);

            if (star != null)
            {
                star.Location         = _location;
                TargetDrawing.IsDirty = true;
            }
        }
예제 #14
0
        public override void Execute()
        {
            var star = TargetDrawing?.FindStarAtPosition(_location);

            if (star != null)
            {
                star.Size             = _newSize;
                TargetDrawing.IsDirty = true;
            }
        }
예제 #15
0
        public override void Undo()
        {
            var star = TargetDrawing?.FindStarAtPosition(_location);

            if (star != null)
            {
                star.IsSelected       = !star.IsSelected;
                TargetDrawing.IsDirty = true;
            }
        }
예제 #16
0
        public override bool Execute()
        {
            TargetDrawing?.Clear();

            StreamReader reader = new StreamReader(_filename);

            TargetDrawing?.LoadFromStream(reader.BaseStream);
            reader.Close();

            return(true);
        }
예제 #17
0
        internal override void Undo()
        {
            if (_previousElements == null || _previousElements.Count == 0)
            {
                return;
            }

            foreach (var element in _previousElements)
            {
                TargetDrawing?.Add(element);
            }
        }
        internal override void Redo()
        {
            if (_deletedElements == null || _deletedElements.Count == 0)
            {
                return;
            }

            foreach (var tree in _deletedElements)
            {
                TargetDrawing?.DeleteElement(tree);
            }
        }
예제 #19
0
        internal override void Undo()
        {
            if (deletedElements == null || deletedElements.Count == 0)
            {
                return;
            }

            foreach (var element in deletedElements)
            {
                TargetDrawing?.Add(element);
            }
        }
예제 #20
0
        internal override void Redo()
        {
            if (deletedElements == null || deletedElements.Count == 0)
            {
                return;
            }

            foreach (var association in deletedElements)
            {
                TargetDrawing?.DeleteElement(association);
            }
        }
예제 #21
0
        public override bool Execute()
        {
            _previousElements = TargetDrawing.GetCloneOfElements();
            TargetDrawing?.Clear();

            StreamReader reader = new StreamReader(_filename);

            TargetDrawing?.LoadFromStream(reader.BaseStream);
            reader.Close();

            return(true);
        }
예제 #22
0
        public override bool Execute()
        {
            if (_start == null || _end == null)
            {
                return(false);
            }

            _line = new Line()
            {
                Start = (Point)_start, End = (Point)_end
            };
            TargetDrawing.Add(_line);

            return(true);
        }
예제 #23
0
        public override bool Execute()
        {
            _element = TargetDrawing.FindElementAtPosition(_location);
            if (_element == null)
            {
                return(false);
            }

            _originalState      = _element.IsSelected;
            _element.IsSelected = !_originalState;

            TargetDrawing.IsDirty = true;

            return(true);
        }
        public override bool Execute()
        {
            if (label == null || corner == null || size == null)
            {
                return(false);
            }

            umlClass = new UmlClass()
            {
                Corner = (Point)corner, Size = (Size)size, Label = label
            };
            TargetDrawing.Add(umlClass);

            return(true);
        }
예제 #25
0
        public override bool Execute()
        {
            if (_start == null || _end == null)
            {
                return(false);
            }

            _line = new Line()
            {
                Start = (Point)_start, End = (Point)_end, LineType = (string)_type, label = (string)_label
            };
            TargetDrawing.Add(_line, _type);

            return(true);
        }
예제 #26
0
        public override bool Execute()
        {
            if (_label == null || _corner == null || _size == null)
            {
                return(false);
            }

            _labelBox = new LabeledBox()
            {
                Corner = (Point)_corner, Size = (Size)_size, Label = _label
            };
            TargetDrawing.Add(_labelBox);

            return(true);
        }
예제 #27
0
        public override bool Execute()
        {
            TargetDrawing.Clear();

            /**
             * TargetDrawing._ClassSymbols.Clear();
             * TargetDrawing._RelationShipLines.Clear();
             **/
            TargetDrawing.DrawingName       = "New Drawing";
            TargetDrawing.BackGroundColor   = Color.White;
            TargetDrawing.ForeGroundColor   = Color.Black;
            TargetDrawing.DefaultClassColor = Color.LightBlue;
            TargetDrawing.IsDirty           = true;

            return(true);
        }
예제 #28
0
 public override void Undo()
 {
     //TargetDrawing._ClassSymbols = OldClassSymbols;
     foreach (var s in OldClassSymbols)
     {
         TargetDrawing.Add(s);
     }
     //TargetDrawing._RelationShipLines = OldRelationships;
     foreach (var l in OldRelationships)
     {
         TargetDrawing.Add(l);
     }
     TargetDrawing.DrawingName       = OldName;
     TargetDrawing.BackGroundColor   = OldBackgroundColor;
     TargetDrawing.ForeGroundColor   = OldForegroundColor;
     TargetDrawing.DefaultClassColor = OldClassColor;
     TargetDrawing.IsDirty           = true;
 }
예제 #29
0
        /// <summary>
        /// Constructor
        ///
        /// </summary>
        /// <param name="commandParameters">An array of parameters, where
        ///     [1]: Point  center location for the star, defaut = top left corner
        ///     [2]: float  scale factor
        ///     [3]: float  new scale factor</param>
        internal CmdScale(params object[] commandParameters)
        {
            if (commandParameters.Length > 2)
            {
                _location = (Point)commandParameters[0];

                float newScale = (float)commandParameters[1];

                var star = TargetDrawing?.FindStarAtPosition(_location);
                _size = star.Size;

                _newSize = new Size()
                {
                    Width  = Convert.ToInt16(Math.Round(NormalWidth * newScale, 0)),
                    Height = Convert.ToInt16(Math.Round(NormalHeight * newScale, 0))
                };
            }
        }
예제 #30
0
        public override void Execute()
        {
            var star = TargetDrawing?.FindStarAtPosition(_location);

            if (star != null)
            {
                // this creates a new point offset from the current location by 10 (should be lower and to the right)
                _location = new Point((star.Location.X - star.Size.Width / 2) + 10, (star.Location.Y - star.Size.Height / 2) + 10);

                StarExtrinsicState extrinsicState = new StarExtrinsicState()
                {
                    StarType   = TargetDrawing.Factory.StarType,
                    Location   = _location,
                    Size       = star.Size,
                    IsSelected = true
                };

                var starDopple = TargetDrawing.Factory.GetStar(extrinsicState);

                TargetDrawing.Add(starDopple);

                TargetDrawing.IsDirty = true;
            }
        }