Пример #1
0
        /// <summary>
        /// Adds an item in the collection and in the TreeListView
        /// </summary>
        /// <param name="item"></param>
        /// <returns>Index of the item in the collection</returns>
        public virtual int Add(TreeListViewItem item)
        {
            if (TreeListView != null)
            {
                if (TreeListView.InvokeRequired)
                {
                    throw(new Exception("Invoke required"));
                }
            }
            // Do not add the item if the collection owns a TreeListView recursively
            // and the item already owns a TreeListView
            if (TreeListView != null && item.ListView != null)
            {
                throw(new Exception("The Item is already in a TreeListView"));
            }
            int index = GetInsertCollectionIndex(item);

            if (index == -1)
            {
                return(-1);
            }
            if (Parent != null)
            {
                item.SetParent(Parent);
            }
            item.Items.Comparer = this.Comparer;
            int treelistviewindex = GetInsertTreeListViewIndex(item, index);

            // Insert in the ListView
            if (treelistviewindex > -1)
            {
                ListView listview = (ListView)TreeListView;
                listview.Items.Insert(treelistviewindex, (ListViewItem)item);
                if (item.IsExpanded)
                {
                    item.Expand();
                }
                item.SetIndentation();
            }
            // Insert in this collection
            if (index > -1)
            {
                List.Insert(index, item);
            }
            if (index > -1)
            {
                OnItemAdded(new TreeListViewEventArgs(item, TreeListViewAction.Unknown));
            }
            if (Count == 1 && TreeListView != null && Parent != null)
            {
                if (Parent.Visible)
                {
                    Parent.Redraw();
                }
            }
            return(index);
        }
 /// <summary>
 /// Adds an item in the collection and in the TreeListView
 /// </summary>
 /// <param name="item"></param>
 /// <returns>Index of the item in the collection</returns>
 public virtual int Add(TreeListViewItem item)
 {
     if(TreeListView != null)
         if(TreeListView.InvokeRequired)
             throw(new Exception("Invoke required"));
     // Do not add the item if the collection owns a TreeListView recursively
     // and the item already owns a TreeListView
     if(TreeListView != null && item.ListView != null)
         throw(new Exception("The Item is already in a TreeListView"));
     int index = GetInsertCollectionIndex(item);
     if(index == -1) return(-1);
     if(Parent != null) item.SetParent(Parent);
     item.Items.Comparer = this.Comparer;
     int treelistviewindex = GetInsertTreeListViewIndex(item, index);
     // Insert in the ListView
     if(treelistviewindex > -1)
     {
         ListView listview = (ListView) TreeListView;
         listview.Items.Insert(treelistviewindex, (ListViewItem) item);
         if(item.IsExpanded) item.Expand();
         item.SetIndentation();
     }
     // Insert in this collection
     if(index > -1) List.Insert(index, item);
     if(index > -1) OnItemAdded(new TreeListViewEventArgs(item, TreeListViewAction.Unknown));
     if(Count == 1 && TreeListView != null && Parent != null)
         if(Parent.Visible) Parent.Redraw();
     return(index);
 }
