Ejemplo n.º 1
0
        public static PrimitiveEllipse Ttr(Plane drawingPlane, SelectedEntity firstEntity, SelectedEntity secondEntity, double radius)
        {
            var first  = firstEntity.Entity;
            var second = secondEntity.Entity;

            if (!CanOffsetEntity(first) || !CanOffsetEntity(second))
            {
                return(null);
            }

            if (!drawingPlane.Contains(first) || !drawingPlane.Contains(second))
            {
                return(null);
            }

            // offset each entity both possible directions, intersect everything, and take the closest
            // point to be the center
            var firstOffsets = OffsetBothDirections(
                drawingPlane: drawingPlane,
                primitive: first.GetPrimitives().First(),
                distance: radius);
            var secondOffsets = OffsetBothDirections(
                drawingPlane: drawingPlane,
                primitive: second.GetPrimitives().First(),
                distance: radius);

            var candidatePoints = (from f in firstOffsets
                                   from s in secondOffsets
                                   where f != null && s != null
                                   select f.IntersectionPoints(s, false))
                                  .SelectMany(x => x);

            if (candidatePoints.Any())
            {
                var center = candidatePoints.OrderBy(x =>
                {
                    return((x - firstEntity.SelectionPoint).LengthSquared
                           * (x - secondEntity.SelectionPoint).LengthSquared);
                }).First();

                return(new PrimitiveEllipse(center, radius, drawingPlane.Normal));
            }

            return(null);
        }
Ejemplo n.º 2
0
        private async void DeleteSelectedEntity()
        {
            await DeleteEntityFromFile();

            string[] type = SelectedEntity.GetType().ToString().Split('.');
            switch (type[type.Length - 1])
            {
            case "Employee":
                var employeeToRemove = CompanyEmployees.FirstOrDefault(c => c.Id == SelectedEntity.Id);
                if (employeeToRemove != null)
                {
                    SelectedCompany.Employees.RemoveAll(e => e.Id == SelectedEntity.Id);
                    CompanyEmployees.Remove(employeeToRemove);
                }
                break;

            case "Todo":
                var todoToRemove = CompanyTodos.FirstOrDefault(c => c.Id == SelectedEntity.Id);
                if (todoToRemove != null)
                {
                    SelectedCompany.Todos.RemoveAll(t => t.Id == SelectedEntity.Id);
                    CompanyTodos.Remove(todoToRemove);
                }
                break;

            case "HistoryPost":
                var historyToRemove = CompanyHistories.FirstOrDefault(c => c.Id == SelectedEntity.Id);
                if (historyToRemove != null)
                {
                    SelectedCompany.Histories.RemoveAll(h => h.Id == SelectedEntity.Id);
                    CompanyHistories.Remove(historyToRemove);
                }
                break;
            }

            SelectedEntity = null;
            EntitySelected(null);
        }
        protected override void EntityGridViewDoubleClick(object sender, EventArgs e)
        {
            base.EntityGridViewDoubleClick(sender, e);
            var view = (ColumnView)sender;
            var pt   = view.GridControl.PointToClient(MousePosition);

            var gridView = view as GridView;

            if (gridView == null)
            {
                return;
            }

            GridHitInfo info = gridView.CalcHitInfo(pt);

            if (!info.InRow && !info.InRowCell)
            {
                return;
            }
            Guid id = SelectedEntity.AsDyanmic().ProjectIterationId;

            OnEditProjectIteration(new EventArgs <Guid>(id));
        }
