Ejemplo n.º 1
0
        public void Execute()
        {
            if (objects == null || objects.Count == 0)
            {
                throw new Exception("No selected objects");
            }

            // group objects
            group = SceneManager.Instance.Group(objects);
            Midget.Events.EventFactory.Instance.GenerateGroupEvent(this, objects, group);

            ICommand select = new SelectObjectCommand(group);

            select.Execute();
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            if (parameters == null)
            {
                obj = ObjectFactory.CreateObject((int)objectType);
            }
            else
            {
                obj = ObjectFactory.CreateObject((int)objectType, parameters);
            }

            Midget.Events.EventFactory.Instance.GenerateCreateObjectEvent(this, obj);

            SceneManager.Instance.AddObject(obj);
            ICommand select = new SelectObjectCommand(obj);

            select.Execute();
        }
Ejemplo n.º 3
0
        public void OnMouseClick(PointF transformedPoint, PointF point, PointF gridStartPoint, float scale, ICommandManager manager)
        {
            TransformedStartPoint = transformedPoint;
            TransformedEndPoint   = transformedPoint;
            StartPoint            = point;
            EndPoint = point;
            if (IsFirstClick)
            {
                IsFirstClick = false;
                ChangeLabelText();
            }

            ICommand command;

            switch (ToolType)
            {
            case ToolType.Select:
                for (int i = 0; i < _objects.Count; i++)
                {
                    var o = _objects[i];
                    if (_objects[i].Contains(TransformedEndPoint, scale, gridStartPoint))
                    {
                        command = new SelectObjectCommand(_objects, new List <IObject>()
                        {
                            _objects[i]
                        });
                        manager.Execute(command);
                    }
                }
                break;

            case ToolType.Line:
                IsDrawing = true;
                _points.Add(transformedPoint);
                if (_points.Count > 1)
                {
                    if (_newObject == null)
                    {
                        _newObject = new Line(_points);
                    }
                    command = new CreateObjectCommand(_objects, _newObject);
                    manager.Execute(command);
                    _newObject = null;
                    _points.RemoveAt(0);
                }
                break;

            case ToolType.Polyline:
                IsDrawing = true;
                _points.Add(transformedPoint);
                if (_points.Count > 1)
                {
                    if (_newObject == null)
                    {
                        _newObject = new Polyline();
                    }
                    if (!_isCreated)
                    {
                        command = new CreateObjectCommand(_objects, _newObject);
                        manager.Execute(command);
                        _isCreated = true;
                    }
                    var newLine  = new Line(_points);
                    var polyline = _newObject as Polyline;
                    polyline.AddLine(newLine);
                    _points.RemoveAt(0);
                }
                break;

            case ToolType.Circle:
                break;

            case ToolType.Arc:
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
 public SelectObjectDescriptor(SelectObjectCommand command)
 {
     Command = command;
 }