示例#1
0
 public static IdentifierPath QualifyIdentifierPath(RowKey rowKey, IdentifierPath identifierPath)
 {
     if (rowKey == null)
     {
         return identifierPath;
     }
     string[] parts = new string[identifierPath.Length];
     while (identifierPath.Length > 0)
     {
         parts[identifierPath.Length - 1] = identifierPath.Name;
         identifierPath = identifierPath.Parent;
     }
     while (rowKey != null)
     {
         if (rowKey.IdentifierPath.Length <= parts.Length)
         {
             parts[rowKey.IdentifierPath.Length - 1] = rowKey.Value.ToString();
         }
         rowKey = rowKey.Parent;
     }
     foreach (var part in parts)
     {
         identifierPath = new IdentifierPath(identifierPath, part);
     }
     return identifierPath;
 }
示例#2
0
        public TreeNode FindTreeNode(IdentifierPath idPath, bool create)
        {
            if (idPath == null)
            {
                return(null);
            }
            TreeNodeCollection nodes = Nodes;

            while (true)
            {
                TreeNode node = FindTreeNode(nodes, idPath);
                if (node == null)
                {
                    return(null);
                }
                if (GetColumnDescriptor(node).IdPath.Equals(idPath))
                {
                    return(node);
                }
                if (create)
                {
                    EnsureChildren(node);
                }
                nodes = node.Nodes;
            }
        }
示例#3
0
        public void SelectColumn(IdentifierPath idPath)
        {
            var node = FindTreeNode(idPath, true);

            if (node == null)
            {
                return;
            }
            SelectedNode = node;
        }
示例#4
0
 public object FindValue(IdentifierPath key)
 {
     if (IdentifierPath.Equals(key))
     {
         return Value;
     }
     if (Parent != null && key.Length < IdentifierPath.Length)
     {
         return Parent.FindValue(key);
     }
     return null;
 }
示例#5
0
 private TreeNode FindTreeNode(TreeNodeCollection nodes, IdentifierPath idPath)
 {
     foreach (TreeNode node in nodes)
     {
         var columnDescriptor = node.Tag as ColumnDescriptor;
         if (columnDescriptor != null)
         {
             if (idPath.StartsWith(columnDescriptor.IdPath))
             {
                 return(node);
             }
         }
     }
     return(null);
 }
示例#6
0
        private void UpdateSublistCombo()
        {
            var availableSublists = new HashSet <IdentifierPath>();

            availableSublists.Add(IdentifierPath.Root);
            foreach (var columnSpec in ViewSpec.Columns)
            {
                for (IdentifierPath idPath = columnSpec.IdentifierPath; !idPath.IsRoot; idPath = idPath.Parent)
                {
                    if (idPath.Name == null)
                    {
                        if (!availableSublists.Add(idPath))
                        {
                            break;
                        }
                    }
                }
            }
            if (availableSublists.Count == 0)
            {
                groupBoxSublist.Visible = false;
                return;
            }
            groupBoxSublist.Visible = true;
            var sublistIdArray = availableSublists.ToArray();

            Array.Sort(sublistIdArray);
            comboSublist.Items.Clear();
            foreach (var idPath in sublistIdArray)
            {
                string label = idPath.IsRoot ? "<none>" : idPath.ToString();
                comboSublist.Items.Add(new SublistItem(label, idPath));
                if (Equals(idPath, ViewSpec.SublistId))
                {
                    comboSublist.SelectedIndex = comboSublist.Items.Count - 1;
                }
            }
        }
示例#7
0
        private void AddColumns(IEnumerable <ColumnDescriptor> columnDescriptors)
        {
            List <ColumnSpec> columnSpecs = new List <ColumnSpec>(ViewSpec.Columns);
            var            addedIds       = new List <IdentifierPath>();
            IdentifierPath lastId         = null;
            int            focusedIndex   = listViewColumns.FocusedItem == null ? -1 : listViewColumns.FocusedItem.Index;

            foreach (var columnDescriptor in columnDescriptors)
            {
                var idPath = columnDescriptor.IdPath;
                var existingColumnIndex = columnSpecs
                                          .FindIndex(c => Equals(idPath, c.IdentifierPath));
                lastId = idPath;
                if (existingColumnIndex >= 0)
                {
                    continue;
                }
                var columnSpec = columnDescriptor.GetColumnSpec();
                columnSpecs.Insert(focusedIndex + 1, columnSpec);
                focusedIndex++;
                addedIds.Add(idPath);
            }
            if (addedIds.Count > 0)
            {
                ViewSpec = ViewSpec.SetColumns(columnSpecs);
            }
            var helper = GetColumnListHelper();

            if (addedIds.Count > 0)
            {
                helper.SelectKeys(addedIds);
            }
            else
            {
                helper.SelectKey(lastId);
            }
        }
示例#8
0
 public RowKey(RowKey parent, IdentifierPath identifierPath, object value)
 {
     Parent = parent;
     IdentifierPath = identifierPath;
     Value = value;
 }
示例#9
0
 public String ToString(String separator)
 {
     return(IdFolder.ToString() + separator + Type.ToString() + separator + ItemsOrderBy.ToString() + separator + Ascending.ToString()
            + separator + (String.IsNullOrEmpty(IdentifierPath) ? "": IdentifierPath.ToString()) + separator + Repository.ToString(separator));
 }
示例#10
0
 public SublistItem(string displayName, IdentifierPath identifierPath)
 {
     DisplayName    = displayName;
     IdentifierPath = identifierPath;
 }