Ejemplo n.º 4
0
        public override gpAx2 GetPointLocation(int index)
        {
            var shape = SelectedEntity.TargetShape();

            if (shape == null)
            {
                return(null);
            }
            var gravityCenter = GeomUtils.ExtractGravityCenter(shape);
            var dir           = GeomUtils.ExtractDirection(shape);

            if (dir == null)
            {
                return(null);
            }
            var orientation = shape.Orientation();

            if (orientation != TopAbsOrientation.TopAbs_REVERSED)
            {
                dir.Reverse();
            }
            solidColor = new NodeBuilder(SelectedEntity.Node).Color;
            return(new gpAx2(gravityCenter.GpPnt, dir));
        }
            public override void Draw()
            {
                base.Draw();

                if (SelectedEntity == null)
                {
                    return;
                }
                MyListDictionary <MemberInfo, MemberInfo> watch = null;

                m_watch.TryGetValue(m_selectedType, out watch);

                if (m_showWatch)
                {
                    DrawWatch(watch);
                    return;
                }

                StringBuilder sb = new StringBuilder(SelectedEntity.GetType().Name);

                Type currentType = m_selectedType;

                m_currentInstance = SelectedEntity;
                foreach (var member in m_currentPath)
                {
                    sb.Append(".");
                    sb.Append(member.Name);
                    m_currentInstance = member.GetValue(m_currentInstance);
                    currentType       = m_currentInstance.GetType();
                }
                if (currentType != m_lastType)
                {
                    m_lastType = currentType;

                    m_members.Clear();
                    MemberInfo[] members = currentType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    foreach (var member in members)
                    {
                        if (member.DeclaringType == currentType)
                        {
                            m_members.Add(member);
                        }
                    }
                    //m_members.AddArray(members);
                    members = currentType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    foreach (var member in members)
                    {
                        if (member.DeclaringType == currentType)
                        {
                            m_members.Add(member);
                        }
                    }
                    m_members.Sort((x, y) => string.Compare(x.Name, y.Name));
                    //m_members.AddArray(members);
                }

                Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f);

                MyRenderProxy.DebugDrawText2D(pos, sb.ToString(),
                                              Color.White, 0.65f);
                pos.Y += 20;
                for (int i = SelectedMember; i < m_members.Count; i++)
                {
                    var    info  = m_members[i];
                    object value = info.GetValue(m_currentInstance);
                    var    text  = value != null?value.ToString() : "null";

                    text = text.Replace("\n", "");
                    MyRenderProxy.DebugDrawText2D(pos, info.Name + " : " + text,
                                                  (watch != null && watch.GetList(info) != null) ? Color.Green : Color.White, 0.55f);
                    pos.Y += 12;
                }
            }
Ejemplo n.º 6
0
 protected abstract void DoTrimExtend(SelectedEntity selectedEntity, IEnumerable <IPrimitive> boundaryPrimitives, out IEnumerable <Entity> removed, out IEnumerable <Entity> added);
Ejemplo n.º 7
0
 protected override void DoTrimExtend(SelectedEntity selectedEntity, IEnumerable <Primitives.IPrimitive> boundaryPrimitives, out IEnumerable <Entity> removed, out IEnumerable <Entity> added)
 {
     EditUtilities.Extend(selectedEntity, boundaryPrimitives, out removed, out added);
 }
Ejemplo n.º 8
0
 private void AddMeshToSelectedEntity()
 {
     SelectedEntity.AddMeshComponent();
     OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(SelectedEntity)));
 }
Ejemplo n.º 9
0
 private void AddTransformToSelectedEntity()
 {
     SelectedEntity.AddTransformComponent();
     //Binding is listening to a value on the entity so we need to tell it the selected entity has changed
     OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(SelectedEntity)));
 }
Ejemplo n.º 10
0
        public async Task LoadTableDataAsync()
        {
            if (Loading)
            {
                return;
            }

            try
            {
                Loading = true;
                _stateHasChanged?.Invoke();
                TotalRecords = await _getEntitiesCount.Invoke(DataLoadingOptions);

                SetCurrentPage();
                DataLoadingOptions.Skip = (CurrentPage - 1) * DataLoadingOptions.Take;
                Entities = await _getEntities.Invoke(DataLoadingOptions);

                SelectedEntity = Entities.FirstOrDefault(x => x.GetType().GetProperty(SyncPropName).GetValue(x).ToString() == SelectedEntity?.GetType().GetProperty(SyncPropName).GetValue(SelectedEntity).ToString());
            }
            finally
            {
                Loading = false;
                _stateHasChanged?.Invoke();
            }
        }
Ejemplo n.º 11
0
 public ValueReceivedEventArgs(SelectedEntity entity)
 {
     this.entity = entity;
     InputType   = InputType.Entity;
 }
Ejemplo n.º 12
0
 public PushEntityOperation(SelectedEntity entity)
 {
     Entity = entity;
 }
