Browse Source

add effects to refresh button for pin tooltip

pull/15/head
Eusebiu Marcu 15 years ago
parent
commit
46f254874e
  1. 26
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinControlsDictionary.xaml
  2. 26
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml
  3. 58
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs

26
src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinControlsDictionary.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Debugger.AddIn.Tooltips" xmlns:local="clr-namespace:Debugger.AddIn.Tooltips"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
> >
<LinearGradientBrush x:Key="OrangeBrushKey" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="OrangeBrushKey" EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops> <LinearGradientBrush.GradientStops>
@ -334,4 +335,29 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<ControlTemplate x:Key="RefreshButton" TargetType="Button">
<Border
Name="ImageBorder"
CornerRadius="7"
BorderBrush="Transparent"
BorderThickness="1"
Height="14"
Width="14">
<Image Width="9" Height="9" Margin="2 2"
x:Name="RefreshContentImage"
Tag="{Binding}"
Source="{core:GetBitmap Icons.16x16.Refresh}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="true">
<Setter TargetName="ImageBorder" Property="Background" Value="{StaticResource SilverBrushKey}"/>
<Setter TargetName="ImageBorder" Property="BorderBrush" Value="Gray"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="ImageBorder" Property="Background" Value="{StaticResource SilverPressedBrushKey}"/>
<Setter TargetName="ImageBorder" Property="BorderBrush" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ResourceDictionary> </ResourceDictionary>

26
src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml

@ -1,9 +1,7 @@
<UserControl x:Class="Debugger.AddIn.Tooltips.PinDebuggerControl" <UserControl x:Class="Debugger.AddIn.Tooltips.PinDebuggerControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:Debugger.AddIn.Tooltips" xmlns:local="clr-namespace:Debugger.AddIn.Tooltips"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
>
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@ -198,27 +196,7 @@
<DataGridTemplateColumn> <DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Border <Button Click="Button_Click" Template="{StaticResource RefreshButton}"/>
Name="ImageBorder"
CornerRadius="7"
BorderBrush="Transparent"
BorderThickness="1"
Height="14"
Width="14">
<Image Width="9" Height="9" Margin="2 2"
x:Name="RefreshContentImage"
MouseDown="RefreshContentImage_MouseDown"
Tag="{Binding}"
Source="{core:GetBitmap Icons.16x16.Refresh}"/>
</Border>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter
TargetName="ImageBorder"
Property="BorderBrush"
Value="Gray" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>

58
src/AddIns/Debugger/Debugger.AddIn/Tooltips/PinDebuggerControl.xaml.cs

@ -286,11 +286,39 @@ namespace Debugger.AddIn.Tooltips
} }
} }
void OnLoaded(object sender, RoutedEventArgs e) private void OnLoaded(object sender, RoutedEventArgs e)
{ {
this.CommentTextBox.Text = Mark.Comment; this.CommentTextBox.Text = Mark.Comment;
} }
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!DebuggerService.IsDebuggerStarted)
return;
// refresh content
ITreeNode node = ((FrameworkElement)e.OriginalSource).DataContext as ITreeNode;
var resultNode = currentDebugger.GetNode(node.FullName, node.ImageName);
if (resultNode == null)
return;
// HACK for updating the pins in tooltip
var observable = new ObservableCollection<ITreeNode>();
var source = lazyGrid.ItemsSource;
source.ForEach(item => {
if (item.CompareTo(node) == 0)
observable.Add(resultNode);
else
observable.Add(item);
});
Mark.Nodes = observable;
// update UI
var newSource = new VirtualizingIEnumerable<ITreeNode>(observable);
lazyGrid.ItemsSource = newSource;
lazyExpandersGrid.ItemsSource = newSource;
}
#region Comment #region Comment
void ShowComment(bool show) void ShowComment(bool show)
@ -320,34 +348,6 @@ namespace Debugger.AddIn.Tooltips
#endregion #endregion
void RefreshContentImage_MouseDown(object sender, MouseButtonEventArgs e)
{
if (!DebuggerService.IsDebuggerStarted)
return;
// refresh content
ITreeNode node = ((Image)sender).DataContext as ITreeNode;
var resultNode = currentDebugger.GetNode(node.FullName, node.ImageName);
if (resultNode == null)
return;
// HACK for updating the pins in tooltip
var observable = new ObservableCollection<ITreeNode>();
var source = lazyGrid.ItemsSource;
source.ForEach(item => {
if (item.CompareTo(node) == 0)
observable.Add(resultNode);
else
observable.Add(item);
});
Mark.Nodes = observable;
// update UI
var newSource = new VirtualizingIEnumerable<ITreeNode>(observable);
lazyGrid.ItemsSource = newSource;
lazyExpandersGrid.ItemsSource = newSource;
}
#region Overrides #region Overrides
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e) protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)

Loading…
Cancel
Save