Beispiel #1
0
        public void UpdateWatch()
        {
            List <WatchValueInfo> watchContent = WatchManager.GetWatchContent(mnuHexDisplay.Checked);

            lstWatch.BeginUpdate();

            if (watchContent.Count != lstWatch.Items.Count - 1)
            {
                lstWatch.Items.Clear();

                List <ListViewItem> itemsToAdd = new List <ListViewItem>();
                foreach (WatchValueInfo watch in watchContent)
                {
                    ListViewItem item = new ListViewItem(watch.Expression);
                    item.UseItemStyleForSubItems             = false;
                    item.SubItems.Add(watch.Value).ForeColor = watch.HasChanged ? Color.Red : Color.Black;
                    itemsToAdd.Add(item);
                }
                var lastItem = new ListViewItem("");
                lastItem.SubItems.Add("");
                itemsToAdd.Add(lastItem);
                lstWatch.Items.AddRange(itemsToAdd.ToArray());
            }
            else
            {
                for (int i = 0; i < watchContent.Count; i++)
                {
                    ListViewItem item = lstWatch.Items[i];
                    item.SubItems[0].Text      = watchContent[i].Expression;
                    item.SubItems[1].Text      = watchContent[i].Value.ToString();
                    item.SubItems[1].ForeColor = watchContent[i].HasChanged ? Color.Red : Color.Black;
                }
            }

            lstWatch.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
            if (colValue.Width < 100)
            {
                colValue.Width = 100;
            }

            lstWatch.EndUpdate();

            if (_currentSelection >= 0 && lstWatch.Items.Count > _currentSelection)
            {
                lstWatch.FocusedItem = lstWatch.Items[_currentSelection];
                lstWatch.Items[_currentSelection].Selected = true;
                _currentSelection = -1;
            }
        }
Beispiel #2
0
        public void UpdateWatch(bool autoResizeColumns = true)
        {
            List <WatchValueInfo> watchContent = WatchManager.GetWatchContent(mnuHexDisplay.Checked);

            bool updating = false;

            if (watchContent.Count != lstWatch.Items.Count - 1)
            {
                lstWatch.BeginUpdate();
                lstWatch.Items.Clear();

                List <ListViewItem> itemsToAdd = new List <ListViewItem>();
                foreach (WatchValueInfo watch in watchContent)
                {
                    ListViewItem item = new ListViewItem(watch.Expression);
                    item.UseItemStyleForSubItems             = false;
                    item.SubItems.Add(watch.Value).ForeColor = watch.HasChanged ? Color.Red : Color.Black;
                    itemsToAdd.Add(item);
                }
                var lastItem = new ListViewItem("");
                lastItem.SubItems.Add("");
                itemsToAdd.Add(lastItem);
                lstWatch.Items.AddRange(itemsToAdd.ToArray());
                updating = true;
            }
            else
            {
                for (int i = 0; i < watchContent.Count; i++)
                {
                    ListViewItem item       = lstWatch.Items[i];
                    bool         needUpdate = (
                        item.SubItems[0].Text != watchContent[i].Expression ||
                        item.SubItems[1].Text != watchContent[i].Value ||
                        item.SubItems[1].ForeColor != (watchContent[i].HasChanged ? Color.Red : Color.Black)
                        );
                    if (needUpdate)
                    {
                        updating = true;
                        item.SubItems[0].Text      = watchContent[i].Expression;
                        item.SubItems[1].Text      = watchContent[i].Value;
                        item.SubItems[1].ForeColor = watchContent[i].HasChanged ? Color.Red : Color.Black;
                    }
                }
            }

            if (updating)
            {
                if (watchContent.Count > 0)
                {
                    int maxLength = watchContent.Select(info => info.Value.Length).Max();
                    if (_previousMaxLength != maxLength)
                    {
                        if (autoResizeColumns)
                        {
                            lstWatch.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
                        }
                        if (colValue.Width < 100)
                        {
                            colValue.Width = 100;
                        }
                        _previousMaxLength = maxLength;
                    }
                }
                lstWatch.EndUpdate();
            }

            if (_currentSelection >= 0 && lstWatch.Items.Count > _currentSelection)
            {
                lstWatch.FocusedItem = lstWatch.Items[_currentSelection];
                lstWatch.Items[_currentSelection].Selected = true;
                _currentSelection = -1;
            }
        }
        public void UpdateWatch(bool autoResizeColumns = true)
        {
            List <WatchValueInfo> watchContent = WatchManager.GetWatchContent(_previousValues);

            _previousValues = watchContent;

            bool updating = false;

            if (watchContent.Count != lstWatch.Items.Count - 1)
            {
                int currentFocus = lstWatch.FocusedItem?.Selected == true ? (lstWatch.FocusedItem?.Index ?? -1) : -1;
                lstWatch.BeginUpdate();
                lstWatch.Items.Clear();

                List <ListViewItem> itemsToAdd = new List <ListViewItem>();
                foreach (WatchValueInfo watch in watchContent)
                {
                    ListViewItem item = new ListViewItem(watch.Expression);
                    item.UseItemStyleForSubItems             = false;
                    item.SubItems.Add(watch.Value).ForeColor = watch.HasChanged ? ThemeHelper.Theme.ErrorTextColor : ThemeHelper.Theme.LabelForeColor;
                    itemsToAdd.Add(item);
                }
                var lastItem = new ListViewItem("");
                lastItem.SubItems.Add("");
                itemsToAdd.Add(lastItem);
                lstWatch.Items.AddRange(itemsToAdd.ToArray());
                if (currentFocus >= 0 && currentFocus < lstWatch.Items.Count)
                {
                    SetSelectedItem(currentFocus);
                }
                updating = true;
            }
            else
            {
                for (int i = 0; i < watchContent.Count; i++)
                {
                    ListViewItem item       = lstWatch.Items[i];
                    bool         needUpdate = (
                        item.SubItems[0].Text != watchContent[i].Expression ||
                        item.SubItems[1].Text != watchContent[i].Value ||
                        item.SubItems[1].ForeColor != (watchContent[i].HasChanged ? ThemeHelper.Theme.ErrorTextColor : ThemeHelper.Theme.LabelForeColor)
                        );
                    if (needUpdate)
                    {
                        updating = true;
                        item.SubItems[0].Text      = watchContent[i].Expression;
                        item.SubItems[1].Text      = watchContent[i].Value;
                        item.SubItems[1].ForeColor = watchContent[i].HasChanged ? ThemeHelper.Theme.ErrorTextColor : ThemeHelper.Theme.LabelForeColor;
                    }
                }
            }

            if (updating)
            {
                if (watchContent.Count > 0)
                {
                    int maxLength = watchContent.Select(info => info.Value.Length).Max();
                    if (_previousMaxLength != maxLength)
                    {
                        if (autoResizeColumns)
                        {
                            lstWatch.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
                        }
                        if (colValue.Width < 100)
                        {
                            colValue.Width = 100;
                        }
                        _previousMaxLength = maxLength;
                    }
                }
                lstWatch.EndUpdate();
            }
        }