/// <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); } }
/// <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; } }
/// <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); } }
/// <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); } }