Exemplo n.º 1
0
        public void SwitchToFaceSelection()
        {
            if (InFaceSelection)
            {
                return;
            }
            foreach (var face in SelectedFaces)
            {
                face.IsSelected = false;
            }
            SelectedFaces.Clear();

            SelectedFaces.UnionWith(GetSelectedObjects()
                                    .OfType <Solid>()
                                    .SelectMany(x => {
                var disps = x.Faces.Where(y => y is Displacement);
                return(disps.Any() ? disps : x.Faces);
            }));

            foreach (var face in SelectedFaces)
            {
                face.IsSelected = true;
            }

            foreach (var obj in SelectedObjects)
            {
                obj.IsSelected = false;
            }
            SelectedObjects.Clear();

            InFaceSelection = true;

            Mediator.Publish(EditorMediator.SelectionTypeChanged, Document);
            Mediator.Publish(EditorMediator.SelectionChanged, Document);
        }
        private void EventHandlerCore_ObjectSelected(object sender, BimPlusEventArgs e)
        {
            Debug.WriteLine(string.Format("Id:{0} Selected:{1} Multiselect:{2}", e.Id, e.Selected, e.Multiselect));

            if (e.Id != Guid.Empty || e.Selected != true)
            {
                DtObject dtObject = _integrationBase.ApiCore.DtObjects.GetObject(e.Id, ObjectRequestProperties.AttributDefinition | ObjectRequestProperties.Pset);

                if (dtObject != null)
                {
                    if (e.Multiselect == true)
                    {
                        if (SelectedObjects.FirstOrDefault(o => o.Id == e.Id) == null)
                        {
                            SelectedObjects.Add(dtObject);
                        }
                    }
                    else
                    {
                        SelectedObjects.Clear();
                        if (e.Selected == true)
                        {
                            SelectedObjects.Add(dtObject);
                        }
                    }
                }

                if (e.Selected == false)
                {
                    DtObject exist = SelectedObjects.FirstOrDefault(o => o.Id == e.Id);
                    if (exist != null)
                    {
                        SelectedObjects.Remove(exist);
                    }
                    else
                    {
                        SelectedObjects.Clear();
                    }
                }
                else if (e.Selected == null && e.Id != Guid.Empty)
                {
                    if (dtObject != null)
                    {
                        if (SelectedObjects.FirstOrDefault(o => o.Id == e.Id) == null)
                        {
                            SelectedObjects.Add(dtObject);
                        }
                    }
                    else
                    {
                        SelectedObjects.Clear();
                    }
                }

                List <DtObject> newList = new List <DtObject>();
                newList.AddRange(SelectedObjects);
                SelectedObjects = newList;
                Trace.WriteLine(string.Format("_selectedObjects.Count:{0}", SelectedObjects.Count()));
            }
        }
Exemplo n.º 3
0
 internal void ExitCreatingMode()
 {
     SelectedObjects.Clear();
     CreatingNodes.Clear();
     HoveredCreatingNode = null;
     IsCreatingMode      = false;
 }
Exemplo n.º 4
0
 public void EditDelete()
 {
     foreach (LevelGeometry geom in SelectedObjects)
     {
         Map.Geometry.Remove(geom);
     }
     SelectedObjects.Clear();
 }
Exemplo n.º 5
0
 internal void SetNewGraph(Graph graph)
 {
     SelectedObjects.Clear();
     HoveredObjects.Clear();
     CreatingNodes.Clear();
     HoveredCreatingNode = null;
     Graph = graph;
 }
Exemplo n.º 6
0
 internal void EnterCreatingMode()
 {
     SelectedObjects.Clear();
     CreatingNodes.Clear();
     HoveredCreatingNode = null;
     PasteMode           = false;
     IsCreatingMode      = true;
     ColorPaintingMode   = false;
 }
 public void InvokeSelectionChanged()
 {
     SelectedObjects.Clear();
     if (structure.Selected != null)
     {
         SelectedObjects.Add(structure.Selected);
     }
     OnSelectionChanged();
 }
        public void ResetSelection()
        {
            if (SelectedObjects.Count > 0)
            {
                USUndoManager.PropertyChange(this, "Select None");

                USEditorUtility.RemoveFromUnitySelection(SelectedObjects);
                SelectedObjects.Clear();
                SourcePositions.Clear();
            }
        }
        public void DeleteSelection()
        {
            USUndoManager.RegisterCompleteObjectUndo(this, "RemoveClip");

            foreach (var selectedObject in SelectedObjects)
            {
                RemoveClip(selectedObject as AnimationClipData);
            }

            SelectedObjects.Clear();
        }
