Example #1
0
 public GrtListNode(string caption, NodeIdWrapper nodeId, GrtTreeNode parent, GrtListModel model)
     : base(caption)
 {
     NodeId = nodeId;
     Parent = parent;
     Model  = model;
 }
Example #2
0
 public GrtListNode(string caption, NodeIdWrapper nodeId, GrtTreeNode parent, GrtListModel model)
     : base(caption)
 {
     NodeId = nodeId;
     Parent = parent;
     Model = model;
 }
Example #3
0
        void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = false;

            System.Windows.Forms.ContextMenuStrip menu = sender as System.Windows.Forms.ContextMenuStrip;

            menu.SuspendLayout();

            // repopulate the context menu with stuff provided by the backend
            menu.Items.Clear();

            List <NodeIdWrapper> selection = new List <NodeIdWrapper>();

            foreach (TreeNodeAdv node in treeControl.SelectedNodes)
            {
                GrtTreeNode treeNode = node.Tag as GrtTreeNode;
                selection.Add(treeNode.NodeId);
            }

            List <MySQL.Base.MenuItem> itemsBE = model.get_popup_items_for_nodes(selection);

            FillMenuItems(itemsBE, menu.Items);

            menu.ResumeLayout();
        }
        /// <summary>
        /// Returns a node list of all child nodes of a given parent node
        /// </summary>
        /// <param name="treePath">The path of the parent node</param>
        /// <returns>The list of child nodes for the given parent path node</returns>
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            NodeIdWrapper parentNodeId;
            bool          settingTopNode = false;

            if (treePath.IsEmpty())
            {
                settingTopNode = true;
                parentNodeId   = model.get_root();
            }
            else
            {
                GrtTreeNode parent = treePath.LastNode as GrtTreeNode;
                if (parent != null)
                {
                    parentNodeId = parent.NodeId;
                }
                else
                {
                    parentNodeId = null;
                }
            }

            if (parentNodeId != null)
            {
                // The backend has child nodes on a node not before it was expanded.
                int childCount = model.count_children(parentNodeId);
                if (childCount == 0)
                {
                    // But expand only if we don't have any children yet. Otherwise
                    // get many unnecessary refresh calls.
                    model.expand_node(parentNodeId);
                    childCount = model.count_children(parentNodeId);
                }

                for (int i = 0; i < childCount; i++)
                {
                    NodeIdWrapper nodeId = model.get_child(parentNodeId, i);
                    GrtTreeNode   node;
                    string        caption;

                    model.get_field(nodeId, columns[0].index, out caption);

                    node = new GrtTreeNode(caption, nodeId, null, this);
                    if (settingTopNode)
                    {
                        topNode = node;
                    }

                    //items.Add(node);
                    yield return(node);
                }
            }

            //return items;
        }
        /// <summary>
        /// Returns a node list of all child nodes of a given parent node
        /// </summary>
        /// <param name="treePath">The path of the parent node</param>
        /// <returns>The list of child nodes for the given parent path node</returns>
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List <GrtTreeNode> items = null;
            NodeIdWrapper      parentNodeId;
            bool settingTopNode = false;

            if (treePath.IsEmpty())
            {
                settingTopNode = true;
                parentNodeId   = model.get_root();
            }
            else
            {
                GrtTreeNode parent = treePath.LastNode as GrtTreeNode;
                if (parent != null)
                {
                    parentNodeId = parent.NodeId;
                }
                else
                {
                    parentNodeId = null;
                }
            }

            if (parentNodeId != null)
            {
                int childCount = model.count_children(parentNodeId);

                items = new List <GrtTreeNode>();

                for (int i = 0; i < childCount; i++)
                {
                    NodeIdWrapper nodeId = model.get_child(parentNodeId, i);
                    GrtTreeNode   node;
                    string        caption;

                    model.get_field(nodeId, columns[0].index, out caption);

                    if (disabledNames.Contains(caption))
                    {
                        continue;
                    }

                    node = new GrtTreeNode(caption, nodeId, null, this);
                    if (settingTopNode)
                    {
                        topNode = node;
                    }

                    items.Add(node);
                }
            }
            return(items);
        }
Example #6
0
        public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
        {
            GrtTreeNode grtNode = node.Tag as GrtTreeNode;

            if (null != grtNode)
            {
                string tooltip;
                Model.get_field(grtNode.NodeId, TooltipColumn, out tooltip);
                return(tooltip);
            }
            return("");
        }
