예제 #1
0
        /// <summary>
        /// Initialize the list of root folders.
        /// </summary>
        private void InitializeFolders()
        {
            lock (DataModel.SyncRoot)
            {
                LambdaComparer <FolderTreeNode> folderTreeNodeComparer = new LambdaComparer <FolderTreeNode>((l, r) => l.Entity.Name.CompareTo(r.Entity.Name));
                List <FolderTreeNode>           folders = new List <FolderTreeNode>();
                EntityRow userEntityRow = DataModel.Entity.EntityKey.Find(UserContext.Instance.UserId);

                foreach (EntityTreeRow entityTreeRow in userEntityRow.GetEntityTreeRowsByFK_Entity_EntityTree_ParentId())
                {
                    FolderTreeNode folderTreeNode = new FolderTreeNode(entityTreeRow);
                    Int32          index          = folders.BinarySearch(folderTreeNode, folderTreeNodeComparer);

                    if (index < 0)
                    {
                        index = ~index;
                    }

                    folders.Insert(index, folderTreeNode);
                }

                this.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    this.Folders = folders;
                    this.ExpandFolder();
                }), DispatcherPriority.Normal);
            }
        }
예제 #2
0
        /// <summary>
        /// Show the properties window for this entity. Launch in a different apartment and make sure there's only one for this entity.
        /// </summary>
        public void ShowProperties(FolderTreeNode rootNode)
        {
            try
            {
                if (this.propertiesWindow != null)
                {
                    if (this.propertiesWindow != null)
                    {
                        this.ShowCurrentProperties();
                    }
                }
                else
                {
                    Entity entity = this.Clone() as Entity;
                    Guid   root   = rootNode == null? Guid.Empty : rootNode.Entity.EntityId;

                    this.ShowProperties(root, entity);
                }
            }
            catch (Exception exception)
            {
                EventLog.Warning("{0}: {1}\n{2}", exception.GetType(), exception.Message, exception.StackTrace);
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Initialize the list of root folders.
        /// </summary>
        private void InitializeFolders(Guid parentId)
        {
            lock (DataModel.SyncRoot)
            {
                LambdaComparer <FolderTreeNode> folderTreeNodeComparer = new LambdaComparer <FolderTreeNode>((l, r) => l.Entity.Name.CompareTo(r.Entity.Name));
                List <FolderTreeNode>           folders = new List <FolderTreeNode>();
                EntityRow parentEntityRow = DataModel.Entity.EntityKey.Find(parentId);

                foreach (EntityTreeRow entityTreeRow in parentEntityRow.GetEntityTreeRowsByFK_Entity_EntityTree_ParentId())
                {
                    FolderTreeNode folderTreeNode = new FolderTreeNode()
                    {
                        Entity = new Entity(entityTreeRow.EntityRowByFK_Entity_EntityTree_ChildId)
                    };
                    Int32 index = folders.BinarySearch(folderTreeNode, folderTreeNodeComparer);

                    if (index < 0)
                    {
                        index = ~index;
                    }

                    folders.Insert(index, folderTreeNode);
                }

                this.Dispatcher.BeginInvoke(new Action(() => this.Folders = folders), DispatcherPriority.Normal);
            }
        }
예제 #4
0
        /// <summary>
        /// Initialize the list of root folders.
        /// </summary>
        private void InitializeFolders()
        {
            lock (DataModel.SyncRoot)
            {
                LambdaComparer <FolderTreeNode> folderTreeNodeComparer = new LambdaComparer <FolderTreeNode>((l, r) => l.Entity.Name.CompareTo(r.Entity.Name));
                List <FolderTreeNode>           folders = new List <FolderTreeNode>();
                var entities = DataModel.Entity.Where(row =>
                                                      (row.GetFolderRows().Length > 0 || row.GetBlotterRows().Length > 0));

                foreach (EntityRow entityRow in entities)
                {
                    Boolean topLevel = true;

                    // Determine whether a folder/blotter has any parent folders or blotters.
                    foreach (EntityTreeRow entityTreeRow in entityRow.GetEntityTreeRowsByFK_Entity_EntityTree_ChildId())
                    {
                        EntityRow parent = entityTreeRow.EntityRowByFK_Entity_EntityTree_ParentId;

                        if (parent.GetFolderRows().Length > 0 || parent.GetBlotterRows().Length > 0)
                        {
                            topLevel = false;
                            break;
                        }
                    }

                    // If they don't add them to our list.
                    if (topLevel)
                    {
                        FolderTreeNode folderTreeNode = new FolderTreeNode(entityRow);
                        Int32          index          = folders.BinarySearch(folderTreeNode, folderTreeNodeComparer);

                        if (index < 0)
                        {
                            index = ~index;
                        }

                        folders.Insert(index, folderTreeNode);
                    }
                }

                this.Dispatcher.BeginInvoke(new Action(() => this.Folders = folders), DispatcherPriority.Normal);
            }
        }