Browse Source

Merge remote branch 'eusebiu/BreakpointPad'

pull/15/head
Daniel Grunwald 15 years ago
parent
commit
1b2c8b4da9
  1. 6
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
  2. 5
      src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs
  3. 16
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/SimpleListViewControl.xaml
  4. 62
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/SimpleListViewControl.xaml.cs
  5. 98
      src/AddIns/Debugger/Debugger.AddIn/Pads/LoadedModulesPad.cs
  6. 52
      src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.Menu.cs
  7. 137
      src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs

6
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj

@ -58,6 +58,7 @@
<StartProgram>..\..\..\..\bin\SharpDevelop.exe</StartProgram> <StartProgram>..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore"> <Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
@ -95,6 +96,10 @@
<DependentUpon>ConditionCell.xaml</DependentUpon> <DependentUpon>ConditionCell.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Pads\Controls\Converters.cs" /> <Compile Include="Pads\Controls\Converters.cs" />
<Compile Include="Pads\Controls\SimpleListViewControl.xaml.cs">
<DependentUpon>SimpleListViewControl.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Pads\Controls\TreeListView.cs" /> <Compile Include="Pads\Controls\TreeListView.cs" />
<Compile Include="Pads\Controls\WatchList.xaml.cs"> <Compile Include="Pads\Controls\WatchList.xaml.cs">
<DependentUpon>WatchList.xaml</DependentUpon> <DependentUpon>WatchList.xaml</DependentUpon>
@ -345,6 +350,7 @@
<ItemGroup> <ItemGroup>
<Page Include="Pads\CallStackPad.xaml" /> <Page Include="Pads\CallStackPad.xaml" />
<Page Include="Pads\Controls\ConditionCell.xaml" /> <Page Include="Pads\Controls\ConditionCell.xaml" />
<Page Include="Pads\Controls\SimpleListViewControl.xaml" />
<Page Include="Pads\Controls\WatchList.xaml" /> <Page Include="Pads\Controls\WatchList.xaml" />
<Page Include="Pads\WatchInputBox.xaml" /> <Page Include="Pads\WatchInputBox.xaml" />
<Page Include="Service\EditBreakpointScriptWindow.xaml" /> <Page Include="Service\EditBreakpointScriptWindow.xaml" />

5
src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs

@ -2,16 +2,13 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) // This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System; using System;
using System.Collections;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Debugger; using Debugger;
using Debugger.AddIn;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;

16
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/SimpleListViewControl.xaml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="Debugger.AddIn.Pads.Controls.SimpleListViewControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<ListView
ItemsSource="{Binding ItemCollection}"
x:Name="ItemsListView">
<ListView.View>
<GridView>
<GridView.Columns>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</UserControl>

62
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/SimpleListViewControl.xaml.cs

@ -0,0 +1,62 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Dynamic;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
namespace Debugger.AddIn.Pads.Controls
{
public partial class SimpleListViewControl : UserControl
{
public event EventHandler ItemActivated;
private ObservableCollection<ExpandoObject> itemCollection = new ObservableCollection<ExpandoObject>();
public SimpleListViewControl()
{
InitializeComponent();
ItemsListView.MouseDoubleClick += new MouseButtonEventHandler(ItemsListView_MouseDoubleClick);
}
public ObservableCollection<ExpandoObject> ItemCollection {
get { return itemCollection; }
}
public IList<ExpandoObject> SelectedItems {
get {
var result = new List<ExpandoObject>();
foreach (var item in ItemsListView.SelectedItems)
result.Add((ExpandoObject)item);
return result;
}
}
public void ClearColumns()
{
((GridView)this.ItemsListView.View).Columns.Clear();
}
public void AddColumn(string header, Binding binding, double width)
{
GridViewColumn column = new GridViewColumn();
column.Width = width;
column.DisplayMemberBinding = binding;
column.Header = header;
((GridView)this.ItemsListView.View).Columns.Add(column);
}
void ItemsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var handler = ItemActivated;
if (handler != null)
handler(this, EventArgs.Empty);
}
}
}

98
src/AddIns/Debugger/Debugger.AddIn/Pads/LoadedModulesPad.cs

