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 @@ @@ -94,7 +94,7 @@
<Compile Include="Src\Commands\GoToDefinition.cs" />
<Compile Include="Src\Commands\ProfileExecutable.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\Dialogs\ProfileExecutableForm.xaml.cs">
<DependentUpon>ProfileExecutableForm.xaml</DependentUpon>

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

@ -21,20 +21,20 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -21,20 +21,20 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of CopySelectedData
/// </summary>
public class CopySelectedData : AbstractMenuCommand
public class CopySelectedData : ProfilerMenuCommand
{
/// <summary>
/// Starts the command
/// </summary>
public override void Run()
{
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList();
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
var list = GetSelectedItems();
if (list.Count > 0) {
if (list.FirstOrDefault() != null) {
StringBuilder builder = new StringBuilder();
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);
}

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

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

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

@ -23,15 +23,14 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -23,15 +23,14 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of FindCallsOfSelected
/// </summary>
public class FindCallsOfSelected : AbstractMenuCommand
public class FindCallsOfSelected : ProfilerMenuCommand
{
/// <summary>
/// Starts the command
/// </summary>
public override void Run()
{
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList();
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
var list = GetSelectedItems().ToList();
if (list.Count > 0) {
var items = from item in list select item.Node;
@ -47,7 +46,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -47,7 +46,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
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 @@ -22,7 +22,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of GoToDefinition
/// </summary>
public class GoToDefinition : AbstractMenuCommand
public class GoToDefinition : ProfilerMenuCommand
{
IAmbience ambience = new CSharpAmbience();
@ -31,12 +31,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -31,12 +31,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// </summary>
public override void Run()
{
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList();
if (list.Count == 0)
return;
CallTreeNodeViewModel selectedItem = list.First();
var selectedItem = GetSelectedItems().FirstOrDefault();
if (selectedItem != null) {
IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName);
@ -44,7 +39,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -44,7 +39,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
{
IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters);
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 @@ -26,7 +26,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of RunExecutable
/// </summary>
public class ProfileExecutable : AbstractMenuCommand
public class ProfileExecutable : ProfilerMenuCommand
{
/// <summary>
/// Starts the command

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

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

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

@ -0,0 +1,61 @@ @@ -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 @@ -23,19 +23,16 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of SetAsRoot
/// </summary>
public class SetAsRoot : AbstractMenuCommand
public class SetAsRoot : ProfilerMenuCommand
{
/// <summary>
/// Starts the command
/// </summary>
public override void Run()
{
IList<CallTreeNodeViewModel> list = ((QueryView)Owner).SelectedItems.ToList();
ProfilerView parent = (((((QueryView)Owner).Parent as TabItem).Parent as TabControl).Parent as Grid).Parent as ProfilerView;
var items = GetSelectedItems().Where(item => item != null && item.Node != null).Select(i => i.Node);
if (list.Count > 0) {
var items = from item in list select item.Node;
if (items.FirstOrDefault() != null) {
List<string> parts = new List<string>();
int? nameId = items.First().NameMapping.Id; // use nullable int to represent non assigned nameId
@ -51,7 +48,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -51,7 +48,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands
if (nameId == null)
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 @@ -21,24 +21,18 @@ namespace ICSharpCode.Profiler.AddIn.Commands
/// <summary>
/// Description of ShowFunctions
/// </summary>
public class ShowFunctions : AbstractMenuCommand
public class ShowFunctions : ProfilerMenuCommand
{
/// <summary>
/// Starts the command
/// </summary>
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) {
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");
}
if (selectedItem != null)
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; @@ -5,6 +5,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Shapes;
using System.Windows.Threading;
using ICSharpCode.Core.Presentation;
@ -34,10 +35,14 @@ namespace ICSharpCode.Profiler.AddIn.Views @@ -34,10 +35,14 @@ namespace ICSharpCode.Profiler.AddIn.Views
foreach (TabItem item in this.tabView.Items) {
if (item.Content != null) {
((QueryView)item.Content).Reporter = new ErrorReporter(UpdateErrorList);
((QueryView)item.Content).Provider = provider;
((QueryView)item.Content).SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex);
((QueryView)item.Content).TreeViewContextMenu = MenuService.CreateContextMenu(item.Content, "/AddIns/Profiler/QueryView/ContextMenu");
QueryView view = item.Content as QueryView;
view.Reporter = new ErrorReporter(UpdateErrorList);
view.Provider = provider;
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 @@ -168,7 +173,7 @@ namespace ICSharpCode.Profiler.AddIn.Views
view.CurrentQuery = query;
view.ShowQueryItems = true;
view.TreeViewContextMenu = MenuService.CreateContextMenu(view, "/AddIns/Profiler/QueryView/ContextMenu");
//view.TreeViewContextMenu = ;
view.CurrentQueryChanged += delegate { ViewCurrentQueryChanged(header, view); };

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

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

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

@ -41,7 +41,6 @@ namespace ICSharpCode.Profiler.Controls @@ -41,7 +41,6 @@ namespace ICSharpCode.Profiler.Controls
bool isDirty;
public string View { get; set; }
public ErrorReporter Reporter { get; set; }
public event EventHandler CurrentQueryChanged;
@ -91,8 +90,13 @@ namespace ICSharpCode.Profiler.Controls @@ -91,8 +90,13 @@ namespace ICSharpCode.Profiler.Controls
this.DataContext = this;
this.task = new SingleTask(this.Dispatcher);
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) {
nameColumn.Width += (e.NewSize.Width - e.PreviousSize.Width);
if (e.NewSize.Width > 0 && e.PreviousSize.Width > 0 &&
(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 @@ -159,6 +163,10 @@ namespace ICSharpCode.Profiler.Controls
list => LoadCompleted(list, layer, ad),
delegate { layer.Remove(ad); });
}
public RingDiagramControl RingDiagram {
get { return ringDiagram; }
}
static HierarchyList<CallTreeNodeViewModel> LoadWorker(ProfilingDataProvider provider, QueryCompiler compiler, int rangeStart, int rangeEnd)
{
@ -212,7 +220,7 @@ namespace ICSharpCode.Profiler.Controls @@ -212,7 +220,7 @@ namespace ICSharpCode.Profiler.Controls
public ContextMenu TreeViewContextMenu {
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 @@ -74,6 +74,7 @@ namespace ICSharpCode.Profiler.Controls
ell.Fill = Brushes.Gray;
ell.Stroke = Brushes.Black;
ell.ToolTip = item.CreateToolTip();
ell.Tag = item;
ell.MouseLeftButtonDown += (sender, e) =>
{
@ -154,6 +155,7 @@ namespace ICSharpCode.Profiler.Controls @@ -154,6 +155,7 @@ namespace ICSharpCode.Profiler.Controls
p.VerticalAlignment = VerticalAlignment.Center;
p.HorizontalAlignment = HorizontalAlignment.Center;
p.Tag = node;
//p.ContextMenu = this.ContextMenu.;
p.MouseLeftButtonDown += new MouseButtonEventHandler(
delegate(object sender, MouseButtonEventArgs e) {

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

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
</ScrollViewer>
<TabControl Name="tabView" HorizontalAlignment="Stretch" Grid.Row="2">
<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>
</TabControl>
<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