Пример #3
0
        internal void ExpandInternal()
        {
            if (IsInATreeListView)
            {
                if (ListView.InvokeRequired)
                {
                    throw(new Exception("Invoke Required"));
                }
            }

            TreeListViewItem selItem = null;

            if (TreeListView != null)
            {
                selItem = TreeListView.FocusedItem;
            }

            // Must set ListView.checkDirection to CheckDirection.None.
            // Forbid recursively checking.
            CheckDirection oldDirection = CheckDirection.All;

            if (ListView != null)
            {
                oldDirection             = ListView._checkDirection;
                ListView._checkDirection = CheckDirection.None;
            }

            // The item wasn't expanded -> raise an event
            if (Visible && !_isexpanded && ListView != null)
            {
                TreeListViewCancelEventArgs e = new TreeListViewCancelEventArgs(
                    this, TreeListViewAction.Expand);
                ListView.RaiseBeforeExpand(e);
                if (e.Cancel)
                {
                    return;
                }
            }

            if (Visible)
            {
                for (int i = Items.Count - 1; i >= 0; i--)
                {
                    TreeListViewItem item = this.Items[i];
                    if (!item.Visible)
                    {
                        ListView LView = this.ListView;
                        LView.Items.Insert(
                            this.Index + 1, item);
                        item.SetIndentation();
                    }
                    if (item.IsExpanded)
                    {
                        item.Expand();
                    }
                }
            }
            // The item wasn't expanded -> raise an event
            if (Visible && !_isexpanded && IsInATreeListView)
            {
                this._isexpanded = true;
                TreeListViewEventArgs e = new TreeListViewEventArgs(
                    this, TreeListViewAction.Expand);
                ListView.RaiseAfterExpand(e);
                if (AfterExpand != null)
                {
                    AfterExpand(this);
                }
            }
            this._isexpanded = true;

            // Reset ListView.checkDirection
            if (IsInATreeListView)
            {
                ListView._checkDirection = oldDirection;
            }
            if (TreeListView != null && selItem != null)
            {
                if (selItem.Visible)
                {
                    selItem.Focused = true;
                }
            }
        }
Пример #4
0
        public void refreshCurrentBuildValues()
        {
            this.BuilderState = ResponseBuilder.Instance;
            this.localsListView.BeginUpdate();
            TreeListViewItem itemParent = null;
            if (this.localsListView.SelectedItems.Count > 0)
            {
                itemParent = this.localsListView.SelectedItems[0];
            }

            //Copy all var
            if (this.BuilderState.Locals != null)
            {
                for (int i = 0; i < this.BuilderState.Locals.Count; i++)
                {
                    Local local = this.BuilderState.Locals[i];
                    TreeListViewItem localItem = new TreeListViewItem();
                    if (itemParent == null)
                    {
                        this.localsListView.Items.Add(localItem);
                    }
                    else
                    {
                        itemParent.Items.Add(localItem);
                    }

                    localItem.Text = local.Name;
                    if (local.Type == null) continue;
                    if (local.Type.Equals("TABLE"))
                        localItem.ImageIndex = 0;
                    else if (local.Type.Equals("FIELD"))
                        localItem.ImageIndex = 3;
                    else if (local.Type.Equals("FUNCTION"))
                        localItem.ImageIndex = 2;
                    else if (local.Type.Equals("USERDATA"))
                        localItem.ImageIndex = 1;

                    localItem.SubItems.Add(local.Type);
                    localItem.SubItems.Add(local.Value);
                    localItem.SetIndentation();
                    localItem.Tag = local;
                }

            }

            this.localsListView.EndUpdate();

            //The Watches
            this.watchesListView.Items.Clear();

            if (this.BuilderState.Watchs != null)
            {
                for (int i = 0; i < this.BuilderState.Watchs.Count; i++)
                {
                    Watch watch = this.BuilderState.Watchs[i];
                    if (watch == null) continue;
                    TreeListViewItem localItem = new TreeListViewItem();
                    localItem.Text = watch.Number;
                    localItem.SubItems.Add(watch.Expression);
                    this.watchesListView.Items.Add(localItem);

                }
            }

            if (this.BuilderState.Backtraces != null)
            {
                for (int i = 0; i < this.BuilderState.Backtraces.Count; i++)
                {
                    Backtrace trace = this.BuilderState.Backtraces[i];
                    if (trace == null) continue;
                    TreeListViewItem localItem = new TreeListViewItem();
                    localItem.Text = trace.Number.ToString();
                    localItem.SubItems.Add(trace.Kind);

                    int indexFileStart = 0;
                    if (trace.File.Contains("\\"))
                        indexFileStart = trace.File.LastIndexOf("\\") + 1;

                    localItem.SubItems.Add(trace.File.Substring(indexFileStart, trace.File.Length - indexFileStart));
                    localItem.SubItems.Add(trace.Line.ToString());
                    this.backtraceListView.Items.Add(localItem);
                    localItem.ImageIndex = 2;

                }
            }
        }