@ -2,27 +2,21 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) // This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System; using System;
using System.Windows.Forms; using System.Dynamic;
using System.Windows;
using System.Windows.Data;
using Debugger; using Debugger;
using Debugger.AddIn.Pads.Controls;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
public class LoadedModulesPad : DebuggerPad public class LoadedModulesPad : DebuggerPad
{ {
ListView loadedModulesList; SimpleListViewControl loadedModulesList;
Process debuggedProcess; Process debuggedProcess;
ColumnHeader name = new ColumnHeader();
ColumnHeader address = new ColumnHeader();
ColumnHeader path = new ColumnHeader();
ColumnHeader order = new ColumnHeader();
ColumnHeader version = new ColumnHeader();
ColumnHeader program = new ColumnHeader();
ColumnHeader timestamp = new ColumnHeader();
ColumnHeader information = new ColumnHeader();
public override object Control { public override object Control {
get { get {
return loadedModulesList; return loadedModulesList;
@ -31,41 +25,26 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
protected override void InitializeComponents() protected override void InitializeComponents()
{ {
loadedModulesList = new ListView(); loadedModulesList = new SimpleListViewControl();
loadedModulesList.FullRowSelect = true;
loadedModulesList.AutoArrange = true;
loadedModulesList.Alignment = ListViewAlignment.Left;
loadedModulesList.View = View.Details;
loadedModulesList.Dock = DockStyle.Fill;
loadedModulesList.GridLines = false;
loadedModulesList.Activation = ItemActivation.OneClick;
loadedModulesList.Columns.AddRange(new ColumnHeader[] {name, address, path, order, version, program, timestamp, information} );
name.Width = 250;
address.Width = 100;
path.Width = 250;
order.Width = 80;
version.Width = 0;//50;
program.Width = 0;//90;
timestamp.Width = 0;//80;
information.Width = 130;
RedrawContent(); RedrawContent();
ResourceService.LanguageChanged += delegate { RedrawContent(); }; ResourceService.LanguageChanged += delegate { RedrawContent(); };
} }
public void RedrawContent() public void RedrawContent()
{ {
name.Text = StringParser.Parse("${res:Global.Name}"); loadedModulesList.ClearColumns();
address.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.AddressColumn}"); loadedModulesList.AddColumn(StringParser.Parse("${res:Global.Name}"),
path.Text = StringParser.Parse("${res:Global.Path}"); new Binding { Path = new PropertyPath("Name") }, 250);
order.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.OrderColumn}"); loadedModulesList.AddColumn(StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.AddressColumn}"),
version.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.VersionColumn}"); new Binding { Path = new PropertyPath("Address") }, 100);
program.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.ProgramColumn}"); loadedModulesList.AddColumn(StringParser.Parse("${res:Global.Path}"),
timestamp.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.TimestampColumn}"); new Binding { Path = new PropertyPath("Path") }, 250);
information.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.SymbolsColumn}"); loadedModulesList.AddColumn(StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.OrderColumn}"),
new Binding { Path = new PropertyPath("Order") }, 80);
loadedModulesList.AddColumn(StringParser.Parse("${res:MainWindow.Windows.Debug.Modules.SymbolsColumn}"),
new Binding { Path = new PropertyPath("Symbols") }, 130);
} }
protected override void SelectProcess(Process process) protected override void SelectProcess(Process process)
{ {
if (debuggedProcess != null) { if (debuggedProcess != null) {
@ -92,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public override void RefreshPad() public override void RefreshPad()
{ {
loadedModulesList.Items.Clear(); loadedModulesList.ItemCollection.Clear();
if (debuggedProcess != null) { if (debuggedProcess != null) {
foreach(Module module in debuggedProcess.Modules) { foreach(Module module in debuggedProcess.Modules) {
AddModule(module); AddModule(module);
@ -102,39 +81,32 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void AddModule(Module module) void AddModule(Module module)
{ {
ListViewItem newItem = new ListViewItem(); dynamic obj = new ExpandoObject();
newItem.Tag = module; obj.Tag = module;
RefreshItem(newItem); RefreshItem(obj);
module.SymbolsUpdated += delegate { RefreshItem(newItem); }; module.SymbolsUpdated += delegate { RefreshItem(obj); };
loadedModulesList.Items.Add(newItem); loadedModulesList.ItemCollection.Add(obj);
} }
void RefreshItem(ListViewItem item) void RefreshItem(ExpandoObject obj)
{ {
dynamic item = obj;
Module module = (Module)item.Tag; Module module = (Module)item.Tag;
item.SubItems.Clear(); item.Name = module.Name;
item.SubItems.AddRange( item.Address = String.Format("{0:X8}", module.BaseAdress);
new string[] { item.Path = module.IsDynamic ? "(dynamic)" : module.IsInMemory ? "(in memory)" : module.FullPath;
module.Name, item.Order = module.OrderOfLoading.ToString();
String.Format("{0:X8}", module.BaseAdress), item.Symbols = StringParser.Parse(module.HasSymbols ? "${res:MainWindow.Windows.Debug.Modules.HasSymbols}" : "${res:MainWindow.Windows.Debug.Modules.HasNoSymbols}");
module.IsDynamic ? "(dynamic)" : module.IsInMemory ? "(in memory)" : module.FullPath,
module.OrderOfLoading.ToString(),
"",
"",
"",
StringParser.Parse(module.HasSymbols ? "${res:MainWindow.Windows.Debug.Modules.HasSymbols}" : "${res:MainWindow.Windows.Debug.Modules.HasNoSymbols}")
}
);
item.SubItems.RemoveAt(0);
} }
void RemoveModule(Module module) void RemoveModule(Module module)
{ {
foreach (ListViewItem item in loadedModulesList.Items) { foreach (dynamic item in loadedModulesList.ItemCollection) {
if (item.Tag == module) { if (item.Tag == module) {
item.Remove(); loadedModulesList.ItemCollection.Remove(item);
break;
} }
} }
} }
} }
} }

52
src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.Menu.cs

@ -1,8 +1,11 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) // This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System.ComponentModel; using System.Collections;
using System.Windows.Forms; using System.Dynamic;
using System.Windows;
using System.Windows.Controls;
using Debugger; using Debugger;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -10,55 +13,50 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
public partial class RunningThreadsPad public partial class RunningThreadsPad
{ {
ContextMenuStrip CreateContextMenuStrip() ContextMenu CreateContextMenuStrip()
{ {
ContextMenuStrip menu = new ContextMenuStrip(); ContextMenu menu = new ContextMenu();
menu.Opening += FillContextMenuStrip; menu.Opened += FillContextMenuStrip;
return menu; return menu;
} }
void FillContextMenuStrip(object sender, CancelEventArgs e) void FillContextMenuStrip(object sender, RoutedEventArgs e)
{ {
ListView.SelectedListViewItemCollection items = runningThreadsList.SelectedItems; var items = runningThreadsList.SelectedItems;
if (items == null || items.Count == 0) {
if (items.Count == 0) { e.Handled = true;
e.Cancel = true;
return; return;
} }
ListViewItem item = items[0]; dynamic item = items[0];
ContextMenuStrip menu = sender as ContextMenuStrip; ContextMenu menu = sender as ContextMenu;
menu.Items.Clear(); menu.Items.Clear();
ToolStripMenuItem freezeItem; MenuItem freezeItem;
freezeItem = new ToolStripMenuItem(); freezeItem = new MenuItem();
freezeItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Freeze"); freezeItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Freeze");
freezeItem.Checked = (item.Tag as Thread).Suspended; freezeItem.IsChecked = (item.Tag as Thread).Suspended;
freezeItem.Click += freezeItem.Click +=
delegate { delegate {
ListView.SelectedListViewItemCollection selItems = runningThreadsList.SelectedItems; if (items == null || items.Count == 0) {
if (selItems.Count == 0) { e.Handled = true;
return; return;
} }
bool suspended = (selItems[0].Tag as Thread).Suspended; bool suspended = (item.Tag as Thread).Suspended;
if (!debuggedProcess.IsPaused) { if (!debuggedProcess.IsPaused) {
MessageService.ShowMessage("${res:MainWindow.Windows.Debug.Threads.CannotFreezeWhileRunning}", "${res:MainWindow.Windows.Debug.Threads.Freeze}"); MessageService.ShowMessage("${res:MainWindow.Windows.Debug.Threads.CannotFreezeWhileRunning}", "${res:MainWindow.Windows.Debug.Threads.Freeze}");
return; return;
} }
foreach(ListViewItem i in selItems) { foreach(dynamic current in items) {
(i.Tag as Thread).Suspended = !suspended; (current.Tag as Thread).Suspended = !suspended;
} }
RefreshPad(); RefreshPad();
}; };
menu.Items.AddRange(new ToolStripItem[] { menu.Items.Add(freezeItem);
freezeItem,
});
e.Cancel = false;
} }
} }
} }

137
src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs

@ -2,51 +2,36 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) // This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System; using System;
using System.Dynamic;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows;
using System.Windows.Data;
using Debugger; using Debugger;
using Debugger.AddIn.Pads.Controls;
using Debugger.AddIn.TreeModel; using Debugger.AddIn.TreeModel;
using ICSharpCode.Core; using ICSharpCode.Core;
using Exception=System.Exception; using Exception = System.Exception;
using Thread=Debugger.Thread; using Thread = Debugger.Thread;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
public partial class RunningThreadsPad : DebuggerPad public partial class RunningThreadsPad : DebuggerPad
{ {
ListView runningThreadsList; SimpleListViewControl runningThreadsList;
Process debuggedProcess; Process debuggedProcess;
ColumnHeader id = new ColumnHeader();
ColumnHeader name = new ColumnHeader();
ColumnHeader location = new ColumnHeader();
ColumnHeader priority = new ColumnHeader();
ColumnHeader breaked = new ColumnHeader();
public override object Control { public override object Control {
get { get {
return runningThreadsList; return runningThreadsList;
} }
} }
protected override void InitializeComponents() protected override void InitializeComponents()
{ {
runningThreadsList = new ListView(); runningThreadsList = new SimpleListViewControl();
runningThreadsList.FullRowSelect = true; runningThreadsList.ContextMenu = CreateContextMenuStrip();
runningThreadsList.AutoArrange = true; runningThreadsList.ItemActivated += RunningThreadsListItemActivate;
runningThreadsList.Alignment = ListViewAlignment.Left;
runningThreadsList.View = View.Details;
runningThreadsList.Dock = DockStyle.Fill;
runningThreadsList.GridLines = false;
runningThreadsList.Activation = ItemActivation.OneClick;
runningThreadsList.Columns.AddRange(new ColumnHeader[] {id, name, location, priority, breaked} );
runningThreadsList.ContextMenuStrip = CreateContextMenuStrip();
runningThreadsList.ItemActivate += new EventHandler(RunningThreadsListItemActivate);
id.Width = 100;
name.Width = 300;
location.Width = 250;
priority.Width = 120;
breaked.Width = 80;
RedrawContent(); RedrawContent();
ResourceService.LanguageChanged += delegate { RedrawContent(); }; ResourceService.LanguageChanged += delegate { RedrawContent(); };
@ -54,13 +39,23 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public void RedrawContent() public void RedrawContent()
{ {
id.Text = ResourceService.GetString("Global.ID"); runningThreadsList.ClearColumns();
name.Text = ResourceService.GetString("Global.Name"); runningThreadsList.AddColumn(ResourceService.GetString("Global.ID"),
location.Text = ResourceService.GetString("AddIns.HtmlHelp2.Location"); new Binding { Path = new PropertyPath("ID") },
priority.Text = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority"); 100);
breaked.Text = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Frozen"); runningThreadsList.AddColumn(ResourceService.GetString("Global.Name"),
new Binding { Path = new PropertyPath("Name") },
300);
runningThreadsList.AddColumn(ResourceService.GetString("AddIns.HtmlHelp2.Location"),
new Binding { Path = new PropertyPath("Location") },
250);
runningThreadsList.AddColumn(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority"),
new Binding { Path = new PropertyPath("Priority") },
120);
runningThreadsList.AddColumn(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Frozen"),
new Binding { Path = new PropertyPath("Frozen") },
80);
} }
protected override void SelectProcess(Process process) protected override void SelectProcess(Process process)
{ {
@ -73,7 +68,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
debuggedProcess.Paused += debuggedProcess_Paused; debuggedProcess.Paused += debuggedProcess_Paused;
debuggedProcess.Threads.Added += debuggedProcess_ThreadStarted; debuggedProcess.Threads.Added += debuggedProcess_ThreadStarted;
} }
runningThreadsList.Items.Clear(); runningThreadsList.ItemCollection.Clear();
RefreshPad(); RefreshPad();
} }
@ -90,7 +85,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public override void RefreshPad() public override void RefreshPad()
{ {
if (debuggedProcess == null || debuggedProcess.IsRunning) { if (debuggedProcess == null || debuggedProcess.IsRunning) {
runningThreadsList.Items.Clear(); runningThreadsList.ItemCollection.Clear();
return; return;
} }
@ -100,7 +95,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (debuggedProcess.IsPaused) { if (debuggedProcess.IsPaused) {
Utils.DoEvents(debuggedProcess); Utils.DoEvents(debuggedProcess);
} }
RefreshThread(t); AddThread(t);
} }
} catch(AbortedBecauseDebuggeeResumedException) { } catch(AbortedBecauseDebuggeeResumedException) {
} catch(Exception) { } catch(Exception) {
@ -117,86 +112,80 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
if (debuggedProcess.IsPaused) { if (debuggedProcess.IsPaused) {
if (debuggedProcess != null) { if (debuggedProcess != null) {
debuggedProcess.SelectedThread = (Thread)(runningThreadsList.SelectedItems[0].Tag); dynamic obj = runningThreadsList.SelectedItems[0];
debuggedProcess.SelectedThread = (Thread)(obj.Tag);
debuggedProcess.OnPaused(); // Force refresh of pads debuggedProcess.OnPaused(); // Force refresh of pads
} }
} else { } else {
MessageService.ShowMessage("${res:MainWindow.Windows.Debug.Threads.CannotSwitchWhileRunning}", "${res:MainWindow.Windows.Debug.Threads.ThreadSwitch}"); MessageService.ShowMessage("${res:MainWindow.Windows.Debug.Threads.CannotSwitchWhileRunning}", "${res:MainWindow.Windows.Debug.Threads.ThreadSwitch}");
} }
} }
void AddThread(Thread thread) void AddThread(Thread thread)
{ {
runningThreadsList.Items.Add(new ListViewItem(thread.ID.ToString())); // remove the object if exists
RefreshThread(thread); RemoveThread(thread);
dynamic obj = new ExpandoObject();
obj.Tag = thread;
RefreshItem(obj);
runningThreadsList.ItemCollection.Add(obj);
thread.NameChanged += delegate { thread.NameChanged += delegate {
RefreshThread(thread); RefreshItem(obj);
}; };
thread.Exited += delegate { thread.Exited += delegate {
RemoveThread(thread); RemoveThread(obj);
}; };
} }
ListViewItem FindItem(Thread thread) void RefreshItem(ExpandoObject obj)
{ {
foreach (ListViewItem item in runningThreadsList.Items) { dynamic item = obj;
if (item.Text == thread.ID.ToString()) { var thread = item.Tag as Thread;
return item;
} item.ID = thread.ID;
}
return null;
}
void RefreshThread(Thread thread)
{
ListViewItem item = FindItem(thread);
if (item == null) {
AddThread(thread);
return;
}
item.SubItems.Clear();
item.Text = thread.ID.ToString();
item.Tag = thread; item.Tag = thread;
item.SubItems.Add(thread.Name);
StackFrame location = null; StackFrame location = null;
if (thread.Process.IsPaused) { if (thread.Process.IsPaused) {
location = thread.MostRecentStackFrame; location = thread.MostRecentStackFrame;
} }
if (location != null) { if (location != null) {
item.SubItems.Add(location.MethodInfo.Name); item.Location = location.MethodInfo.Name;
} else { } else {
item.SubItems.Add(ResourceService.GetString("Global.NA")); item.Location = ResourceService.GetString("Global.NA");
} }
switch (thread.Priority) { switch (thread.Priority) {
case ThreadPriority.Highest: case ThreadPriority.Highest:
item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Highest")); item.Priority = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Highest");
break; break;
case ThreadPriority.AboveNormal: case ThreadPriority.AboveNormal:
item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.AboveNormal")); item.Priority = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.AboveNormal");
break; break;
case ThreadPriority.Normal: case ThreadPriority.Normal:
item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Normal")); item.Priority = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Normal");
break; break;
case ThreadPriority.BelowNormal: case ThreadPriority.BelowNormal:
item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.BelowNormal")); item.Priority = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.BelowNormal");
break; break;
case ThreadPriority.Lowest: case ThreadPriority.Lowest:
item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Lowest")); item.Priority = ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Lowest");
break; break;
default: default:
item.SubItems.Add(thread.Priority.ToString()); item.Priority = thread.Priority.ToString();
break; break;
} }
item.SubItems.Add(ResourceService.GetString(thread.Suspended ? "Global.Yes" : "Global.No")); item.Frozen = ResourceService.GetString(thread.Suspended ? "Global.Yes" : "Global.No");
} }
void RemoveThread(Thread thread) void RemoveThread(Thread thread)
{ {
foreach (ListViewItem item in runningThreadsList.Items) { foreach (dynamic item in runningThreadsList.ItemCollection) {
if (thread.ID.ToString() == item.Text) { if (thread.ID == item.ID) {
item.Remove(); runningThreadsList.ItemCollection.Remove(item);
break;
} }
} }
} }
} }
} }
Loading…
Cancel
Save