Example #7
0
        /// <summary>
        /// Event handler catching the collapsing event and updating the GRT tree model
        /// </summary>
        /// <param name="sender">Object that triggered the event</param>
        /// <param name="e">The event parameters</param>
        private void TreeViewCollapsing(object sender, TreeViewAdvEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                GrtTreeNode node = e.Node.Tag as GrtTreeNode;

                if (node != null)
                {
                    model.collapse_node(node.NodeId);
                }
            }
        }
Example #8
0
        /// <summary>
        /// Virtual function that needs to be overwritten in derived model classes.
        /// Used to specify whether the given node can be expanded
        /// </summary>
        /// <param name="treePath">The path of the node</param>
        /// <returns>False if the node can be expanded, true if the node is a leaf</returns>
        public virtual bool IsLeaf(TreePath treePath)
        {
            GrtTreeNode node = treePath.LastNode as GrtTreeNode;

            if (node != null && model.is_expandable(node.NodeId))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #9
0
        void contextMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolStripMenuItem mitem = sender as System.Windows.Forms.ToolStripMenuItem;

            List <NodeIdWrapper> selection = new List <NodeIdWrapper>();

            foreach (TreeNodeAdv node in treeControl.SelectedNodes)
            {
                GrtTreeNode listNode = node.Tag as GrtTreeNode;
                selection.Add(listNode.NodeId);
            }

            model.activate_popup_item_for_nodes(mitem.Name, selection);
        }
Example #10
0
        private void reexpandChildren(TreeNodeAdv node)
        {
            foreach (TreeNodeAdv child in node.Children)
            {
                GrtTreeNode grtnode = child.Tag as GrtTreeNode;

                if (child.IsExpanded)
                {
                    model.expand_node(grtnode.NodeId);

                    reexpandChildren(child);
                }
            }
        }
        public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
        {
            if (node != null && node.Tag != null)
            {
                GrtTreeNode lnode = node.Tag as GrtTreeNode;
                int         index = GetColumnIndex(nodeControl);
                if (index < 0)
                {
                    index = 0;
                }

                return(model.get_field_description(lnode.NodeId, index));
            }
            return("");
        }
Example #12
0
        /// <summary>
        /// Event handler catching the expanding event and updating the GRT tree model
        /// </summary>
        /// <param name="sender">Object that triggered the event</param>
        /// <param name="e">The event parameters</param>
        private void TreeViewExpanding(object sender, TreeViewAdvEventArgs e)
        {
            if (e.Node != null)
            {
                GrtTreeNode node = e.Node.Tag as GrtTreeNode;

                if (node != null)
                {
                    model.expand_node(node.NodeId);
                }

                // This expands the nodes in the UI which where expanded before.
                reexpandChildren(e.Node);
            }
        }
        private void ValuePushed(object sender, NodeControlValueEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                GrtTreeNode node = e.Node.Tag as GrtTreeNode;

                if (node != null)
                {
                    int index = GetColumnIndex(sender as NodeControl);
                    if (index > -1)
                    {
                        NodeTextBox tnode = sender as NodeTextBox;
                        model.set_convert_field(node.NodeId, index, e.Value as String);
                    }
                    treeControl.Refresh();
                }
            }
        }
        /// <summary>
        /// Event handler that gets the caption for the value column
        /// </summary>
        /// <param name="sender">The object triggering the event</param>
        /// <param name="e">The event parameter</param>
        private void ValueNeeded(object sender, NodeControlValueEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                GrtTreeNode node = e.Node.Tag as GrtTreeNode;

                if (node != null)
                {
                    int index = GetColumnIndex(sender as NodeControl);
                    if (index > -1)
                    {
                        string caption;

                        model.get_field(node.NodeId, index, out caption);
                        e.Value = caption;
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// Event handler that gets the icon for the node
        /// </summary>
        /// <param name="sender">The object triggering the event</param>
        /// <param name="e">The event parameter</param>
        protected virtual void StateIconNeeded(object sender, NodeControlValueEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                // Use the GRT Icon manager to get the correct icon
                GrtTreeNode node = e.Node.Tag as GrtTreeNode;

                if (node != null)
                {
                    int   iconId = GrtTree.get_field_icon(node.NodeId, 0, IconSize.Icon16);
                    Image icon   = IconManagerWrapper.get_instance().get_icon(iconId);

                    if (icon != null)
                    {
                        e.Value = icon;
                    }
                }
            }
        }
        private void PushIntValue(GrtTreeNode node, string value, NodeCustomBox.EditMethod editMethod)
        {
            try
              {
            int intValue = 0;

            switch (editMethod)
            {
              case NodeCustomBox.EditMethod.Bool:
            switch (value)
            {
              case "":
              case "False":
                intValue = 0;
                break;
              default:
                intValue = 1;
                break;
            }
            break;

              default:
            try
            {
              Decimal d = Decimal.Parse(value, System.Globalization.NumberStyles.Float);
              intValue = Decimal.ToInt32(Decimal.Round(d, 0));
            }
            catch (Exception)
            {
            }
            break;
            }

            _grtTree.set_field(node.NodeId, _valueColumn, intValue);
              }
              catch (Exception ex)
              {
            MessageBox.Show(String.Format("The value you have entered is not an integer value.\n\n({0})", ex.Message));
              }
        }
 private void PushStringValue(GrtTreeNode node, string value, NodeCustomBox.EditMethod editMethod)
 {
     _grtTree.set_field(node.NodeId, _valueColumn, value);
 }
 private void PushRealValue(GrtTreeNode node, string value, NodeCustomBox.EditMethod editMethod)
 {
     try
       {
     double doubleValue = double.Parse(value);
     _grtTree.set_field(node.NodeId, _valueColumn, doubleValue);
       }
       catch (Exception ex)
       {
     MessageBox.Show(String.Format("The value you have entered is not a float value.\n\n({0})", ex.Message));
       }
 }
        /// <summary>
        /// Returns a node list of all child nodes of a given parent node
        /// </summary>
        /// <param name="treePath">The path of the parent node</param>
        /// <returns>The list of child nodes for the given parent path node</returns>
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            NodeIdWrapper parentNodeId;
              bool settingTopNode = false;

              if (treePath.IsEmpty())
              {
            settingTopNode = true;
            parentNodeId = model.get_root();
              }
              else
              {
            GrtTreeNode parent = treePath.LastNode as GrtTreeNode;
            if (parent != null)
              parentNodeId = parent.NodeId;
            else
              parentNodeId = null;
              }

              if (parentNodeId != null)
              {
            // The backend has child nodes on a node not before it was expanded.
            int childCount = model.count_children(parentNodeId);
            if (childCount == 0)
            {
              // But expand only if we don't have any children yet. Otherwise
              // get many unnecessary refresh calls.
              model.expand_node(parentNodeId);
              childCount = model.count_children(parentNodeId);
            }

            for (int i = 0; i < childCount; i++)
            {
              NodeIdWrapper nodeId = model.get_child(parentNodeId, i);
              GrtTreeNode node;
              string caption;

              model.get_field(nodeId, columns[0].index, out caption);

              node = new GrtTreeNode(caption, nodeId, null, this);
              if (settingTopNode)
            topNode = node;

              //items.Add(node);
              yield return node;
            }
              }

              //return items;
        }
        /// <summary>
        /// Returns a node list of all child nodes of a given parent node
        /// </summary>
        /// <param name="treePath">The path of the parent node</param>
        /// <returns>The list of child nodes for the given parent path node</returns>
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List<GrtTreeNode> items = null;
              NodeIdWrapper parentNodeId;
              bool settingTopNode = false;

              if (treePath.IsEmpty())
              {
            settingTopNode = true;
            parentNodeId = model.get_root();
              }
              else
              {
            GrtTreeNode parent = treePath.LastNode as GrtTreeNode;
            if (parent != null)
              parentNodeId = parent.NodeId;
            else
              parentNodeId = null;
              }

              if (parentNodeId != null)
              {
            int childCount = model.count_children(parentNodeId);

            items = new List<GrtTreeNode>();

            for (int i = 0; i < childCount; i++)
            {
              NodeIdWrapper nodeId = model.get_child(parentNodeId, i);
              GrtTreeNode node;
              string caption;

              model.get_field(nodeId, columns[0].index, out caption);

              if (disabledNames.Contains(caption))
            continue;

              node = new GrtTreeNode(caption, nodeId, null, this);
              if (settingTopNode)
            topNode = node;

              items.Add(node);
            }
              }
              return items;
        }