Beispiel #1
0
        public void SameNodesAreAccepted()
        {
            var nodeSelection = new NodeSelection(new MyWorkingNode[] { new MyUserInput(), new MyUserInput() });

            Assert.False(nodeSelection.IsEmpty);
            Assert.Equal(2, nodeSelection.Count);
        }
        public BonsaiEditor()
        {
            NodeSelection.SingleSelected += OnSingleSelected;

            Input.selection                = NodeSelection;
            Input.MouseDown               += BeginActionOnMouseDown;
            Input.MouseDown               += (s, e) => UpdateAbortableSelection();
            Input.Click                   += Clicked;
            Input.DoubleClick             += DoubleClicked;
            Input.MouseUp                 += MouseUp;
            Input.CanvasLostFocus         += CanvasLostFocus;
            Input.NodeContextClick        += NodeContextClicked;
            Input.CanvasContextClick      += CanvasContextClicked;
            Input.CreateNodeRequest       += CreateNodeFromType;
            Input.SingleNodeActionRequest += SingleNodeAction;
            Input.MultiNodeActionRequest  += MultiNodeAction;
            Input.TypeChanged             += (s, node) => NodeSelection.SetSingleSelection(node);

            OnEditorModeChanged += (s, mode) =>
            {
                Input.EditInputEnabled = mode == Mode.Edit;
                Viewer.SetEditorMode(mode);
            };

            // init
            //OnEditorModeChanged?.Invoke(this, Mode.Edit);
        }
Beispiel #3
0
        private void PaintSelectedNode(bool isSelected)
        {
            if (mProjectView.Presentation != null && mSelection != null && mSelection.Node != null &&
                mProjectView.Presentation.RootNode != mSelection.Node.Presentation.RootNode)
            {
                mSelection = null;
            }

            if (mSelection != null && !(mSelection is TextSelection))
            {
                TreeNode treeNodeToSelect = FindTreeNodeWithoutLabel((SectionNode)mSelection.Node);
                if (treeNodeToSelect != null)
                {
                    if (isSelected)
                    {
                        treeNodeToSelect.BackColor = SystemColors.Highlight;
                        treeNodeToSelect.ForeColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        treeNodeToSelect.BackColor = Color.Empty;
                        treeNodeToSelect.ForeColor = SystemColors.ControlText;
                        if (mProjectView.ObiForm.Settings.Project_BackgroundColorForEmptySection) // @emptysectioncolor
                        {
                            EmptySectionBackColor(mSelection.Node, treeNodeToSelect);
                        }
                    }
                }
            }
        }
        private Color NodeStatusColor(BonsaiNode node)
        {
            if (IsNodeEvaluating(node))
            {
                return(Preferences.evaluateColor);
            }
            else if (IsNodeRunning(node))
            {
                return(Preferences.runningColor);
            }
            else if (NodeSelection.IsNodeSelected(node))
            {
                return(Preferences.selectedColor);
            }
            else if (NodeSelection.IsReferenced(node))
            {
                return(Preferences.referenceColor);
            }
            else if (IsNodeAbortable(node))
            {
                return(Preferences.abortColor);
            }
            else if (Canvas.Root == node)
            {
                return(Preferences.rootSymbolColor);
            }

            return(Preferences.defaultNodeBackgroundColor);
        }
Beispiel #5
0
        private void CreateNodeFromType(object sender, Type type)
        {
            BonsaiNode node = Canvas.CreateNode(type);

            NodeSelection.SetSingleSelection(node);
            lastCreatedNodeToPosition = node;
        }
        private Color NodeStatusColor(BonsaiNode node)
        {
            if (!node.Behaviour.IsValid())
            {
                return(Color.red);
            }

            if (IsNodeObserving(node))
            {
                return(Preferences.evaluateColor);
            }
            else if (IsNodeRunning(node))
            {
                return(Preferences.runningColor);
            }
            else if (NodeSelection.IsNodeSelected(node))
            {
                return(Preferences.selectedColor);
            }
            //else if (NodeSelection.IsReferenced(node))
            //{
            //    return Preferences.referenceColor;
            //}
            else if (abortableSelected.Contains(node))
            {
                return(Preferences.abortColor);
            }
            else if (Canvas.Root == node)
            {
                return(Preferences.rootSymbolColor);
            }

            return(Preferences.defaultNodeBackgroundColor);
        }
        private void StartAreaSelection(BonsaiInputEvent startEvent)
        {
            Vector2 startScreenSpace = Event.current.mousePosition;
            Vector2 start            = startEvent.canvasMousePostion;

            ApplyAction = (BonsaiInputEvent applyEvent) =>
            {
                Vector2 end           = applyEvent.canvasMousePostion;
                var     areaSelection = EditorAreaSelect.NodesUnderArea(Canvas.Nodes, start, end);
                if (areaSelection != null)
                {
                    NodeSelection.SetMultiSelection(areaSelection.ToList());
                }
            };

            Viewer.CustomOverlayDraw = () =>
            {
                // Construct and display the rect.
                Vector2 endScreenSpace = Event.current.mousePosition;
                Rect    selectionRect  = EditorAreaSelect.SelectionArea(startScreenSpace, endScreenSpace);
                Color   selectionColor = new Color(0f, 0.5f, 1f, 0.1f);
                Handles.DrawSolidRectangleWithOutline(selectionRect, selectionColor, Color.blue);
                OnCanvasChanged();
            };
        }
