Esempio n. 1
0
 void AddNodeToTreeModel(ComponentsLibraryNode node, TreeStore tree, TreeIter parentNode)
 {
     parentNode = tree.AppendValues(parentNode, node);
     foreach (ComponentsLibraryNode childNode in node)
     {
         AddNodeToTreeModel(childNode, tree, parentNode);
     }
 }
Esempio n. 2
0
        bool FilterTree(TreeModel model, TreeIter iter)
        {
            ComponentsLibraryNode node = (ComponentsLibraryNode)model.GetValue(iter, 0);

            if (node == null)
            {
                return(true);
            }
            else
            {
                return(FilterNode(node, filterEntry.Text.ToUpper()));
            }
        }
Esempio n. 3
0
        public static ComponentsLibraryNode Build(ComponentLibraryViewModel viewModel)
        {
            ComponentsLibraryNode root = new ComponentsLibraryNode(String.Empty);

            // package references
            ComponentsLibraryNode packageReferencesNode = new ComponentsLibraryNode("Package References");

            root.AddChild(packageReferencesNode);

            if (viewModel.Experiment != null)
            {
                foreach (IPackageReference reference in viewModel.Experiment.References)
                {
                    ComponentsLibraryNode referenceNode = new ComponentsLibraryNode(reference.Name);
                    packageReferencesNode.AddChild(referenceNode);
                }
            }

            // components
            ComponentsLibraryNode allComponentsNode = new ComponentsLibraryNode("All Components");

            root.AddChild(allComponentsNode);

            foreach (MetadataDefinition component in viewModel.ComponentsCollection)
            {
                ComponentsLibraryNode componentNode = new ComponentsLibraryNode(component.Label, component);
                allComponentsNode.AddChild(componentNode);

                foreach (string qualifiedTag in component.Tags.Values)
                {
                    string[] tags = qualifiedTag.Split(new char[] { '.' });
                    if (tags.Length > 0)
                    {
                        ComponentsLibraryNode node = root;

                        foreach (string tag in tags)
                        {
                            ComponentsLibraryNode childNode = node.GetChild(tag);
                            if (childNode == null)
                            {
                                childNode = new ComponentsLibraryNode(tag);
                                node.AddChild(childNode);
                            }
                            node = childNode;
                        }
                        node.AddChild(componentNode);
                    }
                }
            }
            return(root);
        }
Esempio n. 4
0
        /// <summary>
        /// Handler prepares drag data.
        /// See the EnableDrop and HandleDragDataReceived in the ExperimentCanvasPad
        /// where receiving of the data is done.
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void HandleDragDataGet(object source, DragDataGetArgs args)
        {
            TreeView treeView = source as TreeView;
            TreeIter selectedItem;

            if (treeView != null && treeView.Selection.GetSelected(out selectedItem))
            {
                ComponentsLibraryNode selectedNode = treeView.Model.GetValue(selectedItem, 0) as ComponentsLibraryNode;
                if (selectedNode.Data != null)
                {
                    args.SelectionData.Set(args.SelectionData.Target, args.SelectionData.Format, new byte[] {}); // we send empty byte array just to trigger a drag&drop event. Drop handler will access componentsLibrary once again to get selected node.
                }
            }
        }
Esempio n. 5
0
        bool FilterNode(ComponentsLibraryNode node, string filter)
        {
            if (node.Label.ToUpper().Contains(filter))
            {
                return(true);
            }
            foreach (ComponentsLibraryNode child in node.GetChildren())
            {
                if (FilterNode(child, filter))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Handles the drag data received.
        /// See the EnableDrag and HandleDragDataGet in the ComponentLibraryPad where the drag
        /// has started and drag source is set
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Widget   source   = Drag.GetSourceWidget(args.Context);
            TreeView treeView = source as TreeView;
            TreeIter selectedItem;

            if (treeView != null && treeView.Selection.GetSelected(out selectedItem))
            {
                ComponentsLibraryNode selectedNode = treeView.Model.GetValue(selectedItem, 0) as ComponentsLibraryNode;

                Cairo.PointD   translation = m_experimentCanvasWidget.ExperimentCanvas.View.ViewToDrawing(args.X, args.Y);
                ExperimentNode node        = m_applicationViewModel.Experiment.AddComponentFromDefinition(selectedNode.Data,
                                                                                                          translation.X, translation.Y);
                m_experimentDrawer.DrawComponent(node, true);
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
        void AddNodeToTreeModel(ComponentsLibraryNode node, TreeStore tree, TreeIter parentNode)
        {
            parentNode = tree.AppendValues(parentNode, node);
            //foreach (ComponentsLibraryNode childNode in node)
            //    AddNodeToTreeModel(childNode, tree, parentNode);

            // HERZUM SPRINT 3: TLAB-194
            List <ComponentsLibraryNode> listNode = new List <ComponentsLibraryNode> ();

            foreach (ComponentsLibraryNode childNode in node)
            {
                listNode.Add(childNode);
            }
            listNode.Sort();
            if (listNode.Count > 0)
            {
                foreach (ComponentsLibraryNode childNode in listNode)
                {
                    AddNodeToTreeModel(childNode, tree, parentNode);
                }
            }
            // END HERZUM SPRINT 3: TLAB-194
        }
Esempio n. 8
0
        void RenderNode(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            ComponentsLibraryNode node = (ComponentsLibraryNode)model.GetValue(iter, 0);

            (cell as CellRendererText).Text = node.Label;
        }