Exemplo n.º 10
0
 /// <summary>
 /// This method is used to select single object for property window.
 /// </summary>
 /// <param name="selection">Object to select. Must be a member of SelectableObjects list.</param>
 protected void SelectObject(object selection)
 {
     SelectedObjects.Clear();
     if (selection != null)
     {
         if (!SelectableObjects.Contains(selection))
         {
             Debug.Fail("Trying to select object which is not in the selectable collection!");
             return;
         }
         SelectedObjects.Add(selection);
     }
 }
Exemplo n.º 11
0
        public void Clear()
        {
            foreach (var obj in SelectedObjects)
            {
                obj.IsSelected = false;
            }
            SelectedObjects.Clear();

            foreach (var face in SelectedFaces)
            {
                face.IsSelected = false;
            }
            SelectedFaces.Clear();
        }
Exemplo n.º 12
0
 public override void Reset()
 {
     SelectedObjects.Clear();
     current_group = 0;
     selecting     = false;
     sel_ex        = 0;
     sel_ey        = 0;
     sel_sx        = 0;
     sel_sy        = 0;
     tile_index    = 0;
     tile_id       = 0;
     span_x        = 0;
     span_y        = 0;
     selected      = false;
     selector_on   = false;
 }
Exemplo n.º 13
0
 internal void ChooseSampleDecorator(Decorator decorator, bool alwaysImportTetris)
 {
     SelectedObjects.Clear();
     if (decorator is null)
     {
         SampleDecorator = null;
     }
     else
     {
         SampleDecorator = decorator.Clone() as Decorator;
         bool importTetris = alwaysImportTetris || TetrisTransferHelper.TetrisCompatible(Graph, decorator);
         if (importTetris)
         {
             TetrisIndexToTemplateView(SampleDecorator);
         }
         else
         {
             SelectedTetrisShapes = new bool[SelectedTetrisShapes.Length];
             TetrisTransferHelper.ClearTetrisIndex(SampleDecorator);
         }
     }
     PasteMode         = true;
     ColorPaintingMode = false;
 }
Exemplo n.º 14
0
 public void OnRightDown()
 {
     SelectedObjects.Clear();
     draggingElement = false;
     //throw new NotImplementedException();
 }