Beispiel #8
0
 private void ClearEditor()
 {
     ChangeEditorMode(EditorMode.Design);
     _currentAnimationId = 0;
     NodeSelection.Clear();
     KeySelection.Clear();
     _currentDocument = null;
 }
Beispiel #9
0
 /// <summary>
 /// Add an existing node to a parent node at the given index.
 /// </summary>
 public AddNode(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index) : base(view, "")
 {
     mNode      = node;
     mParent    = parent;
     mIndex     = index;
     mSelection = view.Selection != null && view.Selection.Control is ProjectView.ContentView ?
                  new NodeSelection(mNode, view.Selection.Control) : view.Selection;
 }
Beispiel #10
0
 /// <summary>
 /// Set the selection from the parent view
 /// </summary>
 public override void SetSelectionFromContentView(NodeSelection selection)
 {
     if (selection != null && mWaveform != null)
     {
         mWaveform.Selection = selection is AudioSelection ? ((AudioSelection)selection).AudioRange : null;
     }
     base.SetSelectionFromContentView(selection);
 }
Beispiel #11
0
 private void Clicked(object sender, BonsaiInputEvent inputEvent)
 {
     // Quickly clicked a node when in multi-selection.
     // Select the single node.
     if (!Event.current.control && inputEvent.node != null && NodeSelection.IsMultiSelection)
     {
         NodeSelection.SetSingleSelection(inputEvent.node);
     }
 }
Beispiel #12
0
 public void SetBehaviourTree(BehaviourTree tree)
 {
     NodeSelection.ClearSelection();
     Canvas               = new BonsaiCanvas(tree);
     Viewer.Canvas        = Canvas;
     Viewer.NodeSelection = NodeSelection;
     Viewer.zoom          = tree.zoomPosition;
     Viewer.panOffset     = tree.panPosition;
 }
Beispiel #13
0
 /// <summary>
 /// Create a new command for a view with a label.
 /// </summary>
 public Command(ProjectView.ProjectView view, string label)
 {
     mView                = view;
     mSelectionBefore     = mView.Selection;
     mLabel               = label;
     mRedo                = false;
     UpdateSelection      = true;
     m_ProgressPercentage = -1; //@singleSection
 }
 /// <summary>
 /// Add an existing node to a parent node at the given index.
 /// </summary>
 public UpdateAudioMedia(ProjectView.ProjectView view, PhraseNode node, ManagedAudioMedia media, bool updateSelection) : base(view, "")
 {
     m_Node = node;
     m_OriginalManagedAudioMedia = node.Audio;
     m_ManagedAudioMedia         = media;
     UpdateSelection             = updateSelection;
     mSelection = view.Selection != null && view.Selection.Control is ProjectView.ContentView ?
                  new NodeSelection(m_Node, view.Selection.Control) : view.Selection;
 }
Beispiel #15
0
        // Pass a new selection to the main view.
        // Do not act on reselection of the same item to avoid infinite loops.
        private void TOCTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            NodeSelection s = new NodeSelection((SectionNode)e.Node.Tag, this);

            if (s != mProjectView.Selection)
            {
                mProjectView.Selection = s;
            }
        }
Beispiel #16
0
 private void OnNodePropertyValueChanged(NodePropertyValueChanged msg)
 {
     if (msg.PropertyType == PropertyType.Visibility)
     {
         if (!GetNodePropertyAsBool(msg.NodeId, PropertyType.Visibility) && NodeSelection.Contains(msg.NodeId))
         {
             NodeSelection.Remove(msg.NodeId);
         }
     }
 }
