8
Vote

CAB Visualizer dispose WorkItems

description

I've noticed that the Visualizer does not remove WorkItems after they have been disposed. Would it be possible to update the code so that WorkItems removed from the app would also be removed the the Visualizer?

file attachments

comments

jommelo wrote Jan 12, 2007 at 11:16 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.

jommelo wrote Jan 12, 2007 at 11:17 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.

jommelo wrote Jan 12, 2007 at 11:17 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.

jommelo wrote Jan 12, 2007 at 11:19 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.

jommelo wrote Jan 12, 2007 at 11:19 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.

jommelo wrote Jan 12, 2007 at 11:21 AM

There was a change in the WorkItemAdded event. Added the Disposed event to remove workitems that were not used. I also added a feature to recursivly add the child workitems because i had the need to create a hierarchy of workitems before adding my main workitem to another parent.
    private void WorkItemAdded(object sender, DataEventArgs<WorkItem> e)        {            TreeNodeCollection collection = null;            WorkItem wi = e.Data;

        if (wi.Parent == null)                collection = workItemTree.Nodes;            else            {                WorkItemTreeNode node = GetTreeNode(wi.Parent);

            if (node != null)                    collection = node.Nodes;            }

        if (collection != null)            {                if (wi.WorkItems != null)                {                    wi.WorkItems.Added += new EventHandler<DataEventArgs<WorkItem>>(WorkItemAdded);                    wi.WorkItems.Removed += new EventHandler<DataEventArgs<WorkItem>>(WorkItemRemoved);                }

            wi.IdChanged += new EventHandler<DataEventArgs<string>>(WorkItemIdChanged);                wi.Activated += new EventHandler(WorkItemActivated);                wi.Deactivated += new EventHandler(WorkItemDeactivated);                wi.Disposed += new EventHandler(WorkItemDisposed);

            AddTreeNode(collection, wi);

            if (wi.WorkItems != null && wi.WorkItems.Count != 0)                {                    foreach (KeyValuePair<string, WorkItem> kvWorkItem in wi.WorkItems)                    {                        WorkItemAdded(this, new DataEventArgs<WorkItem>(kvWorkItem.Value));                    }                }            }        }

    private void WorkItemDisposed(object sender, EventArgs e)        {            RemoveWorkItem(sender as WorkItem);        }

    private void WorkItemRemoved(object sender, DataEventArgs<WorkItem> e)        {            WorkItem wi = e.Data;

        RemoveWorkItem(wi);        }

    private void RemoveWorkItem(WorkItem wi)        {            if (wi == null)            {                return;            }

        wi.IdChanged -= new EventHandler<DataEventArgs<string>>(WorkItemIdChanged);            wi.Activated -= new EventHandler(WorkItemActivated);            wi.Deactivated -= new EventHandler(WorkItemDeactivated);            wi.WorkItems.Added -= new EventHandler<DataEventArgs<WorkItem>>(WorkItemAdded);            wi.WorkItems.Removed -= new EventHandler<DataEventArgs<WorkItem>>(WorkItemRemoved);            wi.Disposed -= new EventHandler(WorkItemDisposed);

        WorkItemTreeNode node = GetTreeNode(wi);

        if (node != null && !node.TreeView.IsDisposed)                node.Remove();        }

Raymond wrote Jan 12, 2007 at 6:08 PM

Perfect! Thanks jommelo!

I'm going to attach the 'WorkItemVisualization.cs' file that contains your code for anyone else who needs it.

wrote Jan 12, 2007 at 6:08 PM

wrote Jan 15, 2007 at 3:33 AM

wrote Jan 19, 2007 at 2:36 PM

wrote Feb 21, 2007 at 10:05 PM

wrote Mar 20, 2007 at 10:06 PM

wrote Mar 20, 2007 at 10:38 PM

Vardi wrote May 13, 2008 at 12:51 PM

Hi, I took the CAB Visualizer and improved it.
http://blogs.microsoft.co.il/blogs/vardi/

wrote Feb 22, 2013 at 12:31 AM