Exemplo n.º 15
0
        internal bool MouseDown(int x, int y, MouseButtons button, bool ctrlKey, bool altKey, bool shiftKey) // Return true if copy operation is performed
        {
            bool copyPerformed = false;

            if (IsCreatingMode)
            {
                if (button == MouseButtons.Left) // Add
                {
                    Node addNode;
                    if (HoveredObjects.Count > 0 && HoveredObjects[0] is Node node)
                    {
                        if (CreatingNodes.Contains(node))
                        {
                            if (CreatingNodes.Last() == node)
                            {
                                CreatingNodes.RemoveAt(CreatingNodes.Count - 1);
                            }
                            else if (CreatingNodes.First() == node)
                            {
                                AddToCreatingNodes(node);
                                SubmitCreatingNodes();
                            }
                            return(false);
                        }
                        addNode = node;
                    }
                    else
                    {
                        Vector pos = new Vector(x, y).MapFromScreen(Scale, Origin);
                        addNode = new Node(pos.X, pos.Y);
                    }
                    AddToCreatingNodes(addNode);
                    return(false);
                }
                else if (button == MouseButtons.Right) // Exit
                {
                    SubmitCreatingNodes();
                    return(false);
                }
            }
            if (altKey && PasteMode && SampleDecorator != null) // Create and paste
            {
                GraphEditManager.BeforePreformEdit(Graph, "Create Graph Elements");
                Vector pos     = new Vector(x, y).MapFromScreen(Scale, Origin);
                Node   addNode = new Node(pos.X, pos.Y);
                addNode.Hidden    = true;
                addNode.Decorator = SampleDecorator.Clone() as Decorator;
                if (!shiftKey && addNode.Decorator is TransformableDecorator transformableDecorator)
                {
                    transformableDecorator.ExtraScale = (1 - Graph.MetaData.EdgeWidth) / Graph.MetaData.EdgeWidth;
                }
                GraphManipulation.AddShape(Graph, new List <Node>()
                {
                    addNode
                });
            }
            else if (HoveredObjects.Count > 0 && button != MouseButtons.Middle)
            {
                List <GraphElement> objectToKeep = new List <GraphElement>();
                if (ctrlKey || shiftKey)
                {
                    foreach (GraphElement selectedObject in SelectedObjects)
                    {
                        if (shiftKey || !HoveredObjects.Contains(selectedObject))
                        {
                            objectToKeep.Add(selectedObject);
                        }
                    }
                }
                foreach (GraphElement havoredObject in HoveredObjects)
                {
                    if (!SelectedObjects.Contains(havoredObject))
                    {
                        objectToKeep.Add(havoredObject);
                    }
                }
                SelectedObjects.Clear();
                if (ColorPaintingMode) // Paint mode
                {
                    foreach (GraphElement element in objectToKeep)
                    {
                        Color TryApplyColor(Color oldColor, Color newColor, string hint)
                        {
                            if (oldColor != newColor)
                            {
                                GraphEditManager.BeforePreformEdit(Graph, string.Format(Resources.Lang.Undo_Paint, hint, newColor.ToString()));
                            }
                            return(newColor);
                        }

                        if (element is Node)
                        {
                            if (element.Decorator is PuzzleGraph.Decorators.StartDecorator startDecorator)
                            {
                                if (button == MouseButtons.Right) // Color picking
                                {
                                    PaintingModeControl.Color = startDecorator.Color;
                                }
                                else // Apply color
                                {
                                    startDecorator.Color = TryApplyColor(startDecorator.Color, PaintingModeControl.Color, "start point");
                                }
                            }
                            else if (element.Decorator is PuzzleGraph.Decorators.EndDecorator endDecorator)
                            {
                                if (button == MouseButtons.Right) // Color picking
                                {
                                    PaintingModeControl.Color = endDecorator.Color;
                                }
                                else // Apply color
                                {
                                    endDecorator.Color = TryApplyColor(endDecorator.Color, PaintingModeControl.Color, "end point");
                                }
                            }
                        }
                        else if (element is Face face)
                        {
                            if (button == MouseButtons.Right) // Color picking
                            {
                                PaintingModeControl.Color = face.GraphElementColor;
                            }
                            else // Apply color
                            {
                                face.GraphElementColor = TryApplyColor(face.GraphElementColor, PaintingModeControl.Color, "face");
                            }
                        }
                        else if (element is Edge edge)
                        {
                            if (button == MouseButtons.Right) // Color picking
                            {
                                PaintingModeControl.Color = edge.GraphElementColor;
                            }
                            else // Apply color
                            {
                                edge.GraphElementColor = TryApplyColor(edge.GraphElementColor, PaintingModeControl.Color, "edge");
                            }
                        }
                    }
                }
                else if (button == MouseButtons.Right) // Copy
                {
                    if (objectToKeep.Count > 0)
                    {
                        if (ctrlKey && objectToKeep[0].Decorator is PuzzleGraph.Decorators.CombinedDecorator combinedDecorator) // Combine mode
                        {
                            ChooseSampleDecorator(combinedDecorator.Second, true);
                            objectToKeep[0].Decorator = combinedDecorator.First;
                        }
                        else
                        {
                            ChooseSampleDecorator(objectToKeep[0].Decorator, true);
                        }

                        copyPerformed = true;
                    }
                }
                else
                {
                    if (!PasteMode) // Selection mode
                    {
                        SelectedObjects.AddRange(objectToKeep);
                        if (shiftKey)
                        {
                            nodesToMove = new List <Node>();
                            foreach (GraphElement element in SelectedObjects)
                            {
                                if (element is Node selectedNode)
                                {
                                    nodesToMove.Add(selectedNode);
                                }
                                else if (element is Edge selectedEdge)
                                {
                                    nodesToMove.Add(selectedEdge.Start);
                                    nodesToMove.Add(selectedEdge.End);
                                }
                                else if (element is Face selectedFace)
                                {
                                    nodesToMove.AddRange(selectedFace.Nodes);
                                }
                            }
                            if (nodesToMove.Count > 0)
                            {
                                GraphEditManager.BeforePreformEdit(Graph, "Move Nodes");
                                ElementMoveStartPosition = new Vector(x, y);
                            }
                        }
                        else
                        {
                            ElementMoveStartPosition = null;
                        }
                    }
                    else // Paste mode
                    {
                        foreach (GraphElement element in objectToKeep)
                        {
                            if (ctrlKey && element.Decorator != null) // Combine mode
                            {
                                CombineDecorators(SampleDecorator, element);
                            }
                            else
                            {
                                ApplyDecoratorToObject(SampleDecorator, element);
                            }
                        }
                    }
                }
                HoveredObjects.Clear();
                if (SelectedObjects.Count > 0)
                {
                    TetrisIndexToTemplateView(SelectedObjects[0].Decorator);
                }
            }
            else
            {
                mouseDownPosition = new Vector(x, y);
                IsDragging        = true;
            }
            return(copyPerformed);
        }
Exemplo n.º 16
0
 public static void ClearSelection()
 {
     SelectedObjects.ForEach(x => (x.UserObject as ISelectable).Model.RenderFlags &= ~RenderFlags.Selected);
     SelectedObjects.Clear();
 }