コード例 #1
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);
        }
コード例 #2
0
ファイル: CmdDuplicate.cs プロジェクト: ironLink21/oo_hw3
        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;
            }
        }