Beispiel #17
0
        /// <summary>
        /// Select the block from below (e.g. the cursor bar.)
        /// </summary>
        public void SelectFromBelow()
        {
            Track track = Parent != null && Parent.Parent is Track ? (Track)Parent.Parent : null;

            if (track.View != null)
            {
                Selection = new NodeSelection(track.View, this.node);
                track.SelectFromBelow(this.selection);
            }
        }
Beispiel #18
0
        private NodeSelection mSelection;  // actual selection context


        /// <summary>
        /// Create an empty TOC view.
        /// </summary>
        public TOCView()
        {
            InitializeComponent();
            mBaseFontSize = Font.SizeInPoints;
            mSelection    = null;
            mProjectView  = null;
            this.Context_MergeWithNextMenuItem.Click      += new System.EventHandler(this.Context_MergeWithNextMenuItem_Click);
            this.Context_MultipleOperationsMenuItem.Click += new EventHandler(Context_MultipleOperationsMenuItem_Click);
            this.Context_AddEmptyPagesMenuItem.Click      += new EventHandler(Context_AddEmptyPagesMenuItem_Click);
            this.Context_AddBlankPhraseMenuItem.Click     += new EventHandler(Context_AddBlankPhraseMenuItem_Click);
        }
Beispiel #19
0
    void onSelectionChanged(object o, EventArgs args)
    {
        if (o == null)
        {
            return;
        }
        NodeSelection selection = (NodeSelection)o;
        TableNode     node      = (TableNode)selection.SelectedNode;


        Console.WriteLine("Selection Changed");
    }
Beispiel #20
0
 // Propagate selection upward
 private void SelectUp()
 {
     if (!Selected)
     {
         ProjectView view = Parent as ProjectView;
         if (view != null)
         {
             Selection = new NodeSelection(view, this.node);
             view.SelectFromBelow(this.selection);
         }
     }
 }
Beispiel #21
0
 public Delete(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update) : base(view)
 {
     mNode   = node;
     mParent = parent;
     mIndex  = index;
     if (view.Selection != null && view.Selection.Node == node)
     {
         mAfter = GetPostDeleteSelection();
     }
     else
     {
         mAfter = view.Selection;
     }
 }
 private void OnSelectionChanged(object sender, EventArgs args)
 {
     if (sender is NodeSelection)
     {
         NodeSelection nodeSelection = (NodeSelection)sender;
         if (nodeSelection.SelectedNode is ComponentNode)
         {
             ComponentNode   componentNode  = (ComponentNode)nodeSelection.SelectedNode;
             ComponentDTO    componentDTO   = (ComponentDTO)componentNode.DataTransferObject;
             IComponentModel componentModel = DefaultContainer.Instance["ComponentBuilder"];
             componentModel.ViewHandlerCollection[0].LoadDataForm(componentDTO);
         }
     }
 }
Beispiel #23
0
 public Delete(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update, bool IsAutoPageGenerationInvoked = false)
     : base(view)
 {
     mNode   = node;
     mParent = parent;
     mIndex  = index;
     if (view.Selection != null && view.Selection.Node == node)
     {
         mAfter = GetPostDeleteSelection(IsAutoPageGenerationInvoked);
     }
     else
     {
         mAfter = view.Selection;
     }
 }
Beispiel #24
0
        private void MultiNodeAction(object sender, BonsaiInput.NodeContext actionType)
        {
            switch (actionType)
            {
            case BonsaiInput.NodeContext.DuplicateSelection:
                var duplicates = EditorNodeCreation.DuplicateMultiple(Canvas, NodeSelection.SelectedNodes);
                NodeSelection.SetMultiSelection(duplicates);
                break;

            case BonsaiInput.NodeContext.DeleteSelection:
                Canvas.Remove(node => NodeSelection.IsNodeSelected(node));
                NodeSelection.SetTreeSelection(Canvas.Tree);
                break;
            }
        }
