5 changed files with 141 additions and 0 deletions
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.RightClickContextMenu" |
||||
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer" |
||||
> |
||||
<MenuItem Header="{Binding SendToFrontText, Source={x:Static Translation:Translations.Instance}}" Click="Click_BringToFront" /> |
||||
<MenuItem Header="{Binding SendForward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Forward" /> |
||||
<MenuItem Header="{Binding SendBackward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Backward" /> |
||||
<MenuItem Header="{Binding SendToBack, Source={x:Static Translation:Translations.Instance}}" Click="Click_SendToBack" /> |
||||
</ContextMenu> |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// 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.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.Imaging; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Shapes; |
||||
using ICSharpCode.WpfDesign.PropertyGrid; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
public partial class RightClickContextMenu |
||||
{ |
||||
private DesignItem designItem; |
||||
|
||||
public RightClickContextMenu(DesignItem designItem) |
||||
{ |
||||
this.designItem = designItem; |
||||
|
||||
InitializeComponent(); |
||||
} |
||||
|
||||
void Click_BringToFront(object sender, RoutedEventArgs e) |
||||
{ |
||||
var collection = this.designItem.ParentProperty.CollectionElements; |
||||
collection.Remove(this.designItem); |
||||
collection.Add(this.designItem); |
||||
} |
||||
|
||||
void Click_SendToBack(object sender, RoutedEventArgs e) |
||||
{ |
||||
var collection = this.designItem.ParentProperty.CollectionElements; |
||||
collection.Remove(this.designItem); |
||||
collection.Insert(0, this.designItem); |
||||
} |
||||
|
||||
void Click_Backward(object sender, RoutedEventArgs e) |
||||
{ |
||||
var collection = this.designItem.ParentProperty.CollectionElements; |
||||
var idx = collection.IndexOf(this.designItem); |
||||
collection.RemoveAt(idx); |
||||
collection.Insert((--idx < 0 ? 0: idx), this.designItem); |
||||
} |
||||
|
||||
void Click_Forward(object sender, RoutedEventArgs e) |
||||
{ |
||||
var collection = this.designItem.ParentProperty.CollectionElements; |
||||
var idx = collection.IndexOf(this.designItem); |
||||
collection.RemoveAt(idx); |
||||
var cnt = collection.Count; |
||||
collection.Insert((++idx > cnt ? cnt : idx), this.designItem); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// 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.Media; |
||||
using System.Windows.Shapes; |
||||
|
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
using ICSharpCode.WpfDesign.Designer; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[ExtensionFor(typeof(UIElement))] |
||||
public sealed class RightClickContextMenuExtension : PrimarySelectionAdornerProvider |
||||
{ |
||||
DesignPanel panel; |
||||
|
||||
protected override void OnInitialized() |
||||
{ |
||||
base.OnInitialized(); |
||||
|
||||
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel; |
||||
panel.ContextMenu = new RightClickContextMenu(ExtendedItem); |
||||
} |
||||
|
||||
protected override void OnRemove() |
||||
{ |
||||
panel.ContextMenu = null; |
||||
|
||||
base.OnRemove(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue