Esempio n. 1
0
        private static List <ScheduleTableStyleHeaderNode> CreateChildNodes(List <ColumnHeaderNode> childNodes, ScheduleTableStyleHeaderTree tree, PropertySetDefinition psd, ScheduleTableStyle style)
        {
            Database db = ScheduleSample.GetDatabase();
            List <ScheduleTableStyleHeaderNode> nodesCreated = new List <ScheduleTableStyleHeaderNode>();

            foreach (ColumnHeaderNode childNode in childNodes)
            {
                if (childNode.IsColumn)
                {
                    PropertyClassData        data   = childNode.ColumnData;
                    ScheduleTableStyleColumn column = CreateColumn(data, psd, style);
                    style.Columns.Add(column);
                    nodesCreated.Add(column);
                }
                else if (childNode.IsHeader)
                {
                    string headerName = childNode.NodeData as string;
                    List <ScheduleTableStyleHeaderNode> myChildren = CreateChildNodes(childNode.Children, tree, psd, style);
                    ScheduleTableStyleHeaderNode        header     = tree.InsertNode(headerName, tree.Root.Children.Count, tree.Root, myChildren.ToArray());
                    nodesCreated.Add(header);
                }
                else
                {
                    throw new ArgumentException("Cannot resolve node type properly when creating schedule table style.");
                }
            }
            return(nodesCreated);
        }
 // Remove selected node from the column header tree.
 // The selected node could be either a header or a column.
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (treeColumnHeader.SelectedNode != null && treeColumnHeader.SelectedNode.Tag != null)
     {
         PropertyClassData data = treeColumnHeader.SelectedNode.Tag as PropertyClassData;
     }
     treeColumnHeader.Nodes.Remove(treeColumnHeader.SelectedNode);
 }
 // Little tricks in .NET to make the display text of a node differ from its actual text.
 // In our case, when user edits the node by clicking the node label, they're actually
 // editing the Column name of the property.
 private void treeColumnHeader_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Node.Tag != null)
     {
         PropertyClassData data     = e.Node.Tag as PropertyClassData;
         IntPtr            hEditBox = SendMessage(treeColumnHeader.Handle, TVM_GETEDITCONTROL, IntPtr.Zero, IntPtr.Zero);
         SetWindowText(hEditBox, data.DisplayName);
     }
 }
        void AddPropertyToNodeCollection(TreeNodeCollection nodes, List <RXClass> objectTypes, string propertyName)
        {
            PropertyClassData data = new PropertyClassData();

            data.ObjectTypes.AddRange(objectTypes);
            data.PropertyName = propertyName;
            data.DisplayName  = propertyName;
            TreeNode newNode = nodes.Add(data.FullDisplayText);

            newNode.Tag = data;
            newNode.EnsureVisible();
        }
Esempio n. 5
0
        private static ScheduleTableStyleColumn CreateColumn(PropertyClassData nodeData, PropertySetDefinition psd, ScheduleTableStyle style)
        {
            Database db = ScheduleSample.GetDatabase();
            ScheduleTableStyleColumn column = new ScheduleTableStyleColumn();

            column.SetToStandard(db);
            column.SubSetDatabaseDefaults(db);
            column.PropertySetDefinitionId = psd.Id;
            column.ColumnType = ScheduleTableStyleColumnType.Normal;
            column.Heading    = nodeData.DisplayName;
            column.PropertyId = psd.Definitions.IndexOf(nodeData.PropertyName);
            return(column);
        }
        // Add properties to the column header tree
        private void btnAddColumn_Click(object sender, EventArgs e)
        {
            TreeNode selectedPropertyNode = treeProperties.SelectedNode;

            if (selectedPropertyNode == null || selectedPropertyNode.Tag == null)
            {
                MessageBox.Show("Please selected a property first.");
                return;
            }

            PropertyClassData data = selectedPropertyNode.Tag as PropertyClassData;

            if (IsPropertyAddedToColumnHeaderTree(treeColumnHeader.Nodes, data.PropertyName))
            {
                MessageBox.Show("A property can only be added to the schedule table style once.");
                return;
            }

            TreeNode selectedHeaderNode = treeColumnHeader.SelectedNode;
            TreeNode treeNodeToExpand   = null;

            if (selectedHeaderNode == null) // No selection - add properties as root nodes
            {
                AddPropertyToNodeCollection(treeColumnHeader.Nodes, data.ObjectTypes, data.PropertyName);
            }
            else if (selectedHeaderNode.Tag == null) // Current selection is a header - add properties to a header
            {
                AddPropertyToNodeCollection(selectedHeaderNode.Nodes, data.ObjectTypes, data.PropertyName);
                treeNodeToExpand = selectedHeaderNode;
            }
            else // Current selection is a column(property) - add properties as siblings of the current selected property
            {
                // check if it's root node already
                if (selectedHeaderNode.Parent == null) // add as root nodes
                {
                    AddPropertyToNodeCollection(treeColumnHeader.Nodes, data.ObjectTypes, data.PropertyName);
                }
                else // add to parent header
                {
                    AddPropertyToNodeCollection(selectedHeaderNode.Parent.Nodes, data.ObjectTypes, data.PropertyName);
                    treeNodeToExpand = selectedHeaderNode.Parent;
                }
            }
            if (treeNodeToExpand != null)
            {
                treeNodeToExpand.Expand();
            }
        }
 bool IsPropertyAddedToColumnHeaderTree(TreeNodeCollection nodes, string propertyName)
 {
     foreach (TreeNode node in nodes)
     {
         if (node.Tag != null)
         {
             PropertyClassData data = node.Tag as PropertyClassData;
             if (data.PropertyName == propertyName)
             {
                 return(true);
             }
         }
         else if (IsPropertyAddedToColumnHeaderTree(node.Nodes, propertyName))
         {
             return(true);
         }
     }
     return(false);
 }
        private void treeColumnHeader_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                return;
            }

            if (e.Label.Length == 0)
            {
                MessageBox.Show("Please specify a valid text.");
                e.CancelEdit = true;
            }

            if (e.Node.Tag != null)
            {
                e.CancelEdit = true;
                PropertyClassData data = e.Node.Tag as PropertyClassData;
                data.DisplayName = e.Label;
                e.Node.Text      = data.FullDisplayText;
            }
        }