Browse Source

Updated UI

Added context menu to RingDiagramControl

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3988 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
a98624fe08
  1. 2
      src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj
  2. 8
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/CopySelectedData.cs
  3. 8
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/CopyStacktrace.cs
  4. 7
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/FindCallsOfSelected.cs
  5. 11
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs
  6. 2
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileExecutable.cs
  7. 2
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs
  8. 61
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfilerMenuCommand.cs
  9. 11
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/SetAsRoot.cs
  10. 16
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ShowFunctions.cs
  11. 15
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs
  12. 6
      src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml
  13. 16
      src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs
  14. 2
      src/AddIns/Misc/Profiler/Frontend/Controls/RingDiagramControl.cs
  15. 2
      src/AddIns/Misc/Profiler/Frontend/Gui/Window1.xaml

2
src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj

@ -94,7 +94,7 @@
<Compile Include="Src\Commands\GoToDefinition.cs" /> <Compile Include="Src\Commands\GoToDefinition.cs" />
<Compile Include="Src\Commands\ProfileExecutable.cs" /> <Compile Include="Src\Commands\ProfileExecutable.cs" />
<Compile Include="Src\Commands\ProfileProject.cs" /> <Compile Include="Src\Commands\ProfileProject.cs" />
<Compile Include="Src\Commands\SetAsRoot.cs" /> <Compile Include="Src\Commands\ProfilerMenuCommand.cs" /> <Compile Include="Src\Commands\SetAsRoot.cs" />
<Compile Include="Src\Commands\ShowFunctions.cs" /> <Compile Include="Src\Commands\ShowFunctions.cs" />
<Compile Include="Src\Dialogs\ProfileExecutableForm.xaml.cs"> <Compile Include="Src\Dialogs\ProfileExecutableForm.xaml.cs">
<DependentUpon>ProfileExecutableForm.xaml</DependentUpon> <DependentUpon>ProfileExecutableForm.xaml</DependentUpon>

8
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/CopySelectedData.cs

@ -21,20 +21,20 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of CopySelectedData /// Description of CopySelectedData
/// </summary> /// </summary>
public class CopySelectedData : AbstractMenuCommand public class CopySelectedData : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var list = GetSelectedItems();
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
if (list.Count > 0) { if (list.FirstOrDefault() != null) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
foreach (CallTreeNodeViewModel node in list) { foreach (CallTreeNodeViewModel node in list) {
if (node != null)
builder.AppendLine(new string('\t', node.Level) + node.Name + "\t" + node.CallCount + "\t" + node.TimeSpent + "\t" + node.TimePercentageOfParentAsText); builder.AppendLine(new string('\t', node.Level) + node.Name + "\t" + node.CallCount + "\t" + node.TimeSpent + "\t" + node.TimePercentageOfParentAsText);
} }

8
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/CopyStacktrace.cs

@ -7,9 +7,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Shapes;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Profiler.Controls; using ICSharpCode.Profiler.Controls;
@ -19,15 +20,14 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of CopyStacktrace /// Description of CopyStacktrace
/// </summary> /// </summary>
public class CopyStacktrace : AbstractMenuCommand public class CopyStacktrace : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var selectedItem = GetSelectedItems().FirstOrDefault();
CallTreeNodeViewModel selectedItem = (list.Count > 0) ? list[0] as CallTreeNodeViewModel : null;
if (selectedItem != null) { if (selectedItem != null) {
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();

7
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/FindCallsOfSelected.cs

@ -23,15 +23,14 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of FindCallsOfSelected /// Description of FindCallsOfSelected
/// </summary> /// </summary>
public class FindCallsOfSelected : AbstractMenuCommand public class FindCallsOfSelected : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var list = GetSelectedItems().ToList();
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
if (list.Count > 0) { if (list.Count > 0) {
var items = from item in list select item.Node; var items = from item in list select item.Node;
@ -47,7 +46,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
string header = "Results"; string header = "Results";
parent.CreateTab(header, "from c in Calls where " + string.Join(" || ", parts.ToArray()) + " select c"); Parent.CreateTab(header, "from c in Calls where " + string.Join(" || ", parts.ToArray()) + " select c");
} }
} }
} }