Ejemplo n.º 13
0
        private async void OnMouseDown(object sender, PointerButtonEventArgs e)
        {
            var cursor = GetPointerPosition(e);
            var sp     = await GetActiveModelPointNowAsync(cursor, CancellationToken.None);

            if (IsLeftButtonPressed(e))
            {
                if ((Workspace.InputService.AllowedInputTypes & InputType.Point) == InputType.Point)
                {
                    Workspace.InputService.PushPoint(sp.WorldPoint);
                }
                else if ((Workspace.InputService.AllowedInputTypes & InputType.Entity) == InputType.Entity)
                {
                    var selected = GetHitEntity(cursor);
                    if (selected != null)
                    {
                        Workspace.InputService.PushEntity(selected);
                    }
                }
                else if ((Workspace.InputService.AllowedInputTypes & InputType.Entities) == InputType.Entities || selectingRectangle || !Workspace.IsCommandExecuting)
                {
                    if (selecting)
                    {
                        // finish selection
                        IEnumerable <Entity> entities = null;
                        if (selectingRectangle)
                        {
                            selectingRectangle = false;
                            ClearSnapPoints();
                            SetCursorVisibility();
                            var topLeftScreen     = new Point(Math.Min(firstSelectionPoint.X, sp.ControlPoint.X), Math.Min(firstSelectionPoint.Y, sp.ControlPoint.Y), 0.0);
                            var bottomRightScreen = new Point(Math.Max(firstSelectionPoint.X, sp.ControlPoint.X), Math.Max(firstSelectionPoint.Y, sp.ControlPoint.Y), 0.0);
                            var selection         = new SelectionRectangle(
                                topLeftScreen,
                                bottomRightScreen,
                                Unproject(topLeftScreen),
                                Unproject(bottomRightScreen));
                            selectionDone.SetResult(selection);
                        }
                        else
                        {
                            var rect = new Rect(
                                Math.Min(firstSelectionPoint.X, currentSelectionPoint.X),
                                Math.Min(firstSelectionPoint.Y, currentSelectionPoint.Y),
                                Math.Abs(firstSelectionPoint.X - currentSelectionPoint.X),
                                Math.Abs(firstSelectionPoint.Y - currentSelectionPoint.Y));
                            entities = GetContainedEntities(rect, currentSelectionPoint.X < firstSelectionPoint.X);
                        }

                        selecting = false;
                        SetSelectionLineVisibility(Visibility.Collapsed);
                        if (entities != null)
                        {
                            if (!Workspace.IsCommandExecuting)
                            {
                                Workspace.SelectedEntities.AddRange(entities);
                            }
                            else
                            {
                                Workspace.InputService.PushEntities(entities);
                            }
                        }
                    }
                    else
                    {
                        SelectedEntity selected = null;
                        if (selectingRectangle)
                        {
                            Workspace.OutputService.WriteLine("Select second point");
                        }
                        else
                        {
                            selected = GetHitEntity(cursor);
                        }

                        if (selected != null)
                        {
                            if (!Workspace.IsCommandExecuting)
                            {
                                Workspace.SelectedEntities.Add(selected.Entity);
                            }
                            else
                            {
                                Workspace.InputService.PushEntities(new[] { selected.Entity });
                            }
                        }
                        else
                        {
                            selecting             = true;
                            firstSelectionPoint   = sp.ControlPoint;
                            currentSelectionPoint = cursor;
                            SetSelectionLineVisibility(Visibility.Visible);
                        }
                    }
                }
                else if (Workspace.InputService.AllowedInputTypes == InputType.None || !Workspace.IsCommandExecuting)
                {
                    // do hot-point tracking
                    var selected = GetHitEntity(cursor);
                    if (selected != null)
                    {
                        Workspace.SelectedEntities.Add(selected.Entity);
                    }
                }
            }
            else if (IsMiddleButtonPressed(e))
            {
                panning      = true;
                lastPanPoint = cursor;
            }
            else if (IsRightButtonPressed(e))
            {
                Workspace.InputService.PushNone();
            }
        }
