Conflicts: src/AddIns/Analysis/MachineSpecifications/MachineSpecifications.Tests/Properties/AssemblyInfo.cs src/AddIns/Analysis/MachineSpecifications/MachineSpecifications.Tests/Src/ClassFilterBuilder.cs src/AddIns/Analysis/MachineSpecifications/MachineSpecifications.Tests/Src/MSpecTestFrameworkTests.cs src/AddIns/Analysis/UnitTesting/Src/InnerClassEnumerator.cs src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/BuildOptions.xaml.cs src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildAdvanced.xaml.cs src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs src/Main/Base/Project/Src/Util/ExtensionMethods.cs src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj src/Main/GlobalAssemblyInfo.templatepull/59/merge
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using ICSharpCode.WpfDesign.XamlDom; |
||||
|
||||
namespace ICSharpCode.XamlDesigner |
||||
{ |
||||
public class MyTypeFinder : XamlTypeFinder |
||||
{ |
||||
public override Assembly LoadAssembly(string name) |
||||
{ |
||||
foreach (var assemblyNode in Toolbox.Instance.AssemblyNodes) |
||||
{ |
||||
if (assemblyNode.Name == name) |
||||
return assemblyNode.Assembly; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public override XamlTypeFinder Clone() |
||||
{ |
||||
return _instance; |
||||
} |
||||
|
||||
private static object lockObj = new object(); |
||||
|
||||
private static MyTypeFinder _instance; |
||||
public static MyTypeFinder Instance |
||||
{ |
||||
get |
||||
{ |
||||
lock (lockObj) |
||||
{ |
||||
if (_instance == null) |
||||
{ |
||||
_instance = new MyTypeFinder(); |
||||
_instance.ImportFrom(CreateWpfTypeFinder()); |
||||
} |
||||
} |
||||
|
||||
return _instance; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// 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 ICSharpCode.Core; |
||||
using System; |
||||
using ICSharpCode.WpfDesign.Designer; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SharpDevelopTranslations.
|
||||
/// </summary>
|
||||
public class SharpDevelopTranslations : Translations |
||||
{ |
||||
public override string PressAltText { |
||||
get { return StringParser.Parse("${res:AddIns.WpfDesign.AddIn.PressAltText}"); } |
||||
} |
||||
|
||||
public static void Init() { |
||||
Instance = new SharpDevelopTranslations(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.WpfDesign.Designer.ThumbnailView; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
public class ThumbnailViewPad : AbstractPadContent |
||||
{ |
||||
ContentPresenter contentControl = new ContentPresenter(); |
||||
|
||||
ThumbnailView thumbnailView = new ThumbnailView(); |
||||
|
||||
TextBlock notAvailableTextBlock = new TextBlock { |
||||
Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.OutlinePad.NotAvailable}"), |
||||
TextWrapping = TextWrapping.Wrap |
||||
}; |
||||
|
||||
public ThumbnailViewPad() |
||||
{ |
||||
SD.Workbench.ActiveViewContentChanged += WorkbenchActiveViewContentChanged; |
||||
WorkbenchActiveViewContentChanged(null, null); |
||||
} |
||||
|
||||
void WorkbenchActiveViewContentChanged(object sender, EventArgs e) |
||||
{ |
||||
WpfViewContent wpfView = SD.Workbench.ActiveViewContent as WpfViewContent; |
||||
if (wpfView != null) |
||||
{ |
||||
thumbnailView.DesignSurface = wpfView.DesignSurface; |
||||
SD.WinForms.SetContent(contentControl, thumbnailView); |
||||
} else { |
||||
SD.WinForms.SetContent(contentControl, notAvailableTextBlock); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get { |
||||
return contentControl; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,218 @@
@@ -0,0 +1,218 @@
|
||||
// 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.Input; |
||||
using System.Globalization; |
||||
using System.ComponentModel; |
||||
using System.Diagnostics; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.Media3D; |
||||
using System.Windows.Shapes; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// Adorner that displays the margin of a control in a Grid.
|
||||
/// </summary>
|
||||
public class CanvasPositionHandle : MarginHandle |
||||
{ |
||||
static CanvasPositionHandle() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(CanvasPositionHandle), new FrameworkPropertyMetadata(typeof(CanvasPositionHandle))); |
||||
HandleLengthOffset=2; |
||||
} |
||||
|
||||
private Path line1; |
||||
private Path line2; |
||||
public override void OnApplyTemplate() |
||||
{ |
||||
line1 = GetTemplateChild("line1") as Path; |
||||
line2 = GetTemplateChild("line2") as Path; |
||||
|
||||
base.OnApplyTemplate(); |
||||
} |
||||
|
||||
readonly Canvas canvas; |
||||
readonly DesignItem adornedControlItem; |
||||
readonly AdornerPanel adornerPanel; |
||||
readonly HandleOrientation orientation; |
||||
readonly FrameworkElement adornedControl; |
||||
|
||||
/// <summary> This grid contains the handle line and the endarrow.</summary>
|
||||
Grid lineArrow; |
||||
|
||||
private DependencyPropertyDescriptor leftDescriptor; |
||||
private DependencyPropertyDescriptor rightDescriptor; |
||||
private DependencyPropertyDescriptor topDescriptor; |
||||
private DependencyPropertyDescriptor bottomDescriptor; |
||||
private DependencyPropertyDescriptor widthDescriptor; |
||||
private DependencyPropertyDescriptor heightDescriptor; |
||||
|
||||
public CanvasPositionHandle(DesignItem adornedControlItem, AdornerPanel adornerPanel, HandleOrientation orientation) |
||||
{ |
||||
Debug.Assert(adornedControlItem != null); |
||||
this.adornedControlItem = adornedControlItem; |
||||
this.adornerPanel = adornerPanel; |
||||
this.orientation = orientation; |
||||
|
||||
Angle = (double) orientation; |
||||
|
||||
canvas = (Canvas) adornedControlItem.Parent.Component; |
||||
adornedControl = (FrameworkElement) adornedControlItem.Component; |
||||
Stub = new MarginStub(this); |
||||
ShouldBeVisible = true; |
||||
|
||||
leftDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.LeftProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
leftDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
rightDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.RightProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
rightDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
topDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.TopProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
topDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
bottomDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.BottomProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
bottomDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
widthDescriptor = DependencyPropertyDescriptor.FromProperty(Control.WidthProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
widthDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
heightDescriptor = DependencyPropertyDescriptor.FromProperty(Control.WidthProperty, |
||||
adornedControlItem.Component.GetType()); |
||||
heightDescriptor.AddValueChanged(adornedControl, OnPropertyChanged); |
||||
BindAndPlaceHandle(); |
||||
} |
||||
|
||||
|
||||
void OnPropertyChanged(object sender, EventArgs e) |
||||
{ |
||||
BindAndPlaceHandle(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the angle by which the Canvas display has to be rotated
|
||||
/// </summary>
|
||||
public override double TextTransform |
||||
{ |
||||
get |
||||
{ |
||||
if ((double)orientation == 90 || (double)orientation == 180) |
||||
return 180; |
||||
if ((double)orientation == 270) |
||||
return 0; |
||||
return (double)orientation; |
||||
} |
||||
set { } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Binds the <see cref="HandleLength"/> to the margin and place the handles.
|
||||
/// </summary>
|
||||
void BindAndPlaceHandle() |
||||
{ |
||||
if (!adornerPanel.Children.Contains(this)) |
||||
adornerPanel.Children.Add(this); |
||||
if (!adornerPanel.Children.Contains(Stub)) |
||||
adornerPanel.Children.Add(Stub); |
||||
RelativePlacement placement=new RelativePlacement(); |
||||
switch (orientation) |
||||
{ |
||||
case HandleOrientation.Left: |
||||
{ |
||||
var wr = (double) leftDescriptor.GetValue(adornedControl); |
||||
if (double.IsNaN(wr)) |
||||
{ |
||||
wr = (double) rightDescriptor.GetValue(adornedControl); |
||||
wr = canvas.ActualWidth - (adornedControl.ActualWidth + wr); |
||||
} |
||||
else |
||||
{ |
||||
if (line1 != null) |
||||
{ |
||||
line1.StrokeDashArray.Clear(); |
||||
line2.StrokeDashArray.Clear(); |
||||
} |
||||
} |
||||
this.HandleLength = wr; |
||||
placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center); |
||||
placement.XOffset = -HandleLengthOffset; |
||||
break; |
||||
} |
||||
case HandleOrientation.Top: |
||||
{ |
||||
var wr = (double)topDescriptor.GetValue(adornedControl); |
||||
if (double.IsNaN(wr)) |
||||
{ |
||||
wr = (double)bottomDescriptor.GetValue(adornedControl); |
||||
wr = canvas.ActualHeight - (adornedControl.ActualHeight + wr); |
||||
} |
||||
else |
||||
{ |
||||
if (line1 != null) |
||||
{ |
||||
line1.StrokeDashArray.Clear(); |
||||
line2.StrokeDashArray.Clear(); |
||||
} |
||||
} |
||||
this.HandleLength = wr; |
||||
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top); |
||||
placement.YOffset = -HandleLengthOffset; |
||||
break; |
||||
} |
||||
case HandleOrientation.Right: |
||||
{ |
||||
var wr = (double) rightDescriptor.GetValue(adornedControl); |
||||
if (double.IsNaN(wr)) |
||||
{ |
||||
wr = (double) leftDescriptor.GetValue(adornedControl); |
||||
wr = canvas.ActualWidth - (adornedControl.ActualWidth + wr); |
||||
} |
||||
else |
||||
{ |
||||
if (line1 != null) |
||||
{ |
||||
line1.StrokeDashArray.Clear(); |
||||
line2.StrokeDashArray.Clear(); |
||||
} |
||||
} |
||||
this.HandleLength = wr; |
||||
placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Center); |
||||
placement.XOffset = HandleLengthOffset; |
||||
break; |
||||
} |
||||
case HandleOrientation.Bottom: |
||||
{ |
||||
var wr = (double)bottomDescriptor.GetValue(adornedControl); |
||||
if (double.IsNaN(wr)) |
||||
{ |
||||
wr = (double)topDescriptor.GetValue(adornedControl); |
||||
wr = canvas.ActualHeight - (adornedControl.ActualHeight + wr); |
||||
} |
||||
else |
||||
{ |
||||
if (line1 != null) |
||||
{ |
||||
line1.StrokeDashArray.Clear(); |
||||
line2.StrokeDashArray.Clear(); |
||||
} |
||||
} |
||||
this.HandleLength = wr; |
||||
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Bottom); |
||||
placement.YOffset = HandleLengthOffset; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
AdornerPanel.SetPlacement(this, placement); |
||||
this.Visibility = Visibility.Visible; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
// 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.Input; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||
{ |
||||
public class ClearableTextBox : EnterTextBox |
||||
{ |
||||
private Button textRemoverButton; |
||||
|
||||
static ClearableTextBox() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof (ClearableTextBox), |
||||
new FrameworkPropertyMetadata(typeof (ClearableTextBox))); |
||||
} |
||||
|
||||
public ClearableTextBox() |
||||
{ |
||||
this.GotFocus += this.TextBoxGotFocus; |
||||
this.LostFocus += this.TextBoxLostFocus; |
||||
this.TextChanged += this.TextBoxTextChanged; |
||||
this.KeyUp += this.ClearableTextBox_KeyUp; |
||||
} |
||||
|
||||
void ClearableTextBox_KeyUp(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Escape) |
||||
this.TextRemoverClick(sender, null); |
||||
} |
||||
|
||||
public override void OnApplyTemplate() |
||||
{ |
||||
base.OnApplyTemplate(); |
||||
|
||||
this.textRemoverButton = this.GetTemplateChild("TextRemover") as Button; |
||||
if (null != this.textRemoverButton) |
||||
{ |
||||
this.textRemoverButton.Click += this.TextRemoverClick; |
||||
} |
||||
|
||||
this.UpdateState(); |
||||
} |
||||
|
||||
protected void UpdateState() |
||||
{ |
||||
if (string.IsNullOrEmpty(this.Text)) |
||||
{ |
||||
VisualStateManager.GoToState(this, "TextRemoverHidden", true); |
||||
} |
||||
else |
||||
{ |
||||
VisualStateManager.GoToState(this, "TextRemoverVisible", true); |
||||
} |
||||
} |
||||
|
||||
private void TextBoxTextChanged(object sender, TextChangedEventArgs e) |
||||
{ |
||||
this.UpdateState(); |
||||
} |
||||
|
||||
private void TextRemoverClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.Text = string.Empty; |
||||
this.Focus(); |
||||
} |
||||
|
||||
private void TextBoxGotFocus(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.UpdateState(); |
||||
} |
||||
|
||||
private void TextBoxLostFocus(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.UpdateState(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,101 @@
@@ -0,0 +1,101 @@
|
||||
// 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.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Media; |
||||
using System.Windows.Threading; |
||||
using System.Windows.Media.Animation; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Designer.Services; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// Gray out everything except a specific area.
|
||||
/// </summary>
|
||||
sealed class InfoTextEnterArea : FrameworkElement |
||||
{ |
||||
Geometry designSurfaceRectangle; |
||||
Geometry activeAreaGeometry; |
||||
Geometry combinedGeometry; |
||||
AdornerPanel adornerPanel; |
||||
IDesignPanel designPanel; |
||||
const double MaxOpacity = 0.3; |
||||
|
||||
public InfoTextEnterArea() |
||||
{ |
||||
this.IsHitTestVisible = false; |
||||
} |
||||
|
||||
public Geometry ActiveAreaGeometry { |
||||
get { return activeAreaGeometry; } |
||||
set { |
||||
activeAreaGeometry = value; |
||||
combinedGeometry = activeAreaGeometry; |
||||
} |
||||
} |
||||
|
||||
Rect currentAnimateActiveAreaRectToTarget; |
||||
|
||||
internal void AnimateActiveAreaRectTo(Rect newRect) |
||||
{ |
||||
if (newRect.Equals(currentAnimateActiveAreaRectToTarget)) |
||||
return; |
||||
activeAreaGeometry.BeginAnimation( |
||||
RectangleGeometry.RectProperty, |
||||
new RectAnimation(newRect, new Duration(new TimeSpan(0,0,0,0,100))), |
||||
HandoffBehavior.SnapshotAndReplace); |
||||
currentAnimateActiveAreaRectToTarget = newRect; |
||||
} |
||||
|
||||
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, string text) |
||||
{ |
||||
Debug.Assert(activeContainer != null); |
||||
Start(ref grayOut, services, activeContainer, new Rect(activeContainer.RenderSize), text); |
||||
} |
||||
|
||||
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text) |
||||
{ |
||||
Debug.Assert(services != null); |
||||
Debug.Assert(activeContainer != null); |
||||
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel; |
||||
OptionService optionService = services.GetService<OptionService>(); |
||||
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) { |
||||
grayOut = new InfoTextEnterArea(); |
||||
grayOut.designSurfaceRectangle = new RectangleGeometry( |
||||
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height)); |
||||
grayOut.designPanel = designPanel; |
||||
grayOut.adornerPanel = new AdornerPanel(); |
||||
grayOut.adornerPanel.Order = AdornerOrder.Background; |
||||
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null); |
||||
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement)); |
||||
var tb = new TextBlock(){Text = text}; |
||||
tb.FontSize = 10; |
||||
tb.ClipToBounds = true; |
||||
tb.Width = ((FrameworkElement) activeContainer).ActualWidth; |
||||
tb.Height = ((FrameworkElement) activeContainer).ActualHeight; |
||||
tb.VerticalAlignment = VerticalAlignment.Top; |
||||
tb.HorizontalAlignment = HorizontalAlignment.Left; |
||||
tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement); |
||||
grayOut.adornerPanel.Children.Add(tb); |
||||
|
||||
designPanel.Adorners.Add(grayOut.adornerPanel); |
||||
} |
||||
} |
||||
|
||||
static readonly TimeSpan animationTime = new TimeSpan(2000000); |
||||
|
||||
internal static void Stop(ref InfoTextEnterArea grayOut) |
||||
{ |
||||
if (grayOut != null) { |
||||
IDesignPanel designPanel = grayOut.designPanel; |
||||
AdornerPanel adornerPanelToRemove = grayOut.adornerPanel; |
||||
designPanel.Adorners.Remove(adornerPanelToRemove); |
||||
grayOut = null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// 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.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Controls.Primitives; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// Description of RenderTransformThumb.
|
||||
/// </summary>
|
||||
public class RenderTransformOriginThumb : Thumb |
||||
{ |
||||
static RenderTransformOriginThumb() |
||||
{ |
||||
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
|
||||
//This style is defined in themes\generic.xaml
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(RenderTransformOriginThumb), new FrameworkPropertyMetadata(typeof(RenderTransformOriginThumb))); |
||||
} |
||||
} |
||||
} |
@ -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.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Designer.Extensions; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||
{ |
||||
public class RotateThumb : ResizeThumb |
||||
{ |
||||
private double initialAngle; |
||||
private RotateTransform rotateTransform; |
||||
private Vector startVector; |
||||
private Point centerPoint; |
||||
private Control designerItem; |
||||
private Panel canvas; |
||||
private AdornerPanel parent; |
||||
|
||||
static RotateThumb() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(RotateThumb), new FrameworkPropertyMetadata(typeof(RotateThumb))); |
||||
} |
||||
|
||||
public RotateThumb() |
||||
{ |
||||
this.ResizeThumbVisible = true; |
||||
} |
||||
} |
||||
} |
@ -1,14 +1,38 @@
@@ -1,14 +1,38 @@
|
||||
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.DesignSurface" |
||||
<ResourceDictionary |
||||
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:Default="clr-namespace:ICSharpCode.WpfDesign.Designer" |
||||
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" |
||||
DataContext="{x:Null}" |
||||
Background="#888"> |
||||
<Controls:ZoomControl x:Name="uxZoom" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> |
||||
<Default:DesignPanel x:Name="_designPanel"> |
||||
<!-- Reset some inherited properties to the WPF defaults to avoid values from SharpDevelop applying to designed forms. --> |
||||
<Border x:Name="_sceneContainer" AllowDrop="False" UseLayoutRounding="False" TextOptions.TextFormattingMode="Ideal" /> |
||||
</Default:DesignPanel> |
||||
xmlns:Designer="clr-namespace:ICSharpCode.WpfDesign.Designer" |
||||
xmlns:Widgets="http://icsharpcode.net/sharpdevelop/widgets"> |
||||
<Style TargetType="{x:Type Designer:DesignSurface}"> |
||||
<Setter Property="Template"> |
||||
<Setter.Value> |
||||
<ControlTemplate TargetType="{x:Type Designer:DesignSurface}"> |
||||
<Controls:ZoomControl Background="#888" x:Name="PART_Zoom" MinimumZoom="0.025" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> |
||||
<Controls:ZoomControl.AdditionalControls> |
||||
<StackPanel Orientation="Horizontal" Margin="0"> |
||||
<Controls:EnumButton BorderThickness="0" DataContext="{Binding ElementName=PART_DesignContent}" Margin="0" Height="16" Width="16" IsChecked="{Binding ElementName=PART_DesignContent, Path=Content.UseRasterPlacement, Mode=TwoWay}" ToolTip="Use Raster Placement"> |
||||
<Controls:EnumButton.ContextMenu> |
||||
<ContextMenu DataContext="{Binding PlacementTarget.DataContext,RelativeSource={RelativeSource Self}}"> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<TextBlock Text="RasterWidth:" /> |
||||
<Widgets:NumericUpDown Width="40" Margin="5,0,0,0" Value="{Binding Path=Content.RasterWidth, Mode=TwoWay}"/> |
||||
</StackPanel> |
||||
</ContextMenu> |
||||
</Controls:EnumButton.ContextMenu> |
||||
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.GridSnap.png" Stretch="Uniform" /> |
||||
</Controls:EnumButton> |
||||
<Controls:EnumButton BorderThickness="0" Margin="0" Height="16" Width="16" IsChecked="{Binding ElementName=PART_DesignContent, Path=Content.UseSnaplinePlacement, Mode=TwoWay}" ToolTip="Use Snapline Placement"> |
||||
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.GuideSnap.png" Stretch="Uniform" /> |
||||
</Controls:EnumButton> |
||||
</StackPanel> |
||||
</Controls:ZoomControl.AdditionalControls> |
||||
|
||||
<ContentControl x:Name="PART_DesignContent" /> |
||||
</Controls:ZoomControl> |
||||
</UserControl> |
||||
</ControlTemplate> |
||||
</Setter.Value> |
||||
</Setter> |
||||
</Style> |
||||
</ResourceDictionary> |
||||
|
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// 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.Input; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Designer.Controls; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
[ExtensionFor(typeof(FrameworkElement))] |
||||
[ExtensionServer(typeof(PrimarySelectionExtensionServer))] |
||||
public class CanvasPositionExtension : AdornerProvider |
||||
{ |
||||
private MarginHandle[] _handles; |
||||
private MarginHandle _leftHandle, _topHandle, _rightHandle, _bottomHandle; |
||||
private Canvas _canvas; |
||||
|
||||
protected override void OnInitialized() |
||||
{ |
||||
base.OnInitialized(); |
||||
if (this.ExtendedItem.Parent != null) |
||||
{ |
||||
if (this.ExtendedItem.Parent.ComponentType == typeof(Canvas)) |
||||
{ |
||||
FrameworkElement extendedControl = (FrameworkElement)this.ExtendedItem.Component; |
||||
AdornerPanel adornerPanel = new AdornerPanel(); |
||||
|
||||
// If the Element is rotated/skewed in the grid, then margin handles do not appear
|
||||
if (extendedControl.LayoutTransform.Value == Matrix.Identity && extendedControl.RenderTransform.Value == Matrix.Identity) |
||||
{ |
||||
_canvas = this.ExtendedItem.Parent.View as Canvas; |
||||
_handles = new[] |
||||
{ |
||||
_leftHandle = new CanvasPositionHandle(ExtendedItem, adornerPanel, HandleOrientation.Left), |
||||
_topHandle = new CanvasPositionHandle(ExtendedItem, adornerPanel, HandleOrientation.Top), |
||||
_rightHandle = new CanvasPositionHandle(ExtendedItem, adornerPanel, HandleOrientation.Right), |
||||
_bottomHandle = new CanvasPositionHandle(ExtendedItem, adornerPanel, HandleOrientation.Bottom), |
||||
}; |
||||
} |
||||
|
||||
if (adornerPanel != null) |
||||
this.Adorners.Add(adornerPanel); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void HideHandles() |
||||
{ |
||||
if (_handles != null) |
||||
{ |
||||
foreach (var handle in _handles) |
||||
{ |
||||
handle.ShouldBeVisible = false; |
||||
handle.Visibility = Visibility.Hidden; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void ShowHandles() |
||||
{ |
||||
if (_handles != null) |
||||
{ |
||||
foreach (var handle in _handles) |
||||
{ |
||||
handle.ShouldBeVisible = true; |
||||
handle.Visibility = Visibility.Visible; |
||||
handle.DecideVisiblity(handle.HandleLength); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
// 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.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Shapes; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Designer.Controls; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
public class RasterPlacementBehavior : DefaultPlacementBehavior |
||||
{ |
||||
Canvas surface; |
||||
AdornerPanel adornerPanel; |
||||
bool rasterDrawn = false; |
||||
int raster = 5; |
||||
|
||||
public override void BeginPlacement(PlacementOperation operation) |
||||
{ |
||||
base.BeginPlacement(operation); |
||||
|
||||
DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; |
||||
if (designPanel != null) |
||||
raster = designPanel.RasterWidth; |
||||
|
||||
CreateSurface(operation); |
||||
} |
||||
|
||||
public override void EndPlacement(PlacementOperation operation) |
||||
{ |
||||
base.EndPlacement(operation); |
||||
DeleteSurface(); |
||||
} |
||||
|
||||
public override void EnterContainer(PlacementOperation operation) |
||||
{ |
||||
base.EnterContainer(operation); |
||||
CreateSurface(operation); |
||||
} |
||||
|
||||
public override void LeaveContainer(PlacementOperation operation) |
||||
{ |
||||
base.LeaveContainer(operation); |
||||
DeleteSurface(); |
||||
} |
||||
|
||||
void CreateSurface(PlacementOperation operation) |
||||
{ |
||||
if (ExtendedItem.Services.GetService<IDesignPanel>() != null) |
||||
{ |
||||
surface = new Canvas(); |
||||
adornerPanel = new AdornerPanel(); |
||||
adornerPanel.SetAdornedElement(ExtendedItem.View, ExtendedItem); |
||||
AdornerPanel.SetPlacement(surface, AdornerPlacement.FillContent); |
||||
adornerPanel.Children.Add(surface); |
||||
ExtendedItem.Services.DesignPanel.Adorners.Add(adornerPanel); |
||||
} |
||||
} |
||||
|
||||
void DeleteSurface() |
||||
{ |
||||
rasterDrawn = false; |
||||
if (surface != null) |
||||
{ |
||||
ExtendedItem.Services.DesignPanel.Adorners.Remove(adornerPanel); |
||||
adornerPanel = null; |
||||
surface = null; |
||||
} |
||||
} |
||||
|
||||
public override void BeforeSetPosition(PlacementOperation operation) |
||||
{ |
||||
base.BeforeSetPosition(operation); |
||||
if (surface == null) return; |
||||
|
||||
DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; |
||||
if (designPanel == null || !designPanel.UseRasterPlacement) |
||||
return; |
||||
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl)) |
||||
{ |
||||
surface.Children.Clear(); |
||||
rasterDrawn = false; |
||||
return; |
||||
} |
||||
|
||||
drawRaster(); |
||||
|
||||
var bounds = operation.PlacedItems[0].Bounds; |
||||
bounds.Y = ((int)bounds.Y/raster)*raster; |
||||
bounds.X = ((int)bounds.X/raster)*raster; |
||||
bounds.Width = Convert.ToInt32((bounds.Width/raster))*raster; |
||||
bounds.Height = Convert.ToInt32((bounds.Height/raster))*raster; |
||||
operation.PlacedItems[0].Bounds = bounds; |
||||
} |
||||
|
||||
private void drawRaster() |
||||
{ |
||||
if (!rasterDrawn) |
||||
{ |
||||
rasterDrawn = true; |
||||
|
||||
var w = ModelTools.GetWidth(ExtendedItem.View); |
||||
var h = ModelTools.GetHeight(ExtendedItem.View); |
||||
var dash = new DoubleCollection() {1, raster - 1}; |
||||
for (int i = 0; i <= h; i += raster) |
||||
{ |
||||
var line = new Line() |
||||
{ |
||||
X1 = 0, |
||||
Y1 = i, |
||||
X2 = w, |
||||
Y2 = i, |
||||
StrokeThickness = 1, |
||||
Stroke = Brushes.Black, |
||||
StrokeDashArray = dash, |
||||
}; |
||||
surface.Children.Add(line); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// 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.ComponentModel; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.WpfDesign.Designer.Controls; |
||||
using System.Windows.Media; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
[ExtensionFor(typeof(FrameworkElement))] |
||||
public class RenderTransformOriginExtension : SelectionAdornerProvider |
||||
{ |
||||
readonly AdornerPanel adornerPanel; |
||||
RenderTransformOriginThumb renderTransformOriginThumb; |
||||
/// <summary>An array containing this.ExtendedItem as only element</summary>
|
||||
readonly DesignItem[] extendedItemArray = new DesignItem[1]; |
||||
IPlacementBehavior resizeBehavior; |
||||
PlacementOperation operation; |
||||
ChangeGroup changeGroup; |
||||
|
||||
public RenderTransformOriginExtension() |
||||
{ |
||||
adornerPanel = new AdornerPanel(); |
||||
adornerPanel.Order = AdornerOrder.Foreground; |
||||
this.Adorners.Add(adornerPanel); |
||||
|
||||
CreateRenderTransformOriginThumb(); |
||||
} |
||||
|
||||
void CreateRenderTransformOriginThumb() |
||||
{ |
||||
renderTransformOriginThumb = new RenderTransformOriginThumb(); |
||||
renderTransformOriginThumb.Cursor = Cursors.Hand; |
||||
|
||||
AdornerPanel.SetPlacement(renderTransformOriginThumb, |
||||
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top){XRelativeToContentWidth = renderTransformOrigin.X, YRelativeToContentHeight = renderTransformOrigin.Y}); |
||||
adornerPanel.Children.Add(renderTransformOriginThumb); |
||||
|
||||
renderTransformOriginThumb.DragDelta += new DragDeltaEventHandler(renderTransformOriginThumb_DragDelta); |
||||
} |
||||
|
||||
void renderTransformOriginThumb_DragDelta(object sender, DragDeltaEventArgs e) |
||||
{ |
||||
var p = AdornerPanel.GetPlacement(renderTransformOriginThumb) as RelativePlacement; |
||||
var pointAbs = adornerPanel.RelativeToAbsolute(new Vector(p.XRelativeToContentWidth, p.YRelativeToContentHeight)); |
||||
var pointAbsNew = pointAbs + new Vector(e.HorizontalChange, e.VerticalChange); |
||||
var pRel = adornerPanel.AbsoluteToRelative(pointAbsNew); |
||||
|
||||
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(Math.Round(pRel.X, 4), Math.Round(pRel.Y, 4))); |
||||
} |
||||
|
||||
Point renderTransformOrigin = new Point(0.5, 0.5); |
||||
|
||||
DependencyPropertyDescriptor renderTransformOriginPropertyDescriptor; |
||||
|
||||
protected override void OnInitialized() |
||||
{ |
||||
base.OnInitialized(); |
||||
extendedItemArray[0] = this.ExtendedItem; |
||||
this.ExtendedItem.PropertyChanged += OnPropertyChanged; |
||||
|
||||
if (this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet) { |
||||
renderTransformOrigin = (Point)this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).ValueOnInstance; |
||||
} |
||||
|
||||
AdornerPanel.SetPlacement(renderTransformOriginThumb, |
||||
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top){XRelativeToContentWidth = renderTransformOrigin.X, YRelativeToContentHeight = renderTransformOrigin.Y}); |
||||
|
||||
renderTransformOriginPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(FrameworkElement.RenderTransformOriginProperty, typeof(FrameworkElement)); |
||||
renderTransformOriginPropertyDescriptor.AddValueChanged(this.ExtendedItem.Component, OnRenderTransformOriginPropertyChanged); |
||||
} |
||||
|
||||
private void OnRenderTransformOriginPropertyChanged(object sender, EventArgs e) |
||||
{ |
||||
var pRel = renderTransformOrigin; |
||||
if (this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet) |
||||
pRel = (Point)this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).ValueOnInstance; |
||||
|
||||
AdornerPanel.SetPlacement(renderTransformOriginThumb, |
||||
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top){ XRelativeToContentWidth = pRel.X, YRelativeToContentHeight = pRel.Y }); |
||||
|
||||
} |
||||
|
||||
void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) |
||||
{ } |
||||
|
||||
protected override void OnRemove() |
||||
{ |
||||
renderTransformOriginPropertyDescriptor.RemoveValueChanged(this.ExtendedItem.Component, OnRenderTransformOriginPropertyChanged); |
||||
|
||||
base.OnRemove(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
// 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.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
using ICSharpCode.WpfDesign.Designer.Controls; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
/// <summary>
|
||||
/// The resize thumb around a component.
|
||||
/// </summary>
|
||||
[ExtensionFor(typeof(FrameworkElement))] |
||||
public sealed class RotateThumbExtension : SelectionAdornerProvider |
||||
{ |
||||
readonly AdornerPanel adornerPanel; |
||||
readonly Thumb thumb; |
||||
/// <summary>An array containing this.ExtendedItem as only element</summary>
|
||||
readonly DesignItem[] extendedItemArray = new DesignItem[1]; |
||||
IPlacementBehavior resizeBehavior; |
||||
PlacementOperation operation; |
||||
ChangeGroup changeGroup; |
||||
|
||||
bool _isResizing; |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this extension is resizing any element.
|
||||
/// </summary>
|
||||
public bool IsResizing{ |
||||
get { return _isResizing; } |
||||
} |
||||
|
||||
public RotateThumbExtension() |
||||
{ |
||||
adornerPanel = new AdornerPanel(); |
||||
adornerPanel.Order = AdornerOrder.Foreground; |
||||
this.Adorners.Add(adornerPanel); |
||||
|
||||
thumb = CreateRotateThumb(); |
||||
} |
||||
|
||||
ResizeThumb CreateRotateThumb() |
||||
{ |
||||
ResizeThumb rotateThumb = new RotateThumb(); |
||||
rotateThumb.Cursor = Cursors.Hand; |
||||
rotateThumb.Cursor = ZoomControl.GetCursor("Images/rotate.cur"); |
||||
rotateThumb.Alignment = PlacementAlignment.Top; |
||||
AdornerPanel.SetPlacement(rotateThumb, |
||||
new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top) { WidthRelativeToContentWidth = 1, HeightOffset = 0 }); |
||||
adornerPanel.Children.Add(rotateThumb); |
||||
|
||||
DragListener drag = new DragListener(rotateThumb); |
||||
drag.Started += drag_Rotate_Started; |
||||
drag.Changed += drag_Rotate_Changed; |
||||
return rotateThumb; |
||||
} |
||||
|
||||
Size oldSize; |
||||
|
||||
#region Rotate
|
||||
|
||||
private Point centerPoint; |
||||
private UIElement parent; |
||||
private Vector startVector; |
||||
private RotateTransform rotateTransform; |
||||
private Point renderTransformOrigin; |
||||
private double initialAngle; |
||||
private DesignItem rtTransform; |
||||
private double angle; |
||||
|
||||
private void drag_Rotate_Started(DragListener drag) |
||||
{ |
||||
var designerItem = this.ExtendedItem.Component as FrameworkElement; |
||||
this.parent = VisualTreeHelper.GetParent(designerItem) as UIElement; |
||||
this.centerPoint = designerItem.TranslatePoint( |
||||
new Point(designerItem.ActualWidth*designerItem.RenderTransformOrigin.X, |
||||
designerItem.ActualHeight*designerItem.RenderTransformOrigin.Y), |
||||
this.parent); |
||||
|
||||
Point startPoint = Mouse.GetPosition(this.parent); |
||||
this.startVector = Point.Subtract(startPoint, this.centerPoint); |
||||
|
||||
if (this.rotateTransform == null) |
||||
{ |
||||
this.initialAngle = 0; |
||||
} |
||||
else |
||||
{ |
||||
this.initialAngle = this.rotateTransform.Angle; |
||||
} |
||||
|
||||
rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value; |
||||
|
||||
operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize); |
||||
} |
||||
|
||||
private void drag_Rotate_Changed(DragListener drag) |
||||
{ |
||||
Point currentPoint = Mouse.GetPosition(this.parent); |
||||
Vector deltaVector = Point.Subtract(currentPoint, this.centerPoint); |
||||
|
||||
double angle = Vector.AngleBetween(this.startVector, deltaVector); |
||||
|
||||
var destAngle = this.initialAngle + Math.Round(angle, 0); |
||||
|
||||
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) |
||||
destAngle = ((int)destAngle / 15) * 15; |
||||
|
||||
if (destAngle == 0) |
||||
{ |
||||
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset(); |
||||
rtTransform = null; |
||||
rotateTransform = null; |
||||
} |
||||
else |
||||
{ |
||||
if (rtTransform == null) |
||||
{ |
||||
if (!this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet) { |
||||
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5,0.5)); |
||||
} |
||||
|
||||
if (this.rotateTransform == null) |
||||
this.rotateTransform = new RotateTransform(0); |
||||
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(rotateTransform); |
||||
rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value; |
||||
} |
||||
rtTransform.Properties["Angle"].SetValue(destAngle); |
||||
this.angle = destAngle * Math.PI / 180.0; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnInitialized() |
||||
{ |
||||
if (this.ExtendedItem.Component is WindowClone) |
||||
return; |
||||
base.OnInitialized(); |
||||
extendedItemArray[0] = this.ExtendedItem; |
||||
this.ExtendedItem.PropertyChanged += OnPropertyChanged; |
||||
this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged; |
||||
resizeBehavior = PlacementOperation.GetPlacementBehavior(extendedItemArray); |
||||
OnPrimarySelectionChanged(null, null); |
||||
|
||||
var designerItem = this.ExtendedItem.Component as FrameworkElement; |
||||
this.rotateTransform = designerItem.RenderTransform as RotateTransform; |
||||
|
||||
if (rotateTransform != null) |
||||
angle = rotateTransform.Angle; |
||||
} |
||||
|
||||
void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) |
||||
{ } |
||||
|
||||
protected override void OnRemove() |
||||
{ |
||||
this.ExtendedItem.PropertyChanged -= OnPropertyChanged; |
||||
this.Services.Selection.PrimarySelectionChanged -= OnPrimarySelectionChanged; |
||||
base.OnRemove(); |
||||
} |
||||
|
||||
void OnPrimarySelectionChanged(object sender, EventArgs e) |
||||
{ |
||||
bool isPrimarySelection = this.Services.Selection.PrimarySelection == this.ExtendedItem; |
||||
foreach (RotateThumb g in adornerPanel.Children) { |
||||
g.IsPrimarySelection = isPrimarySelection; |
||||
} |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 535 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 571 B |
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Window |
||||
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FlatCollectionEditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:OutlineView="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView" xmlns:PropertyGrid="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid" |
||||
Height="438" |
||||
Width="750" |
||||
Title="Edit Items" |
||||
WindowStartupLocation="CenterScreen" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
mc:Ignorable="d"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition |
||||
Width="3*" /> |
||||
<ColumnDefinition |
||||
Width="100" /> |
||||
<ColumnDefinition |
||||
Width="4*" /> |
||||
</Grid.ColumnDefinitions> |
||||
<Border |
||||
BorderBrush="Black" |
||||
BorderThickness="0.75" |
||||
Margin="10" |
||||
SnapsToDevicePixels="True"> |
||||
<ListBox |
||||
x:Name="ListBox" |
||||
SelectionChanged="ListBox_SelectionChanged"> |
||||
<ListBox.ItemTemplate> |
||||
<DataTemplate> |
||||
<TextBlock |
||||
Text="{Binding ComponentType.Name}" /> |
||||
</DataTemplate> |
||||
</ListBox.ItemTemplate> |
||||
</ListBox> |
||||
</Border> |
||||
<Button |
||||
Content="Add" |
||||
Click="OnAddItemClicked" |
||||
Grid.Column="1" |
||||
Height="23" |
||||
HorizontalAlignment="Left" |
||||
Margin="0,12,0,0" |
||||
Name="AddItem" |
||||
VerticalAlignment="Top" |
||||
Width="75" /> |
||||
<Button |
||||
Content="Remove" |
||||
Click="OnRemoveItemClicked" |
||||
Grid.Column="1" |
||||
Height="23" |
||||
HorizontalAlignment="Left" |
||||
Margin="0,42,0,0" |
||||
Name="RemoveItem" |
||||
VerticalAlignment="Top" |
||||
Width="75" /> |
||||
<Button |
||||
Content="Move Up" |
||||
Click="OnMoveItemUpClicked" |
||||
Grid.Column="1" |
||||
Height="23" |
||||
HorizontalAlignment="Left" |
||||
Margin="0,72,0,0" |
||||
Name="MoveUpItem" |
||||
VerticalAlignment="Top" |
||||
Width="75" /> |
||||
<Button |
||||
Content="Move Down" |
||||
Click="OnMoveItemDownClicked" |
||||
Grid.Column="1" |
||||
Height="23" |
||||
HorizontalAlignment="Left" |
||||
Margin="0,102,0,0" |
||||
Name="MoveDownItem" |
||||
VerticalAlignment="Top" |
||||
Width="75" /> |
||||
<Border |
||||
BorderBrush="Black" |
||||
BorderThickness="0.75" |
||||
Margin="10" |
||||
Grid.Column="2" |
||||
SnapsToDevicePixels="True"> |
||||
<PropertyGrid:PropertyGridView |
||||
x:Name="PropertyGridView" |
||||
Margin="0.5" /> |
||||
</Border> |
||||
</Grid> |
||||
</Window> |
@ -0,0 +1,111 @@
@@ -0,0 +1,111 @@
|
||||
// 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.ComponentModel; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Diagnostics; |
||||
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.Linq; |
||||
using ICSharpCode.WpfDesign.Designer.OutlineView; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors |
||||
{ |
||||
public partial class FlatCollectionEditor : Window |
||||
{ |
||||
private static readonly Dictionary<Type, Type> TypeMappings = new Dictionary<Type, Type>(); |
||||
static FlatCollectionEditor() |
||||
{ |
||||
TypeMappings.Add(typeof(ListBox),typeof(ListBoxItem)); |
||||
TypeMappings.Add(typeof(ListView),typeof(ListViewItem)); |
||||
TypeMappings.Add(typeof(ComboBox),typeof(ComboBoxItem)); |
||||
TypeMappings.Add(typeof(TabControl),typeof(TabItem)); |
||||
TypeMappings.Add(typeof(ColumnDefinitionCollection),typeof(ColumnDefinition)); |
||||
TypeMappings.Add(typeof(RowDefinitionCollection),typeof(RowDefinition)); |
||||
} |
||||
|
||||
private DesignItemProperty _itemProperty; |
||||
private IComponentService _componentService; |
||||
private Type _type; |
||||
|
||||
public FlatCollectionEditor() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
this.Owner = Application.Current.MainWindow; |
||||
} |
||||
|
||||
public void LoadItemsCollection(DesignItemProperty itemProperty) |
||||
{ |
||||
_itemProperty = itemProperty; |
||||
_componentService=_itemProperty.DesignItem.Services.Component; |
||||
TypeMappings.TryGetValue(_itemProperty.ReturnType, out _type); |
||||
if (_type == null) { |
||||
PropertyGridView.IsEnabled=false; |
||||
ListBox.IsEnabled=false; |
||||
AddItem.IsEnabled=false; |
||||
RemoveItem.IsEnabled=false; |
||||
MoveUpItem.IsEnabled=false; |
||||
MoveDownItem.IsEnabled=false; |
||||
} |
||||
|
||||
ListBox.ItemsSource = _itemProperty.CollectionElements; |
||||
} |
||||
|
||||
private void OnAddItemClicked(object sender, RoutedEventArgs e) |
||||
{ |
||||
DesignItem newItem = _componentService.RegisterComponentForDesigner(Activator.CreateInstance(_type)); |
||||
_itemProperty.CollectionElements.Add(newItem); |
||||
} |
||||
|
||||
private void OnRemoveItemClicked(object sender, RoutedEventArgs e) |
||||
{ |
||||
var selItem = ListBox.SelectedItem as DesignItem; |
||||
if (selItem != null) |
||||
_itemProperty.CollectionElements.Remove(selItem); |
||||
} |
||||
|
||||
private void OnMoveItemUpClicked(object sender, RoutedEventArgs e) |
||||
{ |
||||
DesignItem selectedItem = ListBox.SelectedItem as DesignItem; |
||||
if (selectedItem!=null) { |
||||
if(_itemProperty.CollectionElements.Count!=1 && _itemProperty.CollectionElements.IndexOf(selectedItem)!=0){ |
||||
int moveToIndex=_itemProperty.CollectionElements.IndexOf(selectedItem)-1; |
||||
var itemAtMoveToIndex=_itemProperty.CollectionElements[moveToIndex]; |
||||
_itemProperty.CollectionElements.RemoveAt(moveToIndex); |
||||
if ((moveToIndex + 1) < (_itemProperty.CollectionElements.Count+1)) |
||||
_itemProperty.CollectionElements.Insert(moveToIndex+1,itemAtMoveToIndex); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void OnMoveItemDownClicked(object sender, RoutedEventArgs e) |
||||
{ |
||||
DesignItem selectedItem = ListBox.SelectedItem as DesignItem; |
||||
if (selectedItem!=null) { |
||||
var itemCount=_itemProperty.CollectionElements.Count; |
||||
if(itemCount!=1 && _itemProperty.CollectionElements.IndexOf(selectedItem)!=itemCount){ |
||||
int moveToIndex=_itemProperty.CollectionElements.IndexOf(selectedItem)+1; |
||||
if(moveToIndex<itemCount){ |
||||
var itemAtMoveToIndex=_itemProperty.CollectionElements[moveToIndex]; |
||||
_itemProperty.CollectionElements.RemoveAt(moveToIndex); |
||||
if(moveToIndex>0) |
||||
_itemProperty.CollectionElements.Insert(moveToIndex-1,itemAtMoveToIndex); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
||||
{ |
||||
PropertyGridView.PropertyGrid.SelectedItems = ListBox.SelectedItems.Cast<DesignItem>(); |
||||
} |
||||
} |
||||
} |