Browse Source

ClipboardRingPopup support for long entries - skeleton

pull/289/head
Patryk Mikos 12 years ago
parent
commit
4fb28f4317
  1. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  2. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRing.cs
  3. 7
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingAction.cs
  4. 73
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs
  5. 8
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml
  6. 14
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml.cs
  7. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsHeaderedControl.xaml.cs
  8. 5
      src/Main/Base/Project/Editor/ContextActions/ContextActionViewModel.cs

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -89,6 +89,7 @@ @@ -89,6 +89,7 @@
<Compile Include="Src\ChangeMarkerMargin\LineChangeInfo.cs" />
<Compile Include="Src\ContextActions\ClipboardRing.cs" />
<Compile Include="Src\ContextActions\ClipboardRingAction.cs" />
<Compile Include="Src\ContextActions\ClipboardRingPopup.cs" />
<Compile Include="Src\ContextActions\ContextActionOptionPanelDoozer.cs" />
<Compile Include="Src\ContextActions\ContextActionOptions.xaml.cs">
<DependentUpon>ContextActionOptions.xaml</DependentUpon>

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRing.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -36,7 +36,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
var popupViewModel = new ContextActionsPopupViewModel();
popupViewModel.Title = MenuService.ConvertLabel(StringParser.Parse("${res:SharpDevelop.Refactoring.ClipboardRing}"));
popupViewModel.Actions = BuildClipboardRingData(context);
return new ContextActionsPopup { Actions = popupViewModel };
return new ClipboardRingPopup { Actions = popupViewModel };
}
static ObservableCollection<ContextActionViewModel> BuildClipboardRingData(EditorRefactoringContext context)

7
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingAction.cs

@ -16,6 +16,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -16,6 +16,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
public IEntity Entity { get; private set; }
public IContextActionProvider Provider { get { return null; } }
public ClipboardRingAction(string text)
{
string entry = text.Trim();
@ -26,11 +28,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -26,11 +28,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
this.Text = text;
}
public IContextActionProvider Provider
{
get { return null; }
}
public string GetDisplayName(EditorRefactoringContext context)
{
return DisplayName;

73
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// 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.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.SharpDevelop.Editor.ContextActions;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
{
public class ClipboardRingPopup : ContextActionsPopup
{
ToolTip toolTip;
public ClipboardRingPopup() : base()
{
this.toolTip = new ToolTip();
this.toolTip.PlacementTarget = this.ActionsControl;
this.toolTip.Placement = PlacementMode.Right;
this.toolTip.Closed += new RoutedEventHandler(ClipboardRingPopup_Closed);
this.ActionsControl.ActionExecuted += delegate
{
if(this.toolTip != null)
this.toolTip.IsOpen = false;
};
this.ActionsControl.ActionSelected += new RoutedEventHandler(ClipboardRingPopup_ActionSelected);
this.ActionsControl.ActionUnselected += new RoutedEventHandler(ClipboardRingPopup_ActionUnselected);
}
#region ToolTip handling
string ExtractTextFromEvent(RoutedEventArgs args)
{
var button = args.Source as Button;
if (button == null)
return null;
var command = button.Command as ContextActionCommand;
if (command == null)
return null;
var clipboardRingAction = command.ContextAction as ClipboardRingAction;
if (clipboardRingAction == null)
return null;
return clipboardRingAction.DisplayName;
}
void ClipboardRingPopup_ActionSelected(object sender, RoutedEventArgs e)
{
if (this.toolTip != null) {
var text = ExtractTextFromEvent(e);
this.toolTip.Content = text;
this.toolTip.IsOpen = (text != null);
}
}
void ClipboardRingPopup_ActionUnselected(object sender, RoutedEventArgs e)
{
}
void ClipboardRingPopup_Closed(object sender, RoutedEventArgs e)
{
if(toolTip != null)
toolTip.Content = null;
}
#endregion
}
}

8
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml

@ -66,7 +66,13 @@ @@ -66,7 +66,13 @@
<ControlTemplate TargetType="TreeViewItem">
<StackPanel>
<!-- ActionButtonClick event is used just to close the Popup -->
<Button Command="{Binding ActionCommand}" Style="{StaticResource ClearButton}" Click="ActionButtonClick">
<Button
Command="{Binding ActionCommand}"
Style="{StaticResource ClearButton}"
Click="ActionButtonClick"
GotFocus="ActionGotFocus"
LostFocus="ActionLostFocus"
>
<Border SnapsToDevicePixels="True">
<ContentPresenter Content="{TemplateBinding HeaderedContentControl.Header}" ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}" ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}" ContentSource="Header" Name="PART_Header"
HorizontalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />

14
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml.cs

@ -20,6 +20,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -20,6 +20,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
}
public event EventHandler ActionExecuted;
public event RoutedEventHandler ActionSelected;
public event RoutedEventHandler ActionUnselected;
public new void Focus()
{
@ -43,6 +45,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -43,6 +45,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
ActionExecuted(this, EventArgs.Empty);
}
void ActionGotFocus(object sender, RoutedEventArgs e)
{
if (ActionSelected != null)
ActionSelected(this, e);
}
void ActionLostFocus(object sender, RoutedEventArgs e)
{
if (ActionUnselected != null)
ActionUnselected(this, e);
}
public static readonly DependencyProperty ItemTemplateProperty =
DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(ContextActionsControl),
new FrameworkPropertyMetadata());

15
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsHeaderedControl.xaml.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
@ -10,7 +11,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -10,7 +11,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
/// Interaction logic for ContextActionsHeaderedControl.xaml
/// </summary>
public partial class ContextActionsHeaderedControl : UserControl
{
{
public ContextActionsHeaderedControl()
{
InitializeComponent();
@ -22,6 +23,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -22,6 +23,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
remove { this.ActionsTreeView.ActionExecuted -= value; }
}
public event RoutedEventHandler ActionSelected
{
add { this.ActionsTreeView.ActionSelected += value; }
remove { this.ActionsTreeView.ActionSelected -= value; }
}
public event RoutedEventHandler ActionUnselected
{
add { this.ActionsTreeView.ActionUnselected += value; }
remove { this.ActionsTreeView.ActionUnselected -= value; }
}
public new void Focus()
{
if (this.ActionsTreeView != null)

5
src/Main/Base/Project/Editor/ContextActions/ContextActionViewModel.cs

@ -84,6 +84,11 @@ namespace ICSharpCode.SharpDevelop.Editor.ContextActions @@ -84,6 +84,11 @@ namespace ICSharpCode.SharpDevelop.Editor.ContextActions
remove { }
}
public IContextAction ContextAction
{
get { return action; }
}
public void Execute(object parameter)
{
if (action.Provider != null)

Loading…
Cancel
Save