Beispiel #25
0
        private void MouseDown(object sender, BonsaiInputEvent inputEvent)
        {
            // Busy, action is active.
            if (MotionAction != null)
            {
                return;
            }

            if (inputEvent.IsPortFocused())
            {
                StartConnection(inputEvent);
            }

            else if (inputEvent.IsNodeFocused())
            {
                // Apply node linking.
                if (!NodeSelection.IsEmpty && Event.current.shift)
                {
                    BonsaiNode sourceLink = NodeSelection.FirstNodeSelected;
                    BonsaiNode nodeToLink = inputEvent.node;
                    if (EditorNodeLinking.ApplyLink(sourceLink.Behaviour, nodeToLink.Behaviour))
                    {
                        NodeSelection.SetReferenced(sourceLink.Behaviour);
                    }
                }

                // Extended selection mode.
                else if (Event.current.control)
                {
                    NodeSelection.ToggleSelecion(inputEvent.node);
                }

                else if (!NodeSelection.IsNodeSelected(inputEvent.node))
                {
                    // This condition is necessary, so multi-dragging works when clicking on a node under multi-select.
                    NodeSelection.SetSingleSelection(inputEvent.node);
                }

                StartDrag(inputEvent);
            }

            else
            {
                NodeSelection.SetTreeSelection(Canvas.Tree);
                // Canvas was clicked on.
                StartAreaSelection(inputEvent);
            }
        }
Beispiel #26
0
 public new void SelectAll()
 {
     using (DownloadManager.Instance.LockDownloadList(false))
     {
         try
         {
             NodeSelection.Changed -= lvwDownloads_ItemSelectionChanged;
             NodeSelection.SelectAll();
         }
         finally
         {
             NodeSelection.Changed += lvwDownloads_ItemSelectionChanged;
             lvwDownloads_ItemSelectionChanged(null, null);
         }
     }
 }
        private void CreateNodeFromType(object sender, Type type)
        {
            BonsaiNode node = Canvas.CreateNode(type);

            NodeSelection.SetSingleSelection(node);
            lastCreatedNodeToPosition = node;

            // This is to handle connecting a newly created node from the GenericMenu
            // triggered by a EditorNodeConnection action.
            if (pendingParentConnection != null)
            {
                EditorNodeConnecting.FinishConnection(Canvas, pendingParentConnection, node);
                pendingParentConnection = null;
                UpdateAbortableSelection();
            }
        }
        private void MultiNodeAction(object sender, BonsaiInput.NodeContext actionType)
        {
            switch (actionType)
            {
            case BonsaiInput.NodeContext.DuplicateSelection:
                var duplicates = EditorNodeCreation.DuplicateMultiple(Canvas, NodeSelection.SelectedNodes);
                NodeSelection.SetMultiSelection(duplicates);
                break;

            case BonsaiInput.NodeContext.DeleteSelection:
                RemoveSelectedNodes();
                break;
            }

            UpdateAbortableSelection();
        }
Beispiel #29
0
        /// <summary>
        /// Select all tracks in the view (called from the form.)
        /// </summary>
        public void SelectAllFromAbove()
        {
            NodeSelection s = new NodeSelection(this);

            if (this.selection != null)
            {
                this.selection.Deselect(s);
            }
            foreach (Control c in Controls)
            {
                if (c is Track)
                {
                    ((NodeSelection)this.selection).AddNode(((Track)c).Node);
                }
            }
            this.selection.SelectControls();
        }
Beispiel #30
0
        public XStageListTab(XStageProject xstage, Uri fileUri, ExportListController exportListController)
        {
            this.Build();
            _xstage = xstage;
            this.exportListController = exportListController;


            nodestore = new NodeStore(typeof(ElementExportSettings));

            FileTree.RulesHint      = true;
            FileTree.Selection.Mode = SelectionMode.Multiple;
            FileTree.AppendColumn("Name", new Gtk.CellRendererText(), "text", 1);
            FileTree.AppendColumn("Path", new Gtk.CellRendererText(), "text", 0);

            FileTree.NodeStore = nodestore;
            AddButton.Clicked += (sender, e) => {
                NodeSelection selection = FileTree.NodeSelection;
                foreach (ITreeNode node in selection.SelectedNodes)
                {
                    //Add selected VectorFilePath to the active export list
                    ElementExportSettings current = (ElementExportSettings)node;
                    ElementExportSettings tvg     = new ElementExportSettings();
                    tvg.Name     = current.Name;
                    tvg.FilePath = current.FilePath;
                    exportListController.AddTvg(tvg);
                }
            };



            foreach (XStageElement element in xstage.elements)
            {
                Uri xstageDirectory = new Uri(fileUri, "./");

                foreach (XStageDrawing d in element.drawings)
                {
                    ElementExportSettings vfp = new ElementExportSettings();
                    vfp.FilePath = new Uri(xstageDirectory.LocalPath + element.rootFolder + "/" + element.elementFolder + "/" + element.elementName + "-" + d.name + ".tvg");
                    vfp.Name     = element.elementName + "-" + d.name;
                    nodestore.AddNode(vfp);
                }
            }
        }