Ejemplo n.º 14
0
        public override void UpdatePointPosition(int index, Mouse3DPosition vertex)
        {
            if (SelectedEntity.TargetShape() == null)
            {
                return;
            }
            var  faceToChangeIndex = 0;
            Node nodeToChange      = null;
            var  faceShape         = new TopoDSShape();

            if (SelectedEntity.Node.Get <FunctionInterpreter>().Name == FunctionNames.Cut)
            {
                var nb             = new NodeBuilder(SelectedEntity.Node);
                var affectedShapes = NodeBuilderUtils.GetCutNodeBaseExtrudeNodes(nb).ToList();//nb.Dependency[3];
                var clickedPlane   = GeomUtils.ExtractPlane(SelectedEntity.TargetShape());
                if (clickedPlane == null)
                {
                    return;
                }
                foreach (var node in affectedShapes)
                {
                    var faces = GeomUtils.ExtractFaces(new NodeBuilder(node).Shape);
                    int count = 1;
                    foreach (var face in faces)
                    {
                        var direction = GeomUtils.ExtractPlane(face);
                        if (direction == null)
                        {
                            count++;
                            continue;
                        }
                        count++;
                        if (direction.Axis.Direction.IsParallel(clickedPlane.Axis.Direction, Precision.Confusion))
                        {
                            var projectedPnt = GeomUtils.ProjectPointOnPlane(direction.Location, clickedPlane, Precision.Confusion);
                            if (projectedPnt.IsEqual(direction.Location, Precision.Confusion))
                            {
                                faceShape = face;
                                break;
                            }
                        }
                    }

                    // if the face matches the clicked plane, count will be > 0 and will hold the face index on the extruded solid
                    if (count > 0)
                    {
                        faceToChangeIndex = count - 1;
                        nodeToChange      = node;
                        break;
                    }
                }
            }
            if (SelectedEntity.Node.Get <FunctionInterpreter>().Name == FunctionNames.Extrude)
            {
                faceToChangeIndex = SelectedEntity.ShapeCount;
                nodeToChange      = SelectedEntity.Node;
                faceShape         = SelectedEntity.TargetShape();
            }

            if (prevFaceCount < 0)
            {
                prevFaceCount = faceToChangeIndex;
            }
            if (faceToChangeIndex != prevFaceCount)
            {
                return;
            }
            if (nodeToChange == null)
            {
                return;
            }
            var distance      = 0.0;
            var numberOfFaces = GeomUtils.ExtractFaces(new NodeBuilder(nodeToChange).Shape).Count;

            if (faceToChangeIndex == numberOfFaces) //top of shape
            {
                distance = GeomUtils.CalculateDistance(vertex.Point.GpPnt,
                                                       new NodeBuilder(nodeToChange).Dependency[0].
                                                       ReferenceBuilder.Shape);

                var extrudeNb = new NodeBuilder(nodeToChange);
                if (Math.Abs(distance) < Precision.Confusion)
                {
                    distance = 0.1;
                }
                extrudeNb.Dependency[2].Real = distance;
                extrudeNb.ExecuteFunction();
            }

            if (faceToChangeIndex == (numberOfFaces - 1))
            {
                // bottom of shape - sketch which was extruded
                var extrudeNb       = new NodeBuilder(nodeToChange);
                var extrudeHeight   = extrudeNb.Dependency[2].Real;
                var baseSketch      = extrudeNb.Dependency[0].ReferenceBuilder;
                var faces           = GeomUtils.ExtractFaces(extrudeNb.Shape);
                var topFace         = faces[numberOfFaces - 1];
                var distanceTopFace = GeomUtils.CalculateDistance(vertex.Point.GpPnt,
                                                                  topFace);
                distance = GeomUtils.CalculateDistance(vertex.Point.GpPnt,
                                                       SelectedEntity.TargetShape());

                var dirBottomFace         = GeomUtils.ExtractDirection(SelectedEntity.TargetShape());
                var orientationBottomFace = SelectedEntity.TargetShape().Orientation();
                if (orientationBottomFace != TopAbsOrientation.TopAbs_REVERSED)
                {
                    dirBottomFace.Reverse();
                }
                var bottomFaceGravityCenter = GeomUtils.ExtractGravityCenter(topFace);
                var vertexOnDir             = TransformationInterpreter.ProjectPointOnLine(bottomFaceGravityCenter,
                                                                                           dirBottomFace, vertex.Point).Value;
                var startPointOnDir = TransformationInterpreter.ProjectPointOnLine(bottomFaceGravityCenter,
                                                                                   dirBottomFace, new Point3D(previousMousePosition)).Value;

                var vertexvector = new gpVec(startPointOnDir.GpPnt, vertexOnDir.GpPnt);
                var normalvector = new gpVec(dirBottomFace);
                var isOpposite   = false;
                try
                {
                    isOpposite = vertexvector.IsOpposite(normalvector, Precision.Angular);
                }
                catch { return; }
                // calculate new height for the solid
                var newHeight = 0.0;
                if (isOpposite)
                {
                    newHeight = Math.Abs(extrudeHeight) - Math.Abs(distance);
                }
                else
                {
                    newHeight = Math.Abs(extrudeHeight) + Math.Abs(distance);
                }
                newHeight *= Math.Sign(extrudeHeight);
                var face = SelectedEntity.TargetShape();
                if (face == null)
                {
                    return;
                }

                // calculate the new position for the solid
                var transformation = baseSketch.Node.Get <TransformationInterpreter>().CurrTransform;
                var locationOld    = new gpPnt(0, 0, 0).Transformed(transformation);
                var shape          = SelectedEntity.TargetShape();

                var dir         = GeomUtils.ExtractDirection(shape);
                var orientation = shape.Orientation();
                if (orientation != TopAbsOrientation.TopAbs_REVERSED)
                {
                    dir.Reverse();
                }
                if (isOpposite)
                {
                    dir.Reverse();
                }

                var locationNew = new gpPnt
                {
                    X = locationOld.X + dir.X * Math.Abs(distance),
                    Y = locationOld.Y + dir.Y * Math.Abs(distance),
                    Z = locationOld.Z + dir.Z * Math.Abs(distance)
                };

                // set the new transformation for the base sketch
                var T             = new gpTrsf();
                var oldSystemAxis = new gpAx3(new gpPnt(0, 0, 0), new gpDir(0, 0, 1));
                var newSystemAxis = new gpAx3(locationNew, dir);
                T.SetTransformation(oldSystemAxis, newSystemAxis);

                var transformationSet = baseSketch.Node.Set <TransformationInterpreter>();
                transformationSet.CurrTransform = T.Inverted;

                extrudeNb.Dependency[2].Real = newHeight;
                baseSketch.ExecuteFunction();
                previousMousePosition = vertex.Point.GpPnt;
            }

            if (faceToChangeIndex < (numberOfFaces - 1))
            {
                var         shape           = faceShape;
                var         gravityCenter   = GeomUtils.ExtractGravityCenter(shape);
                var         extrudeNb       = new NodeBuilder(nodeToChange);
                var         baseSketch      = extrudeNb.Dependency[0].ReferenceBuilder;
                var         transformation  = baseSketch.Node.Get <TransformationInterpreter>().CurrTransform;
                var         locationSketch  = new gpPnt(0, 0, 0).Transformed(transformation);
                var         directionSketch = new gpDir(0, 0, 1).Transformed(transformation);
                var         sketchPlane     = new gpPln(locationSketch, directionSketch);
                var         pointOnPlane    = new Point3D(GeomUtils.ProjectPointOnPlane(gravityCenter.GpPnt, sketchPlane, Precision.Confusion));
                var         sketchNodes     = NodeUtils.GetSketchNodes(baseSketch.Node, baseSketch.Node.Root.Get <DocumentContextInterpreter>().Document, true);
                NodeBuilder draggedLine     = null;
                foreach (var node in sketchNodes)
                {
                    var nb = new NodeBuilder(node);
                    if (nb.FunctionName != FunctionNames.LineTwoPoints)
                    {
                        continue;
                    }
                    var edges = GeomUtils.ExtractEdges(nb.Shape);
                    if (edges.Count != 1)
                    {
                        continue;
                    }
                    if (GeomUtils.PointIsOnEdge(edges[0], pointOnPlane))
                    {
                        draggedLine = nb;
                        break;
                    }
                }

                if (draggedLine != null)
                {
                    var axisLength    = CoreGlobalPreferencesSingleton.Instance.ZoomLevel * 10;
                    var faceDirection = GeomUtils.ExtractDirection(shape);
                    var orientation   = shape.Orientation();
                    if (orientation != TopAbsOrientation.TopAbs_REVERSED)
                    {
                        faceDirection.Reverse();
                    }
                    var vertexOnPlane = new Point3D(GeomUtils.ProjectPointOnPlane(vertex.Point.GpPnt, sketchPlane, Precision.Confusion));

                    vertexOnPlane.X = (vertexOnPlane.X) * Math.Abs(faceDirection.X);
                    vertexOnPlane.Y = (vertexOnPlane.Y) * Math.Abs(faceDirection.Y);
                    vertexOnPlane.Z = (vertexOnPlane.Z) * Math.Abs(faceDirection.Z);
                    var pointOnPlaneAxis = new Point3D
                    {
                        X = pointOnPlane.X * Math.Abs(faceDirection.X),
                        Y = pointOnPlane.Y * Math.Abs(faceDirection.Y),
                        Z = pointOnPlane.Z * Math.Abs(faceDirection.Z)
                    };
                    var translateValue = vertexOnPlane.SubstractCoordinate(pointOnPlaneAxis);
                    NodeUtils.TranslateSketchNode(draggedLine, translateValue, baseSketch.Node);
                    var constraintMapper = new ConstraintDocumentHelper(baseSketch.Node.Root.Get <DocumentContextInterpreter>().Document, baseSketch.Node);
                    constraintMapper.SetMousePosition(draggedLine.Dependency[0].Reference.Index);
                    var error = constraintMapper.ImpactAndSolve(draggedLine.Dependency[1].Node.Get <ReferenceInterpreter>().Node);
                    baseSketch.ExecuteFunction();
                    extrudeNb.Color = solidColor;
                    extrudeNb.ExecuteFunction();
                }
            }
        }