11
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of GoToDefinition /// Description of GoToDefinition
/// </summary> /// </summary>
public class GoToDefinition : AbstractMenuCommand public class GoToDefinition : ProfilerMenuCommand
{ {
IAmbience ambience = new CSharpAmbience(); IAmbience ambience = new CSharpAmbience();
@ -31,12 +31,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var selectedItem = GetSelectedItems().FirstOrDefault();
if (list.Count == 0)
return;
CallTreeNodeViewModel selectedItem = list.First();
if (selectedItem != null) { if (selectedItem != null) {
IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName); IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName);
@ -44,7 +39,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
{ {
IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters); IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters);
if (member != null) { if (member != null) {
IViewContent view = FileService.JumpToFilePosition(c.CompilationUnit.FileName, member.BodyRegion.BeginLine, member.BodyRegion.BeginColumn); IViewContent view = FileService.JumpToFilePosition(c.CompilationUnit.FileName, member.BodyRegion.BeginLine - 1, member.BodyRegion.BeginColumn - 1);
} }
} }
} }

2
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileExecutable.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of RunExecutable /// Description of RunExecutable
/// </summary> /// </summary>
public class ProfileExecutable : AbstractMenuCommand public class ProfileExecutable : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command

2
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of RunProject /// Description of RunProject
/// </summary> /// </summary>
public class ProfileProject : AbstractMenuCommand public class ProfileProject : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command

61
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfilerMenuCommand.cs

@ -0,0 +1,61 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.Views;
using ICSharpCode.Profiler.Controls;
namespace ICSharpCode.Profiler.AddIn.Commands
{
/// <summary>
/// Description of ProfilerMenuCommand.
/// </summary>
public abstract class ProfilerMenuCommand : AbstractMenuCommand
{
public abstract override void Run();
protected virtual IEnumerable<CallTreeNodeViewModel> GetSelectedItems()
{
if (Owner is Shape)
yield return (Owner as Shape).Tag as CallTreeNodeViewModel;
else {
var fe = TryToFindParent(typeof(QueryView)) as QueryView;
if (fe != null) {
foreach (var item in fe.SelectedItems)
yield return item;
}
}
}
protected virtual ProfilerView Parent {
get {
return TryToFindParent(typeof(ProfilerView)) as ProfilerView;
}
}
FrameworkElement TryToFindParent(Type type)
{
FrameworkElement start = Owner as FrameworkElement;
if (start == null)
return null;
while (start != null && !start.GetType().Equals(type))
start = start.Parent as FrameworkElement;
return start;
}
}
}

11
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/SetAsRoot.cs

@ -23,19 +23,16 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of SetAsRoot /// Description of SetAsRoot
/// </summary> /// </summary>
public class SetAsRoot : AbstractMenuCommand public class SetAsRoot : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var items = GetSelectedItems().Where(item => item != null && item.Node != null).Select(i => i.Node);
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
if (list.Count > 0) { if (items.FirstOrDefault() != null) {
var items = from item in list select item.Node;
List<string> parts = new List<string>(); List<string> parts = new List<string>();
int? nameId = items.First().NameMapping.Id; // use nullable int to represent non assigned nameId int? nameId = items.First().NameMapping.Id; // use nullable int to represent non assigned nameId
@ -51,7 +48,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
if (nameId == null) if (nameId == null)
header = "Merged Nodes"; header = "Merged Nodes";
parent.CreateTab(header, "Merge(" + string.Join(",", parts.ToArray()) + ")"); Parent.CreateTab(header, "Merge(" + string.Join(",", parts.ToArray()) + ")");
} }
} }
} }

16
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ShowFunctions.cs