Ejemplo n.º 15
0
        public async Task MouseDown(Point position, MouseButton button)
        {
            var sp = await GetActiveModelPointNowAsync(position, CancellationToken.None);

            if (button == MouseButton.Left)
            {
                if (panCommand.IsPanning == true)
                {
                    panning      = true;
                    lastPanPoint = position;
                }
                else if ((_workspace.InputService.AllowedInputTypes & InputType.Point) == InputType.Point)
                {
                    _workspace.InputService.PushPoint(sp.WorldPoint);
                }
                else if ((_workspace.InputService.AllowedInputTypes & InputType.Entity) == InputType.Entity)
                {
                    var selected = GetHitEntity(position);
                    if (selected != null)
                    {
                        _workspace.InputService.PushEntity(selected);
                    }
                }
                else if ((_workspace.InputService.AllowedInputTypes & InputType.Entities) == InputType.Entities || selectingRectangle || !_workspace.IsCommandExecuting)
                {
                    if (selecting)
                    {
                        // finish selection
                        IEnumerable <Entity> entities = null;
                        if (selectingRectangle)
                        {
                            selectingRectangle = false;
                            SetCursorVisibility();
                            var topLeftScreen     = new Point(Math.Min(firstSelectionPoint.X, sp.ControlPoint.X), Math.Min(firstSelectionPoint.Y, sp.ControlPoint.Y), 0.0);
                            var bottomRightScreen = new Point(Math.Max(firstSelectionPoint.X, sp.ControlPoint.X), Math.Max(firstSelectionPoint.Y, sp.ControlPoint.Y), 0.0);
                            var selection         = new SelectionRectangle(
                                topLeftScreen,
                                bottomRightScreen,
                                Unproject(topLeftScreen),
                                Unproject(bottomRightScreen));
                            selectionDone.SetResult(selection);
                        }
                        else
                        {
                            var rect = new Rect(
                                Math.Min(firstSelectionPoint.X, currentSelectionPoint.X),
                                Math.Min(firstSelectionPoint.Y, currentSelectionPoint.Y),
                                Math.Abs(firstSelectionPoint.X - currentSelectionPoint.X),
                                Math.Abs(firstSelectionPoint.Y - currentSelectionPoint.Y));
                            entities = GetContainedEntities(rect, currentSelectionPoint.X < firstSelectionPoint.X);
                        }

                        selecting = false;
                        UpdateSelectionRectangle(null);
                        if (entities != null)
                        {
                            if (!_workspace.IsCommandExecuting)
                            {
                                _workspace.SelectedEntities.AddRange(entities);
                            }
                            else
                            {
                                _workspace.InputService.PushEntities(entities);
                            }
                        }
                    }
                    else
                    {
                        SelectedEntity selected = null;
                        if (selectingRectangle)
                        {
                            _workspace.OutputService.WriteLine("Select second point");
                        }
                        else
                        {
                            selected = GetHitEntity(position);
                        }

                        if (selected != null)
                        {
                            if (!_workspace.IsCommandExecuting)
                            {
                                _workspace.SelectedEntities.Add(selected.Entity);
                            }
                            else
                            {
                                _workspace.InputService.PushEntities(new[] { selected.Entity });
                            }
                        }
                        else
                        {
                            selecting             = true;
                            firstSelectionPoint   = sp.ControlPoint;
                            currentSelectionPoint = position;
                        }
                    }
                }
                else if (_workspace.InputService.AllowedInputTypes == InputType.None || !_workspace.IsCommandExecuting)
                {
                    // do hot-point tracking
                    var selected = GetHitEntity(position);
                    if (selected != null)
                    {
                        _workspace.SelectedEntities.Add(selected.Entity);
                    }
                }
            }
            else if (button == MouseButton.Middle)
            {
                panning      = true;
                lastPanPoint = position;
            }
            else if (button == MouseButton.Right)
            {
                _workspace.InputService.PushNone();
            }
        }