@ -21,24 +21,18 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary> /// <summary>
/// Description of ShowFunctions /// Description of ShowFunctions
/// </summary> /// </summary>
public class ShowFunctions : AbstractMenuCommand public class ShowFunctions : ProfilerMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command /// Starts the command
/// </summary> /// </summary>
public override void Run() public override void Run()
{ {
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList(); var selectedItem = GetSelectedItems().FirstOrDefault();
if (list.Count == 0) if (selectedItem != null)
return; Parent.CreateTab("All functions for " + selectedItem.GetSignature(),
"from f in Functions where f.Signature == \"" + selectedItem.GetSignature() + "\" select f");
CallTreeNodeViewModel selectedItem = list.First();
if (selectedItem != null) {
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
parent.CreateTab("All functions for " + selectedItem.GetSignature(), "from f in Functions where f.Signature == \"" + selectedItem.GetSignature() + "\" select f");
}
} }
} }
} }

15
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs

@ -5,6 +5,7 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Shapes;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
@ -34,10 +35,14 @@ namespace ICSharpCode.Profiler.AddIn.Views
foreach (TabItem item in this.tabView.Items) { foreach (TabItem item in this.tabView.Items) {
if (item.Content != null) { if (item.Content != null) {
((QueryView)item.Content).Reporter = new ErrorReporter(UpdateErrorList); QueryView view = item.Content as QueryView;
((QueryView)item.Content).Provider = provider; view.Reporter = new ErrorReporter(UpdateErrorList);
((QueryView)item.Content).SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex); view.Provider = provider;
((QueryView)item.Content).TreeViewContextMenu = MenuService.CreateContextMenu(item.Content, "/AddIns/Profiler/QueryView/ContextMenu"); view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex);
view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
MenuService.CreateContextMenu(source, "/AddIns/Profiler/QueryView/ContextMenu").IsOpen = true;
};
} }
} }
@ -168,7 +173,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
view.CurrentQuery = query; view.CurrentQuery = query;
view.ShowQueryItems = true; view.ShowQueryItems = true;
view.TreeViewContextMenu = MenuService.CreateContextMenu(view, "/AddIns/Profiler/QueryView/ContextMenu"); //view.TreeViewContextMenu = ;
view.CurrentQueryChanged += delegate { ViewCurrentQueryChanged(header, view); }; view.CurrentQueryChanged += delegate { ViewCurrentQueryChanged(header, view); };

6
src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml

@ -83,21 +83,21 @@
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Call count" Width="60"> <GridViewColumn Header="Call count" Width="60" x:Name="callCountColumn">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding CallCount}" HorizontalAlignment="Right" /> <TextBlock Text="{Binding CallCount}" HorizontalAlignment="Right" />
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Time spent" Width="110"> <GridViewColumn Header="Time spent" Width="110" x:Name="timeSpentColumn">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock HorizontalAlignment="Right" Text="{Binding TimeSpent}" /> <TextBlock HorizontalAlignment="Right" Text="{Binding TimeSpent}" />
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="%" Width="80"> <GridViewColumn Header="%" Width="80" x:Name="percentColumn">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<DockPanel LastChildFill="false"> <DockPanel LastChildFill="false">

16
src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs

@ -41,7 +41,6 @@ namespace ICSharpCode.Profiler.Controls
bool isDirty; bool isDirty;
public string View { get; set; }
public ErrorReporter Reporter { get; set; } public ErrorReporter Reporter { get; set; }
public event EventHandler CurrentQueryChanged; public event EventHandler CurrentQueryChanged;
@ -91,8 +90,13 @@ namespace ICSharpCode.Profiler.Controls
this.DataContext = this; this.DataContext = this;
this.task = new SingleTask(this.Dispatcher); this.task = new SingleTask(this.Dispatcher);
this.treeView.SizeChanged += delegate(object sender, SizeChangedEventArgs e) { this.treeView.SizeChanged += delegate(object sender, SizeChangedEventArgs e) {
if (e.NewSize.Width > 0 && e.PreviousSize.Width > 0 && (nameColumn.Width + (e.NewSize.Width - e.PreviousSize.Width)) > 0) { if (e.NewSize.Width > 0 && e.PreviousSize.Width > 0 &&
nameColumn.Width += (e.NewSize.Width - e.PreviousSize.Width); (nameColumn.Width + (e.NewSize.Width - e.PreviousSize.Width)) > 0) {
if ((nameColumn.Width + (e.NewSize.Width - e.PreviousSize.Width)) >=
(e.NewSize.Width - this.callCountColumn.Width - this.percentColumn.Width - this.timeSpentColumn.Width))
this.nameColumn.Width = e.NewSize.Width - this.callCountColumn.Width - this.percentColumn.Width - this.timeSpentColumn.Width - 25;
else
nameColumn.Width += (e.NewSize.Width - e.PreviousSize.Width);
} }
}; };
} }
@ -159,6 +163,10 @@ namespace ICSharpCode.Profiler.Controls
list => LoadCompleted(list, layer, ad), list => LoadCompleted(list, layer, ad),
delegate { layer.Remove(ad); }); delegate { layer.Remove(ad); });
} }
public RingDiagramControl RingDiagram {
get { return ringDiagram; }
}
static HierarchyList<CallTreeNodeViewModel> LoadWorker(ProfilingDataProvider provider, QueryCompiler compiler, int rangeStart, int rangeEnd) static HierarchyList<CallTreeNodeViewModel> LoadWorker(ProfilingDataProvider provider, QueryCompiler compiler, int rangeStart, int rangeEnd)
{ {
@ -212,7 +220,7 @@ namespace ICSharpCode.Profiler.Controls
public ContextMenu TreeViewContextMenu { public ContextMenu TreeViewContextMenu {
get { return this.treeView.ContextMenu; } get { return this.treeView.ContextMenu; }
set { this.treeView.ContextMenu = value; } set { this.treeView.ContextMenu = this.ringDiagram.ContextMenu = value; }
} }
} }
} }

2
src/AddIns/Misc/Profiler/Frontend/Controls/RingDiagramControl.cs

@ -74,6 +74,7 @@ namespace ICSharpCode.Profiler.Controls
ell.Fill = Brushes.Gray; ell.Fill = Brushes.Gray;
ell.Stroke = Brushes.Black; ell.Stroke = Brushes.Black;
ell.ToolTip = item.CreateToolTip(); ell.ToolTip = item.CreateToolTip();
ell.Tag = item;
ell.MouseLeftButtonDown += (sender, e) => ell.MouseLeftButtonDown += (sender, e) =>
{ {
@ -154,6 +155,7 @@ namespace ICSharpCode.Profiler.Controls
p.VerticalAlignment = VerticalAlignment.Center; p.VerticalAlignment = VerticalAlignment.Center;
p.HorizontalAlignment = HorizontalAlignment.Center; p.HorizontalAlignment = HorizontalAlignment.Center;
p.Tag = node; p.Tag = node;
//p.ContextMenu = this.ContextMenu.;
p.MouseLeftButtonDown += new MouseButtonEventHandler( p.MouseLeftButtonDown += new MouseButtonEventHandler(
delegate(object sender, MouseButtonEventArgs e) { delegate(object sender, MouseButtonEventArgs e) {

2
src/AddIns/Misc/Profiler/Frontend/Gui/Window1.xaml

@ -18,7 +18,7 @@
</ScrollViewer> </ScrollViewer>
<TabControl Name="tabView" HorizontalAlignment="Stretch" Grid.Row="2"> <TabControl Name="tabView" HorizontalAlignment="Stretch" Grid.Row="2">
<TabItem Header="Overview"> <TabItem Header="Overview">
<y:QueryView x:Name="treeView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowQueryItems="False" View="Overview" CurrentQuery="from t in Threads select t" /> <y:QueryView x:Name="treeView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowQueryItems="False" CurrentQuery="from t in Threads select t" />
</TabItem> </TabItem>
</TabControl> </TabControl>
<Button Height="23" Margin="235,9,0,0" Name="btnLoadSession" VerticalAlignment="Top" HorizontalAlignment="Left" Width="87" Click="btnLoadSession_Click">Load session</Button> <Button Height="23" Margin="235,9,0,0" Name="btnLoadSession" VerticalAlignment="Top" HorizontalAlignment="Left" Width="87" Click="btnLoadSession_Click">Load session</Button>

Loading…
Cancel
Save