diff --git a/samples/XamlDesigner/XamlDesigner.csproj b/samples/XamlDesigner/XamlDesigner.csproj
index 61839e3fc6..4a796b9cfe 100644
--- a/samples/XamlDesigner/XamlDesigner.csproj
+++ b/samples/XamlDesigner/XamlDesigner.csproj
@@ -41,14 +41,6 @@
False
..\..\bin\ICSharpCode.TextEditor.dll
-
- False
- ..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.dll
-
-
- False
- ..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.dll
-
3.5
@@ -185,6 +177,10 @@
{78CC29AC-CC79-4355-B1F2-97936DF198AC}
WpfDesign.Designer
+
+ {66A378A1-E9F4-4AD5-8946-D0EC06C2902F}
+ WpfDesign
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/BackendBindings/XamlBinding/Project/XamlBinding.csproj b/src/AddIns/BackendBindings/XamlBinding/Project/XamlBinding.csproj
deleted file mode 100644
index b5f618f0b0..0000000000
--- a/src/AddIns/BackendBindings/XamlBinding/Project/XamlBinding.csproj
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
- {7C96B65D-28A5-4F28-A35B-8D83CE831EE8}
- Debug
- AnyCPU
- Library
- XamlBinding
- XamlBinding
- ..\..\..\..\..\AddIns\AddIns\BackendBindings\XamlBinding
- False
- False
- 4
- false
- C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
- v3.5
-
-
- true
- Full
- True
- DEBUG;TRACE
- False
-
-
- False
- None
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
-
- 3.5
-
-
-
-
-
-
-
-
- Always
-
-
- Configuration\GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
-
- {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
- NRefactory
- False
-
-
- {2748AD25-9C63-4E12-877B-4DCE96FBED54}
- ICSharpCode.SharpDevelop
- False
-
-
- {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
- ICSharpCode.Core
- False
-
-
- {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
- ICSharpCode.SharpDevelop.Dom
- False
-
-
- {6B717BD1-CD5E-498C-A42E-9E6A4584DC48}
- XmlEditor
- False
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/Properties/AssemblyInfo.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 75eeecb3bb..0000000000
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-#region Using directives
-
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-#endregion
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("XamlBinding.Tests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj b/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj
deleted file mode 100644
index cdf9a59770..0000000000
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
- {F390DA70-1FE1-4715-81A0-389AB010C130}
- Debug
- AnyCPU
- Library
- XamlBinding.Tests
- XamlBinding.Tests
- v3.5
- Properties
- C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
- ..\..\..\..\..\bin\UnitTests\
- False
- False
- 4
- false
-
-
- true
- Full
- False
- True
- DEBUG;TRACE
-
-
- False
- None
- True
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
- ..\..\..\..\Tools\NUnit\nunit.framework.dll
- False
-
-
-
- 3.5
-
-
-
- 3.5
-
-
-
-
- Properties\GlobalAssemblyInfo.cs
-
-
-
-
-
-
- {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
- ICSharpCode.SharpDevelop.Dom
-
-
- {6B717BD1-CD5E-498C-A42E-9E6A4584DC48}
- XmlEditor
-
-
- {7C96B65D-28A5-4F28-A35B-8D83CE831EE8}
- XamlBinding
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlExpressionFinderTests.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlExpressionFinderTests.cs
deleted file mode 100644
index f48f483f53..0000000000
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlExpressionFinderTests.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-
-using ICSharpCode.SharpDevelop.Dom;
-using System;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-
-namespace XamlBinding.Tests
-{
- [TestFixture]
- public class XamlExpressionFinderTests
- {
- XamlExpressionContext GetXamlContext(string text)
- {
- return (XamlExpressionContext)GetContext(text);
- }
-
- ExpressionContext GetContext(string text)
- {
- return XamlExpressionFinder.Instance.FindExpression(text, text.Length).Context;
- }
-
- [Test]
- public void FindContextAfterElementName()
- {
- XamlExpressionContext c = GetXamlContext(" Grid", c.ElementPath.ToString());
- Assert.IsNull(c.AttributeName);
- Assert.IsFalse(c.InAttributeValue);
- }
-
- [Test]
- public void FindContextAtElementStart()
- {
- XamlExpressionContext c = GetXamlContext("<");
- Assert.AreEqual(0, c.ElementPath.Elements.Count);
- Assert.IsNull(c.AttributeName);
- Assert.IsFalse(c.InAttributeValue);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs
deleted file mode 100644
index 18eb7ff0c6..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs
+++ /dev/null
@@ -1,245 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Media;
-using System.Windows;
-using System.Windows.Input;
-using System.Windows.Documents;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
-using System.Windows.Media.Imaging;
-using System.Windows.Media.Media3D;
-using System.Windows.Shapes;
-using System.Windows.Media.Animation;
-using System.Windows.Data;
-using System.Windows.Automation;
-using System.Windows.Media.Effects;
-using System.Windows.Navigation;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- public static class BasicMetadata
- {
- static bool registered;
-
- public static void Register()
- {
- if (registered) return;
- registered = true;
-
- Metadata.AddStandardValues(typeof(Brush), typeof(Brushes));
- Metadata.AddStandardValues(typeof(Color), typeof(Colors));
- Metadata.AddStandardValues(typeof(FontStretch), typeof(FontStretches));
- Metadata.AddStandardValues(typeof(FontWeight), typeof(FontWeights));
- Metadata.AddStandardValues(typeof(FontStyle), typeof(FontStyles));
- Metadata.AddStandardValues(typeof(Cursor), typeof(Cursors));
- Metadata.AddStandardValues(typeof(PixelFormat), typeof(PixelFormats));
- Metadata.AddStandardValues(typeof(TextDecorationCollection), typeof(TextDecorations));
- Metadata.AddStandardValues(typeof(FontFamily), Fonts.SystemFontFamilies);
-
- Metadata.AddStandardValues(typeof(ICommand), typeof(ApplicationCommands));
- Metadata.AddStandardValues(typeof(ICommand), typeof(EditingCommands));
- Metadata.AddStandardValues(typeof(ICommand), typeof(NavigationCommands));
- Metadata.AddStandardValues(typeof(ICommand), typeof(ComponentCommands));
- Metadata.AddStandardValues(typeof(ICommand), typeof(MediaCommands));
-
- Metadata.AddPopularProperty(Line.Y2Property);
- Metadata.AddPopularProperty(NavigationWindow.ShowsNavigationUIProperty);
- Metadata.AddPopularProperty(FlowDocumentScrollViewer.DocumentProperty);
- Metadata.AddPopularProperty(GridViewRowPresenterBase.ColumnsProperty);
- Metadata.AddPopularProperty(ListView.ViewProperty);
- Metadata.AddPopularProperty(DocumentPageView.PageNumberProperty);
- Metadata.AddPopularProperty(Popup.PlacementProperty);
- Metadata.AddPopularProperty(Popup.PopupAnimationProperty);
- Metadata.AddPopularProperty(ScrollBar.ViewportSizeProperty);
- Metadata.AddPopularProperty(UniformGrid.RowsProperty);
- Metadata.AddPopularProperty(TabControl.TabStripPlacementProperty);
- Metadata.AddPopularProperty(Line.X1Property);
- Metadata.AddPopularProperty(Line.Y1Property);
- Metadata.AddPopularProperty(Line.X2Property);
- Metadata.AddPopularProperty(Polygon.PointsProperty);
- Metadata.AddPopularProperty(Polyline.PointsProperty);
- Metadata.AddPopularProperty(Path.DataProperty);
- Metadata.AddPopularProperty(HeaderedContentControl.HeaderProperty);
- Metadata.AddPopularProperty(MediaElement.UnloadedBehaviorProperty);
- Metadata.AddPopularProperty(Shape.FillProperty);
- Metadata.AddPopularProperty(Page.TitleProperty);
- Metadata.AddPopularProperty(ItemsControl.ItemsSourceProperty);
- Metadata.AddPopularProperty(Image.SourceProperty);
- Metadata.AddPopularProperty(TextBlock.TextProperty);
- Metadata.AddPopularProperty(DockPanel.LastChildFillProperty);
- Metadata.AddPopularProperty(Expander.IsExpandedProperty);
- Metadata.AddPopularProperty(Shape.StrokeProperty);
- Metadata.AddPopularProperty(RangeBase.ValueProperty);
- Metadata.AddPopularProperty(ItemsControl.ItemContainerStyleProperty);
- Metadata.AddPopularProperty(ToggleButton.IsCheckedProperty);
- Metadata.AddPopularProperty(Window.TitleProperty);
- Metadata.AddPopularProperty(Viewport3DVisual.CameraProperty);
- Metadata.AddPopularProperty(Frame.SourceProperty);
- Metadata.AddPopularProperty(Rectangle.RadiusXProperty);
- Metadata.AddPopularProperty(Rectangle.RadiusYProperty);
- Metadata.AddPopularProperty(FrameworkElement.HeightProperty);
- Metadata.AddPopularProperty(FrameworkElement.WidthProperty);
- Metadata.AddPopularProperty(UniformGrid.ColumnsProperty);
- Metadata.AddPopularProperty(RangeBase.MinimumProperty);
- Metadata.AddPopularProperty(RangeBase.MaximumProperty);
- Metadata.AddPopularProperty(ScrollBar.OrientationProperty);
- Metadata.AddPopularProperty(ContentControl.ContentProperty);
- Metadata.AddPopularProperty(Popup.IsOpenProperty);
- Metadata.AddPopularProperty(TextElement.FontSizeProperty);
- Metadata.AddPopularProperty(FrameworkElement.NameProperty);
- Metadata.AddPopularProperty(Popup.HorizontalOffsetProperty);
- Metadata.AddPopularProperty(Popup.VerticalOffsetProperty);
- Metadata.AddPopularProperty(Window.WindowStyleProperty);
- Metadata.AddPopularProperty(Shape.StrokeThicknessProperty);
- Metadata.AddPopularProperty(TextElement.ForegroundProperty);
- Metadata.AddPopularProperty(FrameworkElement.VerticalAlignmentProperty);
- Metadata.AddPopularProperty(Button.IsDefaultProperty);
- Metadata.AddPopularProperty(UIElement.RenderTransformOriginProperty);
- Metadata.AddPopularProperty(TextElement.FontFamilyProperty);
- Metadata.AddPopularProperty(FrameworkElement.HorizontalAlignmentProperty);
- Metadata.AddPopularProperty(ToolBar.BandProperty);
- Metadata.AddPopularProperty(ToolBar.BandIndexProperty);
- Metadata.AddPopularProperty(ItemsControl.ItemTemplateProperty);
- Metadata.AddPopularProperty(TextBlock.TextWrappingProperty);
- Metadata.AddPopularProperty(FrameworkElement.MarginProperty);
- Metadata.AddPopularProperty(RangeBase.LargeChangeProperty);
- Metadata.AddPopularProperty(RangeBase.SmallChangeProperty);
- Metadata.AddPopularProperty(Panel.BackgroundProperty);
- Metadata.AddPopularProperty(Shape.StrokeMiterLimitProperty);
- Metadata.AddPopularProperty(TextElement.FontWeightProperty);
- Metadata.AddPopularProperty(StackPanel.OrientationProperty);
- Metadata.AddPopularProperty(ListBox.SelectionModeProperty);
- Metadata.AddPopularProperty(FrameworkElement.StyleProperty);
- Metadata.AddPopularProperty(TextBox.TextProperty);
- Metadata.AddPopularProperty(Window.SizeToContentProperty);
- Metadata.AddPopularProperty(Window.ResizeModeProperty);
- Metadata.AddPopularProperty(TextBlock.TextTrimmingProperty);
- Metadata.AddPopularProperty(Window.ShowInTaskbarProperty);
- Metadata.AddPopularProperty(Window.IconProperty);
- Metadata.AddPopularProperty(UIElement.RenderTransformProperty);
- Metadata.AddPopularProperty(Button.IsCancelProperty);
- Metadata.AddPopularProperty(Border.BorderBrushProperty);
- Metadata.AddPopularProperty(Block.TextAlignmentProperty);
- Metadata.AddPopularProperty(Border.CornerRadiusProperty);
- Metadata.AddPopularProperty(Border.BorderThicknessProperty);
- Metadata.AddPopularProperty(TreeViewItem.IsSelectedProperty);
- Metadata.AddPopularProperty(Border.PaddingProperty);
- Metadata.AddPopularProperty(Shape.StretchProperty);
-
- Metadata.AddPopularProperty(typeof(Binding), "Path");
- Metadata.AddPopularProperty(typeof(Binding), "Source");
- Metadata.AddPopularProperty(typeof(Binding), "Mode");
- Metadata.AddPopularProperty(typeof(Binding), "RelativeSource");
- Metadata.AddPopularProperty(typeof(Binding), "ElementName");
- Metadata.AddPopularProperty(typeof(Binding), "Converter");
- Metadata.AddPopularProperty(typeof(Binding), "XPath");
-
- Metadata.AddValueRange(Block.LineHeightProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Canvas.BottomProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Canvas.LeftProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Canvas.TopProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Canvas.RightProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(ColumnDefinition.MaxWidthProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(DocumentViewer.MaxPagesAcrossProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Figure.HorizontalOffsetProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Figure.VerticalOffsetProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(FlowDocument.MaxPageWidthProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(FlowDocument.MaxPageHeightProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(FlowDocumentPageViewer.ZoomProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(FlowDocumentPageViewer.ZoomIncrementProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(FlowDocumentPageViewer.MinZoomProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(FlowDocumentPageViewer.MaxZoomProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(FrameworkElement.MaxHeightProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(FrameworkElement.MaxWidthProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(Grid.ColumnSpanProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Grid.RowSpanProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(GridSplitter.KeyboardIncrementProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(GridSplitter.DragIncrementProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(InkCanvas.BottomProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(InkCanvas.TopProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(InkCanvas.RightProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(InkCanvas.LeftProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Line.Y2Property, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Line.X1Property, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Line.Y1Property, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Line.X2Property, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(List.MarkerOffsetProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(List.StartIndexProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Paragraph.TextIndentProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(RangeBase.ValueProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(RangeBase.MaximumProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(RangeBase.MinimumProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(RepeatButton.IntervalProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(RowDefinition.MaxHeightProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(Selector.SelectedIndexProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Slider.TickFrequencyProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Slider.SelectionStartProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(Slider.SelectionEndProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(TableCell.RowSpanProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(TableCell.ColumnSpanProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(TextBox.MinLinesProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(TextBox.MaxLinesProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(TextBoxBase.UndoLimitProperty, double.MinValue, double.MaxValue);
- Metadata.AddValueRange(TextElement.FontSizeProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Timeline.SpeedRatioProperty, double.Epsilon, double.MaxValue);
- Metadata.AddValueRange(Timeline.DecelerationRatioProperty, 0, 1);
- Metadata.AddValueRange(Timeline.AccelerationRatioProperty, 0, 1);
- Metadata.AddValueRange(Track.ViewportSizeProperty, 0, double.PositiveInfinity);
- Metadata.AddValueRange(UIElement.OpacityProperty, 0, 1);
-
- Metadata.HideProperty(typeof(UIElement), "RenderSize");
- Metadata.HideProperty(FrameworkElement.NameProperty);
- Metadata.HideProperty(typeof(FrameworkElement), "Resources");
- Metadata.HideProperty(typeof(Window), "Owner");
-
- //Metadata.DisablePlacement(typeof(Button));
-
- Metadata.AddPopularControl(typeof(Button));
- Metadata.AddPopularControl(typeof(CheckBox));
- Metadata.AddPopularControl(typeof(ComboBox));
- Metadata.AddPopularControl(typeof(Label));
- Metadata.AddPopularControl(typeof(TextBox));
- Metadata.AddPopularControl(typeof(RadioButton));
- Metadata.AddPopularControl(typeof(Canvas));
- Metadata.AddPopularControl(typeof(Grid));
- Metadata.AddPopularControl(typeof(Border));
- Metadata.AddPopularControl(typeof(DockPanel));
- Metadata.AddPopularControl(typeof(Expander));
- Metadata.AddPopularControl(typeof(GroupBox));
- Metadata.AddPopularControl(typeof(Image));
- Metadata.AddPopularControl(typeof(InkCanvas));
- Metadata.AddPopularControl(typeof(ListBox));
- Metadata.AddPopularControl(typeof(ListView));
- Metadata.AddPopularControl(typeof(Menu));
- Metadata.AddPopularControl(typeof(PasswordBox));
- Metadata.AddPopularControl(typeof(ProgressBar));
- Metadata.AddPopularControl(typeof(RichTextBox));
- Metadata.AddPopularControl(typeof(ScrollViewer));
- Metadata.AddPopularControl(typeof(Slider));
- Metadata.AddPopularControl(typeof(StackPanel));
- Metadata.AddPopularControl(typeof(TabControl));
- Metadata.AddPopularControl(typeof(ToolBar));
- Metadata.AddPopularControl(typeof(TreeView));
- Metadata.AddPopularControl(typeof(Viewbox));
- Metadata.AddPopularControl(typeof(Viewport3D));
- Metadata.AddPopularControl(typeof(WrapPanel));
-
- Metadata.AddDefaultSize(typeof(UIElement), new Size(120, 100));
- Metadata.AddDefaultSize(typeof(ContentControl), new Size(double.NaN, double.NaN));
- Metadata.AddDefaultSize(typeof(Button), new Size(75, 23));
-
- var s1 = new Size(120, double.NaN);
- Metadata.AddDefaultSize(typeof(Slider), s1);
- Metadata.AddDefaultSize(typeof(TextBox), s1);
- Metadata.AddDefaultSize(typeof(PasswordBox), s1);
- Metadata.AddDefaultSize(typeof(ComboBox), s1);
- Metadata.AddDefaultSize(typeof(ProgressBar), s1);
-
- var s2 = new Size(120, 20);
- Metadata.AddDefaultSize(typeof(ToolBar), s2);
- Metadata.AddDefaultSize(typeof(Menu), s2);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
deleted file mode 100644
index 593be1fa1d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Markup;
-using System.Windows;
-using System.Windows.Data;
-using System.Windows.Input;
-using System.Reflection;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- public class CallExtension : MarkupExtension
- {
- public CallExtension(string methodName)
- {
- this.methodName = methodName;
- }
-
- string methodName;
-
- public override object ProvideValue(IServiceProvider sp)
- {
- var t = (IProvideValueTarget)sp.GetService(typeof(IProvideValueTarget));
- return new CallCommand(t.TargetObject as FrameworkElement, methodName);
- }
- }
-
- public class CallCommand : DependencyObject, ICommand
- {
- public CallCommand(FrameworkElement element, string methodName)
- {
- this.element = element;
- this.methodName = methodName;
- element.DataContextChanged += target_DataContextChanged;
-
- BindingOperations.SetBinding(this, CanCallProperty, new Binding("DataContext.Can" + methodName) {
- Source = element
- });
-
- GetMethod();
- }
-
- FrameworkElement element;
- string methodName;
- MethodInfo method;
-
- public static readonly DependencyProperty CanCallProperty =
- DependencyProperty.Register("CanCall", typeof(bool), typeof(CallCommand),
- new PropertyMetadata(true));
-
- public bool CanCall {
- get { return (bool)GetValue(CanCallProperty); }
- set { SetValue(CanCallProperty, value); }
- }
-
- public object DataContext {
- get { return element.DataContext; }
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (e.Property == CanCallProperty) {
- RaiseCanExecuteChanged();
- }
- }
-
- void GetMethod()
- {
- if (DataContext == null) {
- method = null;
- }
- else {
- method = DataContext.GetType().GetMethod(methodName, Type.EmptyTypes);
- }
- }
-
- void target_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- GetMethod();
- RaiseCanExecuteChanged();
- }
-
- void RaiseCanExecuteChanged()
- {
- if (CanExecuteChanged != null) {
- CanExecuteChanged(this, EventArgs.Empty);
- }
- }
-
- #region ICommand Members
-
- public event EventHandler CanExecuteChanged;
-
- public bool CanExecute(object parameter)
- {
- return method != null && CanCall;
- }
-
- public void Execute(object parameter)
- {
- method.Invoke(DataContext, null);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs
deleted file mode 100644
index ac57010a8d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-#region Using directives
-
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Resources;
-using System.Globalization;
-using System.Windows;
-using System.Runtime.InteropServices;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Windows.Markup;
-
-#endregion
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("WpfDesign.Designer")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: CLSCompliant(true)]
-
-//In order to begin building localizable applications, set
-//CultureYouAreCodingWith in your .csproj file
-//inside a . For example, if you are using US english
-//in your source files, set the to en-US. Then uncomment
-//the NeutralResourceLanguage attribute below. Update the "en-US" in
-//the line below to match the UICulture setting in the project file.
-
-//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
- ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
-)]
-
-[assembly: XmlnsPrefix("http://sharpdevelop.net", "sd")]
-
-[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer")]
-[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.Controls")]
-[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid")]
-[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors")]
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
deleted file mode 100644
index eee966f0e9..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-//#define DEBUG_ADORNERLAYER
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// A control that displays adorner panels.
- ///
- sealed class AdornerLayer : Panel
- {
- #region AdornerPanelCollection
- internal sealed class AdornerPanelCollection : ICollection
- {
- readonly AdornerLayer _layer;
-
- public AdornerPanelCollection(AdornerLayer layer)
- {
- this._layer = layer;
- }
-
- public int Count {
- get { return _layer.Children.Count; }
- }
-
- public bool IsReadOnly {
- get { return false; }
- }
-
- public void Add(AdornerPanel item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
-
- _layer.AddAdorner(item);
- }
-
- public void Clear()
- {
- _layer.ClearAdorners();
- }
-
- public bool Contains(AdornerPanel item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
-
- return VisualTreeHelper.GetParent(item) == _layer;
- }
-
- public void CopyTo(AdornerPanel[] array, int arrayIndex)
- {
- foreach (AdornerPanel panel in this)
- array[arrayIndex++] = panel;
- }
-
- public bool Remove(AdornerPanel item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
-
- return _layer.RemoveAdorner(item);
- }
-
- public IEnumerator GetEnumerator()
- {
- foreach (AdornerPanel panel in _layer.Children) {
- yield return panel;
- }
- }
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return this.GetEnumerator();
- }
- }
- #endregion
-
- AdornerPanelCollection _adorners;
- readonly UIElement _designPanel;
-
- #if DEBUG_ADORNERLAYER
- int _totalAdornerCount;
- #endif
-
-
- internal AdornerLayer(UIElement designPanel)
- {
- this._designPanel = designPanel;
-
- this.LayoutUpdated += OnLayoutUpdated;
-
- _adorners = new AdornerPanelCollection(this);
- }
-
- void OnLayoutUpdated(object sender, EventArgs e)
- {
- UpdateAllAdorners(false);
- #if DEBUG_ADORNERLAYER
- Debug.WriteLine("Adorner LayoutUpdated. AdornedElements=" + _dict.Count +
- ", visible adorners=" + VisualChildrenCount + ", total adorners=" + (_totalAdornerCount));
- #endif
- }
-
- protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
- {
- base.OnRenderSizeChanged(sizeInfo);
- UpdateAllAdorners(true);
- }
-
- internal AdornerPanelCollection Adorners {
- get {
- return _adorners;
- }
- }
-
- sealed class AdornerInfo
- {
- internal readonly List adorners = new List();
- internal bool isVisible;
- internal Rect position;
- }
-
- // adorned element => AdornerInfo
- Dictionary _dict = new Dictionary();
-
- void ClearAdorners()
- {
- if (_dict.Count == 0)
- return; // already empty
-
- this.Children.Clear();
- _dict = new Dictionary();
-
- #if DEBUG_ADORNERLAYER
- _totalAdornerCount = 0;
- Debug.WriteLine("AdornerLayer cleared.");
- #endif
- }
-
- AdornerInfo GetOrCreateAdornerInfo(UIElement adornedElement)
- {
- AdornerInfo info;
- if (!_dict.TryGetValue(adornedElement, out info)) {
- info = _dict[adornedElement] = new AdornerInfo();
- info.isVisible = adornedElement.IsDescendantOf(_designPanel);
- }
- return info;
- }
-
- AdornerInfo GetExistingAdornerInfo(UIElement adornedElement)
- {
- AdornerInfo info;
- _dict.TryGetValue(adornedElement, out info);
- return info;
- }
-
- void AddAdorner(AdornerPanel adornerPanel)
- {
- if (adornerPanel.AdornedElement == null)
- throw new DesignerException("adornerPanel.AdornedElement must be set");
-
- AdornerInfo info = GetOrCreateAdornerInfo(adornerPanel.AdornedElement);
- info.adorners.Add(adornerPanel);
-
- if (info.isVisible) {
- AddAdornerToChildren(adornerPanel);
- }
-
- #if DEBUG_ADORNERLAYER
- Debug.WriteLine("Adorner added. AdornedElements=" + _dict.Count +
- ", visible adorners=" + VisualChildrenCount + ", total adorners=" + (++_totalAdornerCount));
- #endif
- }
-
- void AddAdornerToChildren(AdornerPanel adornerPanel)
- {
- UIElementCollection children = this.Children;
- int i = 0;
- for (i = 0; i < children.Count; i++) {
- AdornerPanel p = (AdornerPanel)children[i];
- if (p.Order.CompareTo(adornerPanel.Order) > 0) {
- break;
- }
- }
- children.Insert(i, adornerPanel);
- }
-
- protected override Size MeasureOverride(Size availableSize)
- {
- Size infiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
- foreach (AdornerPanel adorner in this.Children) {
- adorner.Measure(infiniteSize);
- }
- return new Size(0, 0);
- }
-
- protected override Size ArrangeOverride(Size finalSize)
- {
- foreach (AdornerPanel adorner in this.Children) {
- adorner.Arrange(new Rect(new Point(0, 0), adorner.DesiredSize));
- if (adorner.AdornedElement.IsDescendantOf(_designPanel)) {
- adorner.RenderTransform = (Transform)adorner.AdornedElement.TransformToAncestor(_designPanel);
- }
- }
- return finalSize;
- }
-
- bool RemoveAdorner(AdornerPanel adornerPanel)
- {
- if (adornerPanel.AdornedElement == null)
- return false;
-
- AdornerInfo info = GetExistingAdornerInfo(adornerPanel.AdornedElement);
- if (info == null)
- return false;
-
- if (info.adorners.Remove(adornerPanel)) {
- if (info.isVisible) {
- this.Children.Remove(adornerPanel);
- }
-
- if (info.adorners.Count == 0) {
- _dict.Remove(adornerPanel.AdornedElement);
- }
-
- #if DEBUG_ADORNERLAYER
- Debug.WriteLine("Adorner removed. AdornedElements=" + _dict.Count +
- ", visible adorners=" + VisualChildrenCount + ", total adorners=" + (--_totalAdornerCount));
- #endif
-
- return true;
- } else {
- return false;
- }
- }
-
- public void UpdateAdornersForElement(UIElement element, bool forceInvalidate)
- {
- AdornerInfo info = GetExistingAdornerInfo(element);
- if (info != null) {
- UpdateAdornersForElement(element, info, forceInvalidate);
- }
- }
-
- Rect GetPositionCache(UIElement element)
- {
- Transform t = (Transform)element.TransformToAncestor(_designPanel);
- return new Rect(new Point(t.Value.OffsetX, t.Value.OffsetY), element.RenderSize);
- }
-
- void UpdateAdornersForElement(UIElement element, AdornerInfo info, bool forceInvalidate)
- {
- if (element.IsDescendantOf(_designPanel)) {
- if (!info.isVisible) {
- info.isVisible = true;
- // make adorners visible:
- info.adorners.ForEach(AddAdornerToChildren);
- }
- Rect c = GetPositionCache(element);
- if (forceInvalidate || !info.position.Equals(c)) {
- info.position = c;
- foreach (AdornerPanel p in info.adorners) {
- p.InvalidateMeasure();
- }
- this.InvalidateArrange();
- }
- } else {
- if (info.isVisible) {
- info.isVisible = false;
- // make adorners invisible:
- info.adorners.ForEach(this.Children.Remove);
- }
- }
- }
-
- void UpdateAllAdorners(bool forceInvalidate)
- {
- foreach (KeyValuePair pair in _dict) {
- UpdateAdornersForElement(pair.Key, pair.Value, forceInvalidate);
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs
deleted file mode 100644
index fda4b92743..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Controls;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Shapes;
-using System.Windows.Controls.Primitives;
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// A thumb where the look can depend on the IsPrimarySelection property.
- /// Used by UIElementSelectionRectangle.
- ///
- public class ContainerDragHandle : Control
- {
- static ContainerDragHandle()
- {
- //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(ContainerDragHandle), new FrameworkPropertyMetadata(typeof(ContainerDragHandle)));
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
deleted file mode 100644
index c38dff1ff7..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
+++ /dev/null
@@ -1,416 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
deleted file mode 100644
index 1785779481..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Input;
-using System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public delegate void DragHandler(DragListener drag);
-
- public class DragListener
- {
- static DragListener()
- {
- InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput);
- }
-
- public DragListener(IInputElement target)
- {
- Target = target;
-
- Target.PreviewMouseLeftButtonDown += Target_MouseDown;
- Target.PreviewMouseMove += Target_MouseMove;
- Target.PreviewMouseLeftButtonUp += Target_MouseUp;
- }
-
- static DragListener CurrentListener;
-
- static void PostProcessInput(object sender, ProcessInputEventArgs e)
- {
- if (CurrentListener != null) {
- var a = e.StagingItem.Input as KeyEventArgs;
- if (a != null && a.Key == Key.Escape) {
- Mouse.Capture(null);
- CurrentListener.IsDown = false;
- CurrentListener.IsCanceled = true;
- CurrentListener.Complete();
- }
- }
- }
-
- void Target_MouseDown(object sender, MouseButtonEventArgs e)
- {
- StartPoint = Mouse.GetPosition(null);
- CurrentPoint = StartPoint;
- DeltaDelta = new Vector();
- IsDown = true;
- IsCanceled = false;
- }
-
- void Target_MouseMove(object sender, MouseEventArgs e)
- {
- if (IsDown) {
- DeltaDelta = e.GetPosition(null) - CurrentPoint;
- CurrentPoint += DeltaDelta;
-
- if (!IsActive) {
- if (Math.Abs(Delta.X) >= SystemParameters.MinimumHorizontalDragDistance ||
- Math.Abs(Delta.Y) >= SystemParameters.MinimumVerticalDragDistance) {
- IsActive = true;
- CurrentListener = this;
-
- if (Started != null) {
- Started(this);
- }
- }
- }
-
- if (IsActive && Changed != null) {
- Changed(this);
- }
- }
- }
-
- void Target_MouseUp(object sender, MouseButtonEventArgs e)
- {
- IsDown = false;
- if (IsActive) {
- Complete();
- }
- }
-
- void Complete()
- {
- IsActive = false;
- CurrentListener = null;
-
- if (Completed != null) {
- Completed(this);
- }
- }
-
- public event DragHandler Started;
- public event DragHandler Changed;
- public event DragHandler Completed;
-
- public IInputElement Target { get; private set; }
- public Point StartPoint { get; private set; }
- public Point CurrentPoint { get; private set; }
- public Vector DeltaDelta { get; private set; }
- public bool IsActive { get; private set; }
- public bool IsDown { get; private set; }
- public bool IsCanceled { get; private set; }
-
- public Vector Delta {
- get { return CurrentPoint - StartPoint; }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs
deleted file mode 100644
index ea5e4a8182..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Shapes;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// A button with a drop-down arrow.
- ///
- public class DropDownButton : Button
- {
- static readonly Geometry triangle = (Geometry)new GeometryConverter().ConvertFromInvariantString("M0,0 L1,0 0.5,1 z");
-
- public DropDownButton()
- {
- Content = new Path {
- Fill = Brushes.Black,
- Data = triangle,
- Width = 7,
- Height = 3.5,
- Stretch = Stretch.Fill
- };
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs
deleted file mode 100644
index a88814f70c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Data;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public class EnterTextBox : TextBox
- {
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Enter) {
- var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
- if (b != null) {
- b.UpdateSource();
- }
- SelectAll();
- }
- else if (e.Key == Key.Escape) {
- var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
- if (b != null) {
- b.UpdateTarget();
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml
deleted file mode 100644
index 531721005a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
deleted file mode 100644
index 8d75cd3c24..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-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 System.Windows.Controls.Primitives;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public partial class EnumBar
- {
- public EnumBar()
- {
- InitializeComponent();
- }
-
- Type currentEnumType;
-
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
- new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- public object Value {
- get { return (object)GetValue(ValueProperty); }
- set { SetValue(ValueProperty, value); }
- }
-
- public static readonly DependencyProperty ContainerProperty =
- DependencyProperty.Register("Container", typeof(Panel), typeof(EnumBar));
-
- public Panel Container {
- get { return (Panel)GetValue(ContainerProperty); }
- set { SetValue(ContainerProperty, value); }
- }
-
- public static readonly DependencyProperty ButtonStyleProperty =
- DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(EnumBar));
-
- public Style ButtonStyle {
- get { return (Style)GetValue(ButtonStyleProperty); }
- set { SetValue(ButtonStyleProperty, value); }
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (e.Property == ValueProperty) {
-
- var type = e.NewValue.GetType();
-
- if (currentEnumType != type) {
- currentEnumType = type;
- uxPanel.Children.Clear();
- foreach (var v in Enum.GetValues(type)) {
- var b = new EnumButton();
- b.Value = v;
- b.Content = Enum.GetName(type, v);
- b.SetBinding(StyleProperty, new Binding("ButtonStyle") { Source = this });
- b.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(button_PreviewMouseLeftButtonDown);
- uxPanel.Children.Add(b);
- }
- }
-
- UpdateButtons();
- UpdateContainer();
-
- } else if (e.Property == ContainerProperty) {
- UpdateContainer();
- }
- }
-
- void UpdateButtons()
- {
- foreach (EnumButton c in uxPanel.Children) {
- if (c.Value.Equals(Value)) {
- c.IsChecked = true;
- }
- else {
- c.IsChecked = false;
- }
- }
- }
-
- void UpdateContainer()
- {
- if (Container != null) {
- for (int i = 0; i < uxPanel.Children.Count; i++) {
- var c = uxPanel.Children[i] as EnumButton;
- if (c.IsChecked.Value)
- Container.Children[i].Visibility = Visibility.Visible;
- else
- Container.Children[i].Visibility = Visibility.Collapsed;
- }
- }
- }
-
- void button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- Value = (sender as EnumButton).Value;
- e.Handled = true;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumButton.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumButton.cs
deleted file mode 100644
index 1cb487ce90..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumButton.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Controls.Primitives;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public class EnumButton : ToggleButton
- {
- static EnumButton()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(EnumButton),
- new FrameworkPropertyMetadata(typeof(EnumButton)));
- }
-
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register("Value", typeof(object), typeof(EnumButton));
-
- public object Value {
- get { return (object)GetValue(ValueProperty); }
- set { SetValue(ValueProperty, value); }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ErrorBalloon.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ErrorBalloon.cs
deleted file mode 100644
index 6df66934cd..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ErrorBalloon.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// An ErrorBalloon window.
- ///
- public class ErrorBalloon : Window
- {
- static ErrorBalloon()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(ErrorBalloon), new FrameworkPropertyMetadata(typeof(ErrorBalloon)));
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GrayOutDesignerExceptActiveArea.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GrayOutDesignerExceptActiveArea.cs
deleted file mode 100644
index 700ab946dc..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GrayOutDesignerExceptActiveArea.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Windows;
-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
-{
- ///
- /// Gray out everything except a specific area.
- ///
- sealed class GrayOutDesignerExceptActiveArea : FrameworkElement
- {
- Geometry designSurfaceRectangle;
- Geometry activeAreaGeometry;
- Geometry combinedGeometry;
- Brush grayOutBrush;
- AdornerPanel adornerPanel;
- IDesignPanel designPanel;
- const double MaxOpacity = 0.3;
-
- public GrayOutDesignerExceptActiveArea()
- {
- this.GrayOutBrush = new SolidColorBrush(SystemColors.GrayTextColor);
- this.GrayOutBrush.Opacity = MaxOpacity;
- this.IsHitTestVisible = false;
- }
-
- public Brush GrayOutBrush {
- get { return grayOutBrush; }
- set { grayOutBrush = value; }
- }
-
- public Geometry ActiveAreaGeometry {
- get { return activeAreaGeometry; }
- set {
- activeAreaGeometry = value;
- combinedGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, designSurfaceRectangle, activeAreaGeometry);
- }
- }
-
- protected override void OnRender(DrawingContext drawingContext)
- {
- drawingContext.DrawGeometry(grayOutBrush, null, combinedGeometry);
- }
-
- 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 GrayOutDesignerExceptActiveArea grayOut, ServiceContainer services, UIElement activeContainer)
- {
- Debug.Assert(activeContainer != null);
- Start(ref grayOut, services, activeContainer, new Rect(activeContainer.RenderSize));
- }
-
- internal static void Start(ref GrayOutDesignerExceptActiveArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer)
- {
- Debug.Assert(services != null);
- Debug.Assert(activeContainer != null);
- DesignPanel designPanel = services.GetService() as DesignPanel;
- OptionService optionService = services.GetService();
- if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
- grayOut = new GrayOutDesignerExceptActiveArea();
- grayOut.designSurfaceRectangle = new RectangleGeometry(
- new Rect(new Point(0, 0), designPanel.RenderSize));
- grayOut.designPanel = designPanel;
- grayOut.adornerPanel = new AdornerPanel();
- grayOut.adornerPanel.Order = AdornerOrder.BehindForeground;
- grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
- grayOut.adornerPanel.Children.Add(grayOut);
- grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
- Animate(grayOut.GrayOutBrush, Brush.OpacityProperty, 0, MaxOpacity);
- designPanel.Adorners.Add(grayOut.adornerPanel);
- }
- }
-
- static readonly TimeSpan animationTime = new TimeSpan(2000000);
-
- static void Animate(Animatable element, DependencyProperty property, double from, double to)
- {
- element.BeginAnimation(property, new DoubleAnimation(from, to, new Duration(animationTime), FillBehavior.Stop));
- }
-
- internal static void Stop(ref GrayOutDesignerExceptActiveArea grayOut)
- {
- if (grayOut != null) {
- Animate(grayOut.GrayOutBrush, Brush.OpacityProperty, MaxOpacity, 0);
- IDesignPanel designPanel = grayOut.designPanel;
- AdornerPanel adornerPanelToRemove = grayOut.adornerPanel;
- DispatcherTimer timer = new DispatcherTimer();
- timer.Interval = animationTime;
- timer.Tick += delegate {
- timer.Stop();
- designPanel.Adorners.Remove(adornerPanelToRemove);
- };
- timer.Start();
- grayOut = null;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
deleted file mode 100644
index 44cc1678cb..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
+++ /dev/null
@@ -1,371 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// Adorner that displays the blue bar next to grids that can be used to create new rows/column.
- ///
- public class GridRailAdorner : Control
- {
- static GridRailAdorner()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(GridRailAdorner), new FrameworkPropertyMetadata(typeof(GridRailAdorner)));
- }
-
- readonly DesignItem gridItem;
- readonly Grid grid;
- readonly AdornerPanel adornerPanel;
- readonly GridSplitterAdorner previewAdorner;
- readonly Orientation orientation;
-
- public const double RailSize = 10;
- public const double RailDistance = 6;
- public const double SplitterWidth = 10;
-
- public GridRailAdorner(DesignItem gridItem, AdornerPanel adornerPanel, Orientation orientation)
- {
- Debug.Assert(gridItem != null);
- Debug.Assert(adornerPanel != null);
-
- this.gridItem = gridItem;
- this.grid = (Grid)gridItem.Component;
- this.adornerPanel = adornerPanel;
- this.orientation = orientation;
-
- if (orientation == Orientation.Horizontal) {
- this.Height = RailSize;
- previewAdorner = new GridColumnSplitterAdorner(gridItem, null, null);
- } else { // vertical
- this.Width = RailSize;
- previewAdorner = new GridRowSplitterAdorner(gridItem, null, null);
- }
- previewAdorner.IsPreview = true;
- previewAdorner.IsHitTestVisible = false;
- }
-
- #region Handle mouse events to add a new row/column
- protected override void OnMouseEnter(MouseEventArgs e)
- {
- base.OnMouseEnter(e);
- adornerPanel.Children.Add(previewAdorner);
- }
-
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- RelativePlacement rp = new RelativePlacement();
- if (orientation == Orientation.Vertical) {
- rp.XOffset = -(RailSize + RailDistance);
- rp.WidthOffset = RailSize + RailDistance;
- rp.WidthRelativeToContentWidth = 1;
- rp.HeightOffset = SplitterWidth;
- rp.YOffset = e.GetPosition(this).Y - SplitterWidth / 2;
- } else {
- rp.YOffset = -(RailSize + RailDistance);
- rp.HeightOffset = RailSize + RailDistance;
- rp.HeightRelativeToContentHeight = 1;
- rp.WidthOffset = SplitterWidth;
- rp.XOffset = e.GetPosition(this).X - SplitterWidth / 2;
- }
- AdornerPanel.SetPlacement(previewAdorner, rp);
- }
-
- protected override void OnMouseLeave(MouseEventArgs e)
- {
- base.OnMouseLeave(e);
- adornerPanel.Children.Remove(previewAdorner);
- }
-
- protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
- {
- base.OnMouseLeftButtonDown(e);
- e.Handled = true;
- Focus();
- adornerPanel.Children.Remove(previewAdorner);
- if (orientation == Orientation.Vertical) {
- using (ChangeGroup changeGroup = gridItem.OpenGroup("Split grid row")) {
- DesignItemProperty rowCollection = gridItem.Properties["RowDefinitions"];
- if (rowCollection.CollectionElements.Count == 0) {
- DesignItem firstRow = gridItem.Services.Component.RegisterComponentForDesigner(new RowDefinition());
- rowCollection.CollectionElements.Add(firstRow);
- grid.UpdateLayout(); // let WPF assign firstRow.ActualHeight
- }
- double insertionPosition = e.GetPosition(this).Y;
- for (int i = 0; i < grid.RowDefinitions.Count; i++) {
- RowDefinition row = grid.RowDefinitions[i];
- if (row.Offset > insertionPosition) continue;
- if (row.Offset + row.ActualHeight < insertionPosition) continue;
-
- // split row
- GridLength oldLength = (GridLength)row.GetValue(RowDefinition.HeightProperty);
- GridLength newLength1, newLength2;
- SplitLength(oldLength, insertionPosition - row.Offset, row.ActualHeight, out newLength1, out newLength2);
- DesignItem newRowDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new RowDefinition());
- rowCollection.CollectionElements.Insert(i + 1, newRowDefinition);
- rowCollection.CollectionElements[i].Properties[RowDefinition.HeightProperty].SetValue(newLength1);
- newRowDefinition.Properties[RowDefinition.HeightProperty].SetValue(newLength2);
-
- FixIndicesAfterSplit(i, Grid.RowProperty, Grid.RowSpanProperty);
- changeGroup.Commit();
- gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newRowDefinition }, SelectionTypes.Auto);
- break;
- }
- }
- } else {
- using (ChangeGroup changeGroup = gridItem.OpenGroup("Split grid column")) {
- DesignItemProperty columnCollection = gridItem.Properties["ColumnDefinitions"];
- if (columnCollection.CollectionElements.Count == 0) {
- DesignItem firstColumn = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition());
- columnCollection.CollectionElements.Add(firstColumn);
- grid.UpdateLayout(); // let WPF assign firstColumn.ActualWidth
- }
- double insertionPosition = e.GetPosition(this).X;
- for (int i = 0; i < grid.ColumnDefinitions.Count; i++) {
- ColumnDefinition column = grid.ColumnDefinitions[i];
- if (column.Offset > insertionPosition) continue;
- if (column.Offset + column.ActualWidth < insertionPosition) continue;
-
- // split column
- GridLength oldLength = (GridLength)column.GetValue(ColumnDefinition.WidthProperty);
- GridLength newLength1, newLength2;
- SplitLength(oldLength, insertionPosition - column.Offset, column.ActualWidth, out newLength1, out newLength2);
- DesignItem newColumnDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition());
- columnCollection.CollectionElements.Insert(i + 1, newColumnDefinition);
- columnCollection.CollectionElements[i].Properties[ColumnDefinition.WidthProperty].SetValue(newLength1);
- newColumnDefinition.Properties[ColumnDefinition.WidthProperty].SetValue(newLength2);
- FixIndicesAfterSplit(i, Grid.ColumnProperty, Grid.ColumnSpanProperty);
- changeGroup.Commit();
- gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newColumnDefinition }, SelectionTypes.Auto);
- break;
- }
- }
- }
- }
-
- void FixIndicesAfterSplit(int splitIndex, DependencyProperty idxProperty, DependencyProperty spanProperty)
- {
- // increment ColSpan of all controls in the split column, increment Column of all controls in later columns:
- foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements) {
- int start = (int)child.Properties.GetAttachedProperty(idxProperty).ValueOnInstance;
- int span = (int)child.Properties.GetAttachedProperty(spanProperty).ValueOnInstance;
- if (start <= splitIndex && splitIndex < start + span) {
- child.Properties.GetAttachedProperty(spanProperty).SetValue(span + 1);
- } else if (start > splitIndex) {
- child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
- }
- }
- }
-
- void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
- out GridLength newLength1, out GridLength newLength2)
- {
- if (oldLength.IsAuto) {
- oldLength = new GridLength(oldActualValue);
- }
- double percentage = insertionPosition / oldActualValue;
- newLength1 = new GridLength(oldLength.Value * percentage, oldLength.GridUnitType);
- newLength2 = new GridLength(oldLength.Value - newLength1.Value, oldLength.GridUnitType);
- }
- #endregion
- }
-
- public abstract class GridSplitterAdorner : Control
- {
- public static readonly DependencyProperty IsPreviewProperty
- = DependencyProperty.Register("IsPreview", typeof(bool), typeof(GridSplitterAdorner), new PropertyMetadata(SharedInstances.BoxedFalse));
-
- protected readonly Grid grid;
- protected readonly DesignItem gridItem;
- protected readonly DesignItem firstRow, secondRow; // can also be columns
-
- internal GridSplitterAdorner(DesignItem gridItem, DesignItem firstRow, DesignItem secondRow)
- {
- Debug.Assert(gridItem != null);
- this.grid = (Grid)gridItem.Component;
- this.gridItem = gridItem;
- this.firstRow = firstRow;
- this.secondRow = secondRow;
- }
-
- public bool IsPreview {
- get { return (bool)GetValue(IsPreviewProperty); }
- set { SetValue(IsPreviewProperty, SharedInstances.Box(value)); }
- }
-
- ChangeGroup activeChangeGroup;
- double mouseStartPos;
- bool mouseIsDown;
-
- protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
- {
- e.Handled = true;
- if (CaptureMouse()) {
- Focus();
- gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { secondRow }, SelectionTypes.Auto);
- mouseStartPos = GetCoordinate(e.GetPosition(grid));
- mouseIsDown = true;
- }
- }
-
- protected override void OnMouseMove(MouseEventArgs e)
- {
- if (mouseIsDown) {
- double mousePos = GetCoordinate(e.GetPosition(grid));
- if (activeChangeGroup == null) {
- if (Math.Abs(mousePos - mouseStartPos)
- >= GetCoordinate(new Point(SystemParameters.MinimumHorizontalDragDistance, SystemParameters.MinimumVerticalDragDistance))) {
- activeChangeGroup = gridItem.OpenGroup("Change grid row/column size");
- RememberOriginalSize();
- }
- }
- if (activeChangeGroup != null) {
- ChangeSize(mousePos - mouseStartPos);
- }
- }
- }
-
- protected GridLength original1, original2;
- protected double originalPixelSize1, originalPixelSize2;
-
- protected abstract double GetCoordinate(Point point);
- protected abstract void RememberOriginalSize();
- protected abstract DependencyProperty RowColumnSizeProperty { get; }
-
- void ChangeSize(double delta)
- {
- // delta = difference in pixels
-
- if (delta < -originalPixelSize1) delta = -originalPixelSize1;
- if (delta > originalPixelSize2) delta = originalPixelSize2;
-
- // replace Auto lengths with absolute lengths if necessary
- if (original1.IsAuto) original1 = new GridLength(originalPixelSize1);
- if (original2.IsAuto) original2 = new GridLength(originalPixelSize2);
-
- GridLength new1;
- if (original1.IsStar && originalPixelSize1 > 0)
- new1 = new GridLength(original1.Value * (originalPixelSize1 + delta) / originalPixelSize1, GridUnitType.Star);
- else
- new1 = new GridLength(originalPixelSize1 + delta);
- GridLength new2;
- if (original2.IsStar && originalPixelSize2 > 0)
- new2 = new GridLength(original2.Value * (originalPixelSize2 - delta) / originalPixelSize2, GridUnitType.Star);
- else
- new2 = new GridLength(originalPixelSize2 - delta);
- firstRow.Properties[RowColumnSizeProperty].SetValue(new1);
- secondRow.Properties[RowColumnSizeProperty].SetValue(new2);
- ((UIElement)VisualTreeHelper.GetParent(this)).InvalidateArrange();
- }
-
- protected override void OnMouseUp(MouseButtonEventArgs e)
- {
- if (activeChangeGroup != null) {
- activeChangeGroup.Commit();
- activeChangeGroup = null;
- }
- Stop();
- }
-
- protected override void OnLostMouseCapture(MouseEventArgs e)
- {
- Stop();
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Escape) {
- e.Handled = true;
- Stop();
- }
- }
-
- protected void Stop()
- {
- ReleaseMouseCapture();
- mouseIsDown = false;
- if (activeChangeGroup != null) {
- activeChangeGroup.Abort();
- activeChangeGroup = null;
- }
- }
- }
-
- public class GridRowSplitterAdorner : GridSplitterAdorner
- {
- static GridRowSplitterAdorner()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(GridRowSplitterAdorner), new FrameworkPropertyMetadata(typeof(GridRowSplitterAdorner)));
- CursorProperty.OverrideMetadata(typeof(GridRowSplitterAdorner), new FrameworkPropertyMetadata(Cursors.SizeNS));
- }
-
-
- internal GridRowSplitterAdorner(DesignItem gridItem, DesignItem firstRow, DesignItem secondRow) : base(gridItem, firstRow, secondRow)
- {
- }
-
- protected override double GetCoordinate(Point point)
- {
- return point.Y;
- }
-
- protected override void RememberOriginalSize()
- {
- RowDefinition r1 = (RowDefinition)firstRow.Component;
- RowDefinition r2 = (RowDefinition)secondRow.Component;
- original1 = (GridLength)r1.GetValue(RowDefinition.HeightProperty);
- original2 = (GridLength)r2.GetValue(RowDefinition.HeightProperty);
- originalPixelSize1 = r1.ActualHeight;
- originalPixelSize2 = r2.ActualHeight;
- }
-
- protected override DependencyProperty RowColumnSizeProperty {
- get { return RowDefinition.HeightProperty; }
- }
- }
-
- public sealed class GridColumnSplitterAdorner : GridSplitterAdorner
- {
- static GridColumnSplitterAdorner()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(GridColumnSplitterAdorner), new FrameworkPropertyMetadata(typeof(GridColumnSplitterAdorner)));
- CursorProperty.OverrideMetadata(typeof(GridColumnSplitterAdorner), new FrameworkPropertyMetadata(Cursors.SizeWE));
- }
-
- internal GridColumnSplitterAdorner(DesignItem gridItem, DesignItem firstRow, DesignItem secondRow) : base(gridItem, firstRow, secondRow)
- {
- }
-
- protected override double GetCoordinate(Point point)
- {
- return point.X;
- }
-
- protected override void RememberOriginalSize()
- {
- ColumnDefinition r1 = (ColumnDefinition)firstRow.Component;
- ColumnDefinition r2 = (ColumnDefinition)secondRow.Component;
- original1 = (GridLength)r1.GetValue(ColumnDefinition.WidthProperty);
- original2 = (GridLength)r2.GetValue(ColumnDefinition.WidthProperty);
- originalPixelSize1 = r1.ActualWidth;
- originalPixelSize2 = r2.ActualWidth;
- }
-
- protected override DependencyProperty RowColumnSizeProperty {
- get { return ColumnDefinition.WidthProperty; }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs
deleted file mode 100644
index a600f250f4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs
+++ /dev/null
@@ -1,302 +0,0 @@
-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 System.Windows.Controls.Primitives;
-using System.Globalization;
-using System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public class NumericUpDown : Control
- {
- static NumericUpDown()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericUpDown),
- new FrameworkPropertyMetadata(typeof(NumericUpDown)));
- }
-
- TextBox textBox;
- DragRepeatButton upButton;
- DragRepeatButton downButton;
-
- public static readonly DependencyProperty DecimalPlacesProperty =
- DependencyProperty.Register("DecimalPlaces", typeof(int), typeof(NumericUpDown));
-
- public int DecimalPlaces {
- get { return (int)GetValue(DecimalPlacesProperty); }
- set { SetValue(DecimalPlacesProperty, value); }
- }
-
- public static readonly DependencyProperty MinimumProperty =
- DependencyProperty.Register("Minimum", typeof(double), typeof(NumericUpDown));
-
- public double Minimum {
- get { return (double)GetValue(MinimumProperty); }
- set { SetValue(MinimumProperty, value); }
- }
-
- public static readonly DependencyProperty MaximumProperty =
- DependencyProperty.Register("Maximum", typeof(double), typeof(NumericUpDown),
- new FrameworkPropertyMetadata(100.0));
-
- public double Maximum {
- get { return (double)GetValue(MaximumProperty); }
- set { SetValue(MaximumProperty, value); }
- }
-
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown),
- new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- public double Value {
- get { return (double)GetValue(ValueProperty); }
- set { SetValue(ValueProperty, value); }
- }
-
- public static readonly DependencyProperty SmallChangeProperty =
- DependencyProperty.Register("SmallChange", typeof(double), typeof(NumericUpDown),
- new FrameworkPropertyMetadata(1.0));
-
- public double SmallChange {
- get { return (double)GetValue(SmallChangeProperty); }
- set { SetValue(SmallChangeProperty, value); }
- }
-
- public static readonly DependencyProperty LargeChangeProperty =
- DependencyProperty.Register("LargeChange", typeof(double), typeof(NumericUpDown),
- new FrameworkPropertyMetadata(10.0));
-
- public double LargeChange {
- get { return (double)GetValue(LargeChangeProperty); }
- set { SetValue(LargeChangeProperty, value); }
- }
-
- bool IsDragging {
- get {
- return upButton.IsDragging;
- }
- set {
- upButton.IsDragging = value; downButton.IsDragging = value;
- }
- }
-
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
-
- upButton = (DragRepeatButton)Template.FindName("PART_UpButton", this);
- downButton = (DragRepeatButton)Template.FindName("PART_DownButton", this);
- textBox = (TextBox)Template.FindName("PART_TextBox", this);
-
- upButton.Click += new RoutedEventHandler(upButton_Click);
- downButton.Click += new RoutedEventHandler(downButton_Click);
-
- var upDrag = new DragListener(upButton);
- var downDrag = new DragListener(downButton);
-
- upDrag.Started += drag_Started;
- upDrag.Changed += drag_Changed;
- upDrag.Completed += drag_Completed;
-
- downDrag.Started += drag_Started;
- downDrag.Changed += drag_Changed;
- downDrag.Completed += drag_Completed;
-
- Print();
- }
-
- void drag_Started(DragListener drag)
- {
- OnDragStarted();
- }
-
- void drag_Changed(DragListener drag)
- {
- IsDragging = true;
- MoveValue(-drag.DeltaDelta.Y * SmallChange);
- }
-
- void drag_Completed(DragListener drag)
- {
- IsDragging = false;
- OnDragCompleted();
- }
-
- void downButton_Click(object sender, RoutedEventArgs e)
- {
- if (!IsDragging) SmallDown();
- }
-
- void upButton_Click(object sender, RoutedEventArgs e)
- {
- if (!IsDragging) SmallUp();
- }
-
- protected virtual void OnDragStarted()
- {
- }
-
- protected virtual void OnDragCompleted()
- {
- }
-
- public void SmallUp()
- {
- MoveValue(SmallChange);
- }
-
- public void SmallDown()
- {
- MoveValue(-SmallChange);
- }
-
- public void LargeUp()
- {
- MoveValue(LargeChange);
- }
-
- public void LargeDown()
- {
- MoveValue(-LargeChange);
- }
-
- void MoveValue(double delta)
- {
- double result;
- if (double.IsNaN(Value) || double.IsInfinity(Value)) {
- SetValue(delta);
- }
- else if (double.TryParse(textBox.Text, out result)) {
- SetValue(result + delta);
- }
- else {
- SetValue(Value + delta);
- }
- }
-
- void Print()
- {
- if (textBox != null) {
- textBox.Text = Value.ToString("F" + DecimalPlaces);
- textBox.CaretIndex = int.MaxValue;
- }
- }
-
- //wpf bug?: Value = -1 updates bindings without coercing, workaround
- //update: not derived from RangeBase - no problem
- void SetValue(double newValue)
- {
- newValue = CoerceValue(newValue);
- if (Value != newValue) {
- Value = newValue;
- }
- }
-
- double CoerceValue(double newValue)
- {
- return Math.Max(Minimum, Math.Min(newValue, Maximum));
- }
-
- protected override void OnPreviewKeyDown(KeyEventArgs e)
- {
- base.OnPreviewKeyDown(e);
- if (e.Key == Key.Enter) {
- double result;
- if (double.TryParse(textBox.Text, out result)) {
- SetValue(result);
- }
- else {
- Print();
- }
- textBox.SelectAll();
- e.Handled = true;
- }
- else if (e.Key == Key.Up) {
- SmallUp();
- e.Handled = true;
- }
- else if (e.Key == Key.Down) {
- SmallDown();
- e.Handled = true;
- }
- else if (e.Key == Key.PageUp) {
- LargeUp();
- e.Handled = true;
- }
- else if (e.Key == Key.PageDown) {
- LargeDown();
- e.Handled = true;
- }
- //else if (e.Key == Key.Home) {
- // Maximize();
- // e.Handled = true;
- //}
- //else if (e.Key == Key.End) {
- // Minimize();
- // e.Handled = true;
- //}
- }
-
- //protected override void OnMouseWheel(MouseWheelEventArgs e)
- //{
- // if (e.Delta > 0)
- // {
- // if (Keyboard.IsKeyDown(Key.LeftShift))
- // {
- // LargeUp();
- // }
- // else
- // {
- // SmallUp();
- // }
- // }
- // else
- // {
- // if (Keyboard.IsKeyDown(Key.LeftShift))
- // {
- // LargeDown();
- // }
- // else
- // {
- // SmallDown();
- // }
- // }
- // e.Handled = true;
- //}
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (e.Property == ValueProperty) {
- Value = CoerceValue((double)e.NewValue);
- Print();
- }
- else if (e.Property == SmallChangeProperty &&
- ReadLocalValue(LargeChangeProperty) == DependencyProperty.UnsetValue) {
- LargeChange = SmallChange * 10;
- }
- }
- }
-
- public class DragRepeatButton : RepeatButton
- {
- public static readonly DependencyProperty IsDraggingProperty =
- DependencyProperty.Register("IsDragging", typeof(bool), typeof(DragRepeatButton));
-
- public bool IsDragging {
- get { return (bool)GetValue(IsDraggingProperty); }
- set { SetValue(IsDraggingProperty, value); }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml
deleted file mode 100644
index 224930ac98..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
- #DADFEA
- #E6EBEF
- #B6BDD3
- #7F9DB9
- Black
- #B6BDD3
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs
deleted file mode 100644
index 234a9b5ac0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Controls;
-using System.Windows;
-using System.Windows.Input;
-using ICSharpCode.WpfDesign.Designer.Services;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public class PanelMoveAdorner : Control
- {
- static PanelMoveAdorner()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(PanelMoveAdorner),
- new FrameworkPropertyMetadata(typeof(PanelMoveAdorner)));
- }
-
- public PanelMoveAdorner(DesignItem item)
- {
- this.item = item;
- }
-
- DesignItem item;
-
- protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
- {
- e.Handled = true;
- item.Services.Selection.SetSelectedComponents(new DesignItem [] { item }, SelectionTypes.Auto);
- new DragMoveMouseGesture(item, false).Start(item.Services.DesignPanel, e);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
deleted file mode 100644
index 1066e153c5..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-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
-{
- ///
- /// A thumb where the look can depend on the IsPrimarySelection property.
- ///
- public class ResizeThumb : Thumb
- {
- ///
- /// Dependency property for .
- ///
- public static readonly DependencyProperty IsPrimarySelectionProperty
- = DependencyProperty.Register("IsPrimarySelection", typeof(bool), typeof(ResizeThumb));
-
- ///
- /// Dependency property for .
- ///
- public static readonly DependencyProperty ResizeThumbVisibleProperty
- = DependencyProperty.Register("ResizeThumbVisible", typeof(bool), typeof(ResizeThumb), new FrameworkPropertyMetadata(true));
-
- internal PlacementAlignment Alignment;
-
- static ResizeThumb()
- {
- //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(ResizeThumb), new FrameworkPropertyMetadata(typeof(ResizeThumb)));
- }
-
- ///
- /// Gets/Sets if the resize thumb is attached to the primary selection.
- ///
- public bool IsPrimarySelection {
- get { return (bool)GetValue(IsPrimarySelectionProperty); }
- set { SetValue(IsPrimarySelectionProperty, value); }
- }
-
- ///
- /// Gets/Sets if the resize thumb is visible.
- ///
- public bool ResizeThumbVisible {
- get { return (bool)GetValue(ResizeThumbVisibleProperty); }
- set { SetValue(ResizeThumbVisibleProperty, value); }
- }
- }
-
- ///
- /// Resize thumb that automatically disappears if the adornered element is too small.
- ///
- sealed class ResizeThumbImpl : ResizeThumb
- {
- bool checkWidth, checkHeight;
-
- internal ResizeThumbImpl(bool checkWidth, bool checkHeight)
- {
- Debug.Assert((checkWidth && checkHeight) == false);
- this.checkWidth = checkWidth;
- this.checkHeight = checkHeight;
- }
-
- protected override Size ArrangeOverride(Size arrangeBounds)
- {
- AdornerPanel parent = this.Parent as AdornerPanel;
- if (parent != null && parent.AdornedElement != null) {
- if (checkWidth)
- this.ResizeThumbVisible = parent.AdornedElement.RenderSize.Width > 14;
- else if (checkHeight)
- this.ResizeThumbVisible = parent.AdornedElement.RenderSize.Height > 14;
- }
- return base.ArrangeOverride(arrangeBounds);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SelectionFrame.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SelectionFrame.cs
deleted file mode 100644
index b3e1f4159d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SelectionFrame.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// The rectangle shown during a rubber-band selecting operation.
- ///
- public class SelectionFrame : Control
- {
- static SelectionFrame()
- {
- //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(SelectionFrame), new FrameworkPropertyMetadata(typeof(SelectionFrame)));
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
deleted file mode 100644
index 13d6b52c4f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
+++ /dev/null
@@ -1,228 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- ///
- /// A custom control that imitates the properties of , but is not a top-level control.
- ///
- public class WindowClone : ContentControl
- {
- static WindowClone()
- {
- //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(WindowClone), new FrameworkPropertyMetadata(typeof(WindowClone)));
-
- Control.IsTabStopProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
- KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
- KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
- KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
- FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public bool AllowsTransparency {
- get { return (bool)GetValue(Window.AllowsTransparencyProperty); }
- set { SetValue(Window.AllowsTransparencyProperty, SharedInstances.Box(value)); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DialogResultConverter))]
- public bool? DialogResult {
- get {
- return null;
- }
- set { }
- }
-
- ///
- /// Specifies the icon to use.
- ///
- public ImageSource Icon {
- get { return (ImageSource)GetValue(Window.IconProperty); }
- set { SetValue(Window.IconProperty, value); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- [TypeConverter(typeof(LengthConverter))]
- public double Left {
- get { return (double)GetValue(Window.LeftProperty); }
- set { SetValue(Window.LeftProperty, value); }
- }
-
- Window owner;
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public Window Owner {
- get { return owner; }
- set { owner = value; }
- }
-
- ///
- /// Gets or sets the resize mode.
- ///
- public ResizeMode ResizeMode {
- get { return (ResizeMode)GetValue(Window.ResizeModeProperty); }
- set { SetValue(Window.ResizeModeProperty, value); }
- }
-
- public static readonly DependencyProperty ShowActivatedProperty =
- DependencyProperty.Register("ShowActivated", typeof(bool), typeof(WindowClone));
-
- public bool ShowActivated {
- get { return (bool)GetValue(ShowActivatedProperty); }
- set { SetValue(ShowActivatedProperty, value); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public bool ShowInTaskbar {
- get { return (bool)GetValue(Window.ShowInTaskbarProperty); }
- set { SetValue(Window.ShowInTaskbarProperty, SharedInstances.Box(value)); }
- }
-
- ///
- /// Gets or sets a value that specifies whether a window will automatically size itself to fit the size of its content.
- ///
- public SizeToContent SizeToContent {
- get { return (SizeToContent)GetValue(Window.SizeToContentProperty); }
- set { SetValue(Window.SizeToContentProperty, value); }
- }
-
- ///
- /// The title to display in the Window's title bar.
- ///
- public string Title {
- get { return (string)GetValue(Window.TitleProperty); }
- set { SetValue(Window.TitleProperty, value); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- [TypeConverter(typeof(LengthConverter))]
- public double Top {
- get { return (double)GetValue(Window.TopProperty); }
- set { SetValue(Window.TopProperty, value); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public bool Topmost {
- get { return (bool)GetValue(Window.TopmostProperty); }
- set { SetValue(Window.TopmostProperty, SharedInstances.Box(value)); }
- }
-
- WindowStartupLocation windowStartupLocation;
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public WindowStartupLocation WindowStartupLocation {
- get { return windowStartupLocation; }
- set { windowStartupLocation = value; }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public WindowState WindowState {
- get { return (WindowState) GetValue(Window.WindowStateProperty); }
- set { SetValue(Window.WindowStateProperty, value); }
- }
-
- ///
- /// This property has no effect. (for compatibility with only).
- ///
- public WindowStyle WindowStyle {
- get { return (WindowStyle)GetValue(Window.WindowStyleProperty); }
- set { SetValue(Window.WindowStyleProperty, value); }
- }
-
- #pragma warning disable 0067
- // disable "event is never used" warning
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler Activated;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler Closed;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler Closing;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler ContentRendered;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler Deactivated;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler LocationChanged;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler SourceInitialized;
-
- ///
- /// This event is never raised. (for compatibility with only).
- ///
- public event EventHandler StateChanged;
- #pragma warning restore
- }
-
- ///
- /// A for
- /// (and derived classes, unless they specify their own ).
- ///
- [ExtensionFor(typeof(Window))]
- public class WindowCloneExtension : CustomInstanceFactory
- {
- ///
- /// Used to create instances of .
- ///
- public override object CreateInstance(Type type, params object[] arguments)
- {
- Debug.Assert(arguments.Length == 0);
- return new WindowClone();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs
deleted file mode 100644
index 659c6e3738..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-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 System.Windows.Controls.Primitives;
-using System.IO;
-using System.Reflection;
-using System.Resources;
-
-namespace ICSharpCode.WpfDesign.Designer.Controls
-{
- public class ZoomControl : ContentControl
- {
- static ZoomControl()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomControl),
- new FrameworkPropertyMetadata(typeof(ZoomControl)));
-
- PanToolCursor = new Cursor(GetStream("Images/PanToolCursor.cur"));
- PanToolCursorMouseDown = new Cursor(GetStream("Images/PanToolCursorMouseDown.cur"));
- }
-
- static Stream GetStream(string path)
- {
- var a = Assembly.GetExecutingAssembly();
- var m = new ResourceManager(a.GetName().Name + ".g", a);
- var s = m.GetStream(path.ToLower());
- return s;
- }
-
- static Cursor PanToolCursor;
- static Cursor PanToolCursorMouseDown;
- public static double ZoomFactor = 1.1;
- public static double Minimum = 0.1;
- public static double Maximum = 10;
-
- double startHorizontalOffset;
- double startVericalOffset;
-
- internal ScrollViewer ScrollViewer;
- Border container;
- ScaleTransform transform;
- Point startPoint;
- bool isMouseDown;
- bool pan;
-
- public static readonly DependencyProperty ZoomProperty =
- DependencyProperty.Register("Zoom", typeof(double), typeof(ZoomControl),
- new PropertyMetadata(1.0, null, CoerceZoom));
-
- public double Zoom
- {
- get { return (double)GetValue(ZoomProperty); }
- set { SetValue(ZoomProperty, value); }
- }
-
- static object CoerceZoom(DependencyObject d, object baseValue)
- {
- var zoom = (double)baseValue;
- return Math.Max(Minimum, Math.Min(Maximum, zoom));
- }
-
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
-
- ScrollViewer = (ScrollViewer)Template.FindName("scrollViewer", this);
- container = (Border)Template.FindName("container", this);
- transform = new ScaleTransform();
- container.LayoutTransform = transform;
-
- var uxPlus = (ButtonBase)Template.FindName("uxPlus", this);
- var uxMinus = (ButtonBase)Template.FindName("uxMinus", this);
- var uxReset = (ButtonBase)Template.FindName("uxReset", this);
-
- uxPlus.Click += delegate { ZoomIn(); };
- uxMinus.Click += delegate { ZoomOut(); };
- uxReset.Click += delegate { Reset(); };
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
- if (e.Property == ZoomProperty)
- {
- transform.ScaleX = Zoom;
- transform.ScaleY = Zoom;
- CenterViewport((double)e.OldValue);
- }
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (!pan && e.Key == Key.Space)
- {
- Cursor = PanToolCursor;
- pan = true;
- }
- }
-
- protected override void OnKeyUp(KeyEventArgs e)
- {
- if (e.Key == Key.Space)
- {
- ClearValue(CursorProperty);
- pan = false;
- }
- }
-
- protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
- {
- if (pan)
- {
- Cursor = PanToolCursorMouseDown;
- Mouse.Capture(this); // will call move
- isMouseDown = true;
- startPoint = e.GetPosition(this);
- PanStart();
- }
- }
-
- protected override void OnPreviewMouseMove(MouseEventArgs e)
- {
- if (isMouseDown && pan)
- {
- var endPoint = e.GetPosition(this);
- PanContinue(endPoint - startPoint);
- }
- }
-
- protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
- {
- if (isMouseDown)
- {
- Cursor = PanToolCursor;
- isMouseDown = false;
- Mouse.Capture(null);
- }
- }
-
- protected override void OnMouseEnter(MouseEventArgs e)
- {
- Focus();
- }
-
- public void Fit()
- {
- Zoom = Math.Min(
- ScrollViewer.ActualWidth / container.ActualWidth,
- ScrollViewer.ActualHeight / container.ActualHeight);
- }
-
- public void ZoomIn()
- {
- Zoom *= ZoomFactor;
- }
-
- public void ZoomOut()
- {
- Zoom /= ZoomFactor;
- }
-
- public void Reset()
- {
- Zoom = 1;
- ScrollViewer.ScrollToHorizontalOffset(0);
- ScrollViewer.ScrollToVerticalOffset(0);
- }
-
- void PanStart()
- {
- startHorizontalOffset = ScrollViewer.HorizontalOffset;
- startVericalOffset = ScrollViewer.VerticalOffset;
- }
-
- void PanContinue(Vector delta)
- {
- ScrollViewer.ScrollToHorizontalOffset(startHorizontalOffset - delta.X);
- ScrollViewer.ScrollToVerticalOffset(startVericalOffset - delta.Y);
- }
-
- void CenterViewport(double oldZoom)
- {
- var k = Zoom / oldZoom;
- var add = (k * ScrollViewer.ViewportWidth - ScrollViewer.ViewportWidth) / 2;
- ScrollViewer.ScrollToHorizontalOffset(k * ScrollViewer.HorizontalOffset + add);
- add = (k * ScrollViewer.ViewportHeight - ScrollViewer.ViewportHeight) / 2;
- ScrollViewer.ScrollToVerticalOffset(k * ScrollViewer.VerticalOffset + add);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
deleted file mode 100644
index d43fae8d29..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Data;
-using System.Globalization;
-using System.Windows;
-using System.Collections;
-
-namespace ICSharpCode.WpfDesign.Designer.Converters
-{
- public class IntFromEnumConverter : IValueConverter
- {
- public static IntFromEnumConverter Instance = new IntFromEnumConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (int)value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return Enum.ToObject(targetType, (int)value);
- }
- }
-
- public class HiddenWhenFalse : IValueConverter
- {
- public static HiddenWhenFalse Instance = new HiddenWhenFalse();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (bool)value ? Visibility.Visible : Visibility.Hidden;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class CollapsedWhenFalse : IValueConverter
- {
- public static CollapsedWhenFalse Instance = new CollapsedWhenFalse();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (bool)value ? Visibility.Visible : Visibility.Collapsed;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class LevelConverter : IValueConverter
- {
- public static LevelConverter Instance = new LevelConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return new Thickness(2 + 14 * (int)value, 0, 0, 0);
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class CollapsedWhenZero : IValueConverter
- {
- public static CollapsedWhenZero Instance = new CollapsedWhenZero();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value == null || (int)value == 0) {
- return Visibility.Collapsed;
- }
- return Visibility.Visible;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class FalseWhenNull : IValueConverter
- {
- public static FalseWhenNull Instance = new FalseWhenNull();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value != null;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class BoldWhenTrue : IValueConverter
- {
- public static BoldWhenTrue Instance = new BoldWhenTrue();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (bool)value ? FontWeights.Bold : FontWeights.Normal;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- // Boxed int throw exception without converter (wpf bug?)
- public class DummyConverter : IValueConverter
- {
- public static DummyConverter Instance = new DummyConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
deleted file mode 100644
index ded6791a92..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Threading;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- sealed class DesignPanel : Decorator, IDesignPanel
- {
- #region Hit Testing
- ///
- /// this element is always hit (unless HitTestVisible is set to false)
- ///
- sealed class EatAllHitTestRequests : UIElement
- {
- protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
- {
- return new GeometryHitTestResult(this, IntersectionDetail.FullyContains);
- }
-
- protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
- {
- return new PointHitTestResult(this, hitTestParameters.HitPoint);
- }
- }
-
- static void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback)
- {
- VisualTreeHelper.HitTest(reference, filterCallback, resultCallback,
- new PointHitTestParameters(point));
- }
-
- static HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget)
- {
- UIElement element = potentialHitTestTarget as UIElement;
- if (element != null) {
- if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) {
- return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
- }
- }
- return HitTestFilterBehavior.Continue;
- }
-
- ///
- /// Performs a custom hit testing lookup for the specified mouse event args.
- ///
- public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface)
- {
- DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
- HitTest(mousePosition, testAdorners, testDesignSurface,
- delegate(DesignPanelHitTestResult r) {
- result = r;
- return false;
- });
- return result;
- }
-
- ///
- /// Performs a hit test on the design surface, raising for each match.
- /// Hit testing continues while the callback returns true.
- ///
- public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate callback)
- {
- if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) {
- return;
- }
- // First try hit-testing on the adorner layer.
-
- bool continueHitTest = true;
-
- if (testAdorners) {
- RunHitTest(
- _adornerLayer, mousePosition, FilterHitTestInvisibleElements,
- delegate(HitTestResult result) {
- if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
- DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
- DependencyObject obj = result.VisualHit;
- while (obj != null && obj != _adornerLayer) {
- AdornerPanel adorner = obj as AdornerPanel;
- if (adorner != null) {
- customResult.AdornerHit = adorner;
- }
- obj = VisualTreeHelper.GetParent(obj);
- }
- continueHitTest = callback(customResult);
- return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
- } else {
- return HitTestResultBehavior.Continue;
- }
- });
- }
-
- if (continueHitTest && testDesignSurface) {
- RunHitTest(
- this.Child, mousePosition, delegate { return HitTestFilterBehavior.Continue; },
- delegate(HitTestResult result) {
- if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
- DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
-
- ViewService viewService = _context.Services.View;
- DependencyObject obj = result.VisualHit;
- while (obj != null) {
- if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
- break;
- obj = VisualTreeHelper.GetParent(obj);
- }
- if (customResult.ModelHit == null) {
- customResult.ModelHit = _context.RootItem;
- }
- continueHitTest = callback(customResult);
- return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
- } else {
- return HitTestResultBehavior.Continue;
- }
- }
- );
- }
- }
- #endregion
-
- #region Fields + Constructor
- DesignContext _context;
- readonly EatAllHitTestRequests _eatAllHitTestRequests;
- readonly AdornerLayer _adornerLayer;
-
- public DesignPanel()
- {
- this.Focusable = true;
- this.VerticalAlignment = VerticalAlignment.Top;
- this.HorizontalAlignment = HorizontalAlignment.Left;
- this.AllowDrop = true;
- DesignerProperties.SetIsInDesignMode(this, true);
-
- _eatAllHitTestRequests = new EatAllHitTestRequests();
- _eatAllHitTestRequests.MouseDown += delegate {
- // ensure the design panel has focus while the user is interacting with it
- this.Focus();
- };
- _eatAllHitTestRequests.AllowDrop = true;
- _adornerLayer = new AdornerLayer(this);
- }
- #endregion
-
- #region Properties
-
- ///
- /// Gets/Sets the design context.
- ///
- public DesignContext Context {
- get { return _context; }
- set { _context = value; }
- }
-
- public ICollection Adorners {
- get {
- return _adornerLayer.Adorners;
- }
- }
-
- ///
- /// Gets/Sets if the design content is visible for hit-testing purposes.
- ///
- public bool IsContentHitTestVisible {
- get { return !_eatAllHitTestRequests.IsHitTestVisible; }
- set { _eatAllHitTestRequests.IsHitTestVisible = !value; }
- }
-
- ///
- /// Gets/Sets if the adorner layer is visible for hit-testing purposes.
- ///
- public bool IsAdornerLayerHitTestVisible {
- get { return _adornerLayer.IsHitTestVisible; }
- set { _adornerLayer.IsHitTestVisible = value; }
- }
-
- #endregion
-
- #region Visual Child Management
- public override UIElement Child {
- get { return base.Child; }
- set {
- if (base.Child == value)
- return;
- if (value == null) {
- // Child is being set from some value to null
-
- // remove _adornerLayer and _eatAllHitTestRequests
- RemoveVisualChild(_adornerLayer);
- RemoveVisualChild(_eatAllHitTestRequests);
- } else if (base.Child == null) {
- // Child is being set from null to some value
- AddVisualChild(_adornerLayer);
- AddVisualChild(_eatAllHitTestRequests);
- }
- base.Child = value;
- }
- }
-
- protected override Visual GetVisualChild(int index)
- {
- if (base.Child != null) {
- if (index == 0)
- return base.Child;
- else if (index == 1)
- return _eatAllHitTestRequests;
- else if (index == 2)
- return _adornerLayer;
- }
- return base.GetVisualChild(index);
- }
-
- protected override int VisualChildrenCount {
- get {
- if (base.Child != null)
- return 3;
- else
- return base.VisualChildrenCount;
- }
- }
-
- protected override Size MeasureOverride(Size constraint)
- {
- Size result = base.MeasureOverride(constraint);
- if (this.Child != null) {
- _adornerLayer.Measure(constraint);
- _eatAllHitTestRequests.Measure(constraint);
- }
- return result;
- }
-
- protected override Size ArrangeOverride(Size arrangeSize)
- {
- Size result = base.ArrangeOverride(arrangeSize);
- if (this.Child != null) {
- Rect r = new Rect(new Point(0, 0), arrangeSize);
- _adornerLayer.Arrange(r);
- _eatAllHitTestRequests.Arrange(r);
- }
- return result;
- }
- #endregion
-
- protected override void OnQueryCursor(QueryCursorEventArgs e)
- {
- base.OnQueryCursor(e);
- if (_context != null) {
- Cursor cursor = _context.Services.Tool.CurrentTool.Cursor;
- if (cursor != null) {
- e.Cursor = cursor;
- e.Handled = true;
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml
deleted file mode 100644
index 0fe0ad99df..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs
deleted file mode 100644
index 4f09e107aa..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs
+++ /dev/null
@@ -1,258 +0,0 @@
-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 System.Xml;
-using ICSharpCode.WpfDesign.Designer.Xaml;
-using ICSharpCode.WpfDesign.Designer.Services;
-using System.Diagnostics;
-using ICSharpCode.WpfDesign.XamlDom;
-using System.Threading;
-using System.Globalization;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- ///
- /// Surface hosting the WPF designer.
- ///
- public partial class DesignSurface
- {
- static DesignSurface()
- {
- //TODO: this is for converters (see PropertyGrid)
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- }
-
- public DesignSurface()
- {
- InitializeComponent();
-
- this.AddCommandHandler(ApplicationCommands.Undo, Undo, CanUndo);
- this.AddCommandHandler(ApplicationCommands.Redo, Redo, CanRedo);
- this.AddCommandHandler(ApplicationCommands.Copy, Copy, HasSelection);
- this.AddCommandHandler(ApplicationCommands.Cut, Cut, HasSelection);
- this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
- this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
- this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);
- }
-
- protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
- {
- if (e.OriginalSource == uxZoom.ScrollViewer) {
- UnselectAll();
- }
- }
-
- DesignContext _designContext;
-
- ///
- /// Gets the active design context.
- ///
- public DesignContext DesignContext {
- get { return _designContext; }
- }
-
- ///
- /// Initializes the designer content from the specified XmlReader.
- ///
- public void LoadDesigner(XmlReader xamlReader, XamlLoadSettings loadSettings)
- {
- UnloadDesigner();
- loadSettings = loadSettings ?? new XamlLoadSettings();
- loadSettings.CustomServiceRegisterFunctions.Add(
- context => context.Services.AddService(typeof(IDesignPanel), _designPanel));
- InitializeDesigner(new XamlDesignContext(xamlReader, loadSettings));
- }
-
- ///
- /// Saves the designer content into the specified XmlWriter.
- ///
- public void SaveDesigner(XmlWriter writer)
- {
- _designContext.Save(writer);
- }
-
- void InitializeDesigner(DesignContext context)
- {
- _designContext = context;
- _designPanel.Context = context;
-
- if (context.RootItem != null) {
- _sceneContainer.Child = context.RootItem.View;
- }
-
- context.Services.RunWhenAvailable(
- undoService => undoService.UndoStackChanged += delegate {
- CommandManager.InvalidateRequerySuggested();
- }
- );
- context.Services.Selection.SelectionChanged += delegate {
- CommandManager.InvalidateRequerySuggested();
- };
- }
-
- ///
- /// Unloads the designer content.
- ///
- public void UnloadDesigner()
- {
- if (_designContext != null) {
- foreach (object o in _designContext.Services.AllServices) {
- IDisposable d = o as IDisposable;
- if (d != null) d.Dispose();
- }
- }
- _designContext = null;
- _designPanel.Context = null;
- _sceneContainer.Child = null;
- _designPanel.Adorners.Clear();
- }
-
- #region Commands
-
- public bool CanUndo()
- {
- UndoService undoService = GetService();
- return undoService != null && undoService.CanUndo;
- }
-
- public void Undo()
- {
- UndoService undoService = GetService();
- IUndoAction action = undoService.UndoActions.First();
- Debug.WriteLine("Undo " + action.Title);
- undoService.Undo();
- _designContext.Services.Selection.SetSelectedComponents(GetLiveElements(action.AffectedElements));
- }
-
- public bool CanRedo()
- {
- UndoService undoService = GetService();
- return undoService != null && undoService.CanRedo;
- }
-
- public void Redo()
- {
- UndoService undoService = GetService();
- IUndoAction action = undoService.RedoActions.First();
- Debug.WriteLine("Redo " + action.Title);
- undoService.Redo();
- _designContext.Services.Selection.SetSelectedComponents(GetLiveElements(action.AffectedElements));
- }
-
- public bool HasSelection()
- {
- return false;
- }
-
- public void Copy()
- {
- }
-
- public void Cut()
- {
- }
-
- public bool CanDelete()
- {
- if (_designContext != null) {
- return ModelTools.CanDeleteComponents(_designContext.Services.Selection.SelectedItems);
- }
- return false;
- }
-
- public void Delete()
- {
- if (_designContext != null) {
- ModelTools.DeleteComponents(_designContext.Services.Selection.SelectedItems);
- }
- }
-
- public bool CanPaste()
- {
- return false;
- }
-
- public void Paste()
- {
- }
-
- public bool CanSelectAll()
- {
- return DesignContext != null;
- }
-
- //TODO: Do not select layout root
- public void SelectAll()
- {
- var items = Descendants(DesignContext.RootItem).Where(item => ModelTools.CanSelectComponent(item)).ToArray();
- DesignContext.Services.Selection.SetSelectedComponents(items);
- }
-
- public void UnselectAll()
- {
- DesignContext.Services.Selection.SetSelectedComponents(null);
- }
-
- //TODO: Share with Outline / PlacementBehavior
- public static IEnumerable DescendantsAndSelf(DesignItem item)
- {
- yield return item;
- foreach (var child in Descendants(item)) {
- yield return child;
- }
- }
-
- public static IEnumerable Descendants(DesignItem item)
- {
- if (item.ContentPropertyName != null) {
- var content = item.ContentProperty;
- if (content.IsCollection) {
- foreach (var child in content.CollectionElements) {
- foreach (var child2 in DescendantsAndSelf(child)) {
- yield return child2;
- }
- }
- } else {
- if (content.Value != null) {
- foreach (var child2 in DescendantsAndSelf(content.Value)) {
- yield return child2;
- }
- }
- }
- }
- }
-
- // Filters an element list, dropping all elements that are not part of the xaml document
- // (e.g. because they were deleted).
- static List GetLiveElements(ICollection items)
- {
- List result = new List(items.Count);
- foreach (DesignItem item in items) {
- if (ModelTools.IsInDocument(item) && ModelTools.CanSelectComponent(item)) {
- result.Add(item);
- }
- }
- return result;
- }
-
- T GetService() where T : class
- {
- if (_designContext != null)
- return _designContext.Services.GetService();
- else
- return null;
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs
deleted file mode 100644
index 3ef7df9d65..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- ///
- /// When the designer is hosted in a Windows.Forms application, exceptions in
- /// drag'n'drop handlers are silently ignored.
- /// Applications hosting the designer should specify a delegate to their own exception handling
- /// method. The default is Environment.FailFast.
- ///
- public static class DragDropExceptionHandler
- {
- public static Action HandleException = delegate(Exception ex) {
- Environment.FailFast(ex.ToString());
- };
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
deleted file mode 100644
index e9e7c819a5..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Reflection;
-using System.Collections;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- public static class ExtensionMethods
- {
- public static double Coerce(this double d, double min, double max)
- {
- return Math.Max(Math.Min(d, max), min);
- }
-
- public static void AddRange(this ICollection col, IEnumerable items)
- {
- foreach (var item in items) {
- col.Add(item);
- }
- }
-
- public static object GetDataContext(this RoutedEventArgs e)
- {
- var f = e.OriginalSource as FrameworkElement;
- if (f != null) {
- return f.DataContext;
- }
- return null;
- }
-
- public static T FindAncestor(this DependencyObject d, string name) where T : class
- {
- while (true) {
- if (d == null) return null;
- if (d is T && d is FrameworkElement && (d as FrameworkElement).Name == name) return d as T;
- d = VisualTreeHelper.GetParent(d);
- }
- }
-
- public static T FindAncestor(this DependencyObject d) where T : class
- {
- while (true) {
- if (d == null) return null;
- if (d is T) return d as T;
- d = VisualTreeHelper.GetParent(d);
- }
- }
-
- public static T FindChild(this DependencyObject d) where T : class
- {
- if (d is T) return d as T;
- int n = VisualTreeHelper.GetChildrenCount(d);
- for (int i = 0; i < n; i++) {
- var child = VisualTreeHelper.GetChild(d, i);
- var result = FindChild(child);
- if (result != null) return result;
- }
- return null;
- }
-
- public static void AddCommandHandler(this UIElement element, ICommand command, Action execute)
- {
- AddCommandHandler(element, command, execute, null);
- }
-
- public static void AddCommandHandler(this UIElement element, ICommand command, Action execute, Func canExecute)
- {
- var cb = new CommandBinding(command);
- if (canExecute != null) {
- cb.CanExecute += delegate(object sender, CanExecuteRoutedEventArgs e) {
- e.CanExecute = canExecute();
- e.Handled = true;
- };
- }
- cb.Executed += delegate(object sender, ExecutedRoutedEventArgs e) {
- execute();
- };
- element.CommandBindings.Add(cb);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs
deleted file mode 100644
index 95e048c4ac..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Windows.Controls;
-using System.Windows;
-using ICSharpCode.WpfDesign.Designer.Controls;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- [ExtensionFor(typeof(Panel))]
- public class BorderForInvisibleControl : PermanentAdornerProvider
- {
- protected override void OnInitialized()
- {
- base.OnInitialized();
-
- var adornerPanel = new AdornerPanel();
- var border = new Border();
- border.BorderThickness = new Thickness(1);
- border.BorderBrush = Brushes.WhiteSmoke;
- border.IsHitTestVisible = false;
- AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent);
- adornerPanel.Children.Add(border);
- Adorners.Add(adornerPanel);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
deleted file mode 100644
index 4f504a9108..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-
-using ICSharpCode.WpfDesign.Designer.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Provides behavior for .
- ///
- [ExtensionFor(typeof(Canvas), OverrideExtension=typeof(DefaultPlacementBehavior))]
- public sealed class CanvasPlacementSupport : SnaplinePlacementBehavior
- {
- static double GetLeft(UIElement element)
- {
- double v = (double)element.GetValue(Canvas.LeftProperty);
- if (double.IsNaN(v))
- return 0;
- else
- return v;
- }
-
- static double GetTop(UIElement element)
- {
- double v = (double)element.GetValue(Canvas.TopProperty);
- if (double.IsNaN(v))
- return 0;
- else
- return v;
- }
-
- //TODO: Is default way ok?
- //public override Rect GetPosition(PlacementOperation operation, DesignItem childItem)
- //{
- // UIElement child = childItem.View;
- // return new Rect(GetLeft(child), GetTop(child), ModelTools.GetWidth(child), ModelTools.GetHeight(child));
- //}
-
- public override void SetPosition(PlacementInformation info)
- {
- base.SetPosition(info);
- info.Item.Properties[FrameworkElement.MarginProperty].Reset();
-
- UIElement child = info.Item.View;
- Rect newPosition = info.Bounds;
-
- if (newPosition.Left != GetLeft(child)) {
- info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(newPosition.Left);
- }
- if (newPosition.Top != GetTop(child)) {
- info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(newPosition.Top);
- }
- }
-
- public override void LeaveContainer(PlacementOperation operation)
- {
- base.LeaveContainer(operation);
- foreach (PlacementInformation info in operation.PlacedItems) {
- info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
- info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).Reset();
- }
- }
-
- public override void EnterContainer(PlacementOperation operation)
- {
- base.EnterContainer(operation);
- foreach (PlacementInformation info in operation.PlacedItems) {
- info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].Reset();
- info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].Reset();
- info.Item.Properties[FrameworkElement.MarginProperty].Reset();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
deleted file mode 100644
index 90edbbaac9..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Windows.Controls;
-using System.Windows;
-using ICSharpCode.WpfDesign.Designer.Controls;
-using System.Diagnostics;
-using ICSharpCode.WpfDesign.XamlDom;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- [ExtensionFor(typeof(UIElement))]
- public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior
- {
- protected override void OnInitialized()
- {
- base.OnInitialized();
- if (ExtendedItem.ContentProperty == null ||
- Metadata.IsPlacementDisabled(ExtendedItem.ComponentType))
- return;
- ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this);
- }
-
- public virtual bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position)
- {
- return true;
- }
-
- public virtual void BeginPlacement(PlacementOperation operation)
- {
- }
-
- public virtual void EndPlacement(PlacementOperation operation)
- {
- }
-
- public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
- {
- var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View);
- return new Rect(p, item.View.RenderSize);
- }
-
- public virtual void BeforeSetPosition(PlacementOperation operation)
- {
- }
-
- public virtual void SetPosition(PlacementInformation info)
- {
- ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
- }
-
- public virtual bool CanLeaveContainer(PlacementOperation operation)
- {
- return true;
- }
-
- public virtual void LeaveContainer(PlacementOperation operation)
- {
- if (ExtendedItem.ContentProperty.IsCollection) {
- foreach (var info in operation.PlacedItems) {
- ExtendedItem.ContentProperty.CollectionElements.Remove(info.Item);
- }
- } else {
- ExtendedItem.ContentProperty.Reset();
- }
- }
-
- public virtual bool CanEnterContainer(PlacementOperation operation)
- {
- if (ExtendedItem.ContentProperty.IsCollection &&
- CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType,
- operation.PlacedItems.Select(p => p.Item.Component)))
- return true;
- return !ExtendedItem.ContentProperty.IsSet;
- }
-
- public virtual void EnterContainer(PlacementOperation operation)
- {
- if (ExtendedItem.ContentProperty.IsCollection) {
- foreach (var info in operation.PlacedItems) {
- ExtendedItem.ContentProperty.CollectionElements.Add(info.Item);
- }
- } else {
- ExtendedItem.ContentProperty.SetValue(operation.PlacedItems[0].Item);
- }
- if (operation.Type == PlacementType.AddItem) {
- foreach (var info in operation.PlacedItems) {
- SetPosition(info);
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridAdornerProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridAdornerProvider.cs
deleted file mode 100644
index 5425d321d6..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridAdornerProvider.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Threading;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Allows arranging the rows/column on a grid.
- ///
- [ExtensionFor(typeof(Grid))]
- [ExtensionServer(typeof(LogicalOrExtensionServer))]
- public class GridAdornerProvider : AdornerProvider
- {
- sealed class RowSplitterPlacement : AdornerPlacement
- {
- readonly RowDefinition row;
- public RowSplitterPlacement(RowDefinition row) { this.row = row; }
-
- public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
- {
- adorner.Arrange(new Rect(-(GridRailAdorner.RailSize + GridRailAdorner.RailDistance),
- row.Offset - GridRailAdorner.SplitterWidth / 2,
- GridRailAdorner.RailSize + GridRailAdorner.RailDistance + adornedElementSize.Width,
- GridRailAdorner.SplitterWidth));
- }
- }
-
- sealed class ColumnSplitterPlacement : AdornerPlacement
- {
- readonly ColumnDefinition column;
- public ColumnSplitterPlacement(ColumnDefinition column) { this.column = column; }
-
- public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
- {
- adorner.Arrange(new Rect(column.Offset - GridRailAdorner.SplitterWidth / 2,
- -(GridRailAdorner.RailSize + GridRailAdorner.RailDistance),
- GridRailAdorner.SplitterWidth,
- GridRailAdorner.RailSize + GridRailAdorner.RailDistance + adornedElementSize.Height));
- }
- }
-
- AdornerPanel adornerPanel = new AdornerPanel();
- GridRailAdorner topBar, leftBar;
-
- protected override void OnInitialized()
- {
- leftBar = new GridRailAdorner(this.ExtendedItem, adornerPanel, Orientation.Vertical);
- topBar = new GridRailAdorner(this.ExtendedItem, adornerPanel, Orientation.Horizontal);
-
- RelativePlacement rp = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Stretch);
- rp.XOffset -= GridRailAdorner.RailDistance;
- AdornerPanel.SetPlacement(leftBar, rp);
- rp = new RelativePlacement(HorizontalAlignment.Stretch, VerticalAlignment.Top);
- rp.YOffset -= GridRailAdorner.RailDistance;
- AdornerPanel.SetPlacement(topBar, rp);
-
- adornerPanel.Children.Add(leftBar);
- adornerPanel.Children.Add(topBar);
- this.Adorners.Add(adornerPanel);
-
- CreateSplitter();
- this.ExtendedItem.PropertyChanged += OnPropertyChanged;
-
- base.OnInitialized();
- }
-
- protected override void OnRemove()
- {
- this.ExtendedItem.PropertyChanged -= OnPropertyChanged;
- base.OnRemove();
- }
-
- void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "RowDefinitions" || e.PropertyName == "ColumnDefinitions") {
- CreateSplitter();
- }
- }
-
- readonly List splitterList = new List();
- ///
- /// flag used to ensure that the asynchronus splitter creation is only enqueued once
- ///
- bool requireSplitterRecreation;
-
- void CreateSplitter()
- {
- if (requireSplitterRecreation) return;
- requireSplitterRecreation = true;
-
- // splitter creation is delayed to prevent unnecessary splitter re-creation when multiple
- // changes to the collection are done.
- // It also ensures that the Offset property of new rows/columns is initialized when the splitter
- // is added.
- Dispatcher.CurrentDispatcher.BeginInvoke(
- DispatcherPriority.Loaded, // Loaded = after layout, but before input
- (Action)delegate {
- requireSplitterRecreation = false;
- foreach (GridSplitterAdorner splitter in splitterList) {
- adornerPanel.Children.Remove(splitter);
- }
- splitterList.Clear();
- Grid grid = (Grid)this.ExtendedItem.Component;
- IList col = this.ExtendedItem.Properties["RowDefinitions"].CollectionElements;
- for (int i = 1; i < grid.RowDefinitions.Count; i++) {
- RowDefinition row = grid.RowDefinitions[i];
- GridRowSplitterAdorner splitter = new GridRowSplitterAdorner(this.ExtendedItem, col[i-1], col[i]);
- AdornerPanel.SetPlacement(splitter, new RowSplitterPlacement(row));
- adornerPanel.Children.Add(splitter);
- splitterList.Add(splitter);
- }
- col = this.ExtendedItem.Properties["ColumnDefinitions"].CollectionElements;
- for (int i = 1; i < grid.ColumnDefinitions.Count; i++) {
- ColumnDefinition column = grid.ColumnDefinitions[i];
- GridColumnSplitterAdorner splitter = new GridColumnSplitterAdorner(this.ExtendedItem, col[i-1], col[i]);
- AdornerPanel.SetPlacement(splitter, new ColumnSplitterPlacement(column));
- adornerPanel.Children.Add(splitter);
- splitterList.Add(splitter);
- }
- });
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
deleted file mode 100644
index cd51501f95..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Diagnostics;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Provides behavior for .
- ///
- [ExtensionFor(typeof(Grid), OverrideExtension=typeof(DefaultPlacementBehavior))]
- public sealed class GridPlacementSupport : SnaplinePlacementBehavior
- {
- Grid grid;
-
- protected override void OnInitialized()
- {
- base.OnInitialized();
- grid = (Grid)this.ExtendedItem.Component;
- }
-
- //TODO: Is default way ok?
- //public override Rect GetPosition(PlacementOperation operation, DesignItem child)
- //{
- // FrameworkElement obj = child.Component as FrameworkElement;
- // if (obj == null) return new Rect();
-
- // Thickness margin = obj.Margin;
-
- // double left, width, right;
- // switch (obj.HorizontalAlignment) {
- // case HorizontalAlignment.Stretch:
- // left = GetColumnOffset(Grid.GetColumn(obj)) + margin.Left;
- // right = GetColumnOffset(Grid.GetColumn(obj) + Grid.GetColumnSpan(obj)) - margin.Right;
- // width = right - left;
- // break;
- // case HorizontalAlignment.Left:
- // left = GetColumnOffset(Grid.GetColumn(obj)) + margin.Left;
- // width = ModelTools.GetWidth(obj);
- // right = left + width;
- // break;
- // case HorizontalAlignment.Right:
- // right = GetColumnOffset(Grid.GetColumn(obj) + Grid.GetColumnSpan(obj)) - margin.Right;
- // width = ModelTools.GetWidth(obj);
- // left = right - width;
- // break;
- // case HorizontalAlignment.Center:
- // throw new NotImplementedException();
- // default:
- // throw new NotSupportedException();
- // }
-
- // double top, height, bottom;
- // switch (obj.VerticalAlignment) {
- // case VerticalAlignment.Stretch:
- // top = GetRowOffset(Grid.GetRow(obj)) + margin.Top;
- // bottom = GetRowOffset(Grid.GetRow(obj) + Grid.GetRowSpan(obj)) - margin.Bottom;
- // height = bottom - top;
- // break;
- // case VerticalAlignment.Top:
- // top = GetRowOffset(Grid.GetRow(obj)) + margin.Top;
- // height = ModelTools.GetHeight(obj);
- // bottom = top + height;
- // break;
- // case VerticalAlignment.Bottom:
- // bottom = GetRowOffset(Grid.GetRow(obj) + Grid.GetRowSpan(obj)) - margin.Bottom;
- // height = ModelTools.GetHeight(obj);
- // top = bottom - height;
- // break;
- // case VerticalAlignment.Center:
- // throw new NotImplementedException();
- // default:
- // throw new NotSupportedException();
- // }
- // return new Rect(left, top, Math.Max(0, width), Math.Max(0, height));
- //}
-
- double GetColumnOffset(int index)
- {
- // when the grid has no columns, we still need to return 0 for index=0 and grid.Width for index=1
- if (index == 0)
- return 0;
- else if (index < grid.ColumnDefinitions.Count)
- return grid.ColumnDefinitions[index].Offset;
- else
- return grid.ActualWidth;
- }
-
- double GetRowOffset(int index)
- {
- if (index == 0)
- return 0;
- else if (index < grid.RowDefinitions.Count)
- return grid.RowDefinitions[index].Offset;
- else
- return grid.ActualHeight;
- }
-
- const double epsilon = 0.00000001;
-
- int GetColumnIndex(double x)
- {
- if (grid.ColumnDefinitions.Count == 0)
- return 0;
- for (int i = 1; i < grid.ColumnDefinitions.Count; i++) {
- if (x < grid.ColumnDefinitions[i].Offset - epsilon)
- return i - 1;
- }
- return grid.ColumnDefinitions.Count - 1;
- }
-
- int GetRowIndex(double y)
- {
- if (grid.RowDefinitions.Count == 0)
- return 0;
- for (int i = 1; i < grid.RowDefinitions.Count; i++) {
- if (y < grid.RowDefinitions[i].Offset - epsilon)
- return i - 1;
- }
- return grid.RowDefinitions.Count - 1;
- }
-
- int GetEndColumnIndex(double x)
- {
- if (grid.ColumnDefinitions.Count == 0)
- return 0;
- for (int i = 1; i < grid.ColumnDefinitions.Count; i++) {
- if (x <= grid.ColumnDefinitions[i].Offset + epsilon)
- return i - 1;
- }
- return grid.ColumnDefinitions.Count - 1;
- }
-
- int GetEndRowIndex(double y)
- {
- if (grid.RowDefinitions.Count == 0)
- return 0;
- for (int i = 1; i < grid.RowDefinitions.Count; i++) {
- if (y <= grid.RowDefinitions[i].Offset + epsilon)
- return i - 1;
- }
- return grid.RowDefinitions.Count - 1;
- }
-
- static void SetColumn(DesignItem item, int column, int columnSpan)
- {
- Debug.Assert(item != null && column >= 0 && columnSpan > 0);
- item.Properties.GetAttachedProperty(Grid.ColumnProperty).SetValue(column);
- if (columnSpan == 1) {
- item.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).Reset();
- } else {
- item.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).SetValue(columnSpan);
- }
- }
-
- static void SetRow(DesignItem item, int row, int rowSpan)
- {
- Debug.Assert(item != null && row >= 0 && rowSpan > 0);
- item.Properties.GetAttachedProperty(Grid.RowProperty).SetValue(row);
- if (rowSpan == 1) {
- item.Properties.GetAttachedProperty(Grid.RowSpanProperty).Reset();
- } else {
- item.Properties.GetAttachedProperty(Grid.RowSpanProperty).SetValue(rowSpan);
- }
- }
-
- static HorizontalAlignment SuggestHorizontalAlignment(Rect itemBounds, Rect availableSpaceRect)
- {
- if (itemBounds.Right < (availableSpaceRect.Left + availableSpaceRect.Right) / 2) {
- return HorizontalAlignment.Left;
- } else if (itemBounds.Left > (availableSpaceRect.Left + availableSpaceRect.Right) / 2) {
- return HorizontalAlignment.Right;
- } else {
- return HorizontalAlignment.Stretch;
- }
- }
-
- static VerticalAlignment SuggestVerticalAlignment(Rect itemBounds, Rect availableSpaceRect)
- {
- if (itemBounds.Bottom < (availableSpaceRect.Top + availableSpaceRect.Bottom) / 2) {
- return VerticalAlignment.Top;
- } else if (itemBounds.Top > (availableSpaceRect.Top + availableSpaceRect.Bottom) / 2) {
- return VerticalAlignment.Bottom;
- } else {
- return VerticalAlignment.Stretch;
- }
- }
-
- GrayOutDesignerExceptActiveArea grayOut;
-
- public override void EndPlacement(PlacementOperation operation)
- {
- GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
- base.EndPlacement(operation);
- }
-
- public override void SetPosition(PlacementInformation info)
- {
- base.SetPosition(info);
- if (info.Operation.Type == PlacementType.AddItem) {
- SetColumn(info.Item, GetColumnIndex(info.Bounds.Left), 1);
- SetRow(info.Item, GetRowIndex(info.Bounds.Top), 1);
- } else {
- int leftColumnIndex = GetColumnIndex(info.Bounds.Left);
- int rightColumnIndex = GetEndColumnIndex(info.Bounds.Right);
- if (rightColumnIndex < leftColumnIndex) rightColumnIndex = leftColumnIndex;
- SetColumn(info.Item, leftColumnIndex, rightColumnIndex - leftColumnIndex + 1);
- int topRowIndex = GetRowIndex(info.Bounds.Top);
- int bottomRowIndex = GetEndRowIndex(info.Bounds.Bottom);
- if (bottomRowIndex < topRowIndex) bottomRowIndex = topRowIndex;
- SetRow(info.Item, topRowIndex, bottomRowIndex - topRowIndex + 1);
-
- Rect availableSpaceRect = new Rect(
- new Point(GetColumnOffset(leftColumnIndex), GetRowOffset(topRowIndex)),
- new Point(GetColumnOffset(rightColumnIndex + 1), GetRowOffset(bottomRowIndex + 1))
- );
- if (grayOut != null) {
- grayOut.AnimateActiveAreaRectTo(availableSpaceRect);
- } else {
- GrayOutDesignerExceptActiveArea.Start(ref grayOut, this.Services, this.ExtendedItem.View, availableSpaceRect);
- }
-
- HorizontalAlignment ha = (HorizontalAlignment)info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].ValueOnInstance;
- VerticalAlignment va = (VerticalAlignment)info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].ValueOnInstance;
- ha = SuggestHorizontalAlignment(info.Bounds, availableSpaceRect);
- va = SuggestVerticalAlignment(info.Bounds, availableSpaceRect);
-
- info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].SetValue(ha);
- info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].SetValue(va);
-
- Thickness margin = new Thickness(0, 0, 0, 0);
- if (ha == HorizontalAlignment.Left || ha == HorizontalAlignment.Stretch)
- margin.Left = info.Bounds.Left - GetColumnOffset(leftColumnIndex);
- if (va == VerticalAlignment.Top || va == VerticalAlignment.Stretch)
- margin.Top = info.Bounds.Top - GetRowOffset(topRowIndex);
- if (ha == HorizontalAlignment.Right || ha == HorizontalAlignment.Stretch)
- margin.Right = GetColumnOffset(rightColumnIndex + 1) - info.Bounds.Right;
- if (va == VerticalAlignment.Bottom || va == VerticalAlignment.Stretch)
- margin.Bottom = GetRowOffset(bottomRowIndex + 1) - info.Bounds.Bottom;
- info.Item.Properties[FrameworkElement.MarginProperty].SetValue(margin);
-
- if (ha == HorizontalAlignment.Stretch)
- info.Item.Properties[FrameworkElement.WidthProperty].Reset();
- else
- info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);
- if (va == VerticalAlignment.Stretch)
- info.Item.Properties[FrameworkElement.HeightProperty].Reset();
- else
- info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
- }
- }
-
- public override void LeaveContainer(PlacementOperation operation)
- {
- base.LeaveContainer(operation);
- foreach (PlacementInformation info in operation.PlacedItems) {
- if (info.Item.ComponentType == typeof(ColumnDefinition)) {
- // TODO: combine the width of the deleted column with the previous column
- this.ExtendedItem.Properties["ColumnDefinitions"].CollectionElements.Remove(info.Item);
- } else if (info.Item.ComponentType == typeof(RowDefinition)) {
- this.ExtendedItem.Properties["RowDefinitions"].CollectionElements.Remove(info.Item);
- } else {
- info.Item.Properties.GetAttachedProperty(Grid.RowProperty).Reset();
- info.Item.Properties.GetAttachedProperty(Grid.ColumnProperty).Reset();
- info.Item.Properties.GetAttachedProperty(Grid.RowSpanProperty).Reset();
- info.Item.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).Reset();
-
- HorizontalAlignment ha = (HorizontalAlignment)info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].ValueOnInstance;
- VerticalAlignment va = (VerticalAlignment)info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].ValueOnInstance;
-
- if (ha == HorizontalAlignment.Stretch)
- info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);
- if (va == VerticalAlignment.Stretch)
- info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs
deleted file mode 100644
index 4df3dd8482..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2667$
-//
-
-using System;
-using System.Windows.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Windows;
-using System.Windows.Shapes;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
-{
- [ExtensionFor(typeof(ContentControl))]
- public class ContentControlInitializer : DefaultInitializer
- {
- public override void InitializeDefaults(DesignItem item)
- {
- DesignItemProperty contentProperty = item.Properties["Content"];
- if (contentProperty.ValueOnInstance == null) {
- contentProperty.SetValue(item.ComponentType.Name);
- }
- }
- }
-
- [ExtensionFor(typeof(HeaderedContentControl))]
- public class HeaderedContentControlInitializer : DefaultInitializer
- {
- public override void InitializeDefaults(DesignItem item)
- {
- DesignItemProperty headerProperty = item.Properties["Header"];
- if (headerProperty.ValueOnInstance == null) {
- headerProperty.SetValue(item.ComponentType.Name);
- }
- }
- }
-
- [ExtensionFor(typeof(Shape))]
- public class ShapeInitializer : DefaultInitializer
- {
- public override void InitializeDefaults(DesignItem item)
- {
- DesignItemProperty fillProperty = item.Properties["Fill"];
- if (fillProperty.ValueOnInstance == null) {
- fillProperty.SetValue(Brushes.YellowGreen);
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelInstanceFactory.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelInstanceFactory.cs
deleted file mode 100644
index 7ab77750f3..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelInstanceFactory.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.ComponentModel;
-using System.Linq;
-using System.Windows.Media;
-using System.Windows.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Instance factory used to create Panel instances.
- /// Sets the panels Brush to a transparent brush, and modifies the panel's type descriptor so that
- /// the property value is reported as null when the transparent brush is used, and
- /// setting the Brush to null actually restores the transparent brush.
- ///
- [ExtensionFor(typeof(Panel))]
- public sealed class PanelInstanceFactory : CustomInstanceFactory
- {
- Brush _transparentBrush = new SolidColorBrush(Colors.Transparent);
-
- ///
- /// Creates an instance of the specified type, passing the specified arguments to its constructor.
- ///
- public override object CreateInstance(Type type, params object[] arguments)
- {
- object instance = base.CreateInstance(type, arguments);
- Panel panel = instance as Panel;
- if (panel != null) {
- if (panel.Background == null) {
- panel.Background = _transparentBrush;
- }
- TypeDescriptionProvider provider = new DummyValueInsteadOfNullTypeDescriptionProvider(
- TypeDescriptor.GetProvider(panel), "Background", _transparentBrush);
- TypeDescriptor.AddProvider(provider, panel);
- }
- return instance;
- }
- }
-
- sealed class DummyValueInsteadOfNullTypeDescriptionProvider : TypeDescriptionProvider
- {
- // By using a TypeDescriptionProvider, we can intercept all access to the property that is
- // using a PropertyDescriptor. WpfDesign.XamlDom uses a PropertyDescriptor for accessing
- // properties (except for attached properties), so even DesignItemProperty/XamlProperty.ValueOnInstance
- // will report null when the actual value is the dummy value.
-
- readonly string _propertyName;
- readonly object _dummyValue;
-
- public DummyValueInsteadOfNullTypeDescriptionProvider(TypeDescriptionProvider existingProvider,
- string propertyName, object dummyValue)
- : base(existingProvider)
- {
- this._propertyName = propertyName;
- this._dummyValue = dummyValue;
- }
-
- public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
- {
- return new ShadowTypeDescriptor(this, base.GetTypeDescriptor(objectType, instance));
- }
-
- sealed class ShadowTypeDescriptor : CustomTypeDescriptor
- {
- readonly DummyValueInsteadOfNullTypeDescriptionProvider _parent;
-
- public ShadowTypeDescriptor(DummyValueInsteadOfNullTypeDescriptionProvider parent,
- ICustomTypeDescriptor existingDescriptor)
- : base(existingDescriptor)
- {
- this._parent = parent;
- }
-
- public override PropertyDescriptorCollection GetProperties()
- {
- return Filter(base.GetProperties());
- }
-
- public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
- {
- return Filter(base.GetProperties(attributes));
- }
-
- PropertyDescriptorCollection Filter(PropertyDescriptorCollection properties)
- {
- PropertyDescriptor property = properties[_parent._propertyName];
- if (property != null) {
- if ((properties as System.Collections.IDictionary).IsReadOnly) {
- properties = new PropertyDescriptorCollection(properties.Cast().ToArray());
- }
- properties.Remove(property);
- properties.Add(new ShadowPropertyDescriptor(_parent, property));
- }
- return properties;
- }
- }
-
- sealed class ShadowPropertyDescriptor : PropertyDescriptor
- {
- readonly DummyValueInsteadOfNullTypeDescriptionProvider _parent;
- readonly PropertyDescriptor _baseDescriptor;
-
- public ShadowPropertyDescriptor(DummyValueInsteadOfNullTypeDescriptionProvider parent,
- PropertyDescriptor existingDescriptor)
- : base(existingDescriptor)
- {
- this._parent = parent;
- this._baseDescriptor = existingDescriptor;
- }
-
- public override Type ComponentType {
- get { return _baseDescriptor.ComponentType; }
- }
-
- public override bool IsReadOnly {
- get { return _baseDescriptor.IsReadOnly; }
- }
-
- public override Type PropertyType {
- get { return _baseDescriptor.PropertyType; }
- }
-
- public override bool CanResetValue(object component)
- {
- return _baseDescriptor.CanResetValue(component);
- }
-
- public override object GetValue(object component)
- {
- object value = _baseDescriptor.GetValue(component);
- if (value == _parent._dummyValue)
- return null;
- else
- return value;
- }
-
- public override void ResetValue(object component)
- {
- _baseDescriptor.SetValue(component, _parent._dummyValue);
- }
-
- public override void SetValue(object component, object value)
- {
- _baseDescriptor.SetValue(component, value ?? _parent._dummyValue);
- }
-
- public override bool ShouldSerializeValue(object component)
- {
- return _baseDescriptor.ShouldSerializeValue(component)
- && _baseDescriptor.GetValue(component) != _parent._dummyValue;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelMove.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelMove.cs
deleted file mode 100644
index 72f40633b2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelMove.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Windows.Controls;
-using System.Windows;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- [ExtensionFor(typeof(Panel))]
- public class PanelMove : PermanentAdornerProvider
- {
- protected override void OnInitialized()
- {
- base.OnInitialized();
-
- var adornerPanel = new AdornerPanel();
- var adorner = new PanelMoveAdorner(ExtendedItem);
- AdornerPanel.SetPlacement(adorner, AdornerPlacement.FillContent);
- adornerPanel.Children.Add(adorner);
- Adorners.Add(adornerPanel);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelSelectionHandler.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelSelectionHandler.cs
deleted file mode 100644
index c20ea5c055..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelSelectionHandler.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
-using ICSharpCode.WpfDesign.Designer.Services;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Handles selection multiple controls inside a Panel.
- ///
- [ExtensionFor(typeof(Panel))]
- public class PanelSelectionHandler : BehaviorExtension, IHandlePointerToolMouseDown
- {
- protected override void OnInitialized()
- {
- base.OnInitialized();
- this.ExtendedItem.AddBehavior(typeof(IHandlePointerToolMouseDown), this);
- }
-
- public void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result)
- {
- if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
- e.Handled = true;
- new RangeSelectionGesture(result.ModelHit).Start(designPanel, e);
- }
- }
- }
-
- sealed class RangeSelectionGesture : ClickOrDragMouseGesture
- {
- DesignItem container;
- AdornerPanel adornerPanel;
- SelectionFrame selectionFrame;
-
- GrayOutDesignerExceptActiveArea grayOut;
-
- public RangeSelectionGesture(DesignItem container)
- {
- this.container = container;
- this.positionRelativeTo = container.View;
- }
-
- protected override void OnDragStarted(MouseEventArgs e)
- {
- adornerPanel = new AdornerPanel();
- adornerPanel.SetAdornedElement(container.View, container);
-
- selectionFrame = new SelectionFrame();
- adornerPanel.Children.Add(selectionFrame);
-
- designPanel.Adorners.Add(adornerPanel);
-
- GrayOutDesignerExceptActiveArea.Start(ref grayOut, services, container.View);
- }
-
- protected override void OnMouseMove(object sender, MouseEventArgs e)
- {
- base.OnMouseMove(sender, e);
- if (hasDragStarted) {
- SetPlacement(e.GetPosition(positionRelativeTo));
- }
- }
-
- protected override void OnMouseUp(object sender, MouseButtonEventArgs e)
- {
- if (hasDragStarted == false) {
- services.Selection.SetSelectedComponents(new DesignItem [] { container }, SelectionTypes.Auto);
- } else {
- Point endPoint = e.GetPosition(positionRelativeTo);
- Rect frameRect = new Rect(
- Math.Min(startPoint.X, endPoint.X),
- Math.Min(startPoint.Y, endPoint.Y),
- Math.Abs(startPoint.X - endPoint.X),
- Math.Abs(startPoint.Y - endPoint.Y)
- );
-
- ICollection items = GetChildDesignItemsInContainer(container, new RectangleGeometry(frameRect));
- if (items.Count == 0) {
- items.Add(container);
- }
- services.Selection.SetSelectedComponents(items, SelectionTypes.Auto);
- }
- Stop();
- }
-
- static ICollection GetChildDesignItemsInContainer(
- DesignItem container, Geometry geometry)
- {
- HashSet resultItems = new HashSet();
- ViewService viewService = container.Services.View;
-
- HitTestFilterCallback filterCallback = delegate(DependencyObject potentialHitTestTarget) {
- FrameworkElement element = potentialHitTestTarget as FrameworkElement;
- if (element != null) {
- // ensure we are able to select elements with width/height=0
- if (element.ActualWidth == 0 || element.ActualHeight == 0) {
- DependencyObject tmp = element;
- DesignItem model = null;
- while (tmp != null) {
- model = viewService.GetModel(tmp);
- if (model != null) break;
- tmp = VisualTreeHelper.GetParent(tmp);
- }
- if (model != container) {
- resultItems.Add(model);
- return HitTestFilterBehavior.ContinueSkipChildren;
- }
- }
- }
- return HitTestFilterBehavior.Continue;
- };
-
- HitTestResultCallback resultCallback = delegate(HitTestResult result) {
- if (((GeometryHitTestResult) result).IntersectionDetail == IntersectionDetail.FullyInside) {
- // find the model for the visual contained in the selection area
- DependencyObject tmp = result.VisualHit;
- DesignItem model = null;
- while (tmp != null) {
- model = viewService.GetModel(tmp);
- if (model != null) break;
- tmp = VisualTreeHelper.GetParent(tmp);
- }
- if (model != container) {
- resultItems.Add(model);
- }
- }
- return HitTestResultBehavior.Continue;
- };
-
- VisualTreeHelper.HitTest(container.View, filterCallback, resultCallback, new GeometryHitTestParameters(geometry));
- return resultItems;
- }
-
- void SetPlacement(Point endPoint)
- {
- RelativePlacement p = new RelativePlacement();
- p.XOffset = Math.Min(startPoint.X, endPoint.X);
- p.YOffset = Math.Min(startPoint.Y, endPoint.Y);
- p.WidthOffset = Math.Max(startPoint.X, endPoint.X) - p.XOffset;
- p.HeightOffset = Math.Max(startPoint.Y, endPoint.Y) - p.YOffset;
- AdornerPanel.SetPlacement(selectionFrame, p);
- }
-
- protected override void OnStopped()
- {
- if (adornerPanel != null) {
- designPanel.Adorners.Remove(adornerPanel);
- adornerPanel = null;
- }
- GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
- selectionFrame = null;
- base.OnStopped();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
deleted file mode 100644
index b8ab9989a4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Controls.Primitives;
-using System.Windows.Input;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-using System.Collections.Generic;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// The resize thumb around a component.
- ///
- [ExtensionFor(typeof(FrameworkElement))]
- public sealed class ResizeThumbExtension : PrimarySelectionAdornerProvider
- {
- readonly AdornerPanel adornerPanel;
- readonly ResizeThumb[] resizeThumbs;
- /// An array containing this.ExtendedItem as only element
- readonly DesignItem[] extendedItemArray = new DesignItem[1];
- IPlacementBehavior resizeBehavior;
- PlacementOperation operation;
- ChangeGroup changeGroup;
-
- public ResizeThumbExtension()
- {
- adornerPanel = new AdornerPanel();
- adornerPanel.Order = AdornerOrder.Foreground;
- this.Adorners.Add(adornerPanel);
-
- resizeThumbs = new ResizeThumb[] {
- CreateThumb(PlacementAlignment.TopLeft, Cursors.SizeNWSE),
- CreateThumb(PlacementAlignment.Top, Cursors.SizeNS),
- CreateThumb(PlacementAlignment.TopRight, Cursors.SizeNESW),
- CreateThumb(PlacementAlignment.Left, Cursors.SizeWE),
- CreateThumb(PlacementAlignment.Right, Cursors.SizeWE),
- CreateThumb(PlacementAlignment.BottomLeft, Cursors.SizeNESW),
- CreateThumb(PlacementAlignment.Bottom, Cursors.SizeNS),
- CreateThumb(PlacementAlignment.BottomRight, Cursors.SizeNWSE)
- };
- }
-
- ResizeThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
- {
- ResizeThumb resizeThumb = new ResizeThumbImpl( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE );
- resizeThumb.Cursor = cursor;
- resizeThumb.Alignment = alignment;
- AdornerPanel.SetPlacement(resizeThumb, new RelativePlacement(alignment.Horizontal, alignment.Vertical));
- adornerPanel.Children.Add(resizeThumb);
-
- DragListener drag = new DragListener(resizeThumb);
- drag.Started += new DragHandler(drag_Started);
- drag.Changed += new DragHandler(drag_Changed);
- drag.Completed += new DragHandler(drag_Completed);
- return resizeThumb;
- }
-
- Size oldSize;
-
- void drag_Started(DragListener drag)
- {
- oldSize = new Size(ModelTools.GetWidth(ExtendedItem.View), ModelTools.GetHeight(ExtendedItem.View));
- if (resizeBehavior != null)
- operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize);
- else {
- changeGroup = this.ExtendedItem.Context.OpenGroup("Resize", extendedItemArray);
- }
- }
-
- void drag_Changed(DragListener drag)
- {
- double dx = 0;
- double dy = 0;
- var alignment = (drag.Target as ResizeThumb).Alignment;
-
- if (alignment.Horizontal == HorizontalAlignment.Left) dx = -drag.Delta.X;
- if (alignment.Horizontal == HorizontalAlignment.Right) dx = drag.Delta.X;
- if (alignment.Vertical == VerticalAlignment.Top) dy = -drag.Delta.Y;
- if (alignment.Vertical == VerticalAlignment.Bottom) dy = drag.Delta.Y;
-
- var newWidth = Math.Max(0, oldSize.Width + dx);
- var newHeight = Math.Max(0, oldSize.Height + dy);
-
- ModelTools.Resize(ExtendedItem, newWidth, newHeight);
-
- if (operation != null) {
- var info = operation.PlacedItems[0];
- var result = info.OriginalBounds;
-
- if (alignment.Horizontal == HorizontalAlignment.Left)
- result.X = Math.Min(result.Right, result.X - dx);
- if (alignment.Vertical == VerticalAlignment.Top)
- result.Y = Math.Min(result.Bottom, result.Y - dy);
- result.Width = newWidth;
- result.Height = newHeight;
-
- info.Bounds = result;
- info.ResizeThumbAlignment = alignment;
- operation.CurrentContainerBehavior.BeforeSetPosition(operation);
- operation.CurrentContainerBehavior.SetPosition(info);
- }
- }
-
- void drag_Completed(DragListener drag)
- {
- if (operation != null) {
- if (drag.IsCanceled) operation.Abort();
- else operation.Commit();
- operation = null;
- } else {
- if (drag.IsCanceled) changeGroup.Abort();
- else changeGroup.Commit();
- changeGroup = null;
- }
- }
-
- protected override void OnInitialized()
- {
- base.OnInitialized();
- extendedItemArray[0] = this.ExtendedItem;
- this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged;
- resizeBehavior = PlacementOperation.GetPlacementBehavior(extendedItemArray);
- OnPrimarySelectionChanged(null, null);
- }
-
- protected override void OnRemove()
- {
- this.Services.Selection.PrimarySelectionChanged -= OnPrimarySelectionChanged;
- base.OnRemove();
- }
-
- void OnPrimarySelectionChanged(object sender, EventArgs e)
- {
- bool isPrimarySelection = this.Services.Selection.PrimarySelection == this.ExtendedItem;
- foreach (ResizeThumb g in adornerPanel.Children) {
- g.IsPrimarySelection = isPrimarySelection;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs
deleted file mode 100644
index 2086561aa3..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Shapes;
-
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Draws a dotted line around selected UIElements.
- ///
- [ExtensionFor(typeof(UIElement))]
- public sealed class SelectedElementRectangleExtension : SelectionAdornerProvider
- {
- ///
- /// Creates a new SelectedElementRectangleExtension instance.
- ///
- public SelectedElementRectangleExtension()
- {
- Rectangle selectionRect = new Rectangle();
- selectionRect.SnapsToDevicePixels = true;
- selectionRect.Stroke = Brushes.White;
- selectionRect.IsHitTestVisible = false;
-
- Rectangle dottedRect = new Rectangle();
- dottedRect.SnapsToDevicePixels = true;
- dottedRect.Stroke = Brushes.Black;
- dottedRect.StrokeDashCap = PenLineCap.Square;
- dottedRect.StrokeDashArray = new DoubleCollection(new double[] { 0, 2 });
- dottedRect.IsHitTestVisible = false;
-
- RelativePlacement placement = new RelativePlacement(HorizontalAlignment.Stretch, VerticalAlignment.Stretch);
- placement.XOffset = -1;
- placement.YOffset = -1;
- placement.WidthOffset = 2;
- placement.HeightOffset = 2;
-
- this.AddAdorners(placement, selectionRect, dottedRect);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
deleted file mode 100644
index c09fcd5697..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
+++ /dev/null
@@ -1,312 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using ICSharpCode.WpfDesign.Extensions;
-using System.ComponentModel;
-using ICSharpCode.WpfDesign.Adorners;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Shapes;
-using System.Windows.Automation.Peers;
-using System.Windows.Controls.Primitives;
-using System.Diagnostics;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- public class SnaplinePlacementBehavior : DefaultPlacementBehavior
- {
- AdornerPanel adornerPanel;
- Canvas surface;
- List horizontalMap;
- List verticalMap;
- double? baseline;
-
- public static double Accuracy = 5;
- public static double Margin = 8;
-
- public override void BeginPlacement(PlacementOperation operation)
- {
- base.BeginPlacement(operation);
- 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();
- }
-
- public override void BeforeSetPosition(PlacementOperation operation)
- {
- base.BeforeSetPosition(operation);
- if (surface == null) return;
-
- surface.Children.Clear();
- if (Keyboard.IsKeyDown(Key.LeftCtrl)) return;
-
- Rect bounds = Rect.Empty;
- foreach (var item in operation.PlacedItems) {
- bounds.Union(item.Bounds);
- }
-
- var horizontalInput = new List();
- var verticalInput = new List();
- var info = operation.PlacedItems[0];
-
- if (operation.Type == PlacementType.Resize) {
- AddLines(bounds, 0, false, horizontalInput, verticalInput, info.ResizeThumbAlignment);
- } else {
- AddLines(bounds, 0, false, horizontalInput, verticalInput, null);
- if (baseline.HasValue) {
- var textOffset = bounds.Top + baseline.Value;
- horizontalInput.Add(new Snapline() { Group = 1, Offset = textOffset, Start = bounds.Left, End = bounds.Right });
- }
- }
-
- // debug
- //foreach (var t in horizontalMap.Concat(horizontalInput)) {
- // surface.Children.Add(new Line() { X1 = t.Start, X2 = t.End, Y1 = t.Offset, Y2 = t.Offset, Stroke = Brushes.Black });
- //}
- //foreach (var t in verticalMap.Concat(verticalInput)) {
- // surface.Children.Add(new Line() { X1 = t.Offset, X2 = t.Offset, Y1 = t.Start , Y2 = t.End, Stroke = Brushes.Black });
- //}
- //return;
-
- List drawLines;
- double delta;
-
- if (Snap(horizontalInput, horizontalMap, Accuracy, out drawLines, out delta)) {
-
- if (operation.Type == PlacementType.Resize) {
- if (info.ResizeThumbAlignment.Vertical == VerticalAlignment.Top) {
- bounds.Y += delta;
- bounds.Height = Math.Max(0, bounds.Height - delta);
- } else {
- bounds.Height = Math.Max(0, bounds.Height + delta);
- }
- info.Bounds = bounds;
- } else {
- foreach (var item in operation.PlacedItems) {
- var r = item.Bounds;
- r.Y += delta;
- item.Bounds = r;
- }
- }
-
- foreach (var d in drawLines) {
- DrawLine(d.Start, d.Offset, d.End, d.Offset);
- }
- }
-
- if (Snap(verticalInput, verticalMap, Accuracy, out drawLines, out delta)) {
-
- if (operation.Type == PlacementType.Resize) {
- if (info.ResizeThumbAlignment.Horizontal == HorizontalAlignment.Left) {
- bounds.X += delta;
- bounds.Width = Math.Max(0, bounds.Width - delta);
- } else {
- bounds.Width = Math.Max(0, bounds.Width + delta);
- }
- info.Bounds = bounds;
- } else {
- foreach (var item in operation.PlacedItems) {
- var r = item.Bounds;
- r.X += delta;
- item.Bounds = r;
- }
- }
-
- foreach (var d in drawLines) {
- DrawLine(d.Offset, d.Start, d.Offset, d.End);
- }
- }
- }
-
- void CreateSurface(PlacementOperation operation)
- {
- if (ExtendedItem.Services.GetService() != 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);
-
- BuildMaps(operation);
-
- if (operation.Type != PlacementType.Resize && operation.PlacedItems.Count == 1) {
- baseline = GetBaseline(operation.PlacedItems[0].Item.View);
- }
- }
- }
-
- void BuildMaps(PlacementOperation operation)
- {
- horizontalMap = new List();
- verticalMap = new List();
-
- var containerRect = new Rect(0, 0, ModelTools.GetWidth(ExtendedItem.View), ModelTools.GetHeight(ExtendedItem.View));
- AddLines(containerRect, -Margin, false);
-
- foreach (var item in ExtendedItem.ContentProperty.CollectionElements
- .Except(operation.PlacedItems.Select(f => f.Item)))
- {
- var bounds = GetPosition(operation, item);
-
- AddLines(bounds, 0, false);
- AddLines(bounds, Margin, true);
- AddBaseline(item, bounds, horizontalMap);
- }
- }
-
- void AddLines(Rect r, double inflate, bool requireOverlap)
- {
- AddLines(r, inflate, requireOverlap, horizontalMap, verticalMap, null);
- }
-
- void AddLines(Rect r, double inflate, bool requireOverlap, List h, List v, PlacementAlignment? filter)
- {
- Rect r2 = r;
- r2.Inflate(inflate, inflate);
-
- if (filter == null || filter.Value.Vertical == VerticalAlignment.Top)
- h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Top - 1, Start = r.Left, End = r.Right });
- if (filter == null || filter.Value.Vertical == VerticalAlignment.Bottom)
- h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Bottom, Start = r.Left, End = r.Right });
- if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Left)
- v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Left - 1, Start = r.Top, End = r.Bottom });
- if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Right)
- v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Right, Start = r.Top, End = r.Bottom });
- }
-
- void AddBaseline(DesignItem item, Rect bounds, List list)
- {
- var baseline = GetBaseline(item.View);
- if (baseline.HasValue) {
- var textOffset = item.View.TranslatePoint(new Point(0, baseline.Value), ExtendedItem.View).Y;
- list.Add(new Snapline() { Group = 1, Offset = textOffset, Start = bounds.Left, End = bounds.Right });
- }
- }
-
- void DeleteSurface()
- {
- if (surface != null) {
- ExtendedItem.Services.DesignPanel.Adorners.Remove(adornerPanel);
- adornerPanel = null;
- surface = null;
- horizontalMap = null;
- verticalMap = null;
- }
- }
-
- void DrawLine(double x1, double y1, double x2, double y2)
- {
- var line1 = new Line() {
- X1 = x1,
- Y1 = y1,
- X2 = x2,
- Y2 = y2,
- StrokeThickness = 1,
- Stroke = Brushes.White
- };
- surface.Children.Add(line1);
-
- var line2 = new Line() {
- X1 = x1,
- Y1 = y1,
- X2 = x2,
- Y2 = y2,
- StrokeThickness = 1,
- Stroke = Brushes.Orange,
- StrokeDashArray = new DoubleCollection(new double[] { 5, 2 }),
- StrokeDashOffset = x1 + y1 // fix dashes
- };
- surface.Children.Add(line2);
- }
-
- //TODO: GlyphRun must be used
- static double? GetBaseline(UIElement element) {
- var textBox = element.FindChild();
- if (textBox != null) {
- var r = textBox.GetRectFromCharacterIndex(0).Bottom;
- return textBox.TranslatePoint(new Point(0, r), element).Y;
- }
- var textBlock = element.FindChild();
- if (textBlock != null)
- return textBlock.TranslatePoint(new Point(0, textBlock.ActualHeight), element).Y;
-
- return null;
- }
-
- static bool Snap(List input, List map, double accuracy,
- out List drawLines, out double delta)
- {
- delta = double.MaxValue;
- drawLines = null;
-
- foreach (var inputLine in input) {
- foreach (var mapLine in map) {
- if (Math.Abs(mapLine.Offset - inputLine.Offset) <= accuracy) {
- if (!inputLine.RequireOverlap && !mapLine.RequireOverlap ||
- Math.Max(inputLine.Start, mapLine.Start) < Math.Min(inputLine.End, mapLine.End))
- {
- if (mapLine.Group == inputLine.Group)
- delta = mapLine.Offset - inputLine.Offset;
- }
- }
- }
- }
-
- if (delta == double.MaxValue) return false;
- var offsetDict = new Dictionary();
-
- foreach (var inputLine in input) {
- inputLine.Offset += delta;
- foreach (var mapLine in map) {
- if (inputLine.Offset == mapLine.Offset) {
- var offset = mapLine.Offset;
- Snapline drawLine;
- if (!offsetDict.TryGetValue(offset, out drawLine)) {
- drawLine = new Snapline();
- drawLine.Start = double.MaxValue;
- drawLine.End = double.MinValue;
- offsetDict[offset] = drawLine;
- }
- drawLine.Offset = offset;
- drawLine.Start = Math.Min(drawLine.Start, Math.Min(inputLine.Start, mapLine.Start));
- drawLine.End = Math.Max(drawLine.End, Math.Max(inputLine.End, mapLine.End));
- }
- }
- }
-
- drawLines = offsetDict.Values.ToList();
- return true;
- }
-
- [DebuggerDisplay("Snapline: {Offset}")]
- class Snapline
- {
- public double Offset;
- public double Start;
- public double End;
- public bool RequireOverlap;
- public int Group;
- }
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TabItemClickableExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TabItemClickableExtension.cs
deleted file mode 100644
index 61f5da55d0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TabItemClickableExtension.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Controls;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Makes TabItems clickable.
- ///
- [ExtensionFor(typeof(TabItem))]
- [ExtensionServer(typeof(PrimarySelectionExtensionServer))]
- public sealed class TabItemClickableExtension : DefaultExtension
- {
- ///
- protected override void OnInitialized()
- {
- // When tab item becomes primary selection, make it the active tab page in its parent tab control.
- TabItem tabItem = (TabItem)this.ExtendedItem.Component;
- TabControl tabControl = tabItem.Parent as TabControl;
- if (tabControl != null) {
- tabControl.SelectedItem = tabItem;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandle.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandle.cs
deleted file mode 100644
index b779f1bc73..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandle.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Controls;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Shapes;
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Extensions;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- /*
- ///
- /// The drag handle displayed for panels.
- ///
- [ExtensionServer(typeof(PrimarySelectionExtensionServer))]
- [ExtensionFor(typeof(Panel), OverrideExtension = typeof(TopLeftResizeThumb))]
- public class TopLeftContainerDragHandle : AdornerProvider
- {
- ///
- public TopLeftContainerDragHandle()
- {
- ContainerDragHandle rect = new ContainerDragHandle();
-
- rect.PreviewMouseDown += delegate {
- Services.Selection.SetSelectedComponents(new DesignItem[] { this.ExtendedItem }, SelectionTypes.Auto);
- };
-
- RelativePlacement p = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
- p.XOffset = -1;
- p.YOffset = -1;
-
- AddAdorner(p, AdornerOrder.Background, rect);
- }
- }
- */
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WindowResizeBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WindowResizeBehavior.cs
deleted file mode 100644
index d6e6a7eb0a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WindowResizeBehavior.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Designer.Extensions
-{
- ///
- /// Supports resizing a Window.
- ///
- [ExtensionFor(typeof(Window))]
- public class WindowResizeBehavior : BehaviorExtension, IRootPlacementBehavior
- {
- protected override void OnInitialized()
- {
- base.OnInitialized();
- this.ExtendedItem.AddBehavior(typeof(IRootPlacementBehavior), this);
- }
-
- public bool CanPlace(ICollection children, PlacementType type, PlacementAlignment position)
- {
- return type == PlacementType.Resize &&
- (position == PlacementAlignment.Right
- || position == PlacementAlignment.BottomRight
- || position == PlacementAlignment.Bottom);
- }
-
-
- public void BeginPlacement(PlacementOperation operation)
- {
- }
-
- public void EndPlacement(PlacementOperation operation)
- {
- }
-
- public Rect GetPosition(PlacementOperation operation, DesignItem childItem)
- {
- UIElement child = childItem.View;
- return new Rect(0, 0, ModelTools.GetWidth(child), ModelTools.GetHeight(child));
- }
-
- public void BeforeSetPosition(PlacementOperation operation)
- {
- }
-
- public void SetPosition(PlacementInformation info)
- {
- UIElement element = info.Item.View;
- Rect newPosition = info.Bounds;
- if (newPosition.Right != ModelTools.GetWidth(element)) {
- info.Item.Properties[FrameworkElement.WidthProperty].SetValue(newPosition.Right);
- }
- if (newPosition.Bottom != ModelTools.GetHeight(element)) {
- info.Item.Properties[FrameworkElement.HeightProperty].SetValue(newPosition.Bottom);
- }
- }
-
- public bool CanLeaveContainer(PlacementOperation operation)
- {
- return false;
- }
-
- public void LeaveContainer(PlacementOperation operation)
- {
- throw new NotSupportedException();
- }
-
- public bool CanEnterContainer(PlacementOperation operation)
- {
- return false;
- }
-
- public void EnterContainer(PlacementOperation operation)
- {
- throw new NotSupportedException();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Class.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Class.png
deleted file mode 100644
index f8e82b5568..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Class.png and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursor.cur b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursor.cur
deleted file mode 100644
index 6d10c848cd..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursor.cur and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursorMouseDown.cur b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursorMouseDown.cur
deleted file mode 100644
index 5f3c236bac..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/PanToolCursorMouseDown.cur and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Tag.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Tag.png
deleted file mode 100644
index b7686f106b..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Tag.png and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomIn.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomIn.png
deleted file mode 100644
index fbf52d350b..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomIn.png and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomOut.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomOut.png
deleted file mode 100644
index 0c2a6a7bc8..0000000000
Binary files a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/ZoomOut.png and /dev/null differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
deleted file mode 100644
index 003eaf9f75..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Linq;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- ///
- /// Static helper methods for working with the designer DOM.
- ///
- public static class ModelTools
- {
- ///
- /// Compares the positions of a and b in the model file.
- ///
- public static int ComparePositionInModelFile(DesignItem a, DesignItem b)
- {
- // first remember all parent properties of a
- HashSet aProps = new HashSet();
- DesignItem tmp = a;
- while (tmp != null) {
- aProps.Add(tmp.ParentProperty);
- tmp = tmp.Parent;
- }
-
- // now walk up b's parent tree until a matching property is found
- tmp = b;
- while (tmp != null) {
- DesignItemProperty prop = tmp.ParentProperty;
- if (aProps.Contains(prop)) {
- if (prop.IsCollection) {
- return prop.CollectionElements.IndexOf(a).CompareTo(prop.CollectionElements.IndexOf(b));
- } else {
- return 0;
- }
- }
- }
- return 0;
- }
-
- ///
- /// Gets if the specified design item is in the document it belongs to.
- ///
- /// True for live objects, false for deleted objects.
- public static bool IsInDocument(DesignItem item)
- {
- DesignItem rootItem = item.Context.RootItem;
- while (item != null) {
- if (item == rootItem) return true;
- item = item.Parent;
- }
- return false;
- }
-
- ///
- /// Gets if the specified components can be deleted.
- ///
- public static bool CanDeleteComponents(ICollection items)
- {
- IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(items);
- return b != null
- && b.CanPlace(items, PlacementType.Delete, PlacementAlignment.Center);
- }
-
- public static bool CanSelectComponent(DesignItem item)
- {
- return item.View != null;
- }
-
- ///
- /// Deletes the specified components from their parent containers.
- /// If the deleted components are currently selected, they are deselected before they are deleted.
- ///
- public static void DeleteComponents(ICollection items)
- {
- DesignItem parent = items.First().Parent;
- PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Delete);
- try {
- ISelectionService selectionService = items.First().Services.Selection;
- selectionService.SetSelectedComponents(items, SelectionTypes.Remove);
- // if the selection is empty after deleting some components, select the parent of the deleted component
- if (selectionService.SelectionCount == 0 && !items.Contains(parent)) {
- selectionService.SetSelectedComponents(new DesignItem[] { parent });
- }
- operation.DeleteItemsAndCommit();
- } catch {
- operation.Abort();
- throw;
- }
- }
-
- internal static Size GetDefaultSize(DesignItem createdItem)
- {
- var s = Metadata.GetDefaultSize(createdItem.ComponentType);
- if (double.IsNaN(s.Width)) {
- s.Width = GetWidth(createdItem.View);
- }
- if (double.IsNaN(s.Height)) {
- s.Height = GetHeight(createdItem.View);
- }
- return s;
- }
-
- internal static double GetWidth(UIElement element)
- {
- double v = (double)element.GetValue(FrameworkElement.WidthProperty);
- if (double.IsNaN(v))
- return element.RenderSize.Width;
- else
- return v;
- }
-
- internal static double GetHeight(UIElement element)
- {
- double v = (double)element.GetValue(FrameworkElement.HeightProperty);
- if (double.IsNaN(v))
- return element.RenderSize.Height;
- else
- return v;
- }
-
- public static void Resize(DesignItem item, double newWidth, double newHeight)
- {
- if (newWidth != GetWidth(item.View)) {
- item.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth);
- }
- if (newHeight != GetHeight(item.View)) {
- item.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight);
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragListener.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragListener.cs
deleted file mode 100644
index 883b675c32..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragListener.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public class DragListener
- {
- public DragListener(FrameworkElement target)
- {
- this.target = target;
- target.AddHandler(Mouse.MouseDownEvent, new MouseButtonEventHandler(MouseButtonDown), true);
- target.PreviewMouseMove += MouseMove;
- target.PreviewMouseLeftButtonUp += MouseLeftButtonUp;
- }
-
- public event MouseButtonEventHandler DragStarted;
-
- FrameworkElement target;
- Point startPoint;
- bool ready;
- MouseButtonEventArgs args;
-
- void MouseButtonDown(object sender, MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left && Mouse.Captured == null) {
- ready = true;
- startPoint = e.GetPosition(target);
- args = e;
- target.CaptureMouse();
- }
- }
-
- void MouseMove(object sender, MouseEventArgs e)
- {
- if (ready) {
- var currentPoint = e.GetPosition(target);
- if (Math.Abs(currentPoint.X - startPoint.X) >= SystemParameters.MinimumHorizontalDragDistance ||
- Math.Abs(currentPoint.Y - startPoint.Y) >= SystemParameters.MinimumVerticalDragDistance) {
- ready = false;
- if (DragStarted != null) {
- DragStarted(this, args);
- }
- }
- }
- }
-
- void MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- ready = false;
- target.ReleaseMouseCapture();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs
deleted file mode 100644
index c2dfff4f73..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-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 System.Collections.Specialized;
-using System.Collections;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- // limitations:
- // - Do not use ItemsSource (use Root)
- // - Do not use Items (use Root)
- public class DragTreeView : TreeView
- {
- static DragTreeView()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(DragTreeView),
- new FrameworkPropertyMetadata(typeof(DragTreeView)));
- }
-
- public DragTreeView()
- {
- AllowDrop = true;
- new DragListener(this).DragStarted += new MouseButtonEventHandler(DragTreeView_DragStarted);
- }
-
- DragTreeViewItem dropTarget;
- DragTreeViewItem treeItem;
- DragTreeViewItem dropAfter;
- int part;
- bool dropInside;
- bool dropCopy;
- bool canDrop;
-
- Border insertLine;
-
- public static readonly DependencyProperty RootProperty =
- DependencyProperty.Register("Root", typeof(object), typeof(DragTreeView));
-
- public object Root {
- get { return (object)GetValue(RootProperty); }
- set { SetValue(RootProperty, value); }
- }
-
- //public object[] SelectedItems
- //{
- // get { return Selection.Select(item => item.DataContext).ToArray(); }
- //}
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
- if (e.Property == RootProperty) {
- ItemsSource = new[] { Root };
- }
- }
-
- void DragTreeView_DragStarted(object sender, MouseButtonEventArgs e)
- {
- DragDrop.DoDragDrop(this, this, DragDropEffects.All);
- }
-
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- insertLine = (Border)Template.FindName("PART_InsertLine", this);
- }
-
- protected override DependencyObject GetContainerForItemOverride()
- {
- return new DragTreeViewItem();
- }
-
- protected override bool IsItemItsOwnContainerOverride(object item)
- {
- return item is DragTreeViewItem;
- }
-
- protected override void OnDragEnter(DragEventArgs e)
- {
- ProcessDrag(e);
- }
-
- protected override void OnDragOver(DragEventArgs e)
- {
- ProcessDrag(e);
- }
-
- protected override void OnDrop(DragEventArgs e)
- {
- ProcessDrop(e);
- }
-
- protected override void OnDragLeave(DragEventArgs e)
- {
- HideDropMarker();
- }
-
- void PrepareDropInfo(DragEventArgs e)
- {
- dropTarget = null;
- dropAfter = null;
- treeItem = (e.OriginalSource as DependencyObject).FindAncestor();
-
- if (treeItem != null) {
- var parent = ItemsControl.ItemsControlFromItemContainer(treeItem) as DragTreeViewItem;
- ContentPresenter header = treeItem.HeaderPresenter;
- Point p = e.GetPosition(header);
- part = (int)(p.Y / (header.ActualHeight / 3));
- dropCopy = Keyboard.IsKeyDown(Key.LeftCtrl);
- dropInside = false;
-
- if (part == 1 || parent == null) {
- dropTarget = treeItem;
- dropInside = true;
- if (treeItem.Items.Count > 0) {
- dropAfter = treeItem.ItemContainerGenerator.ContainerFromIndex(treeItem.Items.Count - 1) as DragTreeViewItem;
- }
- }
- else if (part == 0) {
- dropTarget = parent;
- var index = dropTarget.ItemContainerGenerator.IndexFromContainer(treeItem);
- if (index > 0) {
- dropAfter = dropTarget.ItemContainerGenerator.ContainerFromIndex(index - 1) as DragTreeViewItem;
- }
- }
- else {
- dropTarget = parent;
- dropAfter = treeItem;
- }
- }
- }
-
- void ProcessDrag(DragEventArgs e)
- {
- e.Effects = DragDropEffects.None;
- e.Handled = true;
- canDrop = false;
-
- if (e.Data.GetData(GetType()) != this) return;
-
- HideDropMarker();
- PrepareDropInfo(e);
-
- if (dropTarget != null && CanInsertInternal()) {
- canDrop = true;
- e.Effects = dropCopy ? DragDropEffects.Copy : DragDropEffects.Move;
- DrawDropMarker();
- }
- }
-
- void ProcessDrop(DragEventArgs e)
- {
- HideDropMarker();
-
- if (canDrop) {
- InsertInternal();
- }
- }
-
- void DrawDropMarker()
- {
- if (dropInside) {
- dropTarget.IsDragHover = true;
- }
- else {
- var header = treeItem.HeaderPresenter;
- var p = header.TransformToVisual(this).Transform(
- new Point(0, part == 0 ? 0 : header.ActualHeight));
-
- insertLine.Visibility = Visibility.Visible;
- insertLine.Margin = new Thickness(p.X, p.Y, 0, 0);
- }
- }
-
- void HideDropMarker()
- {
- insertLine.Visibility = Visibility.Collapsed;
- if (dropTarget != null) {
- dropTarget.IsDragHover = false;
- }
- }
-
- internal HashSet Selection = new HashSet();
- DragTreeViewItem upSelection;
-
- internal void ItemMouseDown(DragTreeViewItem item)
- {
- upSelection = null;
- bool control = Keyboard.IsKeyDown(Key.LeftCtrl);
-
- if (Selection.Contains(item)) {
- if (control) {
- Unselect(item);
- }
- else {
- upSelection = item;
- }
- }
- else {
- if (control) {
- Select(item);
- }
- else {
- SelectOnly(item);
- }
- }
- }
-
- internal void ItemMouseUp(DragTreeViewItem item)
- {
- if (upSelection == item) {
- SelectOnly(item);
- }
- upSelection = null;
- }
-
- internal void ItemAttached(DragTreeViewItem item)
- {
- if (item.IsSelected) Selection.Add(item);
- }
-
- internal void ItemDetached(DragTreeViewItem item)
- {
- if (item.IsSelected) Selection.Remove(item);
- }
-
- internal void ItemIsSelectedChanged(DragTreeViewItem item)
- {
- if (item.IsSelected) {
- Selection.Add(item);
- }
- else {
- Selection.Remove(item);
- }
- }
-
- void Select(DragTreeViewItem item)
- {
- Selection.Add(item);
- item.IsSelected = true;
- OnSelectionChanged();
- }
-
- void Unselect(DragTreeViewItem item)
- {
- Selection.Remove(item);
- item.IsSelected = false;
- OnSelectionChanged();
- }
-
- void SelectOnly(DragTreeViewItem item)
- {
- ClearSelection();
- Select(item);
- OnSelectionChanged();
- }
-
- void ClearSelection()
- {
- foreach (var treeItem in Selection.ToArray()) {
- treeItem.IsSelected = false;
- }
- Selection.Clear();
- OnSelectionChanged();
- }
-
- void OnSelectionChanged()
- {
- }
-
- bool CanInsertInternal()
- {
- if (!dropCopy) {
- var item = dropTarget;
- while (true) {
- if (Selection.Contains(item)) return false;
- item = ItemsControl.ItemsControlFromItemContainer(item) as DragTreeViewItem;
- if (item == null) break;
- }
-
- if (Selection.Contains(dropAfter)) return false;
- }
-
- return CanInsert(dropTarget, Selection.ToArray(), dropAfter, dropCopy);
- }
-
- void InsertInternal()
- {
- var selection = Selection.ToArray();
-
- if (!dropCopy) {
- foreach (var item in Selection.ToArray()) {
- var parent = ItemsControl.ItemsControlFromItemContainer(item) as DragTreeViewItem;
- //TODO
- if (parent != null) {
- Remove(parent, item);
- }
- }
- }
- Insert(dropTarget, selection, dropAfter, dropCopy);
- }
-
- protected virtual bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
- {
- return true;
- }
-
- protected virtual void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
- {
- }
-
- protected virtual void Remove(DragTreeViewItem target, DragTreeViewItem item)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs
deleted file mode 100644
index 22394de453..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-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 System.Windows.Controls.Primitives;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public class DragTreeViewItem : TreeViewItem
- {
- static DragTreeViewItem()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(DragTreeViewItem),
- new FrameworkPropertyMetadata(typeof(DragTreeViewItem)));
- }
-
- public DragTreeViewItem()
- {
- Loaded += new RoutedEventHandler(DragTreeViewItem_Loaded);
- Unloaded += new RoutedEventHandler(DragTreeViewItem_Unloaded);
- }
-
- void DragTreeViewItem_Loaded(object sender, RoutedEventArgs e)
- {
- ParentTree = this.FindAncestor();
- if (ParentTree != null) {
- ParentTree.ItemAttached(this);
- }
- }
-
- void DragTreeViewItem_Unloaded(object sender, RoutedEventArgs e)
- {
- if (ParentTree != null) {
- ParentTree.ItemDetached(this);
- }
- ParentTree = null;
- }
-
- public new static readonly DependencyProperty IsSelectedProperty =
- Selector.IsSelectedProperty.AddOwner(typeof(DragTreeViewItem));
-
- public new bool IsSelected {
- get { return (bool)GetValue(IsSelectedProperty); }
- set { SetValue(IsSelectedProperty, value); }
- }
-
- public static readonly DependencyProperty IsDragHoverProperty =
- DependencyProperty.Register("IsDragHover", typeof(bool), typeof(DragTreeViewItem));
-
- public bool IsDragHover {
- get { return (bool)GetValue(IsDragHoverProperty); }
- set { SetValue(IsDragHoverProperty, value); }
- }
-
- internal ContentPresenter HeaderPresenter {
- get { return (ContentPresenter)Template.FindName("PART_Header", this); }
- }
-
- public static readonly DependencyProperty LevelProperty =
- DependencyProperty.Register("Level", typeof(int), typeof(DragTreeViewItem));
-
- public int Level {
- get { return (int)GetValue(LevelProperty); }
- set { SetValue(LevelProperty, value); }
- }
-
- public DragTreeView ParentTree { get; private set; }
-
- protected override void OnVisualParentChanged(DependencyObject oldParent)
- {
- base.OnVisualParentChanged(oldParent);
-
- var parentItem = ItemsControl.ItemsControlFromItemContainer(this) as DragTreeViewItem;
- if (parentItem != null) Level = parentItem.Level + 1;
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
- if (e.Property == IsSelectedProperty) {
- if (ParentTree != null) {
- ParentTree.ItemIsSelectedChanged(this);
- }
- }
- }
-
- protected override DependencyObject GetContainerForItemOverride()
- {
- return new DragTreeViewItem();
- }
-
- protected override bool IsItemItsOwnContainerOverride(object item)
- {
- return item is DragTreeViewItem;
- }
-
- protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
- {
- base.OnMouseLeftButtonDown(e);
- if (e.Source is ToggleButton || e.Source is ItemsPresenter) return;
- ParentTree.ItemMouseDown(this);
- }
-
- protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
- {
- base.OnMouseLeftButtonUp(e);
- ParentTree.ItemMouseUp(this);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/IconItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/IconItem.cs
deleted file mode 100644
index f6eead04e3..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/IconItem.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Controls;
-using System.Windows;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public class IconItem : Control
- {
- static IconItem()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(IconItem),
- new FrameworkPropertyMetadata(typeof(IconItem)));
- }
-
- public static readonly DependencyProperty IconProperty =
- DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconItem));
-
- public ImageSource Icon {
- get { return (ImageSource)GetValue(IconProperty); }
- set { SetValue(IconProperty, value); }
- }
-
- public static readonly DependencyProperty TextProperty =
- DependencyProperty.Register("Text", typeof(string), typeof(IconItem));
-
- public string Text {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml
deleted file mode 100644
index 5ae7dc3f5a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
deleted file mode 100644
index 64bd561c71..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-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;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public partial class Outline
- {
- public Outline()
- {
- InitializeComponent();
- }
-
- public static readonly DependencyProperty RootProperty =
- DependencyProperty.Register("Root", typeof(OutlineNode), typeof(Outline));
-
- public OutlineNode Root {
- get { return (OutlineNode)GetValue(RootProperty); }
- set { SetValue(RootProperty, value); }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
deleted file mode 100644
index fc079f7b38..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using ICSharpCode.WpfDesign;
-using System.Collections.ObjectModel;
-using System.Collections;
-using ICSharpCode.WpfDesign.Designer;
-using ICSharpCode.WpfDesign.XamlDom;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public class OutlineNode : INotifyPropertyChanged
- {
- public static OutlineNode Create(DesignItem designItem)
- {
- OutlineNode node;
- if (!outlineNodes.TryGetValue(designItem, out node)) {
- node = new OutlineNode(designItem);
- outlineNodes[designItem] = node;
- }
- return node;
- }
-
- //TODO: Reset with DesignContext
- static Dictionary outlineNodes = new Dictionary();
-
- OutlineNode(DesignItem designItem)
- {
- DesignItem = designItem;
- UpdateChildren();
-
- //TODO
- DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged);
- DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged);
- SelectionService.SelectionChanged += new EventHandler(Selection_SelectionChanged);
- }
-
- public DesignItem DesignItem { get; private set; }
-
- public ISelectionService SelectionService {
- get { return DesignItem.Services.Selection; }
- }
-
- bool isExpanded = true;
-
- public bool IsExpanded {
- get {
- return isExpanded;
- }
- set {
- isExpanded = value;
- RaisePropertyChanged("IsExpanded");
- }
- }
-
- bool isSelected;
-
- public bool IsSelected {
- get {
- return isSelected;
- }
- set {
- if (isSelected != value) {
- isSelected = value;
- SelectionService.SetSelectedComponents(new[] { DesignItem },
- value ? SelectionTypes.Add : SelectionTypes.Remove);
- RaisePropertyChanged("IsSelected");
- }
- }
- }
-
- ObservableCollection children = new ObservableCollection();
-
- public ObservableCollection Children {
- get { return children; }
- }
-
- public string Name {
- get {
- if (string.IsNullOrEmpty(DesignItem.Name)) {
- return DesignItem.ComponentType.Name;
- }
- return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
- }
- }
-
- void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e)
- {
- IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem);
- }
-
- void DesignItem_NameChanged(object sender, EventArgs e)
- {
- RaisePropertyChanged("Name");
- }
-
- void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == DesignItem.ContentPropertyName) {
- UpdateChildren();
- }
- }
-
- void UpdateChildren()
- {
- Children.Clear();
-
- if (DesignItem.ContentPropertyName != null) {
- var content = DesignItem.ContentProperty;
- if (content.IsCollection) {
- UpdateChildrenCore(content.CollectionElements);
- }
- else {
- if (content.Value != null) {
- UpdateChildrenCore(new[] { content.Value });
- }
- }
- }
- }
-
- void UpdateChildrenCore(IEnumerable items)
- {
- foreach (var item in items) {
- if (ModelTools.CanSelectComponent(item)) {
- var node = OutlineNode.Create(item);
- Children.Add(node);
- }
- }
- }
-
- // TODO: Outline and IPlacementBehavior must use the same logic (put it inside DesignItem)
- public bool CanInsert(IEnumerable nodes, OutlineNode after, bool copy)
- {
- if (DesignItem.ContentPropertyName == null) return false;
-
- if (DesignItem.ContentProperty.IsCollection) {
- foreach (var node in nodes) {
- if (!CollectionSupport.CanCollectionAdd(DesignItem.ContentProperty.ReturnType,
- node.DesignItem.ComponentType)) {
- return false;
- }
- }
- return true;
- }
- else {
- return after == null && nodes.Count() == 1 &&
- DesignItem.ContentProperty.DeclaringType.IsAssignableFrom(
- nodes.First().DesignItem.ComponentType);
- }
- }
-
- public void Insert(IEnumerable nodes, OutlineNode after, bool copy)
- {
- if (copy) {
- nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone()));
- }
- else {
- foreach (var node in nodes) {
- node.DesignItem.Remove();
- }
- }
-
- var index = after == null ? 0 : Children.IndexOf(after) + 1;
-
- var content = DesignItem.ContentProperty;
- if (content.IsCollection) {
- foreach (var node in nodes) {
- content.CollectionElements.Insert(index++, node.DesignItem);
- }
- }
- else {
- content.SetValue(nodes.First().DesignItem);
- }
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
deleted file mode 100644
index 05c46fba3c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace ICSharpCode.WpfDesign.Designer.OutlineView
-{
- public class OutlineTreeView : DragTreeView
- {
- protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
- {
- return (target.DataContext as OutlineNode).CanInsert(items.Select(t => t.DataContext as OutlineNode),
- after == null ? null : after.DataContext as OutlineNode, copy);
- }
-
- protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
- {
- (target.DataContext as OutlineNode).Insert(items.Select(t => t.DataContext as OutlineNode),
- after == null ? null : after.DataContext as OutlineNode, copy);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml
deleted file mode 100644
index 8dd10c9a17..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
-
-
-
-
- #FFC73C
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml
deleted file mode 100644
index f088519992..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs
deleted file mode 100644
index adf8b4a177..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-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.PropertyGrid.Editors
-{
- [TypeEditor(typeof(bool))]
- public partial class BoolEditor
- {
- public BoolEditor()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditor.cs
deleted file mode 100644
index 87ef6655d9..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditor.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using ICSharpCode.WpfDesign.PropertyGrid;
-using System.Windows.Media;
-using System.Reflection;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public class BrushEditor : INotifyPropertyChanged
- {
- public BrushEditor()
- {
- GradientStopCollection stops = new GradientStopCollection();
- stops.Add(new GradientStop(Colors.Black, 0));
- stops.Add(new GradientStop(Colors.White, 1));
-
- linearGradientBrush = new LinearGradientBrush(stops);
- linearGradientBrush.EndPoint = new Point(1, 0);
- radialGradientBrush = new RadialGradientBrush(stops);
- }
-
- public static BrushItem[] SystemBrushes = typeof(SystemColors)
- .GetProperties(BindingFlags.Static | BindingFlags.Public)
- .Where(p => p.PropertyType == typeof(SolidColorBrush))
- .Select(p => new BrushItem() { Name = p.Name, Brush = (Brush)p.GetValue(null, null) })
- .ToArray();
-
- public static BrushItem[] SystemColors = typeof(SystemColors)
- .GetProperties(BindingFlags.Static | BindingFlags.Public)
- .Where(p => p.PropertyType == typeof(Color))
- .Select(p => new BrushItem()
- {
- Name = p.Name,
- Brush = new SolidColorBrush((Color)p.GetValue(null, null))
- })
- .ToArray();
-
- SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.White);
- LinearGradientBrush linearGradientBrush;
- RadialGradientBrush radialGradientBrush;
-
- PropertyNode property;
-
- public PropertyNode Property {
- get {
- return property;
- }
- set {
- property = value;
- if (property != null) {
- var f = property.Value as Freezable;
- if (f != null && f.IsFrozen) property.Value = f.Clone();
- }
- DetermineCurrentKind();
- RaisePropertyChanged("Property");
- RaisePropertyChanged("Brush");
- }
- }
-
- public Brush Brush {
- get {
- if (property != null) {
- return property.Value as Brush;
- }
- return null;
- }
- set {
- if (property != null && property.Value != value) {
- property.Value = value;
- DetermineCurrentKind();
- RaisePropertyChanged("Brush");
- }
- }
- }
-
- void DetermineCurrentKind()
- {
- if (Brush == null) {
- CurrentKind = BrushEditorKind.None;
- }
- else if (Brush is SolidColorBrush) {
- solidColorBrush = Brush as SolidColorBrush;
- CurrentKind = BrushEditorKind.Solid;
- }
- else if (Brush is LinearGradientBrush) {
- linearGradientBrush = Brush as LinearGradientBrush;
- radialGradientBrush.GradientStops = linearGradientBrush.GradientStops;
- CurrentKind = BrushEditorKind.Linear;
- }
- else if (Brush is RadialGradientBrush) {
- radialGradientBrush = Brush as RadialGradientBrush;
- linearGradientBrush.GradientStops = linearGradientBrush.GradientStops;
- CurrentKind = BrushEditorKind.Radial;
- }
- }
-
- BrushEditorKind currentKind;
-
- public BrushEditorKind CurrentKind {
- get {
- return currentKind;
- }
- set {
- currentKind = value;
- RaisePropertyChanged("CurrentKind");
-
- switch (CurrentKind) {
- case BrushEditorKind.None:
- Brush = null;
- break;
-
- case BrushEditorKind.Solid:
- Brush = solidColorBrush;
- break;
-
- case BrushEditorKind.Linear:
- Brush = linearGradientBrush;
- break;
-
- case BrushEditorKind.Radial:
- Brush = radialGradientBrush;
- break;
-
- case BrushEditorKind.List:
- Brush = solidColorBrush;
- break;
- }
- }
- }
-
- public double GradientAngle {
- get {
- var x = linearGradientBrush.EndPoint.X - linearGradientBrush.StartPoint.X;
- var y = linearGradientBrush.EndPoint.Y - linearGradientBrush.StartPoint.Y;
- return Vector.AngleBetween(new Vector(1, 0), new Vector(x, -y));
- }
- set {
- var d = value * Math.PI / 180;
- var p = new Point(Math.Cos(d), -Math.Sin(d));
- var k = 1 / Math.Max(Math.Abs(p.X), Math.Abs(p.Y));
- p.X *= k;
- p.Y *= k;
- var p2 = new Point(-p.X, -p.Y);
- linearGradientBrush.StartPoint = new Point((p2.X + 1) / 2, (p2.Y + 1) / 2);
- linearGradientBrush.EndPoint = new Point((p.X + 1) / 2, (p.Y + 1) / 2);
- RaisePropertyChanged("GradientAngle");
- }
- }
-
- public IEnumerable AvailableColors {
- get { return SystemColors; }
- }
-
- public IEnumerable AvailableBrushes {
- get { return SystemBrushes; }
- }
-
- public void MakeGradientHorizontal()
- {
- GradientAngle = 0;
- }
-
- public void MakeGradientVertical()
- {
- GradientAngle = -90;
- }
-
- public void Commit()
- {
- if (Brush != null) {
- Property.Value = Brush.Clone();
- }
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
- }
-
- public enum BrushEditorKind
- {
- None,
- Solid,
- Linear,
- Radial,
- List
- }
-
- public class BrushItem
- {
- public string Name { get; set; }
- public Brush Brush { get; set; }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml
deleted file mode 100644
index de8144b584..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs
deleted file mode 100644
index d9568035b8..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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 System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class BrushEditorPopup
- {
- public BrushEditorPopup()
- {
- InitializeComponent();
- }
-
- protected override void OnClosed(EventArgs e)
- {
- base.OnClosed(e);
- BrushEditorView.BrushEditor.Commit();
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Escape) IsOpen = false;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml
deleted file mode 100644
index 8286f1060a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs
deleted file mode 100644
index bc9fba88d5..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-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 System.Diagnostics;
-using System.Globalization;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class BrushEditorView
- {
- public BrushEditorView()
- {
- BrushEditor = new BrushEditor();
- DataContext = BrushEditor;
-
- InitializeComponent();
-
- SetBinding(HeightProperty, new Binding("Brush") {
- Converter = HeightConverter.Instance
- });
- }
-
- public BrushEditor BrushEditor { get; private set; }
-
- class HeightConverter : IValueConverter
- {
- public static HeightConverter Instance = new HeightConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is GradientBrush) return double.NaN;
- return 315;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml
deleted file mode 100644
index 946278c739..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs
deleted file mode 100644
index 7b5aeca5a2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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;
-using System.Windows.Controls.Primitives;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- [TypeEditor(typeof(Brush))]
- public partial class BrushTypeEditor
- {
- public BrushTypeEditor()
- {
- InitializeComponent();
- }
-
- static BrushEditorPopup brushEditorPopup = new BrushEditorPopup();
-
- protected override void OnMouseUp(MouseButtonEventArgs e)
- {
- brushEditorPopup.BrushEditorView.BrushEditor.Property = DataContext as PropertyNode;
- brushEditorPopup.PlacementTarget = this;
- brushEditorPopup.IsOpen = true;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs
deleted file mode 100644
index 6adb30009a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public static class ColorHelper
- {
- public static Color ColorFromString(string s)
- {
- if (string.IsNullOrEmpty(s)) {
- return Colors.White;
- }
- if (s[0] != '#') s = "#" + s;
- try {
- return (Color)ColorConverter.ConvertFromString(s);
- }
- catch {
- return Colors.White;
- }
- }
-
- public static string StringFromColor(Color c)
- {
- return c.ToString().Substring(1);
- }
-
- public static Color ColorFromHsv(double h, double s, double v)
- {
- double r, g, b;
- RgbFromHsv(h, s, v, out r, out g, out b);
- return Color.FromRgb((byte)(r * 255), (byte)(g * 255), (byte)(b * 255));
-
- }
-
- public static void HsvFromColor(Color c, out double h, out double s, out double v)
- {
- HsvFromRgb(c.R / 255.0, c.G / 255.0, c.B / 255.0, out h, out s, out v);
- }
-
- // http://en.wikipedia.org/wiki/HSV_color_space
- public static void HsvFromRgb(double r, double g, double b, out double h, out double s, out double v)
- {
- var max = Math.Max(r, Math.Max(g, b));
- var min = Math.Min(r, Math.Min(g, b));
-
- if (max == min) {
- h = 0;
- }
- else if (max == r) {
- h = (60 * (g - b) / (max - min)) % 360;
- }
- else if (max == g) {
- h = 60 * (b - r) / (max - min) + 120;
- }
- else {
- h = 60 * (r - g) / (max - min) + 240;
- }
-
- if (max == 0) {
- s = 0;
- }
- else {
- s = 1 - min / max;
- }
-
- v = max;
- }
-
- // http://en.wikipedia.org/wiki/HSV_color_space
- public static void RgbFromHsv(double h, double s, double v, out double r, out double g, out double b)
- {
- h = h % 360;
- int hi = (int)(h / 60) % 6;
- var f = h / 60 - (int)(h / 60);
- var p = v * (1 - s);
- var q = v * (1 - f * s);
- var t = v * (1 - (1 - f) * s);
-
- switch (hi) {
- case 0: r = v; g = t; b = p; break;
- case 1: r = q; g = v; b = p; break;
- case 2: r = p; g = v; b = t; break;
- case 3: r = p; g = q; b = v; break;
- case 4: r = t; g = p; b = v; break;
- default: r = v; g = p; b = q; break;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml
deleted file mode 100644
index 933dcd3e69..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml
+++ /dev/null
@@ -1,233 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs
deleted file mode 100644
index 45eb7c927f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-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 System.ComponentModel;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class ColorPicker
- {
- public ColorPicker()
- {
- InitializeComponent();
- }
-
- public static readonly DependencyProperty ColorProperty =
- DependencyProperty.Register("Color", typeof(Color), typeof(ColorPicker),
- new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- public Color Color {
- get { return (Color)GetValue(ColorProperty); }
- set { SetValue(ColorProperty, value); }
- }
-
- public static readonly DependencyProperty HProperty =
- DependencyProperty.Register("H", typeof(int), typeof(ColorPicker));
-
- public int H {
- get { return (int)GetValue(HProperty); }
- set { SetValue(HProperty, value); }
- }
-
- public static readonly DependencyProperty SProperty =
- DependencyProperty.Register("S", typeof(int), typeof(ColorPicker));
-
- public int S {
- get { return (int)GetValue(SProperty); }
- set { SetValue(SProperty, value); }
- }
-
- public static readonly DependencyProperty VProperty =
- DependencyProperty.Register("V", typeof(int), typeof(ColorPicker));
-
- public int V {
- get { return (int)GetValue(VProperty); }
- set { SetValue(VProperty, value); }
- }
-
- public static readonly DependencyProperty RProperty =
- DependencyProperty.Register("R", typeof(byte), typeof(ColorPicker));
-
- public byte R {
- get { return (byte)GetValue(RProperty); }
- set { SetValue(RProperty, value); }
- }
-
- public static readonly DependencyProperty GProperty =
- DependencyProperty.Register("G", typeof(byte), typeof(ColorPicker));
-
- public byte G {
- get { return (byte)GetValue(GProperty); }
- set { SetValue(GProperty, value); }
- }
-
- public static readonly DependencyProperty BProperty =
- DependencyProperty.Register("B", typeof(byte), typeof(ColorPicker));
-
- public byte B {
- get { return (byte)GetValue(BProperty); }
- set { SetValue(BProperty, value); }
- }
-
- public static readonly DependencyProperty AProperty =
- DependencyProperty.Register("A", typeof(byte), typeof(ColorPicker));
-
- public byte A {
- get { return (byte)GetValue(AProperty); }
- set { SetValue(AProperty, value); }
- }
-
- public static readonly DependencyProperty HexProperty =
- DependencyProperty.Register("Hex", typeof(string), typeof(ColorPicker));
-
- public string Hex {
- get { return (string)GetValue(HexProperty); }
- set { SetValue(HexProperty, value); }
- }
-
- public static readonly DependencyProperty HueColorProperty =
- DependencyProperty.Register("HueColor", typeof(Color), typeof(ColorPicker));
-
- public Color HueColor {
- get { return (Color)GetValue(HueColorProperty); }
- set { SetValue(HueColorProperty, value); }
- }
-
- bool updating;
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (updating) return;
- updating = true;
-
- if (e.Property == ColorProperty) {
- UpdateSource(ColorSource.Hsv);
- UpdateRest(ColorSource.Hsv);
- }
- else if (e.Property == HProperty || e.Property == SProperty || e.Property == VProperty) {
- var c = ColorHelper.ColorFromHsv(H, S / 100.0, V / 100.0);
- c.A = A;
- Color = c;
- UpdateRest(ColorSource.Hsv);
- }
- else if (e.Property == RProperty || e.Property == GProperty || e.Property == BProperty || e.Property == AProperty) {
- Color = Color.FromArgb(A, R, G, B);
- UpdateRest(ColorSource.Rgba);
- }
- else if (e.Property == HexProperty) {
- Color = ColorHelper.ColorFromString(Hex);
- UpdateRest(ColorSource.Hex);
- }
-
- updating = false;
- }
-
- void UpdateRest(ColorSource source)
- {
- HueColor = ColorHelper.ColorFromHsv(H, 1, 1);
- UpdateSource((ColorSource)(((int)source + 1) % 3));
- UpdateSource((ColorSource)(((int)source + 2) % 3));
- }
-
- void UpdateSource(ColorSource source)
- {
- if (source == ColorSource.Hsv) {
- double h, s, v;
- ColorHelper.HsvFromColor(Color, out h, out s, out v);
-
- H = (int)h;
- S = (int)(s * 100);
- V = (int)(v * 100);
- }
- else if (source == ColorSource.Rgba) {
- R = Color.R;
- G = Color.G;
- B = Color.B;
- A = Color.A;
- }
- else {
- Hex = ColorHelper.StringFromColor(Color);
- }
- }
-
- enum ColorSource
- {
- Hsv, Rgba, Hex
- }
- }
-
- class HexTextBox : TextBox
- {
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Enter) {
- var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
- if (b != null) {
- b.UpdateTarget();
- }
- SelectAll();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml
deleted file mode 100644
index 900e1af52d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs
deleted file mode 100644
index 7e3a0e0201..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-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;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class GradientBrushEditor
- {
- public GradientBrushEditor()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml
deleted file mode 100644
index cb5e5602eb..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs
deleted file mode 100644
index 5e5d8afc44..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-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 System.Windows.Controls.Primitives;
-using System.ComponentModel;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class GradientSlider
- {
- public GradientSlider()
- {
- InitializeComponent();
-
- BindingOperations.SetBinding(this, SelectedStopProperty, new Binding("SelectedItem") {
- Source = itemsControl,
- Mode = BindingMode.TwoWay
- });
-
- strip.DragStarted += new DragStartedEventHandler(strip_DragStarted);
- strip.DragDelta += new DragDeltaEventHandler(strip_DragDelta);
- }
-
- static GradientSlider()
- {
- EventManager.RegisterClassHandler(typeof(GradientSlider),
- Thumb.DragDeltaEvent, new DragDeltaEventHandler(ClassDragDelta));
- }
-
- GradientStop newStop;
- double startOffset;
-
- public static readonly DependencyProperty BrushProperty =
- DependencyProperty.Register("Brush", typeof(GradientBrush), typeof(GradientSlider));
-
- public GradientBrush Brush {
- get { return (GradientBrush)GetValue(BrushProperty); }
- set { SetValue(BrushProperty, value); }
- }
-
- public static readonly DependencyProperty SelectedStopProperty =
- DependencyProperty.Register("SelectedStop", typeof(GradientStop), typeof(GradientSlider));
-
- public GradientStop SelectedStop {
- get { return (GradientStop)GetValue(SelectedStopProperty); }
- set { SetValue(SelectedStopProperty, value); }
- }
-
- public static readonly DependencyProperty GradientStopsProperty =
- DependencyProperty.Register("GradientStops", typeof(BindingList), typeof(GradientSlider));
-
- public BindingList GradientStops {
- get { return (BindingList)GetValue(GradientStopsProperty); }
- set { SetValue(GradientStopsProperty, value); }
- }
-
- public static Color GetColorAtOffset(IList stops, double offset)
- {
- GradientStop s1 = stops[0], s2 = stops.Last();
- foreach (var item in stops) {
- if (item.Offset < offset && item.Offset > s1.Offset) s1 = item;
- if (item.Offset > offset && item.Offset < s2.Offset) s2 = item;
- }
- return Color.FromArgb(
- (byte)((s1.Color.A + s2.Color.A) / 2),
- (byte)((s1.Color.R + s2.Color.R) / 2),
- (byte)((s1.Color.G + s2.Color.G) / 2),
- (byte)((s1.Color.B + s2.Color.B) / 2)
- );
- }
-
- static void ClassDragDelta(object sender, DragDeltaEventArgs e)
- {
- (sender as GradientSlider).thumb_DragDelta(sender, e);
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (e.Property == BrushProperty) {
- if (Brush != null) {
- GradientStops = new BindingList(Brush.GradientStops);
- SelectedStop = GradientStops.FirstOrDefault();
- }
- else {
- GradientStops = null;
- }
- }
- }
-
- void strip_DragStarted(object sender, DragStartedEventArgs e)
- {
- startOffset = e.HorizontalOffset / strip.ActualWidth;
- newStop = new GradientStop(GetColorAtOffset(GradientStops, startOffset), startOffset);
- GradientStops.Add(newStop);
- SelectedStop = newStop;
- e.Handled = true;
- }
-
- void strip_DragDelta(object sender, DragDeltaEventArgs e)
- {
- MoveStop(newStop, startOffset, e);
- e.Handled = true;
- }
-
- void thumb_DragDelta(object sender, DragDeltaEventArgs e)
- {
- var stop = (e.OriginalSource as GradientThumb).GradientStop;
- MoveStop(stop, stop.Offset, e);
- }
-
- void MoveStop(GradientStop stop, double oldOffset, DragDeltaEventArgs e)
- {
- if (e.VerticalChange > 50 && GradientStops.Count > 2) {
- GradientStops.Remove(stop);
- SelectedStop = GradientStops.FirstOrDefault();
- return;
- }
- stop.Offset = (oldOffset + e.HorizontalChange / strip.ActualWidth).Coerce(0, 1);
- }
- }
-
- public class GradientItemsControl : Selector
- {
- protected override DependencyObject GetContainerForItemOverride()
- {
- return new GradientThumb();
- }
- }
-
- public class GradientThumb : Thumb
- {
- public GradientStop GradientStop {
- get { return DataContext as GradientStop; }
- }
-
- protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
- {
- base.OnPreviewMouseDown(e);
- var itemsControl = ItemsControl.ItemsControlFromItemContainer(this) as GradientItemsControl;
- itemsControl.SelectedItem = GradientStop;
- }
- }
-
- public class Dragger : Thumb
- {
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/NormalizedPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/NormalizedPanel.cs
deleted file mode 100644
index 32171eba4d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/NormalizedPanel.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public class NormalizedPanel : Panel
- {
- public static double GetX(DependencyObject obj)
- {
- return (double)obj.GetValue(XProperty);
- }
-
- public static void SetX(DependencyObject obj, double value)
- {
- obj.SetValue(XProperty, value);
- }
-
- public static readonly DependencyProperty XProperty =
- DependencyProperty.RegisterAttached("X", typeof(double), typeof(NormalizedPanel),
- new PropertyMetadata(OnPositioningChanged));
-
- public static double GetY(DependencyObject obj)
- {
- return (double)obj.GetValue(YProperty);
- }
-
- public static void SetY(DependencyObject obj, double value)
- {
- obj.SetValue(YProperty, value);
- }
-
- public static readonly DependencyProperty YProperty =
- DependencyProperty.RegisterAttached("Y", typeof(double), typeof(NormalizedPanel),
- new PropertyMetadata(OnPositioningChanged));
-
- static void OnPositioningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- NormalizedPanel parent = VisualTreeHelper.GetParent(d) as NormalizedPanel;
- if (parent != null) {
- parent.InvalidateArrange();
- }
- }
-
- protected override Size MeasureOverride(Size availableSize)
- {
- foreach (UIElement item in Children) {
- item.Measure(availableSize);
- }
- return new Size();
- }
-
- protected override Size ArrangeOverride(Size finalSize)
- {
- foreach (UIElement item in Children) {
- Rect r = new Rect(item.DesiredSize);
- r.X = GetX(item) * finalSize.Width - item.DesiredSize.Width / 2;
- r.Y = GetY(item) * finalSize.Height - item.DesiredSize.Height / 2;
- item.Arrange(r);
- }
- return finalSize;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs
deleted file mode 100644
index 1a87e5044a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Controls.Primitives;
-using System.Windows;
-using System.Windows.Input;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Data;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public class Picker : Grid
- {
- public Picker()
- {
- SizeChanged += delegate { UpdateValueOffset(); };
- }
-
- public static readonly DependencyProperty MarkerProperty =
- DependencyProperty.Register("Marker", typeof(UIElement), typeof(Picker));
-
- public UIElement Marker {
- get { return (UIElement)GetValue(MarkerProperty); }
- set { SetValue(MarkerProperty, value); }
- }
-
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register("Value", typeof(double), typeof(Picker),
- new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- public double Value {
- get { return (double)GetValue(ValueProperty); }
- set { SetValue(ValueProperty, value); }
- }
-
- public static readonly DependencyProperty ValueOffsetProperty =
- DependencyProperty.Register("ValueOffset", typeof(double), typeof(Picker));
-
- public double ValueOffset {
- get { return (double)GetValue(ValueOffsetProperty); }
- set { SetValue(ValueOffsetProperty, value); }
- }
-
- public static readonly DependencyProperty OrientationProperty =
- DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Picker));
-
- public Orientation Orientation {
- get { return (Orientation)GetValue(OrientationProperty); }
- set { SetValue(OrientationProperty, value); }
- }
-
- public static readonly DependencyProperty MinimumProperty =
- DependencyProperty.Register("Minimum", typeof(double), typeof(Picker));
-
- public double Minimum {
- get { return (double)GetValue(MinimumProperty); }
- set { SetValue(MinimumProperty, value); }
- }
-
- public static readonly DependencyProperty MaximumProperty =
- DependencyProperty.Register("Maximum", typeof(double), typeof(Picker),
- new FrameworkPropertyMetadata(100.0));
-
- public double Maximum {
- get { return (double)GetValue(MaximumProperty); }
- set { SetValue(MaximumProperty, value); }
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
-
- if (e.Property == MarkerProperty) {
- TranslateTransform t = Marker.RenderTransform as TranslateTransform;
- if (t == null) {
- t = new TranslateTransform();
- Marker.RenderTransform = t;
- }
- var property = Orientation == Orientation.Horizontal ? TranslateTransform.XProperty : TranslateTransform.YProperty;
- BindingOperations.SetBinding(t, property, new Binding("ValueOffset") {
- Source = this
- });
- }
- else if (e.Property == ValueProperty) {
- UpdateValueOffset();
- }
- }
-
- bool isMouseDown;
-
- protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
- {
- isMouseDown = true;
- CaptureMouse();
- UpdateValue();
- }
-
- protected override void OnPreviewMouseMove(MouseEventArgs e)
- {
- if (isMouseDown) {
- UpdateValue();
- }
- }
-
- protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
- {
- isMouseDown = false;
- ReleaseMouseCapture();
- }
-
- void UpdateValue()
- {
- Point p = Mouse.GetPosition(this);
- double length = 0, pos = 0;
-
- if (Orientation == Orientation.Horizontal) {
- length = ActualWidth;
- pos = p.X;
- }
- else {
- length = ActualHeight;
- pos = p.Y;
- }
-
- pos = Math.Max(0, Math.Min(length, pos));
- Value = Minimum + (Maximum - Minimum) * pos / length;
- }
-
- void UpdateValueOffset()
- {
- var length = Orientation == Orientation.Horizontal ? ActualWidth : ActualHeight;
- ValueOffset = length * (Value - Minimum) / (Maximum - Minimum);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml
deleted file mode 100644
index dadf1edc74..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs
deleted file mode 100644
index bf937c4e3a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-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;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
-{
- public partial class SolidBrushEditor
- {
- public SolidBrushEditor()
- {
- InitializeComponent();
- }
-
- public static readonly DependencyProperty ColorProperty =
- DependencyProperty.Register("Color", typeof(Color), typeof(SolidBrushEditor),
- new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- public Color Color {
- get { return (Color)GetValue(ColorProperty); }
- set { SetValue(ColorProperty, value); }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml
deleted file mode 100644
index 1c5472a37a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs
deleted file mode 100644
index 34b6eb370b..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-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.PropertyGrid.Editors
-{
- [TypeEditor(typeof(MulticastDelegate))]
- public partial class EventEditor
- {
- public EventEditor()
- {
- InitializeComponent();
- }
-
- public PropertyNode PropertyNode {
- get { return DataContext as PropertyNode; }
- }
-
- public string ValueString {
- get { return (string)PropertyNode.Value ?? ""; }
- }
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Enter) {
- Commit();
- }
- else if (e.Key == Key.Escape) {
- BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
- }
- }
-
- protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
- {
- Commit();
- }
-
- protected override void OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
- {
- if (PropertyNode != null && Text != ValueString) {
- Commit();
- }
- }
-
- public void Commit()
- {
- if (Text != ValueString) {
- if (string.IsNullOrEmpty(Text)) {
- PropertyNode.Reset();
- return;
- }
- PropertyNode.Value = Text;
- }
- IEventHandlerService s = PropertyNode.Services.GetService();
- if (s != null) {
- s.CreateEventHandler(PropertyNode.FirstProperty);
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml
deleted file mode 100644
index 3d201d21e4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs
deleted file mode 100644
index ed084ddd2e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-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;
-using System.Reflection;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
-{
- [TypeEditor(typeof(byte))]
- [TypeEditor(typeof(sbyte))]
- [TypeEditor(typeof(decimal))]
- [TypeEditor(typeof(double))]
- [TypeEditor(typeof(float))]
- [TypeEditor(typeof(int))]
- [TypeEditor(typeof(uint))]
- [TypeEditor(typeof(long))]
- [TypeEditor(typeof(ulong))]
- [TypeEditor(typeof(short))]
- [TypeEditor(typeof(ushort))]
- public partial class NumberEditor
- {
- static NumberEditor()
- {
- minimums[typeof(byte)] = byte.MinValue;
- minimums[typeof(sbyte)] = sbyte.MinValue;
- minimums[typeof(decimal)] = (double)decimal.MinValue;
- minimums[typeof(double)] = double.MinValue;
- minimums[typeof(float)] = float.MinValue;
- minimums[typeof(int)] = int.MinValue;
- minimums[typeof(uint)] = uint.MinValue;
- minimums[typeof(long)] = long.MinValue;
- minimums[typeof(ulong)] = ulong.MinValue;
- minimums[typeof(short)] = short.MinValue;
- minimums[typeof(ushort)] = ushort.MinValue;
-
- maximums[typeof(byte)] = byte.MaxValue;
- maximums[typeof(sbyte)] = sbyte.MaxValue;
- maximums[typeof(decimal)] = (double)decimal.MaxValue;
- maximums[typeof(double)] = double.MaxValue;
- maximums[typeof(float)] = float.MaxValue;
- maximums[typeof(int)] = int.MaxValue;
- maximums[typeof(uint)] = uint.MaxValue;
- maximums[typeof(long)] = long.MaxValue;
- maximums[typeof(ulong)] = ulong.MaxValue;
- maximums[typeof(short)] = short.MaxValue;
- maximums[typeof(ushort)] = ushort.MaxValue;
- }
-
- public NumberEditor()
- {
- InitializeComponent();
- DataContextChanged += new DependencyPropertyChangedEventHandler(NumberEditor_DataContextChanged);
- }
-
- static Dictionary minimums = new Dictionary();
- static Dictionary maximums = new Dictionary();
-
- public PropertyNode PropertyNode {
- get { return DataContext as PropertyNode; }
- }
-
- void NumberEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (PropertyNode == null) return;
- var type = PropertyNode.FirstProperty.ReturnType;
-
- var range = Metadata.GetValueRange(PropertyNode.FirstProperty);
- if (range == null) {
- range = new NumberRange() { Min = 0, Max = double.MaxValue };
- }
-
- if (range.Min == double.MinValue) {
- Minimum = minimums[type];
- }
- else {
- Minimum = range.Min;
- }
-
- if (range.Max == double.MaxValue) {
- Maximum = maximums[type];
- }
- else {
- Maximum = range.Max;
- }
-
- if (Minimum == 0 && Maximum == 1) {
- DecimalPlaces = 2;
- SmallChange = 0.01;
- LargeChange = 0.1;
- }
- else {
- ClearValue(DecimalPlacesProperty);
- ClearValue(SmallChangeProperty);
- ClearValue(LargeChangeProperty);
- }
- }
-
- ChangeGroup group;
-
- protected override void OnDragStarted()
- {
- group = PropertyNode.FirstProperty.DesignItem.Context.OpenGroup("drag number",
- PropertyNode.Properties.Select(p => p.DesignItem).ToArray());
- }
-
- protected override void OnDragCompleted()
- {
- group.Commit();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml
deleted file mode 100644
index 2694198ab9..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs
deleted file mode 100644
index 89d7315533..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-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.PropertyGrid
-{
- public partial class PropertyContextMenu
- {
- public PropertyContextMenu()
- {
- InitializeComponent();
- }
-
- public PropertyNode PropertyNode {
- get { return DataContext as PropertyNode; }
- }
-
- void Click_Reset(object sender, RoutedEventArgs e)
- {
- PropertyNode.Reset();
- }
-
- void Click_Binding(object sender, RoutedEventArgs e)
- {
- PropertyNode.CreateBinding();
- }
-
- void Click_CustomExpression(object sender, RoutedEventArgs e)
- {
- }
-
- void Click_ConvertToLocalValue(object sender, RoutedEventArgs e)
- {
- }
-
- void Click_SaveAsResource(object sender, RoutedEventArgs e)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
deleted file mode 100644
index 7f3ae0bce7..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
+++ /dev/null
@@ -1,283 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Collections.ObjectModel;
-using System.Threading;
-using System.Globalization;
-using ICSharpCode.WpfDesign.PropertyGrid;
-using System.Windows.Threading;
-using System.Diagnostics;
-using System.Windows.Media;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
-{
- public class PropertyGrid : INotifyPropertyChanged
- {
- public PropertyGrid()
- {
- Categories = new ObservableCollection(new [] {
- specialCategory,
- popularCategory,
- otherCategory
- });
-
- Events = new PropertyNodeCollection();
- }
-
- Category specialCategory = new Category("Special");
- Category popularCategory = new Category("Popular");
- Category otherCategory = new Category("Other");
-
- Dictionary nodeFromDescriptor = new Dictionary();
-
- public ObservableCollection Categories { get; private set; }
- public PropertyNodeCollection Events { get; private set; }
-
- PropertyGridTab currentTab;
-
- public PropertyGridTab CurrentTab {
- get {
- return currentTab;
- }
- set {
- currentTab = value;
- RaisePropertyChanged("CurrentTab");
- RaisePropertyChanged("NameBackground");
- }
- }
-
- string filter;
-
- public string Filter {
- get {
- return filter;
- }
- set {
- filter = value;
- Reload();
- RaisePropertyChanged("Filter");
- }
- }
-
- DesignItem singleItem;
-
- public DesignItem SingleItem {
- get {
- return singleItem;
- }
- private set {
- if (singleItem != null) {
- singleItem.NameChanged -= singleItem_NameChanged;
- }
- singleItem = value;
- if (singleItem != null) {
- singleItem.NameChanged += singleItem_NameChanged;
- }
- RaisePropertyChanged("SingleItem");
- RaisePropertyChanged("Name");
- RaisePropertyChanged("IsNameEnabled");
- IsNameCorrect = true;
- }
- }
-
- void singleItem_NameChanged(object sender, EventArgs e)
- {
- RaisePropertyChanged("Name");
- }
-
- public string Name {
- get {
- if (SingleItem != null) {
- return SingleItem.Name;
- }
- return null;
- }
- set {
- if (SingleItem != null) {
- try {
- if (string.IsNullOrEmpty(value)) {
- SingleItem.Properties["Name"].Reset();
- } else {
- SingleItem.Name = value;
- }
- IsNameCorrect = true;
- } catch {
- IsNameCorrect = false;
- }
- RaisePropertyChanged("Name");
- }
- }
- }
-
- bool isNameCorrect = true;
-
- public bool IsNameCorrect {
- get {
- return isNameCorrect;
- }
- set {
- isNameCorrect = value;
- RaisePropertyChanged("IsNameCorrect");
- }
- }
-
- public bool IsNameEnabled {
- get {
- return SingleItem != null;
- }
- }
-
- IEnumerable selectedItems;
-
- public IEnumerable SelectedItems {
- get {
- return selectedItems;
- }
- set {
- Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(delegate {
- selectedItems = value;
- Reload();
- RaisePropertyChanged("SelectedItems");
- }));
- }
- }
-
- public void ClearFilter()
- {
- Filter = null;
- }
-
- void Reload()
- {
- Clear();
-
- if (SelectedItems == null || SelectedItems.Count() == 0) return;
- if (SelectedItems.Count() == 1) SingleItem = SelectedItems.First();
-
- foreach (var md in GetDescriptors()) {
- if (PassesFilter(md.Name))
- AddNode(md);
- }
- }
-
- void Clear()
- {
- foreach (var c in Categories) {
- c.IsVisible = false;
- foreach (var p in c.Properties) {
- p.IsVisible = false;
- }
- }
-
- foreach (var e in Events) {
- e.IsVisible = false;
- }
-
- SingleItem = null;
- }
-
- List GetDescriptors()
- {
- List list = new List();
-
- if (SelectedItems.Count() == 1) {
- foreach (MemberDescriptor d in TypeHelper.GetAvailableProperties(SingleItem.ComponentType)) {
- list.Add(d);
- }
- foreach (MemberDescriptor d in TypeHelper.GetAvailableEvents(SingleItem.ComponentType)) {
- list.Add(d);
- }
- } else {
- foreach (MemberDescriptor d in TypeHelper.GetCommonAvailableProperties(SelectedItems.Select(t => t.ComponentType))) {
- list.Add(d);
- }
- }
-
- return list;
- }
-
- bool PassesFilter(string name)
- {
- if (string.IsNullOrEmpty(Filter)) return true;
- for (int i = 0; i < name.Length; i++) {
- if (i == 0 || char.IsUpper(name[i])) {
- if (string.Compare(name, i, Filter, 0, Filter.Length, true) == 0) {
- return true;
- }
- }
- }
- return false;
- }
-
- void AddNode(MemberDescriptor md)
- {
- var designProperties = SelectedItems.Select(item => item.Properties[md.Name]).ToArray();
- if (!Metadata.IsBrowsable(designProperties[0])) return;
-
- PropertyNode node;
- if (nodeFromDescriptor.TryGetValue(md, out node)) {
- node.Load(designProperties);
- } else {
- node = new PropertyNode();
- node.Load(designProperties);
- if (node.IsEvent) {
- Events.AddSorted(node);
- } else {
- var cat = PickCategory(node);
- cat.Properties.AddSorted(node);
- node.Category = cat;
- }
- nodeFromDescriptor[md] = node;
- }
- node.IsVisible = true;
- if (node.Category != null)
- node.Category.IsVisible = true;
- }
-
- Category PickCategory(PropertyNode node)
- {
- if (Metadata.IsPopularProperty(node.FirstProperty)) return popularCategory;
- var typeName = node.FirstProperty.DeclaringType.FullName;
- if (typeName.StartsWith("System.Windows.") || typeName.StartsWith("ICSharpCode.WpfDesign.Designer.Controls."))
- return otherCategory;
- return specialCategory;
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
-
- //class CategoryNameComparer : IComparer
- //{
- // public static CategoryNameComparer Instance = new CategoryNameComparer();
-
- // public int Compare(string x, string y)
- // {
- // int i1 = Array.IndexOf(Metadata.CategoryOrder, x);
- // if (i1 == -1) i1 = int.MaxValue;
- // int i2 = Array.IndexOf(Metadata.CategoryOrder, y);
- // if (i2 == -1) i2 = int.MaxValue;
- // if (i1 == i2) return x.CompareTo(y);
- // return i1.CompareTo(i2);
- // }
- //}
- }
-
- public enum PropertyGridTab
- {
- Properties,
- Events
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml
deleted file mode 100644
index c94ece8ec3..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml
+++ /dev/null
@@ -1,356 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml.cs
deleted file mode 100644
index 766973f2c5..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-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 System.Windows.Controls.Primitives;
-using ICSharpCode.WpfDesign.PropertyGrid;
-
-namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
-{
- public partial class PropertyGridView
- {
- public PropertyGridView()
- {
- PropertyGrid = new PropertyGrid();
- DataContext = PropertyGrid;
-
- InitializeComponent();
-
- thumb.DragDelta += new DragDeltaEventHandler(thumb_DragDelta);
- }
-
- static PropertyContextMenu propertyContextMenu = new PropertyContextMenu();
-
- public PropertyGrid PropertyGrid { get; private set; }
-
- public static readonly DependencyProperty FirstColumnWidthProperty =
- DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView),
- new PropertyMetadata(120.0));
-
- public double FirstColumnWidth {
- get { return (double)GetValue(FirstColumnWidthProperty); }
- set { SetValue(FirstColumnWidthProperty, value); }
- }
-
- public static readonly DependencyProperty SelectedItemsProperty =
- DependencyProperty.Register("SelectedItems", typeof(IEnumerable), typeof(PropertyGridView));
-
- public IEnumerable SelectedItems {
- get { return (IEnumerable)GetValue(SelectedItemsProperty); }
- set { SetValue(SelectedItemsProperty, value); }
- }
-
- protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
- {
- base.OnPropertyChanged(e);
- if (e.Property == SelectedItemsProperty) {
- PropertyGrid.SelectedItems = SelectedItems;
- }
- }
-
- protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
- {
- var row = (e.OriginalSource as DependencyObject).FindAncestor("uxPropertyNodeRow");
- if (row == null) return;
-
- var node = row.DataContext as PropertyNode;
- if (node.IsEvent) return;
-
- var contextMenu = new PropertyContextMenu();
- contextMenu.DataContext = node;
- contextMenu.Placement = PlacementMode.Bottom;
- contextMenu.HorizontalOffset = -30;
- contextMenu.PlacementTarget = row;
- contextMenu.IsOpen = true;
- }
-
- void clearButton_Click(object sender, RoutedEventArgs e)
- {
- PropertyGrid.ClearFilter();
- }
-
- void thumb_DragDelta(object sender, DragDeltaEventArgs e)
- {
- FirstColumnWidth = Math.Max(0, FirstColumnWidth + e.HorizontalChange);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs
deleted file mode 100644
index 2de88f5cac..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Runtime.Serialization;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- ///
- /// Exception class used for designer failures.
- ///
- [Serializable]
- public class ServiceRequiredException : DesignerException
- {
- ///
- /// Create a new ServiceRequiredException instance.
- ///
- public ServiceRequiredException(Type serviceType)
- : this("Service " + serviceType.FullName + " is required.")
- {
- }
-
- ///
- /// Create a new ServiceRequiredException instance.
- ///
- public ServiceRequiredException()
- {
- }
-
- ///
- /// Create a new ServiceRequiredException instance.
- ///
- public ServiceRequiredException(string message) : base(message)
- {
- }
-
- ///
- /// Create a new ServiceRequiredException instance.
- ///
- public ServiceRequiredException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- ///
- /// Create a new ServiceRequiredException instance.
- ///
- protected ServiceRequiredException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClass.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClass.cs
deleted file mode 100644
index 2f34c47ab6..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClass.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Windows.Data;
-using System.IO;
-using System.Reflection;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- public class ChooseClass : INotifyPropertyChanged
- {
- public ChooseClass(IEnumerable assemblies)
- {
- foreach (var a in assemblies) {
- foreach (var t in a.GetExportedTypes()) {
- if (t.IsClass) {
- if (t.IsAbstract) continue;
- if (t.IsNested) continue;
- if (t.IsGenericTypeDefinition) continue;
- if (t.GetConstructor(Type.EmptyTypes) == null) continue;
- projectClasses.Add(t);
- }
- }
- }
-
- projectClasses.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
- classes = new ListCollectionView(projectClasses);
- classes.Filter = FilterPredicate;
- }
-
- List projectClasses = new List();
-
- ListCollectionView classes;
-
- public ICollectionView Classes {
- get { return classes; }
- }
-
- string filter;
-
- public string Filter {
- get {
- return filter;
- }
- set {
- filter = value;
- Classes.Refresh();
- RaisePropertyChanged("Filter");
- }
- }
-
- bool showSystemClasses;
-
- public bool ShowSystemClasses {
- get {
- return showSystemClasses;
- }
- set {
- showSystemClasses = value;
- Classes.Refresh();
- RaisePropertyChanged("ShowSystemClasses");
- }
- }
-
- public Type CurrentClass {
- get { return Classes.CurrentItem as Type; }
- }
-
- bool FilterPredicate(object item)
- {
- Type c = item as Type;
- if (!ShowSystemClasses) {
- if (c.Namespace.StartsWith("System") || c.Namespace.StartsWith("Microsoft")) {
- return false;
- }
- }
- return Match(c.Name, Filter);
- }
-
- static bool Match(string className, string filter)
- {
- if (string.IsNullOrEmpty(filter))
- return true;
- else
- return className.StartsWith(filter, StringComparison.InvariantCultureIgnoreCase);
- }
-
- #region INotifyPropertyChanged Members
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml
deleted file mode 100644
index d8a81a4b15..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs
deleted file mode 100644
index 605569e5e6..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
-using System.Windows.Data;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- public partial class ChooseClassDialog
- {
- public ChooseClassDialog(ChooseClass core)
- {
- DataContext = core;
- InitializeComponent();
-
- uxFilter.Focus();
- uxList.MouseDoubleClick += uxList_MouseDoubleClick;
- uxOk.Click += delegate { Ok(); };
-
- AddHandler(Keyboard.GotKeyboardFocusEvent,
- new KeyboardFocusChangedEventHandler(
- (sender, e) => uxList.SetValue(IsSelectionActivePropertyKey, true)
- ),
- true);
- }
-
- //HACK: listbox is always highlighted
- public static DependencyPropertyKey IsSelectionActivePropertyKey =
- (DependencyPropertyKey)typeof(Selector).GetField("IsSelectionActivePropertyKey",
- BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
-
- protected override void OnPreviewKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Enter) {
- Ok();
- e.Handled = true;
- } else if (e.Key == Key.Up) {
- uxList.SelectedIndex = Math.Max(0, uxList.SelectedIndex - 1);
- e.Handled = true;
- } else if (e.Key == Key.Down) {
- uxList.SelectedIndex++;
- e.Handled = true;
- }
- }
-
- void uxList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- var f = e.OriginalSource as FrameworkElement;
- if (f != null && f.DataContext is Type) {
- Ok();
- }
- }
-
- void Ok()
- {
- DialogResult = true;
- Close();
- }
- }
-
- class ClassListBox : ListBox
- {
- protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
- {
- base.OnItemsChanged(e);
- SelectedIndex = 0;
- ScrollIntoView(SelectedItem);
- }
-
- protected override void OnSelectionChanged(SelectionChangedEventArgs e)
- {
- base.OnSelectionChanged(e);
- ScrollIntoView(SelectedItem);
- }
- }
-
- public class ClassNameConverter : IValueConverter
- {
- public static ClassNameConverter Instance = new ClassNameConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var c = value as Type;
- if (c == null) return value;
- return c.Name + " (" + c.Namespace + ")";
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class NullToBoolConverter : IValueConverter
- {
- public static NullToBoolConverter Instance = new NullToBoolConverter();
-
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value == null ? false : true;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassServiceBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassServiceBase.cs
deleted file mode 100644
index f74413c2dc..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassServiceBase.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-using System.IO;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- public abstract class ChooseClassServiceBase
- {
- public Type ChooseClass()
- {
- var core = new ChooseClass(GetAssemblies());
- var window = new ChooseClassDialog(core);
-
- if (window.ShowDialog().Value) {
- return core.CurrentClass;
- }
- return null;
- }
-
- public abstract IEnumerable GetAssemblies();
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs
deleted file mode 100644
index b3dda95e72..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// Base class for mouse gestures that should start dragging only after a minimum drag distance.
- ///
- abstract class ClickOrDragMouseGesture : MouseGestureBase
- {
- protected Point startPoint;
- protected bool hasDragStarted;
- protected IInputElement positionRelativeTo;
-
- const double MinimumDragDistance = 3;
-
- protected sealed override void OnStarted(MouseButtonEventArgs e)
- {
- Debug.Assert(positionRelativeTo != null);
- hasDragStarted = false;
- startPoint = e.GetPosition(positionRelativeTo);
- }
-
- protected override void OnMouseMove(object sender, MouseEventArgs e)
- {
- if (!hasDragStarted) {
- Vector v = e.GetPosition(positionRelativeTo) - startPoint;
- if (Math.Abs(v.X) >= SystemParameters.MinimumHorizontalDragDistance
- || Math.Abs(v.Y) >= SystemParameters.MinimumVerticalDragDistance) {
- hasDragStarted = true;
- OnDragStarted(e);
- }
- }
- }
-
- protected override void OnStopped()
- {
- hasDragStarted = false;
- }
-
- protected virtual void OnDragStarted(MouseEventArgs e) {}
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
deleted file mode 100644
index 7d8695dbf0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
+++ /dev/null
@@ -1,258 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System.Windows;
-using System;
-using System.Diagnostics;
-using System.Windows.Input;
-using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// A tool that creates a component.
- ///
- public class CreateComponentTool : ITool
- {
- readonly Type componentType;
- MoveLogic moveLogic;
- ChangeGroup changeGroup;
- Point createPoint;
-
- ///
- /// Creates a new CreateComponentTool instance.
- ///
- public CreateComponentTool(Type componentType)
- {
- if (componentType == null)
- throw new ArgumentNullException("componentType");
- this.componentType = componentType;
- }
-
- ///
- /// Gets the type of the component to be created.
- ///
- public Type ComponentType {
- get { return componentType; }
- }
-
- public Cursor Cursor {
- get { return Cursors.Cross; }
- }
-
- public void Activate(IDesignPanel designPanel)
- {
- designPanel.MouseDown += OnMouseDown;
- //designPanel.DragEnter += designPanel_DragOver;
- designPanel.DragOver += designPanel_DragOver;
- designPanel.Drop += designPanel_Drop;
- designPanel.DragLeave += designPanel_DragLeave;
- }
-
- public void Deactivate(IDesignPanel designPanel)
- {
- designPanel.MouseDown -= OnMouseDown;
- //designPanel.DragEnter -= designPanel_DragOver;
- designPanel.DragOver -= designPanel_DragOver;
- designPanel.Drop -= designPanel_Drop;
- designPanel.DragLeave -= designPanel_DragLeave;
- }
-
- void designPanel_DragOver(object sender, DragEventArgs e)
- {
- try {
- IDesignPanel designPanel = (IDesignPanel)sender;
- e.Effects = DragDropEffects.Copy;
- e.Handled = true;
- Point p = e.GetPosition(designPanel);
-
- if (moveLogic == null) {
- if (e.Data.GetData(typeof(CreateComponentTool)) != this) return;
- // TODO: dropLayer in designPanel
- designPanel.IsAdornerLayerHitTestVisible = false;
- DesignPanelHitTestResult result = designPanel.HitTest(p, false, true);
-
- if (result.ModelHit != null) {
- designPanel.Focus();
- DesignItem createdItem = CreateItem(designPanel.Context);
- if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View))) {
- moveLogic = new MoveLogic(createdItem);
- createPoint = p;
- } else {
- changeGroup.Abort();
- }
- }
- } else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded) {
- if (moveLogic.Operation == null) {
- moveLogic.Start(createPoint);
- } else {
- moveLogic.Move(p);
- }
- }
- } catch (Exception x) {
- DragDropExceptionHandler.HandleException(x);
- }
- }
-
- void designPanel_Drop(object sender, DragEventArgs e)
- {
- try {
- if (moveLogic != null) {
- moveLogic.Stop();
- if (moveLogic.ClickedOn.Services.Tool.CurrentTool is CreateComponentTool) {
- moveLogic.ClickedOn.Services.Tool.CurrentTool = moveLogic.ClickedOn.Services.Tool.PointerTool;
- }
- moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
- moveLogic = null;
- changeGroup.Commit();
- }
- } catch (Exception x) {
- DragDropExceptionHandler.HandleException(x);
- }
- }
-
- void designPanel_DragLeave(object sender, DragEventArgs e)
- {
- try {
- if (moveLogic != null) {
- moveLogic.Cancel();
- moveLogic.ClickedOn.Services.Selection.SetSelectedComponents(null);
- moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
- moveLogic = null;
- changeGroup.Abort();
-
- }
- } catch (Exception x) {
- DragDropExceptionHandler.HandleException(x);
- }
- }
-
- ///
- /// Is called to create the item used by the CreateComponentTool.
- ///
- protected virtual DesignItem CreateItem(DesignContext context)
- {
- object newInstance = context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(componentType, null);
- DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance);
- changeGroup = item.OpenGroup("Drop Control");
- context.Services.ExtensionManager.ApplyDefaultInitializers(item);
- return item;
- }
-
- internal static bool AddItemWithDefaultSize(DesignItem container, DesignItem createdItem, Point position)
- {
- var size = ModelTools.GetDefaultSize(createdItem);
- PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
- container,
- new DesignItem[] { createdItem },
- new Rect[] { new Rect(position, size) },
- PlacementType.AddItem
- );
- if (operation != null) {
- container.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
- operation.Commit();
- return true;
- } else {
- return false;
- }
- }
-
- void OnMouseDown(object sender, MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
- e.Handled = true;
- IDesignPanel designPanel = (IDesignPanel)sender;
- DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
- if (result.ModelHit != null) {
- IPlacementBehavior behavior = result.ModelHit.GetBehavior();
- if (behavior != null) {
- DesignItem createdItem = CreateItem(designPanel.Context);
-
- new CreateComponentMouseGesture(result.ModelHit, createdItem).Start(designPanel, e);
- }
- }
- }
- }
- }
-
- sealed class CreateComponentMouseGesture : ClickOrDragMouseGesture
- {
- DesignItem createdItem;
- PlacementOperation operation;
- DesignItem container;
-
- public CreateComponentMouseGesture(DesignItem clickedOn, DesignItem createdItem)
- {
- this.container = clickedOn;
- this.createdItem = createdItem;
- this.positionRelativeTo = clickedOn.View;
- }
-
-// GrayOutDesignerExceptActiveArea grayOut;
-// SelectionFrame frame;
-// AdornerPanel adornerPanel;
-
- Rect GetStartToEndRect(MouseEventArgs e)
- {
- Point endPoint = e.GetPosition(positionRelativeTo);
- return new Rect(
- Math.Min(startPoint.X, endPoint.X),
- Math.Min(startPoint.Y, endPoint.Y),
- Math.Abs(startPoint.X - endPoint.X),
- Math.Abs(startPoint.Y - endPoint.Y)
- );
- }
-
- protected override void OnDragStarted(MouseEventArgs e)
- {
- operation = PlacementOperation.TryStartInsertNewComponents(container,
- new DesignItem[] { createdItem },
- new Rect[] { GetStartToEndRect(e) },
- PlacementType.Resize);
- if (operation != null) {
- services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
- }
- }
-
- protected override void OnMouseMove(object sender, MouseEventArgs e)
- {
- base.OnMouseMove(sender, e);
- if (operation != null) {
- foreach (PlacementInformation info in operation.PlacedItems) {
- info.Bounds = GetStartToEndRect(e);
- operation.CurrentContainerBehavior.SetPosition(info);
- }
- }
- }
-
- protected override void OnMouseUp(object sender, MouseButtonEventArgs e)
- {
- if (hasDragStarted) {
- if (operation != null) {
- operation.Commit();
- operation = null;
- }
- } else {
- CreateComponentTool.AddItemWithDefaultSize(container, createdItem, e.GetPosition(positionRelativeTo));
- }
- base.OnMouseUp(sender, e);
- }
-
- protected override void OnStopped()
- {
- if (operation != null) {
- operation.Abort();
- operation = null;
- }
- if (services.Tool.CurrentTool is CreateComponentTool) {
- services.Tool.CurrentTool = services.Tool.PointerTool;
- }
- base.OnStopped();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
deleted file mode 100644
index df58dbdf1b..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// Mouse gesture for moving elements inside a container or between containers.
- /// Belongs to the PointerTool.
- ///
- sealed class DragMoveMouseGesture : ClickOrDragMouseGesture
- {
- bool isDoubleClick;
- MoveLogic moveLogic;
-
- internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick)
- {
- Debug.Assert(clickedOn != null);
-
- this.isDoubleClick = isDoubleClick;
-
- if (clickedOn.Parent != null)
- this.positionRelativeTo = clickedOn.Parent.View;
- else
- this.positionRelativeTo = clickedOn.View;
-
- moveLogic = new MoveLogic(clickedOn);
- }
-
- protected override void OnDragStarted(MouseEventArgs e)
- {
- moveLogic.Start(startPoint);
- }
-
- protected override void OnMouseMove(object sender, MouseEventArgs e)
- {
- base.OnMouseMove(sender, e); // call OnDragStarted if min. drag distace is reached
- moveLogic.Move(e.GetPosition(positionRelativeTo));
- }
-
- protected override void OnMouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!hasDragStarted && isDoubleClick) {
- // user made a double-click
- Debug.Assert(moveLogic.Operation == null);
- moveLogic.HandleDoubleClick();
- }
- moveLogic.Stop();
- Stop();
- }
-
- protected override void OnStopped()
- {
- moveLogic.Cancel();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ErrorService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ErrorService.cs
deleted file mode 100644
index 16f414b47a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ErrorService.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-using ICSharpCode.WpfDesign.Designer.Controls;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- sealed class DefaultErrorService : IErrorService
- {
- sealed class AttachedErrorBalloon : ErrorBalloon
- {
- FrameworkElement attachTo;
-
- public AttachedErrorBalloon(FrameworkElement attachTo, UIElement errorElement)
- {
- this.attachTo = attachTo;
- this.Content = errorElement;
- }
-
- internal void AttachEvents()
- {
- attachTo.Unloaded += OnCloseEvent;
- attachTo.PreviewKeyDown += OnCloseEvent;
- attachTo.PreviewMouseDown += OnCloseEvent;
- attachTo.LostFocus += OnCloseEvent;
- }
-
- void OnCloseEvent(object sender, EventArgs e)
- {
- this.Close();
- }
-
- protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
- {
- attachTo.Unloaded -= OnCloseEvent;
- attachTo.PreviewKeyDown -= OnCloseEvent;
- attachTo.PreviewMouseDown -= OnCloseEvent;
- attachTo.LostFocus -= OnCloseEvent;
- base.OnClosing(e);
- }
-
- protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
- {
- base.OnMouseDown(e);
- Close();
- }
- }
-
- ServiceContainer services;
-
- public DefaultErrorService(DesignContext context)
- {
- this.services = context.Services;
- }
-
- public void ShowErrorTooltip(FrameworkElement attachTo, UIElement errorElement)
- {
- if (attachTo == null)
- throw new ArgumentNullException("attachTo");
- if (errorElement == null)
- throw new ArgumentNullException("errorElement");
-
- AttachedErrorBalloon b = new AttachedErrorBalloon(attachTo, errorElement);
- Point pos = attachTo.PointToScreen(new Point(0, attachTo.ActualHeight));
- b.Left = pos.X;
- b.Top = pos.Y - 8;
- b.Focusable = false;
- ITopLevelWindowService windowService = services.GetService();
- ITopLevelWindow ownerWindow = (windowService != null) ? windowService.GetTopLevelWindow(attachTo) : null;
- if (ownerWindow != null) {
- ownerWindow.SetOwner(b);
- }
- b.Show();
-
- if (ownerWindow != null) {
- ownerWindow.Activate();
- }
-
- b.AttachEvents();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs
deleted file mode 100644
index 48dcb86418..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// Base class for classes handling mouse gestures on the design surface.
- ///
- abstract class MouseGestureBase
- {
- ///
- /// Checks if is the only button that is currently pressed.
- ///
- internal static bool IsOnlyButtonPressed(MouseEventArgs e, MouseButton button)
- {
- return e.LeftButton == (button == MouseButton.Left ? MouseButtonState.Pressed : MouseButtonState.Released)
- && e.MiddleButton == (button == MouseButton.Middle ? MouseButtonState.Pressed : MouseButtonState.Released)
- && e.RightButton == (button == MouseButton.Right ? MouseButtonState.Pressed : MouseButtonState.Released)
- && e.XButton1 == (button == MouseButton.XButton1 ? MouseButtonState.Pressed : MouseButtonState.Released)
- && e.XButton2 == (button == MouseButton.XButton2 ? MouseButtonState.Pressed : MouseButtonState.Released);
- }
-
- protected IDesignPanel designPanel;
- protected ServiceContainer services;
- protected bool canAbortWithEscape = true;
- bool isStarted;
-
- public void Start(IDesignPanel designPanel, MouseButtonEventArgs e)
- {
- if (designPanel == null)
- throw new ArgumentNullException("designPanel");
- if (e == null)
- throw new ArgumentNullException("e");
- if (isStarted)
- throw new InvalidOperationException("Gesture already was started");
-
- isStarted = true;
- this.designPanel = designPanel;
- this.services = designPanel.Context.Services;
- if (designPanel.CaptureMouse()) {
- RegisterEvents();
- OnStarted(e);
- } else {
- Stop();
- }
- }
-
- void RegisterEvents()
- {
- designPanel.LostMouseCapture += OnLostMouseCapture;
- designPanel.MouseDown += OnMouseDown;
- designPanel.MouseMove += OnMouseMove;
- designPanel.MouseUp += OnMouseUp;
- designPanel.KeyDown += OnKeyDown;
- }
-
- void UnRegisterEvents()
- {
- designPanel.LostMouseCapture -= OnLostMouseCapture;
- designPanel.MouseDown -= OnMouseDown;
- designPanel.MouseMove -= OnMouseMove;
- designPanel.MouseUp -= OnMouseUp;
- designPanel.KeyDown -= OnKeyDown;
- }
-
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- if (canAbortWithEscape && e.Key == Key.Escape) {
- e.Handled = true;
- Stop();
- }
- }
-
- void OnLostMouseCapture(object sender, MouseEventArgs e)
- {
- Stop();
- }
-
- protected virtual void OnMouseDown(object sender, MouseButtonEventArgs e)
- {
- }
-
- protected virtual void OnMouseMove(object sender, MouseEventArgs e)
- {
- }
-
- protected virtual void OnMouseUp(object sender, MouseButtonEventArgs e)
- {
- Stop();
- }
-
- protected void Stop()
- {
- if (!isStarted) return;
- isStarted = false;
- designPanel.ReleaseMouseCapture();
- UnRegisterEvents();
- OnStopped();
- }
-
- protected virtual void OnStarted(MouseButtonEventArgs e) {}
- protected virtual void OnStopped() {}
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs
deleted file mode 100644
index fc82bfbe34..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- class MoveLogic
- {
- public MoveLogic(DesignItem clickedOn)
- {
- this.clickedOn = clickedOn;
-
- selectedItems = clickedOn.Services.Selection.SelectedItems;
- if (!selectedItems.Contains(clickedOn))
- selectedItems = SharedInstances.EmptyDesignItemArray;
- }
-
- DesignItem clickedOn;
- PlacementOperation operation;
- ICollection selectedItems;
- Point startPoint;
-
- public DesignItem ClickedOn {
- get { return clickedOn; }
- }
-
- public PlacementOperation Operation {
- get { return operation; }
- }
-
- public IDesignPanel DesignPanel {
- get { return clickedOn.Services.DesignPanel; }
- }
-
- public void Start(Point p)
- {
- startPoint = p;
- IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(selectedItems);
- if (b != null && b.CanPlace(selectedItems, PlacementType.Move, PlacementAlignment.TopLeft)) {
- List sortedSelectedItems = new List(selectedItems);
- sortedSelectedItems.Sort(ModelTools.ComparePositionInModelFile);
- selectedItems = sortedSelectedItems;
- operation = PlacementOperation.Start(selectedItems, PlacementType.Move);
- }
- }
-
- public void Move(Point p)
- {
- if (operation != null) {
-
- // try to switch the container
- if (operation.CurrentContainerBehavior.CanLeaveContainer(operation)) {
- ChangeContainerIfPossible(p);
- }
-
- Vector v = p - startPoint;
- foreach (PlacementInformation info in operation.PlacedItems) {
- info.Bounds = new Rect(info.OriginalBounds.Left + v.X,
- info.OriginalBounds.Top + v.Y,
- info.OriginalBounds.Width,
- info.OriginalBounds.Height);
- }
- operation.CurrentContainerBehavior.BeforeSetPosition(operation);
- foreach (PlacementInformation info in operation.PlacedItems) {
- operation.CurrentContainerBehavior.SetPosition(info);
- }
- }
- }
-
- public void Stop()
- {
- if (operation != null) {
- operation.Commit();
- operation = null;
- }
- }
-
- public void Cancel()
- {
- if (operation != null) {
- operation.Abort();
- operation = null;
- }
- }
-
- // Perform hit testing on the design panel and return the first model that is not selected
- DesignPanelHitTestResult HitTestUnselectedModel(Point p)
- {
- DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
- ISelectionService selection = clickedOn.Services.Selection;
-
- DesignPanel.HitTest(p, false, true, delegate(DesignPanelHitTestResult r) {
- if (r.ModelHit == null)
- return true; // continue hit testing
- if (selection.IsComponentSelected(r.ModelHit))
- return true; // continue hit testing
- result = r;
- return false; // finish hit testing
- });
-
- return result;
- }
-
- bool ChangeContainerIfPossible(Point p)
- {
- DesignPanelHitTestResult result = HitTestUnselectedModel(p);
- if (result.ModelHit == null) return false;
- if (result.ModelHit == operation.CurrentContainer) return false;
-
- // check that we don't move an item into itself:
- DesignItem tmp = result.ModelHit;
- while (tmp != null) {
- if (tmp == clickedOn) return false;
- tmp = tmp.Parent;
- }
-
- IPlacementBehavior b = result.ModelHit.GetBehavior();
- if (b != null && b.CanEnterContainer(operation)) {
- operation.ChangeContainer(result.ModelHit);
- return true;
- }
- return false;
- }
-
- public void HandleDoubleClick()
- {
- if (selectedItems.Count == 1) {
- IEventHandlerService ehs = clickedOn.Services.GetService();
- if (ehs != null) {
- DesignItemProperty defaultEvent = ehs.GetDefaultEvent(clickedOn);
- if (defaultEvent != null) {
- ehs.CreateEventHandler(defaultEvent);
- }
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/OptionService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/OptionService.cs
deleted file mode 100644
index 2c13727ca2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/OptionService.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// Contains a set of options regarding the default designer components.
- ///
- public sealed class OptionService
- {
- ///
- /// Gets/Sets whether the design surface should be grayed out while dragging/selection.
- ///
- public bool GrayOutDesignSurfaceExceptParentContainerWhenDragging = true;
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs
deleted file mode 100644
index 539e92f375..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- sealed class PointerTool : ITool
- {
- internal static readonly PointerTool Instance = new PointerTool();
-
- public Cursor Cursor {
- get { return null; }
- }
-
- public void Activate(IDesignPanel designPanel)
- {
- designPanel.MouseDown += OnMouseDown;
- }
-
- public void Deactivate(IDesignPanel designPanel)
- {
- designPanel.MouseDown -= OnMouseDown;
- }
-
- void OnMouseDown(object sender, MouseButtonEventArgs e)
- {
- IDesignPanel designPanel = (IDesignPanel)sender;
- DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
- if (result.ModelHit != null) {
- IHandlePointerToolMouseDown b = result.ModelHit.GetBehavior();
- if (b != null) {
- b.HandleSelectionMouseDown(designPanel, e, result);
- }
- if (!e.Handled) {
- if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
- e.Handled = true;
- ISelectionService selectionService = designPanel.Context.Services.Selection;
- selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto);
- if (selectionService.IsComponentSelected(result.ModelHit)) {
- new DragMoveMouseGesture(result.ModelHit, e.ClickCount == 2).Start(designPanel, e);
- }
- }
- }
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/SelectionService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/SelectionService.cs
deleted file mode 100644
index 646c378d68..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/SelectionService.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows.Input;
-using System.ComponentModel;
-using System.Linq;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- ///
- /// Manages the collection of selected components and the primary selection.
- /// Notifies components with attached DesignSite when their selection state changes.
- ///
- sealed class DefaultSelectionService : ISelectionService, INotifyPropertyChanged
- {
- HashSet _selectedComponents = new HashSet();
- DesignItem _primarySelection;
-
- public bool IsComponentSelected(DesignItem component)
- {
- return _selectedComponents.Contains(component);
- }
-
- public ICollection SelectedItems {
- get { return _selectedComponents.Clone(); }
- }
-
- public DesignItem PrimarySelection {
- get { return _primarySelection; }
- }
-
- public int SelectionCount {
- get { return _selectedComponents.Count; }
- }
-
- public event EventHandler SelectionChanging;
- public event EventHandler SelectionChanged;
- public event EventHandler PrimarySelectionChanging;
- public event EventHandler PrimarySelectionChanged;
-
- public void SetSelectedComponents(ICollection components)
- {
- SetSelectedComponents(components, SelectionTypes.Replace);
- }
-
- public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
- {
- if (components == null)
- components = SharedInstances.EmptyDesignItemArray;
-
- var prevSelectedItems = _selectedComponents.ToArray();
-
- if (SelectionChanging != null)
- SelectionChanging(this, EventArgs.Empty);
-
- DesignItem newPrimarySelection = _primarySelection;
-
- if (selectionType == SelectionTypes.Auto) {
- if (Keyboard.Modifiers == ModifierKeys.Control)
- selectionType = SelectionTypes.Toggle; // Ctrl pressed: toggle selection
- else if ((Keyboard.Modifiers & ~ModifierKeys.Control) == ModifierKeys.Shift)
- selectionType = SelectionTypes.Add; // Shift or Ctrl+Shift pressed: add to selection
- else
- selectionType = SelectionTypes.Primary; // otherwise: change primary selection
- }
-
- if ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary) {
- // change primary selection to first new component
- newPrimarySelection = null;
- foreach (DesignItem obj in components) {
- newPrimarySelection = obj;
- break;
- }
-
- selectionType &= ~SelectionTypes.Primary;
- if (selectionType == 0) {
- // if selectionType was only Primary, and components has only one item that
- // changes the primary selection was changed to an already-selected item,
- // then we keep the current selection.
- // otherwise, we replace it
- if (components.Count == 1 && IsComponentSelected(newPrimarySelection)) {
- // keep selectionType = 0 -> don't change the selection
- } else {
- selectionType = SelectionTypes.Replace;
- }
- }
- }
-
- HashSet componentsToNotifyOfSelectionChange = new HashSet();
- switch (selectionType) {
- case SelectionTypes.Add:
- // add to selection and notify if required
- foreach (DesignItem obj in components) {
- if (_selectedComponents.Add(obj))
- componentsToNotifyOfSelectionChange.Add(obj);
- }
- break;
- case SelectionTypes.Remove:
- // remove from selection and notify if required
- foreach (DesignItem obj in components) {
- if (_selectedComponents.Remove(obj))
- componentsToNotifyOfSelectionChange.Add(obj);
- }
- break;
- case SelectionTypes.Replace:
- // notify all old components:
- componentsToNotifyOfSelectionChange.AddRange(_selectedComponents);
- // set _selectedCompontents to new components
- _selectedComponents.Clear();
- foreach (DesignItem obj in components) {
- _selectedComponents.Add(obj);
- // notify the new components
- componentsToNotifyOfSelectionChange.Add(obj);
- }
- break;
- case SelectionTypes.Toggle:
- // toggle selection and notify
- foreach (DesignItem obj in components) {
- if (_selectedComponents.Contains(obj)) {
- _selectedComponents.Remove(obj);
- } else {
- _selectedComponents.Add(obj);
- }
- componentsToNotifyOfSelectionChange.Add(obj);
- }
- break;
- case 0:
- // do nothing
- break;
- default:
- throw new NotSupportedException("The selection type " + selectionType + " is not supported");
- }
-
- if (!IsComponentSelected(newPrimarySelection)) {
- // primary selection is not selected anymore - change primary selection to any other selected component
- newPrimarySelection = null;
- foreach (DesignItem obj in _selectedComponents) {
- newPrimarySelection = obj;
- break;
- }
- }
-
- // Primary selection has changed:
- if (newPrimarySelection != _primarySelection) {
- componentsToNotifyOfSelectionChange.Add(_primarySelection);
- componentsToNotifyOfSelectionChange.Add(newPrimarySelection);
- if (PrimarySelectionChanging != null) {
- PrimarySelectionChanging(this, EventArgs.Empty);
- }
- _primarySelection = newPrimarySelection;
- if (PrimarySelectionChanged != null) {
- PrimarySelectionChanged(this, EventArgs.Empty);
- }
- }
-
- if (!SelectedItems.SequenceEqual(prevSelectedItems)) {
- if (SelectionChanged != null) {
- SelectionChanged(this, new DesignItemCollectionEventArgs(componentsToNotifyOfSelectionChange));
- }
- RaisePropertyChanged("SelectedItems");
- }
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
deleted file mode 100644
index a12e2c711f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Input;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- // See IToolService for description.
- sealed class DefaultToolService : IToolService, IDisposable
- {
- ITool _currentTool;
- IDesignPanel _designPanel;
-
- public DefaultToolService(DesignContext context)
- {
- _currentTool = this.PointerTool;
- context.Services.RunWhenAvailable(
- delegate(IDesignPanel designPanel) {
- _designPanel = designPanel;
- _currentTool.Activate(designPanel);
- });
- }
-
- public void Dispose()
- {
- if (_designPanel != null) {
- _currentTool.Deactivate(_designPanel);
- _designPanel = null;
- }
- }
-
- public ITool PointerTool {
- get { return Services.PointerTool.Instance; }
- }
-
- public ITool CurrentTool {
- get { return _currentTool; }
- set {
- if (value == null)
- throw new ArgumentNullException("value");
- if (_currentTool == value) return;
- if (_designPanel != null) {
- _currentTool.Deactivate(_designPanel);
- }
- _currentTool = value;
- if (_designPanel != null) {
- _currentTool.Activate(_designPanel);
- }
- if (CurrentToolChanged != null) {
- CurrentToolChanged(this, EventArgs.Empty);
- }
- }
- }
-
- public event EventHandler CurrentToolChanged;
-
- public IDesignPanel DesignPanel {
- get { return _designPanel; }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs
deleted file mode 100644
index 6b4a0f69c4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs
+++ /dev/null
@@ -1,316 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using ICSharpCode.WpfDesign.Designer.Xaml;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- #region ITransactionItem
- interface ITransactionItem : IUndoAction
- {
- void Do();
- void Undo();
- }
- #endregion
-
- #region IUndoAction
- ///
- /// Describes an action available on the undo or redo stack.
- ///
- public interface IUndoAction
- {
- ///
- /// The list of elements affected by the action.
- ///
- ICollection AffectedElements { get; }
-
- ///
- /// The title of the action.
- ///
- string Title { get; }
- }
- #endregion
-
- #region UndoTransaction
- ///
- /// Supports ChangeGroup transactions and undo behavior.
- ///
- sealed class UndoTransaction : ChangeGroup, ITransactionItem
- {
- readonly ICollection affectedElements;
-
- internal UndoTransaction(ICollection affectedElements)
- {
- this.affectedElements = affectedElements;
- }
-
- public ICollection AffectedElements {
- get { return affectedElements; }
- }
-
- public enum TransactionState
- {
- Open,
- Completed,
- Undone,
- Failed
- }
-
- TransactionState _state;
-
- public TransactionState State {
- get { return _state; }
- }
-
- List items = new List();
-
- public void Execute(ITransactionItem item)
- {
- AssertState(TransactionState.Open);
- item.Do();
-
- var a = item as XamlModelProperty.PropertyChangeAction;
- if (a != null) {
- foreach (var b in items.OfType()) {
- if (b.MergeWith(a)) return;
- }
- }
-
- items.Add(item);
- }
-
- private void AssertState(TransactionState expectedState)
- {
- if (_state != expectedState)
- throw new InvalidOperationException("Expected state " + expectedState + ", but state is " + _state);
- }
-
- public event EventHandler Committed;
- public event EventHandler RolledBack;
-
- public override void Commit()
- {
- AssertState(TransactionState.Open);
- _state = TransactionState.Completed;
- if (Committed != null)
- Committed(this, EventArgs.Empty);
- }
-
- public override void Abort()
- {
- AssertState(TransactionState.Open);
- _state = TransactionState.Failed;
- InternalRollback();
- if (RolledBack != null)
- RolledBack(this, EventArgs.Empty);
- }
-
- public void Undo()
- {
- AssertState(TransactionState.Completed);
- _state = TransactionState.Undone;
- InternalRollback();
- }
-
- void InternalRollback()
- {
- try {
- for (int i = items.Count - 1; i >= 0; i--) {
- items[i].Undo();
- }
- } catch {
- _state = TransactionState.Failed;
- throw;
- }
- }
-
- public void Redo()
- {
- AssertState(TransactionState.Undone);
- try {
- for (int i = 0; i < items.Count; i++) {
- items[i].Do();
- }
- _state = TransactionState.Completed;
- } catch {
- _state = TransactionState.Failed;
- try {
- InternalRollback();
- } catch (Exception ex) {
- Debug.WriteLine("Exception rolling back after Redo error:\n" + ex.ToString());
- }
- throw;
- }
- }
-
- void ITransactionItem.Do()
- {
- if (_state != TransactionState.Completed) {
- Redo();
- }
- }
-
- protected override void Disposed()
- {
- if (_state == TransactionState.Open) {
- try {
- Abort();
- } catch (Exception ex) {
- Debug.WriteLine("Exception rolling back after failure:\n" + ex.ToString());
- }
- }
- }
- }
- #endregion
-
- #region UndoService
- ///
- /// Service supporting Undo/Redo actions on the design surface.
- ///
- public sealed class UndoService
- {
- Stack _transactionStack = new Stack();
- Stack _undoStack = new Stack();
- Stack _redoStack = new Stack();
-
- internal UndoTransaction StartTransaction(ICollection affectedItems)
- {
- UndoTransaction t = new UndoTransaction(affectedItems);
- _transactionStack.Push(t);
- t.Committed += TransactionFinished;
- t.RolledBack += TransactionFinished;
- t.Committed += delegate(object sender, EventArgs e) {
- Execute((UndoTransaction)sender);
- };
- return t;
- }
-
- void TransactionFinished(object sender, EventArgs e)
- {
- if (sender != _transactionStack.Pop()) {
- throw new Exception("Invalid transaction finish, nested transactions must finish first");
- }
- }
-
- internal void Execute(ITransactionItem item)
- {
- if (_transactionStack.Count == 0) {
- item.Do();
- _undoStack.Push(item);
- _redoStack.Clear();
- OnUndoStackChanged(EventArgs.Empty);
- } else {
- _transactionStack.Peek().Execute(item);
- }
- }
-
- ///
- /// Gets if undo actions are available.
- ///
- public bool CanUndo {
- get { return _undoStack.Count > 0; }
- }
-
- ///
- /// Is raised when the undo stack has changed.
- ///
- public event EventHandler UndoStackChanged;
-
- void OnUndoStackChanged(EventArgs e)
- {
- if (UndoStackChanged != null) {
- UndoStackChanged(this, e);
- }
- }
-
- ///
- /// Undoes the last action.
- ///
- public void Undo()
- {
- if (!CanUndo)
- throw new InvalidOperationException("Cannot Undo: undo stack is empty");
- if (_transactionStack.Count != 0)
- throw new InvalidOperationException("Cannot Undo while transaction is running");
- ITransactionItem item = _undoStack.Pop();
- try {
- item.Undo();
- _redoStack.Push(item);
- OnUndoStackChanged(EventArgs.Empty);
- } catch {
- // state might be invalid now, clear stacks to prevent getting more inconsistencies
- Clear();
- throw;
- }
- }
-
- ///
- /// Gets the list of names of the available actions on the undo stack.
- ///
- public IEnumerable UndoActions {
- get {
- return GetActions(_undoStack);
- }
- }
-
- ///
- /// Gets the list of names of the available actions on the undo stack.
- ///
- public IEnumerable RedoActions {
- get {
- return GetActions(_redoStack);
- }
- }
-
- static IEnumerable GetActions(Stack stack)
- {
- foreach (ITransactionItem item in stack)
- yield return item;
- }
-
- ///
- /// Gets if there are redo actions available.
- ///
- public bool CanRedo { get { return _redoStack.Count > 0; } }
-
- ///
- /// Redoes a previously undone action.
- ///
- public void Redo()
- {
- if (!CanRedo)
- throw new InvalidOperationException("Cannot Redo: redo stack is empty");
- if (_transactionStack.Count != 0)
- throw new InvalidOperationException("Cannot Redo while transaction is running");
- ITransactionItem item = _redoStack.Pop();
- try {
- item.Do();
- _undoStack.Push(item);
- OnUndoStackChanged(EventArgs.Empty);
- } catch {
- // state might be invalid now, clear stacks to prevent getting more inconsistencies
- Clear();
- throw;
- }
- }
-
- ///
- /// Clears saved actions (both undo and redo stack).
- ///
- public void Clear()
- {
- _undoStack.Clear();
- _redoStack.Clear();
- OnUndoStackChanged(EventArgs.Empty);
- }
- }
- #endregion
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ViewService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ViewService.cs
deleted file mode 100644
index 7c729048a8..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ViewService.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- sealed class DefaultViewService : ViewService
- {
- readonly DesignContext context;
-
- public DefaultViewService(DesignContext context)
- {
- this.context = context;
- }
-
- public override DesignItem GetModel(System.Windows.DependencyObject view)
- {
- // In the WPF designer, we do not support having a different view for a component
- return context.Services.Component.GetDesignItem(view);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/WpfTopLevelWindowService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/WpfTopLevelWindowService.cs
deleted file mode 100644
index 2f2dea0496..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/WpfTopLevelWindowService.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2667$
-//
-
-using System;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- sealed class WpfTopLevelWindowService : ITopLevelWindowService
- {
- public ITopLevelWindow GetTopLevelWindow(System.Windows.UIElement element)
- {
- Window window = Window.GetWindow(element);
- if (window != null)
- return new WpfTopLevelWindow(window);
- else
- return null;
- }
-
- sealed class WpfTopLevelWindow : ITopLevelWindow
- {
- Window window;
-
- public WpfTopLevelWindow(Window window)
- {
- this.window = window;
- }
-
- public void SetOwner(Window child)
- {
- child.Owner = window;
- }
-
- public bool Activate()
- {
- return window.Activate();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/XamlErrorService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/XamlErrorService.cs
deleted file mode 100644
index f263473024..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/XamlErrorService.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ICSharpCode.WpfDesign.XamlDom;
-using System.Collections.ObjectModel;
-
-namespace ICSharpCode.WpfDesign.Designer.Services
-{
- public class XamlErrorService : IXamlErrorSink
- {
- public XamlErrorService()
- {
- Errors = new ObservableCollection();
- }
-
- public ObservableCollection Errors { get; private set; }
-
- public void ReportError(string message, int line, int column)
- {
- Errors.Add(new XamlError() { Message = message, Line = line, Column = column });
- }
- }
-
- public class XamlError
- {
- public string Message { get; set; }
- public int Line { get; set; }
- public int Column { get; set; }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/SharedInstances.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/SharedInstances.cs
deleted file mode 100644
index 11b2906382..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/SharedInstances.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Designer
-{
- static class SharedInstances
- {
- internal static readonly object BoxedTrue = true;
- internal static readonly object BoxedFalse = false;
- internal static readonly object[] EmptyObjectArray = new object[0];
- internal static readonly DesignItem[] EmptyDesignItemArray = new DesignItem[0];
-
- internal static object Box(bool value)
- {
- return value ? BoxedTrue : BoxedFalse;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
deleted file mode 100644
index 678fcfb295..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
+++ /dev/null
@@ -1,301 +0,0 @@
-
-
- {78CC29AC-CC79-4355-B1F2-97936DF198AC}
- Debug
- AnyCPU
- Library
- ICSharpCode.WpfDesign.Designer
- ICSharpCode.WpfDesign.Designer
- False
- False
- 4
- false
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml
- 1591
- v3.5
-
-
- true
- Full
- True
- DEBUG;TRACE
- False
-
-
- False
- None
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
- False
- False
- 3.0
-
-
- False
- False
- 3.0
-
-
-
- 3.5
-
-
-
-
- 3.0
-
-
- False
- 3.0
-
-
-
-
- Configuration\GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
- EnumBar.xaml
-
-
-
- Code
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DesignSurface.xaml
-
-
-
-
- Code
-
-
-
-
- Code
-
-
-
-
- Code
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Outline.xaml
- Code
-
-
-
-
-
- BoolEditor.xaml
-
-
-
- BrushEditorPopup.xaml
-
-
- BrushEditorView.xaml
-
-
- BrushTypeEditor.xaml
-
-
-
- ColorPicker.xaml
-
-
- GradientBrushEditor.xaml
-
-
- GradientSlider.xaml
-
-
-
-
- SolidBrushEditor.xaml
-
-
- EventEditor.xaml
-
-
- NumberEditor.xaml
-
-
- PropertyContextMenu.xaml
-
-
-
- PropertyGridView.xaml
-
-
-
-
- ChooseClassDialog.xaml
-
-
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {88DA149F-21B2-48AB-82C4-28FB6BDFD783}
- WpfDesign.XamlDom
- True
-
-
- {66A378A1-E9F4-4AD5-8946-D0EC06C2902F}
- WpfDesign
- False
- True
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
deleted file mode 100644
index 82bb39d197..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using ICSharpCode.WpfDesign.XamlDom;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.Designer.Xaml
-{
- sealed class XamlComponentService : IComponentService
- {
- #region IdentityEqualityComparer
- sealed class IdentityEqualityComparer : IEqualityComparer
@@ -34,15 +34,7 @@
4194304
AnyCPU
4096
-
-
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml
-
-
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml
-
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Tests/WpfDesign.Tests.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Tests/WpfDesign.Tests.csproj
index d9c4f8ec1c..9a1472a5f6 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Tests/WpfDesign.Tests.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Tests/WpfDesign.Tests.csproj
@@ -6,7 +6,7 @@
Library
ICSharpCode.WpfDesign.Tests
ICSharpCode.WpfDesign.Tests
- ..\..\..\..\..\..\bin\UnitTests\
+ ..\..\..\..\..\bin\UnitTests\
False
False
4
@@ -40,13 +40,7 @@
4194304
AnyCPU
4096
-
-
- ..\..\..\..\..\bin\UnitTests\
-
-
- ..\..\..\..\..\bin\UnitTests\
-
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/AssemblyInfo.cs
deleted file mode 100644
index 48e0b155e5..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/AssemblyInfo.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("ICSharpCode.WpfDesign.XamlDom")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: CLSCompliant(true)]
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionElementsCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionElementsCollection.cs
deleted file mode 100644
index d690e1a5b8..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionElementsCollection.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.ObjectModel;
-using System.Collections.Generic;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// The collection used by XamlProperty.CollectionElements
- ///
- sealed class CollectionElementsCollection : Collection
- {
- XamlProperty property;
-
- internal CollectionElementsCollection(XamlProperty property)
- {
- this.property = property;
- }
-
- ///
- /// Used by parser to construct the collection without changing the XmlDocument.
- ///
- internal void AddInternal(XamlPropertyValue value)
- {
- base.InsertItem(this.Count, value);
- }
-
- protected override void ClearItems()
- {
- while (Count > 0) {
- RemoveAt(Count - 1);
- }
- }
-
- protected override void RemoveItem(int index)
- {
- XamlPropertyInfo info = property.propertyInfo;
- object collection = info.GetValue(property.ParentObject.Instance);
- if (!CollectionSupport.RemoveItemAt(info.ReturnType, collection, index)) {
- CollectionSupport.RemoveItem(info.ReturnType, collection, this[index].GetValueFor(info));
- }
-
- this[index].RemoveNodeFromParent();
- this[index].ParentProperty = null;
- base.RemoveItem(index);
- }
-
- protected override void InsertItem(int index, XamlPropertyValue item)
- {
- XamlPropertyInfo info = property.propertyInfo;
- object collection = info.GetValue(property.ParentObject.Instance);
- CollectionSupport.Insert(info.ReturnType, collection, item, index);
-
- item.ParentProperty = property;
- property.InsertNodeInCollection(item.GetNodeForCollection(), index);
-
- base.InsertItem(index, item);
- }
-
- protected override void SetItem(int index, XamlPropertyValue item)
- {
- RemoveItem(index);
- InsertItem(index, item);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
deleted file mode 100644
index 8d8f00adad..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Collections;
-using System.ComponentModel;
-using System.Globalization;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Static class containing helper methods to work with collections (like the XamlParser does)
- ///
- public static class CollectionSupport
- {
- ///
- /// Gets if the type is considered a collection in XAML.
- ///
- public static bool IsCollectionType(Type type)
- {
- return typeof(IList).IsAssignableFrom(type)
- || type.IsArray
- || typeof(IAddChild).IsAssignableFrom(type)
- || typeof(ResourceDictionary).IsAssignableFrom(type);
- }
-
- ///
- /// Gets if the collection type can accepts items of type
- /// .
- ///
- public static bool CanCollectionAdd(Type col, Type item)
- {
- var e = col.GetInterface("IEnumerable`1");
- if (e != null && e.IsGenericType) {
- var a = e.GetGenericArguments()[0];
- return a.IsAssignableFrom(item);
- }
- return true;
- }
-
- ///
- /// Gets if the collection type can accept the specified items.
- ///
- public static bool CanCollectionAdd(Type col, IEnumerable items)
- {
- foreach (var item in items) {
- if (!CanCollectionAdd(col, item.GetType())) return false;
- }
- return true;
- }
-
- ///
- /// Adds a value to the end of a collection.
- ///
- public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement)
- {
- IAddChild addChild = collectionInstance as IAddChild;
- if (addChild != null) {
- if (newElement is XamlTextValue) {
- addChild.AddText((string)newElement.GetValueFor(null));
- } else {
- addChild.AddChild(newElement.GetValueFor(null));
- }
- } else if (collectionInstance is ResourceDictionary) {
- object val = newElement.GetValueFor(null);
- object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null;
- if (key == null) {
- if (val is Style)
- key = ((Style)val).TargetType;
- }
- ((ResourceDictionary)collectionInstance).Add(key, val);
- } else {
- collectionType.InvokeMember(
- "Add", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
- null, collectionInstance,
- new object[] { newElement.GetValueFor(null) },
- CultureInfo.InvariantCulture);
- }
- }
-
- ///
- /// Adds a value at the specified index in the collection.
- ///
- public static void Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
- {
- collectionType.InvokeMember(
- "Insert", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
- null, collectionInstance,
- new object[] { index, newElement.GetValueFor(null) },
- CultureInfo.InvariantCulture);
- }
-
- static readonly Type[] RemoveAtParameters = { typeof(int) };
-
- ///
- /// Removes the item at the specified index of the collection.
- ///
- /// True if the removal succeeded, false if the collection type does not support RemoveAt.
- public static bool RemoveItemAt(Type collectionType, object collectionInstance, int index)
- {
- MethodInfo m = collectionType.GetMethod("RemoveAt", RemoveAtParameters);
- if (m != null) {
- m.Invoke(collectionInstance, new object[] { index });
- return true;
- } else {
- return false;
- }
- }
-
- ///
- /// Removes an item instance from the specified collection.
- ///
- public static void RemoveItem(Type collectionType, object collectionInstance, object item)
- {
- collectionType.InvokeMember(
- "Remove", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
- null, collectionInstance,
- new object[] { item },
- CultureInfo.InvariantCulture);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
deleted file mode 100644
index 01b75c89f0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Interface where errors during XAML loading are reported.
- ///
- public interface IXamlErrorSink
- {
- ///
- /// Reports a XAML load error.
- ///
- void ReportError(string message, int line, int column);
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs
deleted file mode 100644
index 52ece80518..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs
+++ /dev/null
@@ -1,323 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Text;
-using System.Windows.Markup;
-using System.Xml;
-using System.Reflection;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Tokenizer for markup extension attributes.
- /// [MS-XAML 6.6.7.1]
- ///
- sealed class MarkupExtensionTokenizer
- {
- private MarkupExtensionTokenizer() {}
-
- string text;
- int pos;
- List tokens = new List();
-
- public static List Tokenize(string text)
- {
- MarkupExtensionTokenizer t = new MarkupExtensionTokenizer();
- t.text = text;
- t.Parse();
- return t.tokens;
- }
-
- void AddToken(MarkupExtensionTokenKind kind, string val)
- {
- tokens.Add(new MarkupExtensionToken(kind, val));
- }
-
- void Parse()
- {
- AddToken(MarkupExtensionTokenKind.OpenBrace, "{");
- Expect('{');
- ConsumeWhitespace();
- CheckNotEOF();
-
- StringBuilder b = new StringBuilder();
- while (pos < text.Length && !char.IsWhiteSpace(text, pos) && text[pos] != '}')
- b.Append(text[pos++]);
- AddToken(MarkupExtensionTokenKind.TypeName, b.ToString());
-
- ConsumeWhitespace();
- while (pos < text.Length) {
- switch (text[pos]) {
- case '}':
- AddToken(MarkupExtensionTokenKind.CloseBrace, "}");
- pos++;
- break;
- case '=':
- AddToken(MarkupExtensionTokenKind.Equals, "=");
- pos++;
- break;
- case ',':
- AddToken(MarkupExtensionTokenKind.Comma, ",");
- pos++;
- break;
- default:
- MembernameOrString();
- break;
- }
- ConsumeWhitespace();
- }
- }
-
- void MembernameOrString()
- {
- StringBuilder b = new StringBuilder();
- if (text[pos] == '"' || text[pos] == '\'') {
- char quote = text[pos++];
- CheckNotEOF();
- while (!(text[pos] == quote && text[pos-1] != '\\')) {
- char c = text[pos++];
- if (c != '\\')
- b.Append(c);
- CheckNotEOF();
- }
- pos++; // consume closing quote
- ConsumeWhitespace();
- } else {
- int braceTotal = 0;
- while (true) {
- CheckNotEOF();
- switch (text[pos]) {
- case '\\':
- pos++;
- CheckNotEOF();
- b.Append(text[pos++]);
- break;
- case '{':
- b.Append(text[pos++]);
- braceTotal++;
- break;
- case '}':
- if (braceTotal == 0) goto stop;
- b.Append(text[pos++]);
- braceTotal--;
- break;
- case ',':
- case '=':
- if (braceTotal == 0) goto stop;
- b.Append(text[pos++]);
- break;
- default:
- b.Append(text[pos++]);
- break;
- }
- }
- stop:;
- }
- CheckNotEOF();
- string valueText = b.ToString();
- if (text[pos] == '=') {
- AddToken(MarkupExtensionTokenKind.Membername, valueText.Trim());
- } else {
- AddToken(MarkupExtensionTokenKind.String, valueText);
- }
- }
-
- void Expect(char c)
- {
- CheckNotEOF();
- if (text[pos] != c)
- throw new XamlMarkupExtensionParseException("Expected '" + c + "'");
- pos++;
- }
-
- void ConsumeWhitespace()
- {
- while (pos < text.Length && char.IsWhiteSpace(text, pos))
- pos++;
- }
-
- void CheckNotEOF()
- {
- if (pos >= text.Length)
- throw new XamlMarkupExtensionParseException("Unexpected end of markup extension");
- }
- }
-
- ///
- /// Exception thrown when XAML loading fails because there is a syntax error in a markup extension.
- ///
- [Serializable]
- public class XamlMarkupExtensionParseException : XamlLoadException
- {
- ///
- /// Create a new XamlMarkupExtensionParseException instance.
- ///
- public XamlMarkupExtensionParseException()
- {
- }
-
- ///
- /// Create a new XamlMarkupExtensionParseException instance.
- ///
- public XamlMarkupExtensionParseException(string message) : base(message)
- {
- }
-
- ///
- /// Create a new XamlMarkupExtensionParseException instance.
- ///
- public XamlMarkupExtensionParseException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- ///
- /// Create a new XamlMarkupExtensionParseException instance.
- ///
- protected XamlMarkupExtensionParseException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
- }
-
- enum MarkupExtensionTokenKind
- {
- OpenBrace,
- CloseBrace,
- Equals,
- Comma,
- TypeName,
- Membername,
- String
- }
-
- sealed class MarkupExtensionToken
- {
- public readonly MarkupExtensionTokenKind Kind;
- public readonly string Value;
-
- public MarkupExtensionToken(MarkupExtensionTokenKind kind, string value)
- {
- this.Kind = kind;
- this.Value = value;
- }
-
- public override string ToString()
- {
- return "[" + Kind + " " + Value + "]";
- }
- }
-
- ///
- /// [MS-XAML 6.6.7.2]
- ///
- static class MarkupExtensionParser
- {
- public static XamlObject Parse(string text, XamlObject parent, XmlAttribute attribute)
- {
- var tokens = MarkupExtensionTokenizer.Tokenize(text);
- if (tokens.Count < 3
- || tokens[0].Kind != MarkupExtensionTokenKind.OpenBrace
- || tokens[1].Kind != MarkupExtensionTokenKind.TypeName
- || tokens[tokens.Count-1].Kind != MarkupExtensionTokenKind.CloseBrace)
- {
- throw new XamlMarkupExtensionParseException("Invalid markup extension");
- }
-
- var typeResolver = parent.ServiceProvider.Resolver;
-
- string typeName = tokens[1].Value;
- Type extensionType = typeResolver.Resolve(typeName + "Extension");
- if (extensionType == null) extensionType = typeResolver.Resolve(typeName);
- if (extensionType == null || !typeof(MarkupExtension).IsAssignableFrom(extensionType)) {
- throw new XamlMarkupExtensionParseException("Unknown markup extension " + typeName + "Extension");
- }
-
- List positionalArgs = new List();
- List> namedArgs = new List>();
- for (int i = 2; i < tokens.Count - 1; i++) {
- if (tokens[i].Kind == MarkupExtensionTokenKind.String) {
- positionalArgs.Add(tokens[i].Value);
- } else if (tokens[i].Kind == MarkupExtensionTokenKind.Membername) {
- if (tokens[i+1].Kind != MarkupExtensionTokenKind.Equals
- || tokens[i+2].Kind != MarkupExtensionTokenKind.String)
- {
- throw new XamlMarkupExtensionParseException("Invalid markup extension");
- }
- namedArgs.Add(new KeyValuePair(tokens[i].Value, tokens[i+2].Value));
- i += 2;
- }
- }
-
- // Find the constructor with positionalArgs.Count arguments
- var ctors = extensionType.GetConstructors().Where(c => c.GetParameters().Length == positionalArgs.Count).ToList();
- if (ctors.Count < 1)
- throw new XamlMarkupExtensionParseException("No constructor for " +
- extensionType.FullName + " found that takes " + positionalArgs.Count + " arguments");
- if (ctors.Count > 1) {
- Debug.WriteLine("Multiple constructors for " +
- extensionType.FullName + " found that take " + positionalArgs.Count + " arguments");
- }
-
- var ctor = ctors[0];
- var defaultCtor = extensionType.GetConstructor(Type.EmptyTypes);
- bool mappingToProperties = defaultCtor != null;
- List map = new List();
-
- if (mappingToProperties) {
- foreach (var param in ctor.GetParameters()) {
- var prop = extensionType.GetProperty(param.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
- if (prop == null) {
- mappingToProperties = false;
- break;
- }
- map.Add(prop);
- }
- }
-
- object instance;
- if (mappingToProperties) {
- instance = defaultCtor.Invoke(null);
- } else {
- var ctorParamsInfo = ctor.GetParameters();
- var ctorParams = new object[ctorParamsInfo.Length];
- for (int i = 0; i < ctorParams.Length; i++) {
- var paramType = ctorParamsInfo[i].ParameterType;
- ctorParams[i] = XamlParser.CreateObjectFromAttributeText(positionalArgs[i], paramType, parent);
- }
- instance = ctor.Invoke(ctorParams);
- //TODO
- //XamlObject.ConstructorArgsProperty - args collection
- //Reinvoke ctor when needed
- }
-
- XamlObject result = parent.OwnerDocument.CreateObject(instance);
- if (attribute != null) result.XmlAttribute = attribute;
- result.ParentObject = parent;
-
- if (mappingToProperties) {
- for (int i = 0; i < positionalArgs.Count; i++) {
- var a = parent.OwnerDocument.XmlDocument.CreateAttribute(map[i].Name);
- a.Value = positionalArgs[i];
- XamlParser.ParseObjectAttribute(result, a, false);
- }
- }
- foreach (var pair in namedArgs) {
- var a = parent.OwnerDocument.XmlDocument.CreateAttribute(pair.Key);
- a.Value = pair.Value;
- XamlParser.ParseObjectAttribute(result, a, false);
- }
- return result;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
deleted file mode 100644
index dee154ae18..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Static class that can generate XAML markup extension code ("{Binding Path=...}").
- ///
- public static class MarkupExtensionPrinter
- {
- ///
- /// Gets whether shorthand XAML markup extension code can be generated for the object.
- ///
- public static bool CanPrint(XamlObject obj)
- {
- return true;
- }
-
- ///
- /// Generates XAML markup extension code for the object.
- ///
- public static string Print(XamlObject obj)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("{");
- sb.Append(obj.GetNameForMarkupExtension());
-
- bool first = true;
- foreach (var property in obj.Properties) {
- if (!property.IsSet) continue;
-
- if (first)
- sb.Append(" ");
- else
- sb.Append(", ");
- first = false;
-
- sb.Append(property.GetNameForMarkupExtension());
- sb.Append("=");
-
- var value = property.PropertyValue;
- if (value is XamlTextValue) {
- sb.Append((value as XamlTextValue).Text);
- } else if (value is XamlObject) {
- sb.Append(Print(value as XamlObject));
- }
- }
- sb.Append("}");
- return sb.ToString();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
deleted file mode 100644
index 99227bbf78..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- // SuppressMessage justification: we're just adding position info to XmlDocument and don't want to fix
- // any of it's other issues.
-
- ///
- /// Class derived from System.Xml.XmlDocument that remembers line/column information for elements and attributes
- /// when loading from a or other -implementing reader.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1058:TypesShouldNotExtendCertainBaseTypes")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public class PositionXmlDocument : XmlDocument
- {
- IXmlLineInfo lineInfo; // a reference to the XmlReader, only set during load time
-
- ///
- /// Creates a PositionXmlElement.
- ///
- public override XmlElement CreateElement(string prefix, string localName, string namespaceURI)
- {
- return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo);
- }
-
- ///
- /// Creates a PositionXmlAttribute.
- ///
- public override XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI)
- {
- return new PositionXmlAttribute(prefix, localName, namespaceURI, this, lineInfo);
- }
-
- ///
- /// Loads the XML document from the specified .
- ///
- public override void Load(XmlReader reader)
- {
- lineInfo = reader as IXmlLineInfo;
- try {
- base.Load(reader);
- } finally {
- lineInfo = null;
- }
- }
- }
-
- ///
- /// XML Element with line/column information.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public class PositionXmlElement : XmlElement, IXmlLineInfo
- {
- internal PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
- : base(prefix, localName, namespaceURI, doc)
- {
- if (lineInfo != null) {
- this.lineNumber = lineInfo.LineNumber;
- this.linePosition = lineInfo.LinePosition;
- this.hasLineInfo = true;
- }
- }
-
- int lineNumber;
- int linePosition;
- bool hasLineInfo;
-
- ///
- /// Gets whether the element has line information.
- ///
- public bool HasLineInfo()
- {
- return hasLineInfo;
- }
-
- ///
- /// Gets the line number.
- ///
- public int LineNumber {
- get { return lineNumber; }
- }
-
- ///
- /// Gets the line position (column).
- ///
- public int LinePosition {
- get { return linePosition; }
- }
- }
-
- ///
- /// XML Attribute with line/column information.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
- public class PositionXmlAttribute : XmlAttribute, IXmlLineInfo
- {
- internal PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
- : base(prefix, localName, namespaceURI, doc)
- {
- if (lineInfo != null) {
- this.lineNumber = lineInfo.LineNumber;
- this.linePosition = lineInfo.LinePosition;
- this.hasLineInfo = true;
- }
- }
-
- int lineNumber;
- int linePosition;
- bool hasLineInfo;
-
- ///
- /// Gets whether the element has line information.
- ///
- public bool HasLineInfo()
- {
- return hasLineInfo;
- }
-
- ///
- /// Gets the line number.
- ///
- public int LineNumber {
- get { return lineNumber; }
- }
-
- ///
- /// Gets the line position (column).
- ///
- public int LinePosition {
- get { return linePosition; }
- }
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
deleted file mode 100644
index 2536ee12c1..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
- {88DA149F-21B2-48AB-82C4-28FB6BDFD783}
- Debug
- AnyCPU
- Library
- ICSharpCode.WpfDesign.XamlDom
- ICSharpCode.WpfDesign.XamlDom
- False
- False
- 4
- false
- True
- ..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk
- False
- File
- False
- -Microsoft.Performance#CA1800
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml
- v3.5
- C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
-
-
- true
- Full
- True
- DEBUG;TRACE
- False
-
-
- False
- None
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
- False
-
-
- False
-
-
-
- 3.5
-
-
-
-
- False
-
-
-
-
- GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
deleted file mode 100644
index af639b33ae..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Contains constants used by the Xaml parser.
- ///
- public static class XamlConstants
- {
- ///
- /// The namespace used to identify "xmlns".
- /// Value: "http://www.w3.org/2000/xmlns/"
- ///
- public const string XmlnsNamespace = "http://www.w3.org/2000/xmlns/";
-
- ///
- /// The namespace used for the XAML schema.
- /// Value: "http://schemas.microsoft.com/winfx/2006/xaml"
- ///
- public const string XamlNamespace = "http://schemas.microsoft.com/winfx/2006/xaml";
-
- ///
- /// The namespace used for the WPF schema.
- /// Value: "http://schemas.microsoft.com/netfx/2007/xaml/presentation"
- ///
- public const string PresentationNamespace = "http://schemas.microsoft.com/netfx/2007/xaml/presentation";
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
deleted file mode 100644
index 8c60ef28b6..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.ComponentModel;
-using System.Windows.Markup;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Represents a .xaml document.
- ///
- public sealed class XamlDocument
- {
- XmlDocument _xmlDoc;
- XamlObject _rootElement;
- IServiceProvider _serviceProvider;
-
- XamlTypeFinder _typeFinder;
-
- internal XmlDocument XmlDocument {
- get { return _xmlDoc; }
- }
-
- ///
- /// Gets the type finder used for this XAML document.
- ///
- public XamlTypeFinder TypeFinder {
- get { return _typeFinder; }
- }
-
- ///
- /// Gets the service provider used for markup extensions in this document.
- ///
- public IServiceProvider ServiceProvider {
- get { return _serviceProvider; }
- }
-
- ///
- /// Gets the type descriptor context used for type conversions.
- ///
- /// The containing object, used when the
- /// type descriptor context needs to resolve an XML namespace.
- internal ITypeDescriptorContext GetTypeDescriptorContext(XamlObject containingObject)
- {
- return new DummyTypeDescriptorContext(this, containingObject);
- }
-
- sealed class DummyTypeDescriptorContext : ITypeDescriptorContext
- {
- IServiceProvider baseServiceProvider;
-
- public DummyTypeDescriptorContext(XamlDocument document, XamlObject containingObject)
- {
- if (containingObject != null) {
- if (containingObject.OwnerDocument != document)
- throw new ArgumentException("Containing object must belong to the document!");
- baseServiceProvider = containingObject.ServiceProvider;
- } else {
- baseServiceProvider = document.ServiceProvider;
- }
- }
-
- public IContainer Container {
- get { return null; }
- }
-
- public object Instance {
- get { return null; }
- }
-
- public PropertyDescriptor PropertyDescriptor {
- get { return null; }
- }
-
- public bool OnComponentChanging()
- {
- return false;
- }
-
- public void OnComponentChanged()
- {
- }
-
- public object GetService(Type serviceType)
- {
- return baseServiceProvider.GetService(serviceType);
- }
- }
-
- ///
- /// Gets the root xaml object.
- ///
- public XamlObject RootElement {
- get { return _rootElement; }
- }
-
- ///
- /// Gets the object instance created by the root xaml object.
- ///
- public object RootInstance {
- get { return (_rootElement != null) ? _rootElement.Instance : null; }
- }
-
- ///
- /// Saves the xaml document into the .
- ///
- public void Save(XmlWriter writer)
- {
- if (writer == null)
- throw new ArgumentNullException("writer");
- _xmlDoc.Save(writer);
- }
-
- ///
- /// Internal constructor, used by XamlParser.
- ///
- internal XamlDocument(XmlDocument xmlDoc, XamlParserSettings settings)
- {
- this._xmlDoc = xmlDoc;
- this._typeFinder = settings.TypeFinder;
- this._serviceProvider = settings.ServiceProvider;
- }
-
- ///
- /// Called by XamlParser to finish initializing the document.
- ///
- internal void ParseComplete(XamlObject rootElement)
- {
- this._rootElement = rootElement;
- }
-
- ///
- /// Create an XamlObject from the instance.
- ///
- public XamlObject CreateObject(object instance)
- {
- return (XamlObject)CreatePropertyValue(instance, null);
- }
-
- ///
- /// Creates a value that represents {x:Null}
- ///
- public XamlPropertyValue CreateNullValue()
- {
- return CreateObject(new NullExtension());
- }
-
- ///
- /// Create a XamlPropertyValue for the specified value instance.
- ///
- public XamlPropertyValue CreatePropertyValue(object instance, XamlProperty forProperty)
- {
- if (instance == null)
- throw new ArgumentNullException("instance");
-
- Type elementType = instance.GetType();
- TypeConverter c = TypeDescriptor.GetConverter(instance);
- bool hasStringConverter = c.CanConvertTo(typeof(string)) && c.CanConvertFrom(typeof(string));
-
- if (forProperty != null && hasStringConverter) {
- return new XamlTextValue(this, c.ConvertToInvariantString(instance));
- }
-
-
- XmlElement xml = _xmlDoc.CreateElement(elementType.Name, GetNamespaceFor(elementType));
-
- if (hasStringConverter) {
- xml.InnerText = c.ConvertToInvariantString(instance);
- }
- return new XamlObject(this, xml, elementType, instance);
- }
-
- internal string GetNamespaceFor(Type type)
- {
- return _typeFinder.GetXmlNamespaceFor(type.Assembly, type.Namespace);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlLoadException.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlLoadException.cs
deleted file mode 100644
index e81bee8c13..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlLoadException.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Runtime.Serialization;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Exception class used for xaml loading failures.
- ///
- [Serializable]
- public class XamlLoadException : Exception
- {
- ///
- /// Create a new XamlLoadException instance.
- ///
- public XamlLoadException()
- {
- }
-
- ///
- /// Create a new XamlLoadException instance.
- ///
- public XamlLoadException(string message) : base(message)
- {
- }
-
- ///
- /// Create a new XamlLoadException instance.
- ///
- public XamlLoadException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- ///
- /// Create a new XamlLoadException instance.
- ///
- protected XamlLoadException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
deleted file mode 100644
index 32aa56c0d0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
+++ /dev/null
@@ -1,395 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows.Markup;
-using System.Xml;
-using System.Windows.Data;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Represents a xaml object element.
- ///
- [DebuggerDisplay("XamlObject: {Instance}")]
- public sealed class XamlObject : XamlPropertyValue
- {
- XamlDocument document;
- XmlElement element;
- Type elementType;
- object instance;
- List properties = new List();
-
- /// For use by XamlParser only.
- internal XamlObject(XamlDocument document, XmlElement element, Type elementType, object instance)
- {
- this.document = document;
- this.element = element;
- this.elementType = elementType;
- this.instance = instance;
-
- var contentAttrs = elementType.GetCustomAttributes(typeof(ContentPropertyAttribute), true) as ContentPropertyAttribute[];
- if (contentAttrs != null && contentAttrs.Length > 0) {
- this.contentPropertyName = contentAttrs[0].Name;
- }
-
- ServiceProvider = new XamlObjectServiceProvider(this);
- CreateWrapper();
- }
-
- /// For use by XamlParser only.
- internal void AddProperty(XamlProperty property)
- {
- #if DEBUG
- if (property.IsAttached == false) {
- foreach (XamlProperty p in properties) {
- if (p.IsAttached == false && p.PropertyName == property.PropertyName)
- Debug.Fail("duplicate property");
- }
- }
- #endif
- properties.Add(property);
- }
-
- #region XamlPropertyValue implementation
- internal override object GetValueFor(XamlPropertyInfo targetProperty)
- {
- if (IsMarkupExtension) {
- var value = ProvideValue();
- if (value is string && targetProperty != null && targetProperty.ReturnType != typeof(string)) {
- return XamlParser.CreateObjectFromAttributeText((string)value, targetProperty, this);
- }
- return value;
- } else {
- return instance;
- }
- }
-
- internal override XmlNode GetNodeForCollection()
- {
- return element;
- }
- #endregion
-
- XamlObject parentObject;
-
- ///
- /// Gets the parent object.
- ///
- public XamlObject ParentObject {
- get {
- return parentObject;
- }
- internal set { parentObject = value; }
- }
-
- internal override void OnParentPropertyChanged()
- {
- parentObject = (ParentProperty != null) ? ParentProperty.ParentObject : null;
- base.OnParentPropertyChanged();
- }
-
- internal XmlElement XmlElement {
- get { return element; }
- }
-
- XmlAttribute xmlAttribute;
-
- internal XmlAttribute XmlAttribute {
- get { return xmlAttribute; }
- set {
- xmlAttribute = value;
- element = VirualAttachTo(XmlElement, value.OwnerElement);
- }
- }
-
- static XmlElement VirualAttachTo(XmlElement e, XmlElement target)
- {
- var prefix = target.GetPrefixOfNamespace(e.NamespaceURI);
- XmlElement newElement = e.OwnerDocument.CreateElement(prefix, e.LocalName, e.NamespaceURI);
-
- foreach (XmlAttribute a in target.Attributes) {
- if (a.Prefix == "xmlns" || a.Name == "xmlns") {
- newElement.Attributes.Append(a.Clone() as XmlAttribute);
- }
- }
-
- while (e.HasChildNodes) {
- newElement.AppendChild(e.FirstChild);
- }
-
- XmlAttributeCollection ac = e.Attributes;
- while (ac.Count > 0) {
- newElement.Attributes.Append(ac[0]);
- }
-
- return newElement;
- }
-
- internal override void AddNodeTo(XamlProperty property)
- {
- if (!UpdateXmlAttribute(true)) {
- property.AddChildNodeToProperty(element);
- }
- UpdateMarkupExtensionChain();
- }
-
- internal override void RemoveNodeFromParent()
- {
- if (XmlAttribute != null) {
- XmlAttribute.OwnerElement.RemoveAttribute(XmlAttribute.Name);
- xmlAttribute = null;
- } else {
- if (!UpdateXmlAttribute(false)) {
- element.ParentNode.RemoveChild(element);
- }
- }
- //TODO: PropertyValue still there
- //UpdateMarkupExtensionChain();
- }
-
- //TODO: reseting path property for binding doesn't work in XamlProperty
- //use CanResetValue()
- internal void OnPropertyChanged(XamlProperty property)
- {
- UpdateXmlAttribute(false);
- UpdateMarkupExtensionChain();
- }
-
- void UpdateMarkupExtensionChain()
- {
- var obj = this;
- while (obj != null && obj.IsMarkupExtension) {
- obj.ParentProperty.UpdateValueOnInstance();
- obj = obj.ParentObject;
- }
- }
-
- bool UpdateXmlAttribute(bool force)
- {
- var holder = FindXmlAttributeHolder();
- if (holder == null && force && IsMarkupExtension) {
- holder = this;
- }
- if (holder != null && MarkupExtensionPrinter.CanPrint(holder)) {
- var s = MarkupExtensionPrinter.Print(holder);
- holder.XmlAttribute = holder.ParentProperty.SetAttribute(s);
- return true;
- }
- return false;
- }
-
- XamlObject FindXmlAttributeHolder()
- {
- var obj = this;
- while (obj != null && obj.IsMarkupExtension) {
- if (obj.XmlAttribute != null) {
- return obj;
- }
- obj = obj.ParentObject;
- }
- return null;
- }
-
- ///
- /// Gets the XamlDocument where this XamlObject is declared in.
- ///
- public XamlDocument OwnerDocument {
- get { return document; }
- }
-
- ///
- /// Gets the instance created by this object element.
- ///
- public object Instance {
- get { return instance; }
- }
-
- ///
- /// Gets whether this instance represents a MarkupExtension.
- ///
- public bool IsMarkupExtension {
- get { return instance is MarkupExtension; }
- }
-
- ///
- /// Gets whether there were load errors for this object.
- ///
- public bool HasErrors { get; internal set; }
-
- ///
- /// Gets the type of this object element.
- ///
- public Type ElementType {
- get { return elementType; }
- }
-
- ///
- /// Gets a read-only collection of properties set on this XamlObject.
- /// This includes both attribute and element properties.
- ///
- public IList Properties {
- get {
- return properties.AsReadOnly();
- }
- }
-
- string contentPropertyName;
-
- ///
- /// Gets the name of the content property.
- ///
- public string ContentPropertyName {
- get {
- return contentPropertyName;
- }
- }
-
- ///
- /// Finds the specified property, or creates it if it doesn't exist.
- ///
- public XamlProperty FindOrCreateProperty(string propertyName)
- {
- if (propertyName == null)
- throw new ArgumentNullException("propertyName");
-
- foreach (XamlProperty p in properties) {
- if (!p.IsAttached && p.PropertyName == propertyName)
- return p;
- }
- PropertyDescriptorCollection propertyDescriptors = TypeDescriptor.GetProperties(instance);
- PropertyDescriptor propertyInfo = propertyDescriptors[propertyName];
- XamlProperty newProperty;
- if (propertyInfo != null) {
- newProperty = new XamlProperty(this, new XamlNormalPropertyInfo(propertyInfo));
- } else {
- EventDescriptorCollection events = TypeDescriptor.GetEvents(instance);
- EventDescriptor eventInfo = events[propertyName];
- if (eventInfo != null) {
- newProperty = new XamlProperty(this, new XamlEventPropertyInfo(eventInfo));
- } else {
- throw new ArgumentException("The property '" + propertyName + "' doesn't exist on " + elementType.FullName, "propertyName");
- }
- }
- properties.Add(newProperty);
- return newProperty;
- }
-
- ///
- /// Finds the specified property, or creates it if it doesn't exist.
- ///
- public XamlProperty FindOrCreateAttachedProperty(Type ownerType, string propertyName)
- {
- if (ownerType == null)
- throw new ArgumentNullException("ownerType");
- if (propertyName == null)
- throw new ArgumentNullException("propertyName");
-
- foreach (XamlProperty p in properties) {
- if (p.IsAttached && p.PropertyTargetType == ownerType && p.PropertyName == propertyName)
- return p;
- }
- XamlPropertyInfo info = XamlParser.TryFindAttachedProperty(ownerType, propertyName);
- if (info == null) {
- throw new ArgumentException("The attached property '" + propertyName + "' doesn't exist on " + ownerType.FullName, "propertyName");
- }
- XamlProperty newProperty = new XamlProperty(this, info);
- properties.Add(newProperty);
- return newProperty;
- }
-
- ///
- /// Gets an attribute in the x:-namespace.
- ///
- public string GetXamlAttribute(string name)
- {
- return element.GetAttribute(name, XamlConstants.XamlNamespace);
- }
-
- ///
- /// Sets an attribute in the x:-namespace.
- ///
- public void SetXamlAttribute(string name, string value)
- {
- if (value == null)
- element.RemoveAttribute(name, XamlConstants.XamlNamespace);
- else
- element.SetAttribute(name, XamlConstants.XamlNamespace, value);
- }
-
- ///
- /// Gets/Sets the associated with this XamlObject.
- ///
- public XamlObjectServiceProvider ServiceProvider { get; set; }
-
- MarkupExtensionWrapper wrapper;
-
- void CreateWrapper()
- {
- if (Instance is Binding) {
- wrapper = new BindingWrapper();
- } else if (Instance is StaticResourceExtension) {
- wrapper = new StaticResourceWrapper();
- }
- if (wrapper != null) {
- wrapper.XamlObject = this;
- }
- }
-
- object ProvideValue()
- {
- if (wrapper != null) {
- return wrapper.ProvideValue();
- }
- return (Instance as MarkupExtension).ProvideValue(ServiceProvider);
- }
-
- internal string GetNameForMarkupExtension()
- {
- return XmlElement.Name;
- }
- }
-
- abstract class MarkupExtensionWrapper
- {
- public XamlObject XamlObject { get; set; }
- public abstract object ProvideValue();
- }
-
- class BindingWrapper : MarkupExtensionWrapper
- {
- public override object ProvideValue()
- {
- var target = XamlObject.Instance as Binding;
- //TODO: XamlObject.Clone()
- var b = new Binding();
- foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(target)) {
- if (pd.IsReadOnly) continue;
- try {
- var val1 = pd.GetValue(b);
- var val2 = pd.GetValue(target);
- if (object.Equals(val1, val2)) continue;
- pd.SetValue(b, val2);
- } catch {}
- }
- return b.ProvideValue(XamlObject.ServiceProvider);
- }
- }
-
- class StaticResourceWrapper : MarkupExtensionWrapper
- {
- public override object ProvideValue()
- {
- var target = XamlObject.Instance as StaticResourceExtension;
- return XamlObject.ServiceProvider.Resolver.FindResource(target.ResourceKey);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
deleted file mode 100644
index 18a906a06c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// A service provider that provides the IProvideValueTarget and IXamlTypeResolver services.
- /// No other services (e.g. from the document's service provider) are offered.
- ///
- public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget
- {
- ///
- /// Creates a new XamlObjectServiceProvider instance.
- ///
- public XamlObjectServiceProvider(XamlObject obj)
- {
- if (obj == null)
- throw new ArgumentNullException("obj");
- XamlObject = obj;
- Resolver = new XamlTypeResolverProvider(obj);
- }
-
- ///
- /// Gets the XamlObject that owns this service provider (e.g. the XamlObject that represents a markup extension).
- ///
- public XamlObject XamlObject { get; private set; }
- internal XamlTypeResolverProvider Resolver { get; private set; }
-
- #region IServiceProvider Members
-
- ///
- /// Retrieves the service of the specified type.
- ///
- public object GetService(Type serviceType)
- {
- if (serviceType == typeof(IProvideValueTarget)) {
- return this;
- }
- if (serviceType == typeof(IXamlTypeResolver)) {
- return Resolver;
- }
- return null;
- }
-
- #endregion
-
- #region IProvideValueTarget Members
-
- ///
- /// Gets the target object (the DependencyObject instance on which a property should be set)
- ///
- public object TargetObject {
- get { return XamlObject.ParentProperty.ParentObject.Instance; }
- }
-
- ///
- /// Gets the target dependency property.
- ///
- public object TargetProperty {
- get { return XamlObject.ParentProperty.DependencyProperty; }
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
deleted file mode 100644
index c3ca3f5347..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
+++ /dev/null
@@ -1,579 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Globalization;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Markup;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Class with static methods to parse XAML files and output a .
- ///
- public sealed class XamlParser
- {
- #region Static methods
- ///
- /// Parses a XAML document using a stream.
- ///
- public static XamlDocument Parse(Stream stream)
- {
- return Parse(stream, new XamlParserSettings());
- }
-
- ///
- /// Parses a XAML document using a TextReader.
- ///
- public static XamlDocument Parse(TextReader reader)
- {
- return Parse(reader, new XamlParserSettings());
- }
-
- ///
- /// Parses a XAML document using an XmlReader.
- ///
- public static XamlDocument Parse(XmlReader reader)
- {
- return Parse(reader, new XamlParserSettings());
- }
-
- ///
- /// Parses a XAML document using a stream.
- ///
- public static XamlDocument Parse(Stream stream, XamlParserSettings settings)
- {
- if (stream == null)
- throw new ArgumentNullException("stream");
- return Parse(XmlReader.Create(stream), settings);
- }
-
- ///
- /// Parses a XAML document using a TextReader.
- ///
- public static XamlDocument Parse(TextReader reader, XamlParserSettings settings)
- {
- if (reader == null)
- throw new ArgumentNullException("reader");
- return Parse(XmlReader.Create(reader), settings);
- }
-
- ///
- /// Parses a XAML document using an XmlReader.
- ///
- public static XamlDocument Parse(XmlReader reader, XamlParserSettings settings)
- {
- if (reader == null)
- throw new ArgumentNullException("reader");
-
- XmlDocument doc = new PositionXmlDocument();
- var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
-
- try {
- doc.Load(reader);
- return Parse(doc, settings);
- } catch (XmlException x) {
- if (errorSink != null) {
- errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition);
- } else {
- throw;
- }
- }
-
- return null;
- }
-
- ///
- /// Creates a XAML document from an existing XmlDocument.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
- Justification="We need to continue parsing, and the error is reported to the user.")]
- internal static XamlDocument Parse(XmlDocument document, XamlParserSettings settings)
- {
- if (settings == null)
- throw new ArgumentNullException("settings");
- if (document == null)
- throw new ArgumentNullException("document");
- XamlParser p = new XamlParser();
- p.settings = settings;
- p.errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
- p.document = new XamlDocument(document, settings);
-
- try {
- var root = p.ParseObject(document.DocumentElement);
- p.document.ParseComplete(root);
- } catch (Exception x) {
- p.ReportException(x, document.DocumentElement);
- }
-
- return p.document;
- }
- #endregion
-
- private XamlParser() { }
-
- XamlDocument document;
- XamlParserSettings settings;
- IXamlErrorSink errorSink;
-
- static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
- {
- Type elementType = typeFinder.GetType(namespaceUri, localName);
- if (elementType == null)
- throw new XamlLoadException("Cannot find type " + localName + " in " + namespaceUri);
- return elementType;
- }
-
- static string GetAttributeNamespace(XmlAttribute attribute)
- {
- if (attribute.NamespaceURI.Length > 0)
- return attribute.NamespaceURI;
- else
- return attribute.OwnerElement.GetNamespaceOfPrefix("");
- }
-
- readonly static object[] emptyObjectArray = new object[0];
- XmlSpace currentXmlSpace = XmlSpace.None;
- XamlObject currentXamlObject;
-
- void ReportException(Exception x, XmlNode node)
- {
- if (errorSink != null) {
- var lineInfo = node as IXmlLineInfo;
- if (lineInfo != null) {
- errorSink.ReportError(x.Message, lineInfo.LineNumber, lineInfo.LinePosition);
- } else {
- errorSink.ReportError(x.Message, 0, 0);
- }
- if (currentXamlObject != null) {
- currentXamlObject.HasErrors = true;
- }
- } else {
- throw x;
- }
- }
-
- XamlObject ParseObject(XmlElement element)
- {
- Type elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName);
- if (elementType == null) {
- elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName + "Extension");
- if (elementType == null) {
- throw new XamlLoadException("Cannot find type " + element.Name);
- }
- }
-
- XmlSpace oldXmlSpace = currentXmlSpace;
- XamlObject parentXamlObject = currentXamlObject;
- if (element.HasAttribute("xml:space")) {
- currentXmlSpace = (XmlSpace)Enum.Parse(typeof(XmlSpace), element.GetAttribute("xml:space"), true);
- }
-
- XamlPropertyInfo defaultProperty = GetDefaultProperty(elementType);
-
- XamlTextValue initializeFromTextValueInsteadOfConstructor = null;
-
- if (defaultProperty == null) {
- int numberOfTextNodes = 0;
- bool onlyTextNodes = true;
- foreach (XmlNode childNode in element.ChildNodes) {
- if (childNode.NodeType == XmlNodeType.Text) {
- numberOfTextNodes++;
- } else if (childNode.NodeType == XmlNodeType.Element) {
- onlyTextNodes = false;
- }
- }
- if (onlyTextNodes && numberOfTextNodes == 1) {
- foreach (XmlNode childNode in element.ChildNodes) {
- if (childNode.NodeType == XmlNodeType.Text) {
- initializeFromTextValueInsteadOfConstructor = (XamlTextValue)ParseValue(childNode);
- }
- }
- }
- }
-
- object instance;
- if (initializeFromTextValueInsteadOfConstructor != null) {
- instance = TypeDescriptor.GetConverter(elementType).ConvertFromString(
- document.GetTypeDescriptorContext(null),
- CultureInfo.InvariantCulture,
- initializeFromTextValueInsteadOfConstructor.Text);
- } else {
- instance = settings.CreateInstanceCallback(elementType, emptyObjectArray);
- }
-
- XamlObject obj = new XamlObject(document, element, elementType, instance);
- currentXamlObject = obj;
- obj.ParentObject = parentXamlObject;
-
- if (parentXamlObject == null && obj.Instance is DependencyObject) {
- NameScope.SetNameScope((DependencyObject)obj.Instance, new NameScope());
- }
-
- ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize;
- if (iSupportInitializeInstance != null) {
- iSupportInitializeInstance.BeginInit();
- }
-
- foreach (XmlAttribute attribute in element.Attributes) {
- if (attribute.NamespaceURI == XamlConstants.XmlnsNamespace)
- continue;
- if (attribute.Name == "xml:space") {
- continue;
- }
- if (GetAttributeNamespace(attribute) == XamlConstants.XamlNamespace)
- continue;
- ParseObjectAttribute(obj, attribute);
- }
-
- if (!(obj.Instance is Style)) {
- ParseObjectContent(obj, element, defaultProperty, initializeFromTextValueInsteadOfConstructor);
- }
-
- if (iSupportInitializeInstance != null) {
- iSupportInitializeInstance.EndInit();
- }
-
- currentXmlSpace = oldXmlSpace;
- currentXamlObject = parentXamlObject;
-
- return obj;
- }
-
- void ParseObjectContent(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, XamlTextValue initializeFromTextValueInsteadOfConstructor)
- {
- XamlPropertyValue setDefaultValueTo = null;
- object defaultPropertyValue = null;
- XamlProperty defaultCollectionProperty = null;
-
- if (defaultProperty != null && defaultProperty.IsCollection && !element.IsEmpty) {
- defaultPropertyValue = defaultProperty.GetValue(obj.Instance);
- obj.AddProperty(defaultCollectionProperty = new XamlProperty(obj, defaultProperty));
- }
-
- foreach (XmlNode childNode in GetNormalizedChildNodes(element)) {
-
- // I don't know why the official XamlReader runs the property getter
- // here, but let's try to imitate it as good as possible
- if (defaultProperty != null && !defaultProperty.IsCollection) {
- for (; combinedNormalizedChildNodes > 0; combinedNormalizedChildNodes--) {
- defaultProperty.GetValue(obj.Instance);
- }
- }
-
- XmlElement childElement = childNode as XmlElement;
- if (childElement != null) {
- if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
- continue;
-
- if (ObjectChildElementIsPropertyElement(childElement)) {
- // I don't know why the official XamlReader runs the property getter
- // here, but let's try to imitate it as good as possible
- if (defaultProperty != null && !defaultProperty.IsCollection) {
- defaultProperty.GetValue(obj.Instance);
- }
- ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty, defaultPropertyValue);
- continue;
- }
- }
- if (initializeFromTextValueInsteadOfConstructor != null)
- continue;
- XamlPropertyValue childValue = ParseValue(childNode);
- if (childValue != null) {
- if (defaultProperty != null && defaultProperty.IsCollection) {
- defaultCollectionProperty.ParserAddCollectionElement(null, childValue);
- CollectionSupport.AddToCollection(defaultProperty.ReturnType, defaultPropertyValue, childValue);
- } else {
- if (setDefaultValueTo != null)
- throw new XamlLoadException("default property may have only one value assigned");
- setDefaultValueTo = childValue;
- }
- }
- }
-
- if (defaultProperty != null && !defaultProperty.IsCollection && !element.IsEmpty) {
- // Runs even when defaultValueSet==false!
- // Again, no idea why the official XamlReader does this.
- defaultProperty.GetValue(obj.Instance);
- }
- if (setDefaultValueTo != null) {
- if (defaultProperty == null) {
- throw new XamlLoadException("This element does not have a default value, cannot assign to it");
- }
- obj.AddProperty(new XamlProperty(obj, defaultProperty, setDefaultValueTo));
- }
- }
-
- int combinedNormalizedChildNodes;
-
- IEnumerable GetNormalizedChildNodes(XmlElement element)
- {
- XmlNode node = element.FirstChild;
- while (node != null) {
- XmlText text = node as XmlText;
- XmlCDataSection cData = node as XmlCDataSection;
- if (node.NodeType == XmlNodeType.SignificantWhitespace) {
- text = element.OwnerDocument.CreateTextNode(node.Value);
- element.ReplaceChild(text, node);
- node = text;
- }
- if (text != null || cData != null) {
- node = node.NextSibling;
- while (node != null
- && (node.NodeType == XmlNodeType.Text
- || node.NodeType == XmlNodeType.CDATA
- || node.NodeType == XmlNodeType.SignificantWhitespace)) {
- combinedNormalizedChildNodes++;
-
- if (text != null) text.Value += node.Value;
- else cData.Value += node.Value;
- XmlNode nodeToDelete = node;
- node = node.NextSibling;
- element.RemoveChild(nodeToDelete);
- }
- if (text != null) yield return text;
- else yield return cData;
- } else {
- yield return node;
- node = node.NextSibling;
- }
- }
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
- Justification="We need to continue parsing, and the error is reported to the user.")]
- XamlPropertyValue ParseValue(XmlNode childNode)
- {
- try {
- return ParseValueCore(childNode);
- } catch (Exception x) {
- ReportException(x, childNode);
- }
- return null;
- }
-
- XamlPropertyValue ParseValueCore(XmlNode childNode)
- {
- XmlText childText = childNode as XmlText;
- if (childText != null) {
- return new XamlTextValue(document, childText, currentXmlSpace);
- }
- XmlCDataSection cData = childNode as XmlCDataSection;
- if (cData != null) {
- return new XamlTextValue(document, cData, currentXmlSpace);
- }
- XmlElement element = childNode as XmlElement;
- if (element != null) {
- return ParseObject(element);
- }
- return null;
- }
-
- static XamlPropertyInfo GetDefaultProperty(Type elementType)
- {
- foreach (ContentPropertyAttribute cpa in elementType.GetCustomAttributes(typeof(ContentPropertyAttribute), true)) {
- return FindProperty(null, elementType, cpa.Name);
- }
- return null;
- }
-
- internal static XamlPropertyInfo FindProperty(object elementInstance, Type propertyType, string propertyName)
- {
- PropertyDescriptorCollection properties;
- if (elementInstance != null) {
- properties = TypeDescriptor.GetProperties(elementInstance);
- } else {
- properties = TypeDescriptor.GetProperties(propertyType);
- }
- PropertyDescriptor propertyInfo = properties[propertyName];
- if (propertyInfo != null) {
- return new XamlNormalPropertyInfo(propertyInfo);
- } else {
- XamlPropertyInfo pi = TryFindAttachedProperty(propertyType, propertyName);
- if (pi != null) {
- return pi;
- }
- }
- EventDescriptorCollection events;
- if (elementInstance != null) {
- events = TypeDescriptor.GetEvents(elementInstance);
- } else {
- events = TypeDescriptor.GetEvents(propertyType);
- }
- EventDescriptor eventInfo = events[propertyName];
- if (eventInfo != null) {
- return new XamlEventPropertyInfo(eventInfo);
- }
- throw new XamlLoadException("property " + propertyName + " not found");
- }
-
- internal static XamlPropertyInfo TryFindAttachedProperty(Type elementType, string propertyName)
- {
- MethodInfo getMethod = elementType.GetMethod("Get" + propertyName, BindingFlags.Public | BindingFlags.Static);
- MethodInfo setMethod = elementType.GetMethod("Set" + propertyName, BindingFlags.Public | BindingFlags.Static);
- if (getMethod != null && setMethod != null) {
- FieldInfo field = elementType.GetField(propertyName + "Property", BindingFlags.Public | BindingFlags.Static);
- if (field != null && field.FieldType == typeof(DependencyProperty)) {
- return new XamlDependencyPropertyInfo((DependencyProperty)field.GetValue(null), true);
- }
- }
- return null;
- }
-
- static XamlPropertyInfo FindAttachedProperty(Type elementType, string propertyName)
- {
- XamlPropertyInfo pi = TryFindAttachedProperty(elementType, propertyName);
- if (pi != null) {
- return pi;
- } else {
- throw new XamlLoadException("attached property " + elementType.Name + "." + propertyName + " not found");
- }
- }
-
- static XamlPropertyInfo GetPropertyInfo(object elementInstance, Type elementType, XmlAttribute attribute, XamlTypeFinder typeFinder)
- {
- if (attribute.LocalName.Contains(".")) {
- return GetPropertyInfo(typeFinder, elementInstance, elementType, GetAttributeNamespace(attribute), attribute.LocalName);
- } else {
- return FindProperty(elementInstance, elementType, attribute.LocalName);
- }
- }
-
- internal static XamlPropertyInfo GetPropertyInfo(XamlTypeFinder typeFinder, object elementInstance, Type elementType, string xmlNamespace, string localName)
- {
- string typeName, propertyName;
- SplitQualifiedIdentifier(localName, out typeName, out propertyName);
- Type propertyType = FindType(typeFinder, xmlNamespace, typeName);
- if (elementType == propertyType || propertyType.IsAssignableFrom(elementType)) {
- return FindProperty(elementInstance, propertyType, propertyName);
- } else {
- // This is an attached property
- return FindAttachedProperty(propertyType, propertyName);
- }
- }
-
- static void SplitQualifiedIdentifier(string qualifiedName, out string typeName, out string propertyName)
- {
- int pos = qualifiedName.IndexOf('.');
- Debug.Assert(pos > 0);
- typeName = qualifiedName.Substring(0, pos);
- propertyName = qualifiedName.Substring(pos + 1);
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
- Justification="We need to continue parsing, and the error is reported to the user.")]
- void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute)
- {
- try {
- ParseObjectAttribute(obj, attribute, true);
- } catch (Exception x) {
- ReportException(x, attribute);
- }
- }
-
- internal static void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute, bool real)
- {
- XamlPropertyInfo propertyInfo = GetPropertyInfo(obj.Instance, obj.ElementType, attribute, obj.OwnerDocument.TypeFinder);
- XamlPropertyValue value = null;
-
- var valueText = attribute.Value;
- if (valueText.StartsWith("{", StringComparison.Ordinal) && !valueText.StartsWith("{}", StringComparison.Ordinal)) {
- var xamlObject = MarkupExtensionParser.Parse(valueText, obj, real ? attribute : null);
- value = xamlObject;
- } else {
- if (real)
- value = new XamlTextValue(obj.OwnerDocument, attribute);
- else
- value = new XamlTextValue(obj.OwnerDocument, valueText);
- }
-
- var property = new XamlProperty(obj, propertyInfo, value);
- obj.AddProperty(property);
- }
-
- static bool ObjectChildElementIsPropertyElement(XmlElement element)
- {
- return element.LocalName.Contains(".");
- }
-
- void ParseObjectChildElementAsPropertyElement(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, object defaultPropertyValue)
- {
- Debug.Assert(element.LocalName.Contains("."));
- // this is a element property syntax
-
- XamlPropertyInfo propertyInfo = GetPropertyInfo(settings.TypeFinder, obj.Instance, obj.ElementType, element.NamespaceURI, element.LocalName);
- bool valueWasSet = false;
-
- object collectionInstance = null;
- XamlProperty collectionProperty = null;
- if (propertyInfo.IsCollection) {
- if (defaultProperty != null && defaultProperty.FullyQualifiedName == propertyInfo.FullyQualifiedName) {
- collectionInstance = defaultPropertyValue;
- foreach (XamlProperty existing in obj.Properties) {
- if (existing.propertyInfo == defaultProperty) {
- collectionProperty = existing;
- break;
- }
- }
- } else {
- collectionInstance = propertyInfo.GetValue(obj.Instance);
- }
- if (collectionProperty == null) {
- obj.AddProperty(collectionProperty = new XamlProperty(obj, propertyInfo));
- }
- collectionProperty.ParserSetPropertyElement(element);
- }
-
- XmlSpace oldXmlSpace = currentXmlSpace;
- if (element.HasAttribute("xml:space")) {
- currentXmlSpace = (XmlSpace)Enum.Parse(typeof(XmlSpace), element.GetAttribute("xml:space"), true);
- }
-
- foreach (XmlNode childNode in element.ChildNodes) {
- XamlPropertyValue childValue = ParseValue(childNode);
- if (childValue != null) {
- if (propertyInfo.IsCollection) {
- CollectionSupport.AddToCollection(propertyInfo.ReturnType, collectionInstance, childValue);
- collectionProperty.ParserAddCollectionElement(element, childValue);
- } else {
- if (valueWasSet)
- throw new XamlLoadException("non-collection property may have only one child element");
- valueWasSet = true;
- XamlProperty xp = new XamlProperty(obj, propertyInfo, childValue);
- xp.ParserSetPropertyElement(element);
- obj.AddProperty(xp);
- }
- }
- }
-
- currentXmlSpace = oldXmlSpace;
- }
-
- internal static object CreateObjectFromAttributeText(string valueText, XamlPropertyInfo targetProperty, XamlObject scope)
- {
- return targetProperty.TypeConverter.ConvertFromString(
- scope.OwnerDocument.GetTypeDescriptorContext(scope),
- CultureInfo.InvariantCulture, valueText);
- }
-
- internal static object CreateObjectFromAttributeText(string valueText, Type targetType, XamlObject scope)
- {
- var converter =
- XamlNormalPropertyInfo.GetCustomTypeConverter(targetType) ??
- TypeDescriptor.GetConverter(targetType);
-
- return converter.ConvertFromInvariantString(
- scope.OwnerDocument.GetTypeDescriptorContext(scope), valueText);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParserSettings.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParserSettings.cs
deleted file mode 100644
index 1099de520c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParserSettings.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Delegate used for XamlParserSettings.CreateInstanceCallback.
- ///
- public delegate object CreateInstanceCallback(Type type, object[] arguments);
-
- ///
- /// Settings used for the XamlParser.
- ///
- public sealed class XamlParserSettings
- {
- CreateInstanceCallback _createInstanceCallback = Activator.CreateInstance;
- XamlTypeFinder _typeFinder = XamlTypeFinder.CreateWpfTypeFinder();
- IServiceProvider _serviceProvider = DummyServiceProvider.Instance;
-
- ///
- /// Gets/Sets the method used to create object instances.
- ///
- public CreateInstanceCallback CreateInstanceCallback {
- get { return _createInstanceCallback; }
- set {
- if (value == null)
- throw new ArgumentNullException("value");
- _createInstanceCallback = value;
- }
- }
-
- ///
- /// Gets/Sets the type finder to do type lookup.
- ///
- public XamlTypeFinder TypeFinder {
- get { return _typeFinder; }
- set {
- if (value == null)
- throw new ArgumentNullException("value");
- _typeFinder = value;
- }
- }
-
- ///
- /// Gets/Sets the service provider to use to initialize markup extensions.
- ///
- public IServiceProvider ServiceProvider {
- get { return _serviceProvider; }
- set {
- if (value == null)
- throw new ArgumentNullException("value");
- _serviceProvider = value;
- }
- }
-
- sealed class DummyServiceProvider : IServiceProvider
- {
- public static readonly DummyServiceProvider Instance = new DummyServiceProvider();
-
- public object GetService(Type serviceType)
- {
- return null;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
deleted file mode 100644
index 4f8fb853a2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
+++ /dev/null
@@ -1,455 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Text;
-using System.Xml;
-using System.Windows;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Describes a property on a .
- ///
- [DebuggerDisplay("XamlProperty: {PropertyName}")]
- public sealed class XamlProperty
- {
- XamlObject parentObject;
- internal readonly XamlPropertyInfo propertyInfo;
- XamlPropertyValue propertyValue;
-
- CollectionElementsCollection collectionElements;
- bool isCollection;
-
- static readonly IList emptyCollectionElementsArray = new XamlPropertyValue[0];
-
- // for use by parser only
- internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo, XamlPropertyValue propertyValue)
- : this(parentObject, propertyInfo)
- {
- PossiblyNameChanged(null, propertyValue);
-
- this.propertyValue = propertyValue;
- if (propertyValue != null) {
- propertyValue.ParentProperty = this;
- }
-
- UpdateValueOnInstance();
- }
-
- internal XamlProperty(XamlObject parentObject, XamlPropertyInfo propertyInfo)
- {
- this.parentObject = parentObject;
- this.propertyInfo = propertyInfo;
-
- if (propertyInfo.IsCollection) {
- isCollection = true;
- collectionElements = new CollectionElementsCollection(this);
- }
- }
-
- ///
- /// Gets the parent object for which this property was declared.
- ///
- public XamlObject ParentObject {
- get { return parentObject; }
- }
-
- ///
- /// Gets the property name.
- ///
- public string PropertyName {
- get { return propertyInfo.Name; }
- }
-
- ///
- /// Gets the type the property is declared on.
- ///
- public Type PropertyTargetType {
- get { return propertyInfo.TargetType; }
- }
-
- ///
- /// Gets if this property is an attached property.
- ///
- public bool IsAttached {
- get { return propertyInfo.IsAttached; }
- }
-
- ///
- /// Gets if this property is an event.
- ///
- public bool IsEvent {
- get { return propertyInfo.IsEvent; }
- }
-
- ///
- /// Gets the return type of the property.
- ///
- public Type ReturnType {
- get { return propertyInfo.ReturnType; }
- }
-
- ///
- /// Gets the type converter used to convert property values to/from string.
- ///
- public TypeConverter TypeConverter {
- get { return propertyInfo.TypeConverter; }
- }
-
- ///
- /// Gets the category of the property.
- ///
- public string Category {
- get { return propertyInfo.Category; }
- }
-
- ///
- /// Gets the value of the property. Can be null if the property is a collection property.
- ///
- public XamlPropertyValue PropertyValue {
- get { return propertyValue; }
- set { SetPropertyValue(value); }
- }
-
- ///
- /// Gets if the property is a collection property.
- ///
- public bool IsCollection {
- get { return isCollection; }
- }
-
- ///
- /// Gets the collection elements of the property. Is empty if the property is not a collection.
- ///
- public IList CollectionElements {
- get { return collectionElements ?? emptyCollectionElementsArray; }
- }
-
- ///
- /// Gets if the property is set.
- ///
- public bool IsSet {
- get { return propertyValue != null ||
- _propertyElement != null; // collection
- }
- }
-
- ///
- /// Occurs when the value of the IsSet property has changed.
- ///
- public event EventHandler IsSetChanged;
-
- ///
- /// Occurs when the value of the property has changed.
- ///
- public event EventHandler ValueChanged;
-
- ///
- /// Occurs when MarkupExtension evaluated PropertyValue dosn't changed but ValueOnInstance does.
- ///
- public event EventHandler ValueOnInstanceChanged;
-
- void SetPropertyValue(XamlPropertyValue value)
- {
- // Binding...
- //if (IsCollection) {
- // throw new InvalidOperationException("Cannot set the value of collection properties.");
- //}
-
- bool wasSet = this.IsSet;
-
- PossiblyNameChanged(propertyValue, value);
-
- //reset expression
- var xamlObject = propertyValue as XamlObject;
- if (xamlObject != null && xamlObject.IsMarkupExtension)
- propertyInfo.ResetValue(parentObject.Instance);
-
- ResetInternal();
-
- propertyValue = value;
- propertyValue.ParentProperty = this;
- propertyValue.AddNodeTo(this);
- UpdateValueOnInstance();
-
- ParentObject.OnPropertyChanged(this);
-
- if (!wasSet) {
- if (IsSetChanged != null) {
- IsSetChanged(this, EventArgs.Empty);
- }
- }
-
- if (ValueChanged != null) {
- ValueChanged(this, EventArgs.Empty);
- }
- }
-
- internal void UpdateValueOnInstance()
- {
- if (PropertyValue != null) {
- try {
- ValueOnInstance = PropertyValue.GetValueFor(propertyInfo);
- }
- catch {
- Debug.WriteLine("UpdateValueOnInstance() failed");
- }
- }
- }
-
- ///
- /// Resets the properties value.
- ///
- public void Reset()
- {
- if (IsSet) {
-
- propertyInfo.ResetValue(parentObject.Instance);
- ResetInternal();
-
- ParentObject.OnPropertyChanged(this);
-
- if (IsSetChanged != null) {
- IsSetChanged(this, EventArgs.Empty);
- }
- if (ValueChanged != null) {
- ValueChanged(this, EventArgs.Empty);
- }
- }
- }
-
- void ResetInternal()
- {
- if (propertyValue != null) {
- propertyValue.RemoveNodeFromParent();
- propertyValue.ParentProperty = null;
- propertyValue = null;
- }
- if (_propertyElement != null) {
- _propertyElement.ParentNode.RemoveChild(_propertyElement);
- _propertyElement = null;
- }
- }
-
- XmlElement _propertyElement;
-
- internal void ParserSetPropertyElement(XmlElement propertyElement)
- {
- XmlElement oldPropertyElement = _propertyElement;
- if (oldPropertyElement == propertyElement) return;
-
- _propertyElement = propertyElement;
-
- if (oldPropertyElement != null && IsCollection) {
- Debug.WriteLine("Property element for " + this.PropertyName + " already exists, merging..");
- foreach (XamlPropertyValue val in this.collectionElements) {
- val.RemoveNodeFromParent();
- val.AddNodeTo(this);
- }
- oldPropertyElement.ParentNode.RemoveChild(oldPropertyElement);
- }
- }
-
- internal void AddChildNodeToProperty(XmlNode newChildNode)
- {
- if (this.IsCollection) {
- // this is the default collection
- InsertNodeInCollection(newChildNode, collectionElements.Count);
- return;
- }
- if (_propertyElement == null) {
- _propertyElement = parentObject.OwnerDocument.XmlDocument.CreateElement(
- this.PropertyTargetType.Name + "." + this.PropertyName,
- parentObject.OwnerDocument.GetNamespaceFor(this.PropertyTargetType)
- );
- parentObject.XmlElement.InsertBefore(_propertyElement, parentObject.XmlElement.FirstChild);
- }
- _propertyElement.AppendChild(newChildNode);
- }
-
- internal void InsertNodeInCollection(XmlNode newChildNode, int index)
- {
- Debug.Assert(index >= 0 && index <= collectionElements.Count);
- XmlElement collection = _propertyElement;
- if (collection == null) {
- if (collectionElements.Count == 0) {
- // we have to create the collection element
- _propertyElement = parentObject.OwnerDocument.XmlDocument.CreateElement(
- this.PropertyTargetType.Name + "." + this.PropertyName,
- parentObject.OwnerDocument.GetNamespaceFor(this.PropertyTargetType)
- );
- parentObject.XmlElement.AppendChild(_propertyElement);
- collection = _propertyElement;
- } else {
- // this is the default collection
- collection = parentObject.XmlElement;
- }
- }
- if (collectionElements.Count == 0) {
- // collection is empty -> we may insert anywhere
- collection.AppendChild(newChildNode);
- } else if (index == collectionElements.Count) {
- // insert after last element in collection
- collection.InsertAfter(newChildNode, collectionElements[collectionElements.Count - 1].GetNodeForCollection());
- } else {
- // insert before specified index
- collection.InsertBefore(newChildNode, collectionElements[index].GetNodeForCollection());
- }
- }
-
- internal XmlAttribute SetAttribute(string value)
- {
- string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
- string name;
- if (IsAttached)
- name = PropertyTargetType.Name + "." + PropertyName;
- else
- name = PropertyName;
-
- var element = ParentObject.XmlElement;
- if (string.IsNullOrEmpty(element.GetPrefixOfNamespace(ns))) {
- element.SetAttribute(name, value);
- return element.GetAttributeNode(name);
- } else {
- element.SetAttribute(name, ns, value);
- return element.GetAttributeNode(name, ns);
- }
- }
-
- internal string GetNameForMarkupExtension()
- {
- string name;
- if (IsAttached)
- name = PropertyTargetType.Name + "." + PropertyName;
- else
- name = PropertyName;
-
- var element = ParentObject.XmlElement;
- string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
- var prefix = element.GetPrefixOfNamespace(ns);
- if (string.IsNullOrEmpty(prefix))
- return name;
- else
- return prefix + ":" + name;
- }
-
- ///
- /// used internally by the XamlParser.
- /// Add a collection element that already is part of the XML DOM.
- ///
- internal void ParserAddCollectionElement(XmlElement collectionPropertyElement, XamlPropertyValue val)
- {
- if (collectionPropertyElement != null && _propertyElement == null) {
- ParserSetPropertyElement(collectionPropertyElement);
- }
- collectionElements.AddInternal(val);
- val.ParentProperty = this;
- if (collectionPropertyElement != _propertyElement) {
- val.RemoveNodeFromParent();
- val.AddNodeTo(this);
- }
- }
-
- ///
- /// Gets/Sets the value of the property on the instance without updating the XAML document.
- ///
- public object ValueOnInstance {
- get {
- if (IsEvent) {
- if (propertyValue != null)
- return propertyValue.GetValueFor(null);
- else
- return null;
- } else {
- return propertyInfo.GetValue(parentObject.Instance);
- }
- }
- set {
- propertyInfo.SetValue(parentObject.Instance, value);
- if (ValueOnInstanceChanged != null)
- ValueOnInstanceChanged(this, EventArgs.Empty);
- }
- }
-
- ///
- /// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
- ///
- public bool IsAdvanced {
- get { return propertyInfo.IsAdvanced; }
- }
-
- ///
- /// Gets the dependency property.
- ///
- public DependencyProperty DependencyProperty {
- get {
- return propertyInfo.DependencyProperty;
- }
- }
-
- void PossiblyNameChanged(XamlPropertyValue oldValue, XamlPropertyValue newValue)
- {
- if (PropertyName == "Name" && ReturnType == typeof(string)) {
-
- string oldName = null;
- string newName = null;
-
- var oldTextValue = oldValue as XamlTextValue;
- if (oldTextValue != null) oldName = oldTextValue.Text;
-
- var newTextValue = newValue as XamlTextValue;
- if (newTextValue != null) newName = newTextValue.Text;
-
- var obj = ParentObject;
- while (obj != null) {
- var nameScope = obj.Instance as INameScope;
- if (nameScope == null) {
- if (obj.Instance is DependencyObject)
- nameScope = NameScope.GetNameScope((DependencyObject)obj.Instance);
- }
- if (nameScope != null) {
- if (oldName != null) {
- try {
- nameScope.UnregisterName(oldName);
- } catch (Exception x) {
- Debug.WriteLine(x.Message);
- }
- }
- if (newName != null) {
- nameScope.RegisterName(newName, ParentObject.Instance);
- }
- break;
- }
- obj = obj.ParentObject;
- }
- }
- }
-
- /*public bool IsAttributeSyntax {
- get {
- return attribute != null;
- }
- }
-
- public bool IsElementSyntax {
- get {
- return element != null;
- }
- }
-
- public bool IsImplicitDefaultProperty {
- get {
- return attribute == null && element == null;
- }
- }*/
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs
deleted file mode 100644
index 61e5743850..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs
+++ /dev/null
@@ -1,339 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Collections;
-using System.ComponentModel;
-using System.Globalization;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Represents a property assignable in XAML.
- /// This can be a normal .NET property or an attached property.
- ///
- internal abstract class XamlPropertyInfo
- {
- public abstract object GetValue(object instance);
- public abstract void SetValue(object instance, object value);
- public abstract void ResetValue(object instance);
- public abstract TypeConverter TypeConverter { get; }
- public abstract Type TargetType { get; }
- public abstract Type ReturnType { get; }
- public abstract string Name { get; }
- public abstract string FullyQualifiedName { get; }
- public abstract bool IsAttached { get; }
- public abstract bool IsCollection { get; }
- public virtual bool IsEvent { get { return false; } }
- public virtual bool IsAdvanced { get { return false; } }
- public virtual DependencyProperty DependencyProperty { get { return null; } }
- public abstract string Category { get; }
- }
-
- #region XamlDependencyPropertyInfo
- internal class XamlDependencyPropertyInfo : XamlPropertyInfo
- {
- readonly DependencyProperty property;
- readonly bool isAttached;
-
- public override DependencyProperty DependencyProperty {
- get { return property; }
- }
-
- public XamlDependencyPropertyInfo(DependencyProperty property, bool isAttached)
- {
- Debug.Assert(property != null);
- this.property = property;
- this.isAttached = isAttached;
- }
-
- public override TypeConverter TypeConverter {
- get {
- return TypeDescriptor.GetConverter(this.ReturnType);
- }
- }
-
- public override string FullyQualifiedName {
- get {
- return this.TargetType.FullName + "." + this.Name;
- }
- }
-
- public override Type TargetType {
- get { return property.OwnerType; }
- }
-
- public override Type ReturnType {
- get { return property.PropertyType; }
- }
-
- public override string Name {
- get { return property.Name; }
- }
-
- public override string Category {
- get { return "Misc"; }
- }
-
- public override bool IsAttached {
- get { return isAttached; }
- }
-
- public override bool IsCollection {
- get { return false; }
- }
-
- public override object GetValue(object instance)
- {
- return ((DependencyObject)instance).GetValue(property);
- }
-
- public override void SetValue(object instance, object value)
- {
- ((DependencyObject)instance).SetValue(property, value);
- }
-
- public override void ResetValue(object instance)
- {
- ((DependencyObject)instance).ClearValue(property);
- }
- }
- #endregion
-
- #region XamlNormalPropertyInfo
- internal sealed class XamlNormalPropertyInfo : XamlPropertyInfo
- {
- PropertyDescriptor _propertyDescriptor;
- DependencyProperty dependencyProperty;
-
- public XamlNormalPropertyInfo(PropertyDescriptor propertyDescriptor)
- {
- this._propertyDescriptor = propertyDescriptor;
- var dpd = DependencyPropertyDescriptor.FromProperty(propertyDescriptor);
- if (dpd != null) {
- dependencyProperty = dpd.DependencyProperty;
- }
- }
-
- public override DependencyProperty DependencyProperty {
- get {
- return dependencyProperty;
- }
- }
-
- public override object GetValue(object instance)
- {
- return _propertyDescriptor.GetValue(instance);
- }
-
- public override void SetValue(object instance, object value)
- {
- _propertyDescriptor.SetValue(instance, value);
- }
-
- public override void ResetValue(object instance)
- {
- _propertyDescriptor.ResetValue(instance);
- }
-
- public override Type ReturnType {
- get { return _propertyDescriptor.PropertyType; }
- }
-
- public override Type TargetType {
- get { return _propertyDescriptor.ComponentType; }
- }
-
- public override string Category {
- get { return _propertyDescriptor.Category; }
- }
-
- public override TypeConverter TypeConverter {
- get {
- return GetCustomTypeConverter(_propertyDescriptor.PropertyType) ?? _propertyDescriptor.Converter;
- }
- }
-
- public override string FullyQualifiedName {
- get {
- return _propertyDescriptor.ComponentType.FullName + "." + _propertyDescriptor.Name;
- }
- }
-
- public override string Name {
- get { return _propertyDescriptor.Name; }
- }
-
- public override bool IsAttached {
- get { return false; }
- }
-
- public override bool IsCollection {
- get {
- return CollectionSupport.IsCollectionType(_propertyDescriptor.PropertyType);
- }
- }
-
- public override bool IsAdvanced {
- get {
- var a = _propertyDescriptor.Attributes[typeof(EditorBrowsableAttribute)] as EditorBrowsableAttribute;
- if (a != null) {
- return a.State == EditorBrowsableState.Advanced;
- }
- return false;
- }
- }
-
- public static readonly TypeConverter StringTypeConverter = TypeDescriptor.GetConverter(typeof(string));
-
- public static TypeConverter GetCustomTypeConverter(Type propertyType)
- {
- if (propertyType == typeof(object))
- return StringTypeConverter;
- else if (propertyType == typeof(Type))
- return TypeTypeConverter.Instance;
- else if (propertyType == typeof(DependencyProperty))
- return DependencyPropertyConverter.Instance;
- else
- return null;
- }
-
- sealed class TypeTypeConverter : TypeConverter
- {
- public readonly static TypeTypeConverter Instance = new TypeTypeConverter();
-
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
- else
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
- {
- if (value == null)
- return null;
- if (value is string) {
- IXamlTypeResolver xamlTypeResolver = (IXamlTypeResolver)context.GetService(typeof(IXamlTypeResolver));
- if (xamlTypeResolver == null)
- throw new XamlLoadException("IXamlTypeResolver not found in type descriptor context.");
- return xamlTypeResolver.Resolve((string)value);
- } else {
- return base.ConvertFrom(context, culture, value);
- }
- }
- }
-
- sealed class DependencyPropertyConverter : TypeConverter
- {
- public readonly static DependencyPropertyConverter Instance = new DependencyPropertyConverter();
-
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
- else
- return base.CanConvertFrom(context, sourceType);
- }
-
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
- {
- if (value == null)
- return null;
- if (value is string) {
- XamlTypeResolverProvider xamlTypeResolver = (XamlTypeResolverProvider)context.GetService(typeof(XamlTypeResolverProvider));
- if (xamlTypeResolver == null)
- throw new XamlLoadException("XamlTypeResolverProvider not found in type descriptor context.");
- XamlPropertyInfo prop = xamlTypeResolver.ResolveProperty((string)value);
- if (prop == null)
- throw new XamlLoadException("Could not find property " + value + ".");
- XamlDependencyPropertyInfo depProp = prop as XamlDependencyPropertyInfo;
- if (depProp != null)
- return depProp.DependencyProperty;
- FieldInfo field = prop.TargetType.GetField(prop.Name + "Property", BindingFlags.Public | BindingFlags.Static);
- if (field != null && field.FieldType == typeof(DependencyProperty)) {
- return (DependencyProperty)field.GetValue(null);
- }
- throw new XamlLoadException("Property " + value + " is not a dependency property.");
- } else {
- return base.ConvertFrom(context, culture, value);
- }
- }
- }
- }
- #endregion
-
- #region XamlEventPropertyInfo
- sealed class XamlEventPropertyInfo : XamlPropertyInfo
- {
- readonly EventDescriptor _eventDescriptor;
-
- public XamlEventPropertyInfo(EventDescriptor eventDescriptor)
- {
- this._eventDescriptor = eventDescriptor;
- }
-
- public override object GetValue(object instance)
- {
- throw new NotSupportedException();
- }
-
- public override void SetValue(object instance, object value)
- {
-
- }
-
- public override void ResetValue(object instance)
- {
-
- }
-
- public override Type ReturnType {
- get { return _eventDescriptor.EventType; }
- }
-
- public override Type TargetType {
- get { return _eventDescriptor.ComponentType; }
- }
-
- public override string Category {
- get { return _eventDescriptor.Category; }
- }
-
- public override TypeConverter TypeConverter {
- get { return XamlNormalPropertyInfo.StringTypeConverter; }
- }
-
- public override string FullyQualifiedName {
- get {
- return _eventDescriptor.ComponentType.FullName + "." + _eventDescriptor.Name;
- }
- }
-
- public override string Name {
- get { return _eventDescriptor.Name; }
- }
-
- public override bool IsEvent {
- get { return true; }
- }
-
- public override bool IsAttached {
- get { return false; }
- }
-
- public override bool IsCollection {
- get { return false; }
- }
- }
- #endregion
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs
deleted file mode 100644
index 1eda445aab..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Text;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Used for the value of a .
- /// Can be a or a .
- ///
- public abstract class XamlPropertyValue
- {
- ///
- /// used internally by the XamlParser.
- ///
- internal abstract object GetValueFor(XamlPropertyInfo targetProperty);
-
- XamlProperty _parentProperty;
-
- ///
- /// Gets the parent property that this value is assigned to.
- ///
- public XamlProperty ParentProperty {
- get { return _parentProperty; }
- internal set {
- if (_parentProperty != value) {
- _parentProperty = value;
- OnParentPropertyChanged();
- }
- }
- }
-
- ///
- /// Occurs when the value of the ParentProperty property changes.
- ///
- public event EventHandler ParentPropertyChanged;
-
- internal virtual void OnParentPropertyChanged()
- {
- if (ParentPropertyChanged != null) {
- ParentPropertyChanged(this, EventArgs.Empty);
- }
- }
-
- internal abstract void RemoveNodeFromParent();
-
- internal abstract void AddNodeTo(XamlProperty property);
-
- internal abstract XmlNode GetNodeForCollection();
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
deleted file mode 100644
index 9e9f632d6e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Text;
-using System.Windows.Markup;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// A textual value in a .xaml file.
- ///
- public sealed class XamlTextValue : XamlPropertyValue
- {
- XamlDocument document;
- XmlAttribute attribute;
- XmlText textNode;
- XmlSpace xmlSpace;
- string textValue;
- XmlCDataSection cDataSection;
-
- internal XamlTextValue(XamlDocument document, XmlAttribute attribute)
- {
- this.document = document;
- this.attribute = attribute;
- }
-
- internal XamlTextValue(XamlDocument document, string textValue)
- {
- this.document = document;
- this.textValue = textValue;
- }
-
- internal XamlTextValue(XamlDocument document, XmlText textNode, XmlSpace xmlSpace)
- {
- this.document = document;
- this.xmlSpace = xmlSpace;
- this.textNode = textNode;
- }
-
- internal XamlTextValue(XamlDocument document, XmlCDataSection cDataSection, XmlSpace xmlSpace)
- {
- this.document = document;
- this.xmlSpace = xmlSpace;
- this.cDataSection = cDataSection;
- }
-
- ///
- /// The text represented by the value.
- ///
- public string Text {
- get {
- if (attribute != null) {
- if (attribute.Value.StartsWith("{}", StringComparison.Ordinal))
- return attribute.Value.Substring(2);
- else
- return attribute.Value;
- } else if (textValue != null)
- return textValue;
- else if (cDataSection != null)
- return cDataSection.Value;
- else
- return NormalizeWhitespace(textNode.Value);
- }
- set {
- if (value == null)
- throw new ArgumentNullException("value");
-
- if (attribute != null)
- attribute.Value = value;
- else if (textValue != null)
- textValue = value;
- else if (cDataSection != null)
- cDataSection.Value = value;
- else
- textNode.Value = value;
- }
- }
-
- string NormalizeWhitespace(string text)
- {
- if (xmlSpace == XmlSpace.Preserve) {
- return text.Replace("\r", "");
- }
- StringBuilder b = new StringBuilder();
- bool wasWhitespace = true;
- foreach (char c in text) {
- if (char.IsWhiteSpace(c)) {
- if (!wasWhitespace) {
- b.Append(' ');
- }
- wasWhitespace = true;
- } else {
- wasWhitespace = false;
- b.Append(c);
- }
- }
- if (b.Length > 0 && wasWhitespace)
- b.Length -= 1;
- return b.ToString();
- }
-
- internal override object GetValueFor(XamlPropertyInfo targetProperty)
- {
- if (ParentProperty == null)
- throw new InvalidOperationException("Cannot call GetValueFor while ParentProperty is null");
-
- if (targetProperty == null)
- return this.Text;
-
- return XamlParser.CreateObjectFromAttributeText(Text, targetProperty, ParentProperty.ParentObject);
- }
-
- internal override void RemoveNodeFromParent()
- {
- if (attribute != null)
- attribute.OwnerElement.RemoveAttribute(attribute.Name);
- else if (textNode != null)
- textNode.ParentNode.RemoveChild(textNode);
- else if (cDataSection != null)
- cDataSection.ParentNode.RemoveChild(cDataSection);
- }
-
- internal override void AddNodeTo(XamlProperty property)
- {
- if (attribute != null) {
- property.ParentObject.XmlElement.Attributes.Append(attribute);
- } else if (textValue != null) {
- attribute = property.SetAttribute(textValue);
- textValue = null;
- } else if (cDataSection != null) {
- property.AddChildNodeToProperty(cDataSection);
- } else {
- property.AddChildNodeToProperty(textNode);
- }
- }
-
- internal override XmlNode GetNodeForCollection()
- {
- if (textNode != null)
- return textNode;
- else if (cDataSection != null)
- return cDataSection;
- else
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
deleted file mode 100644
index ad61fc8733..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
+++ /dev/null
@@ -1,241 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- ///
- /// Allows finding types in a set of assemblies.
- ///
- public class XamlTypeFinder : ICloneable
- {
- sealed class AssemblyNamespaceMapping : IEquatable
- {
- internal readonly Assembly Assembly;
- internal readonly string Namespace;
-
- internal AssemblyNamespaceMapping(Assembly assembly, string @namespace)
- {
- this.Assembly = assembly;
- this.Namespace = @namespace;
- }
-
- public override int GetHashCode()
- {
- return Assembly.GetHashCode() ^ Namespace.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- return Equals(obj as AssemblyNamespaceMapping);
- }
-
- public bool Equals(AssemblyNamespaceMapping other)
- {
- return other != null && other.Assembly == this.Assembly && other.Namespace == this.Namespace;
- }
- }
-
- sealed class XamlNamespace
- {
- internal readonly string XmlNamespace;
-
- internal XamlNamespace(string xmlNamespace)
- {
- this.XmlNamespace = xmlNamespace;
- }
-
- internal List ClrNamespaces = new List();
-
- internal XamlNamespace Clone()
- {
- XamlNamespace copy = new XamlNamespace(this.XmlNamespace);
- // AssemblyNamespaceMapping is immutable
- copy.ClrNamespaces.AddRange(this.ClrNamespaces);
- return copy;
- }
- }
-
- Dictionary namespaces = new Dictionary();
- Dictionary reverseDict = new Dictionary();
-
- ///
- /// Gets a type referenced in XAML.
- ///
- /// The XML namespace to use to look up the type.
- /// This can be a registered namespace or a 'clr-namespace' value.
- /// The local name of the type to find.
- ///
- /// The requested type, or null if it could not be found.
- ///
- public Type GetType(string xmlNamespace, string localName)
- {
- if (xmlNamespace == null)
- throw new ArgumentNullException("xmlNamespace");
- if (localName == null)
- throw new ArgumentNullException("localName");
- XamlNamespace ns;
- if (!namespaces.TryGetValue(xmlNamespace, out ns)) {
- if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.Ordinal)) {
- ns = namespaces[xmlNamespace] = ParseNamespace(xmlNamespace);
- } else {
- return null;
- }
- }
- foreach (AssemblyNamespaceMapping mapping in ns.ClrNamespaces) {
- Type type = mapping.Assembly.GetType(mapping.Namespace + "." + localName);
- if (type != null)
- return type;
- }
- return null;
- }
-
- ///
- /// Gets the XML namespace that can be used for the specified assembly/namespace combination.
- ///
- public string GetXmlNamespaceFor(Assembly assembly, string @namespace)
- {
- AssemblyNamespaceMapping mapping = new AssemblyNamespaceMapping(assembly, @namespace);
- string xmlNamespace;
- if (reverseDict.TryGetValue(mapping, out xmlNamespace)) {
- return xmlNamespace;
- } else {
- return "clr-namespace:" + mapping.Namespace + ";assembly=" + mapping.Assembly.GetName().Name;
- }
- }
-
- XamlNamespace ParseNamespace(string xmlNamespace)
- {
- string name = xmlNamespace;
- Debug.Assert(name.StartsWith("clr-namespace:", StringComparison.Ordinal));
- name = name.Substring("clr-namespace:".Length);
- string namespaceName, assembly;
- int pos = name.IndexOf(';');
- if (pos < 0) {
- namespaceName = name;
- assembly = "";
- } else {
- namespaceName = name.Substring(0, pos);
- name = name.Substring(pos + 1).Trim();
- if (!name.StartsWith("assembly=", StringComparison.Ordinal)) {
- throw new XamlLoadException("Expected: 'assembly='");
- }
- assembly = name.Substring("assembly=".Length);
- }
- XamlNamespace ns = new XamlNamespace(xmlNamespace);
- Assembly asm = LoadAssembly(assembly);
- if (asm != null) {
- AddMappingToNamespace(ns, new AssemblyNamespaceMapping(asm, namespaceName));
- }
- return ns;
- }
-
- void AddMappingToNamespace(XamlNamespace ns, AssemblyNamespaceMapping mapping)
- {
- ns.ClrNamespaces.Add(mapping);
-
- string xmlNamespace;
- if (reverseDict.TryGetValue(mapping, out xmlNamespace)) {
- if (xmlNamespace == XamlConstants.PresentationNamespace) {
- return;
- }
- }
- reverseDict[mapping] = ns.XmlNamespace;
- }
-
- ///
- /// Registers XAML namespaces defined in the for lookup.
- ///
- public void RegisterAssembly(Assembly assembly)
- {
- if (assembly == null)
- throw new ArgumentNullException("assembly");
- foreach (XmlnsDefinitionAttribute xmlnsDef in assembly.GetCustomAttributes(typeof(XmlnsDefinitionAttribute), true)) {
- XamlNamespace ns;
- if (!namespaces.TryGetValue(xmlnsDef.XmlNamespace, out ns)) {
- ns = namespaces[xmlnsDef.XmlNamespace] = new XamlNamespace(xmlnsDef.XmlNamespace);
- }
- if (string.IsNullOrEmpty(xmlnsDef.AssemblyName)) {
- AddMappingToNamespace(ns, new AssemblyNamespaceMapping(assembly, xmlnsDef.ClrNamespace));
- } else {
- Assembly asm = LoadAssembly(xmlnsDef.AssemblyName);
- if (asm != null) {
- AddMappingToNamespace(ns, new AssemblyNamespaceMapping(asm, xmlnsDef.ClrNamespace));
- }
- }
- }
- }
-
- ///
- /// Load the assembly with the specified name.
- /// You can override this method to implement custom assembly lookup.
- ///
- public virtual Assembly LoadAssembly(string name)
- {
- return Assembly.Load(name);
- }
-
- ///
- /// Clones this XamlTypeFinder.
- ///
- public virtual XamlTypeFinder Clone()
- {
- XamlTypeFinder copy = new XamlTypeFinder();
- copy.ImportFrom(this);
- return copy;
- }
-
- ///
- /// Import information from another XamlTypeFinder.
- /// Use this if you override Clone().
- ///
- protected void ImportFrom(XamlTypeFinder source)
- {
- if (source == null)
- throw new ArgumentNullException("source");
- foreach (KeyValuePair pair in source.namespaces) {
- this.namespaces.Add(pair.Key, pair.Value.Clone());
- }
- foreach (KeyValuePair pair in source.reverseDict) {
- this.reverseDict.Add(pair.Key, pair.Value);
- }
- }
-
- object ICloneable.Clone()
- {
- return this.Clone();
- }
-
- ///
- /// Creates a new XamlTypeFinder where the WPF namespaces are registered.
- ///
- public static XamlTypeFinder CreateWpfTypeFinder()
- {
- return WpfTypeFinder.Instance.Clone();
- }
-
- static class WpfTypeFinder
- {
- internal static readonly XamlTypeFinder Instance;
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",
- Justification = "We're using an explicit constructor to get it's lazy-loading semantics.")]
- static WpfTypeFinder()
- {
- Instance = new XamlTypeFinder();
- Instance.RegisterAssembly(typeof(MarkupExtension).Assembly); // WindowsBase
- Instance.RegisterAssembly(typeof(IAddChild).Assembly); // PresentationCore
- Instance.RegisterAssembly(typeof(XamlReader).Assembly); // PresentationFramework
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs
deleted file mode 100644
index 97a35f87d7..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Text;
-using System.Windows;
-using System.Windows.Markup;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign.XamlDom
-{
- sealed class XamlTypeResolverProvider : IXamlTypeResolver, IServiceProvider
- {
- XamlDocument document;
- XamlObject containingObject;
-
- public XamlTypeResolverProvider(XamlObject containingObject)
- {
- if (containingObject == null)
- throw new ArgumentNullException("containingObject");
- this.document = containingObject.OwnerDocument;
- this.containingObject = containingObject;
- }
-
- XmlElement ContainingElement{
- get { return containingObject.XmlElement; }
- }
-
- public Type Resolve(string typeName)
- {
- string typeNamespaceUri;
- string typeLocalName;
- if (typeName.Contains(":")) {
- typeNamespaceUri = ContainingElement.GetNamespaceOfPrefix(typeName.Substring(0, typeName.IndexOf(':')));
- typeLocalName = typeName.Substring(typeName.IndexOf(':') + 1);
- } else {
- typeNamespaceUri = ContainingElement.GetNamespaceOfPrefix("");
- typeLocalName = typeName;
- }
- if (string.IsNullOrEmpty(typeNamespaceUri))
- throw new XamlMarkupExtensionParseException("Unrecognized namespace prefix in type " + typeName);
- return document.TypeFinder.GetType(typeNamespaceUri, typeLocalName);
- }
-
- public object GetService(Type serviceType)
- {
- if (serviceType == typeof(IXamlTypeResolver) || serviceType == typeof(XamlTypeResolverProvider))
- return this;
- else
- return document.ServiceProvider.GetService(serviceType);
- }
-
- public XamlPropertyInfo ResolveProperty(string propertyName)
- {
- string propertyNamespace;
- if (propertyName.Contains(":")) {
- propertyNamespace = ContainingElement.GetNamespaceOfPrefix(propertyName.Substring(0, propertyName.IndexOf(':')));
- propertyName = propertyName.Substring(propertyName.IndexOf(':') + 1);
- } else {
- propertyNamespace = ContainingElement.GetNamespaceOfPrefix("");
- }
- Type elementType = null;
- XamlObject obj = containingObject;
- while (obj != null) {
- Style style = obj.Instance as Style;
- if (style != null && style.TargetType != null) {
- elementType = style.TargetType;
- break;
- }
- obj = obj.ParentObject;
- }
- if (propertyName.Contains(".")) {
- return XamlParser.GetPropertyInfo(document.TypeFinder, null, elementType, propertyNamespace, propertyName);
- } else if (elementType != null) {
- return XamlParser.FindProperty(null, elementType, propertyName);
- } else {
- return null;
- }
- }
-
- public object FindResource(object key)
- {
- XamlObject obj = containingObject;
- while (obj != null) {
- FrameworkElement el = obj.Instance as FrameworkElement;
- if (el != null) {
- object val = el.Resources[key];
- if (val != null)
- return val;
- }
- obj = obj.ParentObject;
- }
- return null;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs
deleted file mode 100644
index fa09234e90..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- ///
- /// Manages display of adorners on the design surface.
- ///
- public sealed class AdornerPanel : Panel
- {
- #region Attached Property Placement
- ///
- /// The dependency property used to store the placement of adorner visuals.
- ///
- public static readonly DependencyProperty PlacementProperty = DependencyProperty.RegisterAttached(
- "Placement", typeof(AdornerPlacement), typeof(AdornerPanel),
- new FrameworkPropertyMetadata(AdornerPlacement.FillContent, FrameworkPropertyMetadataOptions.AffectsParentMeasure)
- );
-
- ///
- /// Gets the placement of the specified adorner.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- public static AdornerPlacement GetPlacement(UIElement adorner)
- {
- if (adorner == null)
- throw new ArgumentNullException("adorner");
- return (AdornerPlacement)adorner.GetValue(PlacementProperty);
- }
-
- ///
- /// Sets the placement of the specified adorner.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
- public static void SetPlacement(UIElement adorner, AdornerPlacement placement)
- {
- if (adorner == null)
- throw new ArgumentNullException("adorner");
- if (placement == null)
- throw new ArgumentNullException("placement");
- adorner.SetValue(PlacementProperty, placement);
- }
- #endregion
-
- UIElement _adornedElement;
- DesignItem _adornedDesignItem;
- AdornerOrder _Order = AdornerOrder.Content;
-
-
- ///
- /// Gets the element adorned by this AdornerPanel.
- ///
- public UIElement AdornedElement {
- get { return _adornedElement; }
- }
-
- ///
- /// Gets the design item adorned by this AdornerPanel.
- ///
- public DesignItem AdornedDesignItem {
- get { return _adornedDesignItem; }
- }
-
- ///
- /// Sets the AdornedElement and AdornedDesignItem properties.
- /// This method can be called only once.
- ///
- public void SetAdornedElement(UIElement adornedElement, DesignItem adornedDesignItem)
- {
- if (adornedElement == null)
- throw new ArgumentNullException("adornedElement");
-
- if (_adornedElement == adornedElement && _adornedDesignItem == adornedDesignItem) {
- return; // ignore calls when nothing was changed
- }
-
- if (_adornedElement != null)
- throw new InvalidOperationException("AdornedElement is already set.");
-
- _adornedElement = adornedElement;
- _adornedDesignItem = adornedDesignItem;
- }
-
- ///
- /// Gets/Sets the order used to display the AdornerPanel relative to other AdornerPanels.
- /// Do not change this property after the panel was added to an AdornerLayer!
- ///
- public AdornerOrder Order {
- get { return _Order; }
- set { _Order = value; }
- }
-
- ///
- protected override Size MeasureOverride(Size availableSize)
- {
- if (this.AdornedElement != null) {
- foreach (DependencyObject v in this.VisualChildren) {
- UIElement e = v as UIElement;
- if (e != null) {
- e.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
- }
- }
- return this.AdornedElement.RenderSize;
- } else {
- return base.MeasureOverride(availableSize);
- }
- }
-
- ///
- protected override Size ArrangeOverride(Size finalSize)
- {
- foreach (UIElement element in base.InternalChildren) {
- GetPlacement(element).Arrange(this, element, finalSize);
- }
- return finalSize;
- }
-
- private DependencyObject[] VisualChildren {
- get {
- int count = VisualTreeHelper.GetChildrenCount(this);
- DependencyObject[] children = new DependencyObject[count];
- for (int i = 0; i < children.Length; i++) {
- children[i] = VisualTreeHelper.GetChild(this, i);
- }
- return children;
- }
- }
- }
-
- ///
- /// Describes where an Adorner is positioned on the Z-Layer.
- ///
- public struct AdornerOrder : IComparable, IEquatable
- {
- ///
- /// The adorner is in the background layer.
- ///
- public static readonly AdornerOrder Background = new AdornerOrder(100);
-
- ///
- /// The adorner is in the content layer.
- ///
- public static readonly AdornerOrder Content = new AdornerOrder(200);
-
- ///
- /// The adorner is in the layer behind the foreground but above the content. This layer
- /// is used for the gray-out effect.
- ///
- public static readonly AdornerOrder BehindForeground = new AdornerOrder(280);
-
- ///
- /// The adorner is in the foreground layer.
- ///
- public static readonly AdornerOrder Foreground = new AdornerOrder(300);
-
- int i;
-
- internal AdornerOrder(int i)
- {
- this.i = i;
- }
-
- ///
- public override int GetHashCode()
- {
- return i.GetHashCode();
- }
-
- ///
- public override bool Equals(object obj)
- {
- if (!(obj is AdornerOrder)) return false;
- return this == (AdornerOrder)obj;
- }
-
- ///
- public bool Equals(AdornerOrder other)
- {
- return i == other.i;
- }
-
- ///
- /// Compares the to another AdornerOrder.
- ///
- public int CompareTo(AdornerOrder other)
- {
- return i.CompareTo(other.i);
- }
-
- ///
- public static bool operator ==(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
- {
- return leftHandSide.i == rightHandSide.i;
- }
-
- ///
- public static bool operator !=(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
- {
- return leftHandSide.i != rightHandSide.i;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacement.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacement.cs
deleted file mode 100644
index f869abb859..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacement.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.ObjectModel;
-using System.Windows;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- ///
- /// Defines how a design-time adorner is placed.
- ///
- public abstract class AdornerPlacement
- {
- ///
- /// A placement instance that places the adorner above the content, using the same bounds as the content.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly AdornerPlacement FillContent = new FillContentPlacement();
-
- ///
- /// Arranges the adorner element on the specified adorner panel.
- ///
- public abstract void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize);
-
- sealed class FillContentPlacement : AdornerPlacement
- {
- public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
- {
- adorner.Arrange(new Rect(adornedElementSize));
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacementSpace.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacementSpace.cs
deleted file mode 100644
index 3f8dbaf5ef..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPlacementSpace.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.ObjectModel;
-using System.Windows;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- ///
- /// Describes the space in which an adorner is placed.
- ///
- public enum AdornerPlacementSpace
- {
- ///
- /// The adorner is affected by the render transform of the adorned element.
- ///
- Render,
- ///
- /// The adorner is affected by the layout transform of the adorned element.
- ///
- Layout,
- ///
- /// The adorner is not affected by transforms of designed controls.
- ///
- Designer
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProvider.cs
deleted file mode 100644
index 49c4cdf72e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProvider.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.ObjectModel;
-using System.Windows;
-using System.Windows.Media;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- ///
- /// Base class for extensions that present adorners on the screen.
- ///
- ///
- /// Cider adorner introduction:
- /// http://blogs.msdn.com/jnak/archive/2006/04/24/580393.aspx
- ///
- /// Adorners are WPF elements that float on top of the design surface and track the
- /// size and location of the elements they are adorning. All of the UI the designer
- /// presents to the user, including snap lines, grab handles and grid rulers,
- /// is composed of these adorners.
- ///
- /// About design-time adorners and their placement:
- /// read http://myfun.spaces.live.com/blog/cns!AC1291870308F748!240.entry
- /// and http://myfun.spaces.live.com/blog/cns!AC1291870308F748!242.entry
- ///
- public abstract class AdornerProvider : DefaultExtension
- {
- #region class AdornerCollection
- ///
- /// Describes a collection of adorner visuals.
- ///
- sealed class AdornerPanelCollection : Collection
- {
- readonly AdornerProvider _provider;
-
- internal AdornerPanelCollection(AdornerProvider provider)
- {
- this._provider = provider;
- }
-
- ///
- protected override void InsertItem(int index, AdornerPanel item)
- {
- base.InsertItem(index, item);
- _provider.OnAdornerAdd(item);
- }
-
- ///
- protected override void RemoveItem(int index)
- {
- _provider.OnAdornerRemove(base[index]);
- base.RemoveItem(index);
- }
-
- ///
- protected override void SetItem(int index, AdornerPanel item)
- {
- _provider.OnAdornerRemove(base[index]);
- base.SetItem(index, item);
- _provider.OnAdornerAdd(item);
- }
-
- ///
- protected override void ClearItems()
- {
- foreach (AdornerPanel v in this) {
- _provider.OnAdornerRemove(v);
- }
- base.ClearItems();
- }
- }
- #endregion
-
- readonly AdornerPanelCollection _adorners;
- bool isVisible;
-
- ///
- /// Creates a new AdornerProvider instance.
- ///
- protected AdornerProvider()
- {
- _adorners = new AdornerPanelCollection(this);
- }
-
- ///
- /// Is called after the ExtendedItem was set.
- /// This methods displays the registered adorners
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- isVisible = true;
- foreach (AdornerPanel v in _adorners) {
- OnAdornerAdd(v);
- }
- }
-
- ///
- /// Is called when the extension is removed.
- /// This method hides the registered adorners.
- ///
- protected override void OnRemove()
- {
- base.OnRemove();
- foreach (AdornerPanel v in _adorners) {
- OnAdornerRemove(v);
- }
- isVisible = false;
- }
-
- ///
- /// Gets the list of adorners displayed by this AdornerProvider.
- ///
- public Collection Adorners {
- get { return _adorners; }
- }
-
- ///
- /// Adds an UIElement as adorner with the specified placement.
- ///
- protected void AddAdorner(AdornerPlacement placement, AdornerOrder order, UIElement adorner)
- {
- AdornerPanel p = new AdornerPanel();
- p.Order = order;
- AdornerPanel.SetPlacement(adorner, placement);
- p.Children.Add(adorner);
- this.Adorners.Add(p);
- }
-
- ///
- /// Adds several UIElements as adorners with the specified placement.
- ///
- protected void AddAdorners(AdornerPlacement placement, params UIElement[] adorners)
- {
- AdornerPanel p = new AdornerPanel();
- foreach (UIElement adorner in adorners) {
- AdornerPanel.SetPlacement(adorner, placement);
- p.Children.Add(adorner);
- }
- this.Adorners.Add(p);
- }
-
- internal void OnAdornerAdd(AdornerPanel item)
- {
- if (!isVisible) return;
-
- item.SetAdornedElement(this.ExtendedItem.View, this.ExtendedItem);
-
- IDesignPanel avs = Services.GetService();
- avs.Adorners.Add(item);
- }
-
- internal void OnAdornerRemove(AdornerPanel item)
- {
- if (!isVisible) return;
-
- IDesignPanel avs = Services.GetService();
- avs.Adorners.Remove(item);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProviderClasses.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProviderClasses.cs
deleted file mode 100644
index 8ed6be5235..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerProviderClasses.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- // Some classes that derive from AdornerProvider to specify a certain ExtensionServer.
-
- ///
- /// An adorner extension that is attached permanently.
- ///
- [ExtensionServer(typeof(DefaultExtensionServer.PermanentWithDesignPanel))]
- public abstract class PermanentAdornerProvider : AdornerProvider
- {
-
- }
-
- ///
- /// An adorner extension that is attached to selected components.
- ///
- [ExtensionServer(typeof(SelectionExtensionServer))]
- public abstract class SelectionAdornerProvider : AdornerProvider
- {
-
- }
-
- ///
- /// An adorner extension that is attached to the primary selection.
- ///
- [ExtensionServer(typeof(PrimarySelectionExtensionServer))]
- public abstract class PrimarySelectionAdornerProvider : AdornerProvider
- {
-
- }
-
- ///
- /// An adorner extension that is attached to the secondary selection.
- ///
- [ExtensionServer(typeof(SecondarySelectionExtensionServer))]
- public abstract class SecondarySelectionAdornerProvider : AdornerProvider
- {
-
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/RelativePlacement.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/RelativePlacement.cs
deleted file mode 100644
index b340be8552..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/RelativePlacement.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.ObjectModel;
-using System.Windows;
-using System.Windows.Media;
-
-namespace ICSharpCode.WpfDesign.Adorners
-{
- // We have to support the different coordinate spaces as explained in
- // http://myfun.spaces.live.com/blog/cns!AC1291870308F748!242.entry
-
- ///
- /// Placement class providing properties for different kinds of relative placements.
- ///
- public sealed class RelativePlacement : AdornerPlacement
- {
- ///
- /// Creates a new RelativePlacement instance. The default instance is a adorner with zero size, you
- /// have to set some properties to define the placement.
- ///
- public RelativePlacement()
- {
- }
-
- ///
- /// Creates a new RelativePlacement instance from the specified horizontal and vertical alignments.
- ///
- public RelativePlacement(HorizontalAlignment horizontal, VerticalAlignment vertical)
- {
- switch (horizontal) {
- case HorizontalAlignment.Left:
- widthRelativeToDesiredWidth = 1;
- xRelativeToAdornerWidth = -1;
- break;
- case HorizontalAlignment.Right:
- widthRelativeToDesiredWidth = 1;
- xRelativeToContentWidth = 1;
- break;
- case HorizontalAlignment.Center:
- widthRelativeToDesiredWidth = 1;
- xRelativeToContentWidth = 0.5;
- xRelativeToAdornerWidth = -0.5;
- break;
- case HorizontalAlignment.Stretch:
- widthRelativeToContentWidth = 1;
- break;
- }
- switch (vertical) {
- case VerticalAlignment.Top:
- heightRelativeToDesiredHeight = 1;
- yRelativeToAdornerHeight = -1;
- break;
- case VerticalAlignment.Bottom:
- heightRelativeToDesiredHeight = 1;
- yRelativeToContentHeight = 1;
- break;
- case VerticalAlignment.Center:
- heightRelativeToDesiredHeight = 1;
- yRelativeToContentHeight = 0.5;
- yRelativeToAdornerHeight = -0.5;
- break;
- case VerticalAlignment.Stretch:
- heightRelativeToContentHeight = 1;
- break;
- }
- }
-
- double widthRelativeToDesiredWidth, heightRelativeToDesiredHeight;
-
- ///
- /// Gets/Sets the width of the adorner as factor relative to the desired adorner width.
- ///
- public double WidthRelativeToDesiredWidth {
- get { return widthRelativeToDesiredWidth; }
- set { widthRelativeToDesiredWidth = value; }
- }
-
- ///
- /// Gets/Sets the height of the adorner as factor relative to the desired adorner height.
- ///
- public double HeightRelativeToDesiredHeight {
- get { return heightRelativeToDesiredHeight; }
- set { heightRelativeToDesiredHeight = value; }
- }
-
- double widthRelativeToContentWidth, heightRelativeToContentHeight;
-
- ///
- /// Gets/Sets the width of the adorner as factor relative to the width of the adorned item.
- ///
- public double WidthRelativeToContentWidth {
- get { return widthRelativeToContentWidth; }
- set { widthRelativeToContentWidth = value; }
- }
-
- ///
- /// Gets/Sets the height of the adorner as factor relative to the height of the adorned item.
- ///
- public double HeightRelativeToContentHeight {
- get { return heightRelativeToContentHeight; }
- set { heightRelativeToContentHeight = value; }
- }
-
- double widthOffset, heightOffset;
-
- ///
- /// Gets/Sets an offset that is added to the adorner width for the size calculation.
- ///
- public double WidthOffset {
- get { return widthOffset; }
- set { widthOffset = value; }
- }
-
- ///
- /// Gets/Sets an offset that is added to the adorner height for the size calculation.
- ///
- public double HeightOffset {
- get { return heightOffset; }
- set { heightOffset = value; }
- }
-
- Size CalculateSize(UIElement adorner, Size adornedElementSize)
- {
- return new Size(Math.Max(widthOffset
- + widthRelativeToDesiredWidth * adorner.DesiredSize.Width
- + widthRelativeToContentWidth * adornedElementSize.Width, 0),
- Math.Max(heightOffset
- + heightRelativeToDesiredHeight * adorner.DesiredSize.Height
- + heightRelativeToContentHeight * adornedElementSize.Height, 0));
- }
-
- double xOffset, yOffset;
-
- ///
- /// Gets/Sets an offset that is added to the adorner position.
- ///
- public double XOffset {
- get { return xOffset; }
- set { xOffset = value; }
- }
-
- ///
- /// Gets/Sets an offset that is added to the adorner position.
- ///
- public double YOffset {
- get { return yOffset; }
- set { yOffset = value; }
- }
-
- double xRelativeToAdornerWidth, yRelativeToAdornerHeight;
-
- ///
- /// Gets/Sets the left border of the adorner element as factor relative to the width of the adorner.
- ///
- public double XRelativeToAdornerWidth {
- get { return xRelativeToAdornerWidth; }
- set { xRelativeToAdornerWidth = value; }
- }
-
- ///
- /// Gets/Sets the top border of the adorner element as factor relative to the height of the adorner.
- ///
- public double YRelativeToAdornerHeight {
- get { return yRelativeToAdornerHeight; }
- set { yRelativeToAdornerHeight = value; }
- }
-
- double xRelativeToContentWidth, yRelativeToContentHeight;
-
- ///
- /// Gets/Sets the left border of the adorner element as factor relative to the width of the adorned content.
- ///
- public double XRelativeToContentWidth {
- get { return xRelativeToContentWidth; }
- set { xRelativeToContentWidth = value; }
- }
-
- ///
- /// Gets/Sets the top border of the adorner element as factor relative to the height of the adorned content.
- ///
- public double YRelativeToContentHeight {
- get { return yRelativeToContentHeight; }
- set { yRelativeToContentHeight = value; }
- }
-
- Point CalculatePosition(Size adornedElementSize, Size adornerSize)
- {
- return new Point(xOffset
- + xRelativeToAdornerWidth * adornerSize.Width
- + xRelativeToContentWidth * adornedElementSize.Width,
- yOffset
- + yRelativeToAdornerHeight * adornerSize.Height
- + yRelativeToContentHeight * adornedElementSize.Height);
- }
-
- ///
- /// Arranges the adorner element on the specified adorner panel.
- ///
- public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
- {
- Size adornerSize = CalculateSize(adorner, adornedElementSize);
- adorner.Arrange(new Rect(CalculatePosition(adornedElementSize, adornerSize), adornerSize));
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs
deleted file mode 100644
index 02c0f6faf0..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Base class for change groups.
- ///
- public abstract class ChangeGroup : IDisposable
- {
- string title;
-
- ///
- /// Gets/Sets the title of the change group.
- ///
- public string Title {
- get { return title; }
- set { title = value; }
- }
-
- ///
- /// Commits the change group.
- ///
- public abstract void Commit();
-
- ///
- /// Aborts the change group.
- ///
- public abstract void Abort();
-
- ///
- /// Is called when the change group is disposed. Should Abort the change group if it is not already committed.
- ///
- protected abstract void Disposed();
-
- void IDisposable.Dispose()
- {
- Disposed();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/AssemblyInfo.cs
deleted file mode 100644
index 06adcd178f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/AssemblyInfo.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("WpfDesign")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: CLSCompliant(true)]
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
deleted file mode 100644
index 372044af0c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Xml;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// The context that the designer uses.
- ///
- public abstract class DesignContext
- {
- readonly ServiceContainer _services = new ServiceContainer();
-
- ///
- /// Creates a new DesignContext instance.
- ///
- protected DesignContext()
- {
- _services.AddService(typeof(Extensions.ExtensionManager), new Extensions.ExtensionManager(this));
- }
-
- ///
- /// Gets the .
- ///
- public ServiceContainer Services {
- [DebuggerStepThrough]
- get { return _services; }
- }
-
- ///
- /// Gets the root design item.
- ///
- public abstract DesignItem RootItem {
- get;
- }
-
- ///
- /// Gets whether the design context can be saved.
- ///
- public abstract bool CanSave { get; }
-
- ///
- /// Save the designed elements as XML.
- ///
- public abstract void Save(XmlWriter writer);
-
- ///
- /// Opens a new change group used to batch several changes.
- /// ChangeGroups work as transactions and are used to support the Undo/Redo system.
- ///
- public abstract ChangeGroup OpenGroup(string changeGroupTitle, ICollection affectedItems);
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
deleted file mode 100644
index 19339f799a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
+++ /dev/null
@@ -1,260 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows;
-
-using ICSharpCode.WpfDesign.Extensions;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// The DesignItem connects a component with the service system and the designers.
- /// Equivalent to Cider's ModelItem.
- ///
- public abstract class DesignItem : INotifyPropertyChanged
- {
- ///
- /// Gets the component this DesignSite was created for.
- ///
- public abstract object Component { get; }
-
- ///
- /// Gets the component type of this design site.
- /// This value may be different from Component.GetType() if a CustomInstanceFactory created
- /// an object using a different type (e.g. ComponentType=Window but Component.GetType()=WindowClone).
- ///
- public abstract Type ComponentType { get; }
-
- ///
- /// Gets the view used for the component.
- ///
- public abstract UIElement View { get; }
-
- ///
- /// Gets the design context.
- ///
- public abstract DesignContext Context { get; }
-
- ///
- /// Gets the parent design item.
- ///
- public abstract DesignItem Parent { get; }
-
- ///
- /// Occurs when the parent of this design item changes.
- ///
- public abstract event EventHandler ParentChanged;
-
- ///
- /// Gets the property where this DesignItem is used as a value.
- ///
- public abstract DesignItemProperty ParentProperty { get; }
-
- ///
- /// Gets properties set on the design item.
- ///
- public abstract DesignItemPropertyCollection Properties { get; }
-
- ///
- /// Gets/Sets the name of the design item.
- ///
- public abstract string Name { get; set; }
-
- ///
- /// Is raised when the name of the design item changes.
- ///
- public abstract event EventHandler NameChanged;
-
- ///
- /// Gets an instance that provides convenience properties for the most-used designers.
- ///
- public ServiceContainer Services {
- [DebuggerStepThrough]
- get { return this.Context.Services; }
- }
-
- ///
- /// Opens a new change group used to batch several changes.
- /// ChangeGroups work as transactions and are used to support the Undo/Redo system.
- /// Note: the ChangeGroup applies to the whole , not just to
- /// this item!
- ///
- public ChangeGroup OpenGroup(string changeGroupTitle)
- {
- return this.Context.OpenGroup(changeGroupTitle, new DesignItem[] { this });
- }
-
- #region Extensions support
- private struct ExtensionEntry
- {
- internal readonly Extension Extension;
- internal readonly ExtensionServer Server;
-
- public ExtensionEntry(Extension extension, ExtensionServer server)
- {
- this.Extension = extension;
- this.Server = server;
- }
- }
-
- ExtensionServer[] _extensionServers;
- bool[] _extensionServerIsApplied;
-
- List _extensions = new List();
-
- ///
- /// Gets the extensions registered for this DesignItem.
- ///
- public IEnumerable Extensions {
- get {
- foreach (ExtensionEntry entry in _extensions) {
- yield return entry.Extension;
- }
- }
- }
-
- internal void SetExtensionServers(ExtensionManager extensionManager, ExtensionServer[] extensionServers)
- {
- Debug.Assert(_extensionServers == null);
- Debug.Assert(extensionServers != null);
-
- _extensionServers = extensionServers;
- _extensionServerIsApplied = new bool[extensionServers.Length];
-
- for (int i = 0; i < _extensionServers.Length; i++) {
- bool shouldApply = _extensionServers[i].ShouldApplyExtensions(this);
- if (shouldApply != _extensionServerIsApplied[i]) {
- _extensionServerIsApplied[i] = shouldApply;
- ApplyUnapplyExtensionServer(extensionManager, shouldApply, _extensionServers[i]);
- }
- }
- }
-
- internal void ReapplyExtensionServer(ExtensionManager extensionManager, ExtensionServer server)
- {
- Debug.Assert(_extensionServers != null);
-
- for (int i = 0; i < _extensionServers.Length; i++) {
- if (_extensionServers[i] == server) {
- bool shouldApply = server.ShouldApplyExtensions(this);
- if (shouldApply != _extensionServerIsApplied[i]) {
- _extensionServerIsApplied[i] = shouldApply;
- ApplyUnapplyExtensionServer(extensionManager, shouldApply, server);
- }
- }
- }
- }
-
- private void ApplyUnapplyExtensionServer(ExtensionManager extensionManager, bool shouldApply, ExtensionServer server)
- {
- if (shouldApply) {
- // add extensions
- foreach (Extension ext in extensionManager.CreateExtensions(server, this)) {
- _extensions.Add(new ExtensionEntry(ext, server));
- }
- } else {
- // remove extensions
- _extensions.RemoveAll(
- delegate (ExtensionEntry entry) {
- if (entry.Server == server) {
- server.RemoveExtension(entry.Extension);
- return true;
- } else {
- return false;
- }
- });
- }
- }
- #endregion
-
- #region Manage behavior
- readonly Dictionary _behaviorObjects = new Dictionary();
-
- ///
- /// Adds a bevahior extension object to this design item.
- ///
- public void AddBehavior(Type bevahiorInterface, object behaviorImplementation)
- {
- if (bevahiorInterface == null)
- throw new ArgumentNullException("bevahiorInterface");
- if (behaviorImplementation == null)
- throw new ArgumentNullException("behaviorImplementation");
- if (!bevahiorInterface.IsInstanceOfType(behaviorImplementation))
- throw new ArgumentException("behaviorImplementation must implement bevahiorInterface", "behaviorImplementation");
-
- _behaviorObjects.Add(bevahiorInterface, behaviorImplementation);
- }
-
- ///
- /// Gets a bevahior extension object from the design item.
- ///
- /// The behavior object, or null if it was not found.
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- public T GetBehavior() where T : class
- {
- object obj;
- _behaviorObjects.TryGetValue(typeof(T), out obj);
- return (T)obj;
- }
- #endregion
-
- ///
- /// This event is raised whenever a model property on the DesignItem changes.
- ///
- public event PropertyChangedEventHandler PropertyChanged;
-
- ///
- /// Raises the event.
- ///
- protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, e);
- }
- }
-
- ///
- /// Gets the name of the content property (the property that contains the logical children)
- ///
- public abstract string ContentPropertyName { get; }
-
- ///
- /// Gets the content property (the property that contains the logical children)
- ///
- public DesignItemProperty ContentProperty {
- get {
- if (ContentPropertyName == null) return null;
- return Properties[ContentPropertyName];
- }
- }
-
- ///
- /// Removes this design item from its parent property/collection.
- ///
- public void Remove()
- {
- if (ParentProperty != null) {
- if (ParentProperty.IsCollection) {
- ParentProperty.CollectionElements.Remove(this);
- }
- else {
- ParentProperty.Reset();
- }
- }
- }
-
- ///
- /// Creates a copy of this design item.
- ///
- public abstract DesignItem Clone();
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs
deleted file mode 100644
index 89457222e4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Represents a property of a DesignItem.
- /// All changes done via the DesignItemProperty class are represented in the underlying model (e.g. XAML).
- /// All such changes are recorded in the currently running designer transaction (),
- /// enabling Undo/Redo support.
- /// Warning: Changes directly done to control instances might not be reflected in the model.
- ///
- public abstract class DesignItemProperty
- {
- ///
- /// Gets the property name.
- ///
- public abstract string Name { get; }
-
- ///
- /// Gets the return type of the property.
- ///
- public abstract Type ReturnType { get; }
-
- ///
- /// Gets the type that declares the property.
- ///
- public abstract Type DeclaringType { get; }
-
- ///
- /// Gets the category of the property.
- ///
- public abstract string Category { get; }
-
- ///
- /// Gets the type converter used to convert property values to/from string.
- ///
- public virtual TypeConverter TypeConverter {
- get { return TypeDescriptor.GetConverter(this.ReturnType); }
- }
-
- ///
- /// Gets if the property represents a collection.
- ///
- public abstract bool IsCollection { get; }
-
- ///
- /// Gets if the property represents an event.
- ///
- public abstract bool IsEvent { get; }
-
- ///
- /// Gets the elements represented by the collection.
- ///
- public abstract IList CollectionElements { get; }
-
- ///
- /// Gets the value of the property. This property returns null if the value is not set,
- /// or if the value is set to a primitive value.
- ///
- public abstract DesignItem Value { get; }
-
- ///
- /// Is raised when the value of the property changes (by calling or ).
- ///
- public abstract event EventHandler ValueChanged;
-
- ///
- /// Is raised when the property changes.
- /// This event is not raised when the value is changed without going through the designer infrastructure.
- ///
- public abstract event EventHandler ValueOnInstanceChanged;
-
- ///
- /// Gets/Sets the value of the property on the designed instance.
- /// If the property is not set, this returns the default value.
- /// The setter does NOT update the underlying model, use SetValue() instead!
- ///
- public abstract object ValueOnInstance { get; set; }
-
- ///
- /// Sets the value of the property.
- ///
- public abstract void SetValue(object value);
-
- ///
- /// Gets if the property is set on the design item.
- ///
- public abstract bool IsSet { get; }
-
- ///
- /// Occurs when the value of the IsSet property changes.
- ///
- public abstract event EventHandler IsSetChanged;
-
- ///
- /// Resets the property value to the default, possibly removing it from the list of properties.
- ///
- public abstract void Reset();
-
- ///
- /// Gets the parent design item.
- ///
- public abstract DesignItem DesignItem { get; }
-
- ///
- /// Gets the dependency property, or null if this property does not represent a dependency property.
- ///
- public abstract DependencyProperty DependencyProperty { get; }
-
- ///
- /// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
- ///
- public virtual bool IsAdvanced { get { return false; } }
-
- ///
- /// Gets the full name of the property (DeclaringType.FullName + "." + Name).
- ///
- public string FullName {
- get {
- return DeclaringType.FullName + "." + Name;
- }
- }
-
- ///
- /// Gets the full name of the dependency property. Returns the normal FullName if the property
- /// isn't a dependency property.
- ///
- public string DependencyFullName {
- get {
- if (DependencyProperty != null) {
- return DependencyProperty.GetFullName();
- }
- return FullName;
- }
- }
- }
-
- ///
- /// Represents a collection of design item properties.
- ///
- public abstract class DesignItemPropertyCollection : IEnumerable
- {
- ///
- /// Gets the property with the specified name.
- ///
- public DesignItemProperty this[string name] {
- get { return GetProperty(name); }
- }
-
- ///
- /// Gets the design item property representing the specified dependency property.
- /// The property must not be an attached property.
- ///
- public DesignItemProperty this[DependencyProperty dependencyProperty] {
- get {
- Debug.Assert(DependencyPropertyDescriptor.FromProperty(dependencyProperty, dependencyProperty.OwnerType).IsAttached == false);
- return GetProperty(dependencyProperty);
- }
- }
-
- ///
- /// Gets the design item property with the specified name.
- ///
- public abstract DesignItemProperty GetProperty(string name);
-
- ///
- /// Gets the attached property on the specified owner with the specified name.
- ///
- public abstract DesignItemProperty GetAttachedProperty(Type ownerType, string name);
-
- ///
- /// Gets the design item property representing the specified dependency property.
- /// The property must not be an attached property.
- ///
- public DesignItemProperty GetProperty(DependencyProperty dependencyProperty)
- {
- if (dependencyProperty == null)
- throw new ArgumentNullException("dependencyProperty");
- return GetProperty(dependencyProperty.Name);
- }
-
- ///
- /// Gets the design item property representing the specified attached dependency property.
- ///
- public DesignItemProperty GetAttachedProperty(DependencyProperty dependencyProperty)
- {
- if (dependencyProperty == null)
- throw new ArgumentNullException("dependencyProperty");
- return GetAttachedProperty(dependencyProperty.OwnerType, dependencyProperty.Name);
- }
-
- ///
- /// Gets an enumerator to enumerate the properties that have a non-default value.
- ///
- public abstract IEnumerator GetEnumerator();
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return this.GetEnumerator();
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignPanelHitTestResult.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignPanelHitTestResult.cs
deleted file mode 100644
index 1e0b9ca893..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignPanelHitTestResult.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-using System.Windows.Media;
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Describes the result of a call.
- ///
- public struct DesignPanelHitTestResult : IEquatable
- {
- ///
- /// Represents the result that nothing was hit.
- ///
- public static readonly DesignPanelHitTestResult NoHit = new DesignPanelHitTestResult();
-
- readonly Visual _visualHit;
- AdornerPanel _adornerHit;
- DesignItem _modelHit;
-
- ///
- /// The actual visual that was hit.
- ///
- public Visual VisualHit {
- get { return _visualHit; }
- }
-
- ///
- /// The adorner panel containing the adorner that was hit.
- ///
- public AdornerPanel AdornerHit {
- get { return _adornerHit; }
- set { _adornerHit = value; }
- }
-
- ///
- /// The model item that was hit.
- ///
- public DesignItem ModelHit {
- get { return _modelHit; }
- set { _modelHit = value; }
- }
-
- ///
- /// Create a new DesignPanelHitTestResult instance.
- ///
- public DesignPanelHitTestResult(Visual visualHit)
- {
- this._visualHit = visualHit;
- this._adornerHit = null;
- this._modelHit = null;
- }
-
- #region Equals and GetHashCode implementation
- // The code in this region is useful if you want to use this structure in collections.
- // If you don't need it, you can just remove the region and the ": IEquatable" declaration.
-
- ///
- /// Tests if this hit test result equals the other result.
- ///
- public override bool Equals(object obj)
- {
- if (obj is DesignPanelHitTestResult)
- return Equals((DesignPanelHitTestResult)obj); // use Equals method below
- else
- return false;
- }
-
- ///
- /// Tests if this hit test result equals the other result.
- ///
- public bool Equals(DesignPanelHitTestResult other)
- {
- // add comparisions for all members here
- return _visualHit == other._visualHit && _adornerHit == other._adornerHit && _modelHit == other._modelHit;
- }
-
- ///
- /// Gets the hash code.
- ///
- public override int GetHashCode()
- {
- // combine the hash codes of all members here (e.g. with XOR operator ^)
- return (_visualHit != null ? _visualHit.GetHashCode() : 0)
- ^ (_adornerHit != null ? _adornerHit.GetHashCode() : 0)
- ^ (_modelHit != null ? _modelHit.GetHashCode() : 0);
- }
-
- ///
- public static bool operator ==(DesignPanelHitTestResult lhs, DesignPanelHitTestResult rhs)
- {
- return lhs.Equals(rhs);
- }
-
- ///
- public static bool operator !=(DesignPanelHitTestResult lhs, DesignPanelHitTestResult rhs)
- {
- return !(lhs.Equals(rhs)); // use operator == and negate result
- }
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignerException.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignerException.cs
deleted file mode 100644
index 1ed2a518a2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignerException.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Runtime.Serialization;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Exception class used for designer failures.
- ///
- [Serializable]
- public class DesignerException : Exception
- {
- ///
- /// Create a new DesignerException instance.
- ///
- public DesignerException()
- {
- }
-
- ///
- /// Create a new DesignerException instance.
- ///
- public DesignerException(string message) : base(message)
- {
- }
-
- ///
- /// Create a new DesignerException instance.
- ///
- public DesignerException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- ///
- /// Create a new DesignerException instance.
- ///
- protected DesignerException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
deleted file mode 100644
index 9dfd25a699..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Event arguments specifying a component as parameter.
- ///
- public class DesignItemEventArgs : EventArgs
- {
- readonly DesignItem _item;
-
- ///
- /// Creates a new ComponentEventArgs instance.
- ///
- public DesignItemEventArgs(DesignItem item)
- {
- _item = item;
- }
-
- ///
- /// The component affected by the event.
- ///
- public DesignItem Item {
- get { return _item; }
- }
- }
-
- ///
- /// Event arguments specifying a component as parameter.
- ///
- public class DesignItemCollectionEventArgs : EventArgs
- {
- readonly ICollection _items;
-
- ///
- /// Creates a new ComponentCollectionEventArgs instance.
- ///
- public DesignItemCollectionEventArgs(ICollection items)
- {
- _items = items;
- }
-
- ///
- /// The components affected by the event.
- ///
- public ICollection Items {
- get { return _items; }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/BehaviorExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/BehaviorExtension.cs
deleted file mode 100644
index 50869d8a62..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/BehaviorExtension.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Base class for extensions that provide a behavior interface for the designed item.
- /// These extensions are always loaded. They must have an parameter-less constructor.
- ///
- [ExtensionServer(typeof(DefaultExtensionServer.Permanent))]
- public class BehaviorExtension : DefaultExtension
- {
-
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
deleted file mode 100644
index 01a97c340b..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// A special kind of extension that is used to create instances of objects when loading XAML inside
- /// the designer.
- ///
- ///
- /// CustomInstanceFactory in Cider: http://blogs.msdn.com/jnak/archive/2006/04/10/572241.aspx
- ///
- [ExtensionServer(typeof(NeverApplyExtensionsExtensionServer))]
- public class CustomInstanceFactory : Extension
- {
- ///
- /// Gets a default instance factory that uses Activator.CreateInstance to create instances.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly CustomInstanceFactory DefaultInstanceFactory = new CustomInstanceFactory();
-
- ///
- /// Creates a new CustomInstanceFactory instance.
- ///
- protected CustomInstanceFactory()
- {
- }
-
- ///
- /// Creates an instance of the specified type, passing the specified arguments to its constructor.
- ///
- public virtual object CreateInstance(Type type, params object[] arguments)
- {
- return Activator.CreateInstance(type, arguments);
- }
- }
-
- // An extension server that never applies its extensions - used for special extensions
- // like CustomInstanceFactory
- sealed class NeverApplyExtensionsExtensionServer : ExtensionServer
- {
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return false;
- }
-
- public override Extension CreateExtension(Type extensionType, DesignItem extendedItem)
- {
- throw new NotImplementedException();
- }
-
- public override void RemoveExtension(Extension extension)
- {
- throw new NotImplementedException();
- }
-
- // since the event is never raised, we don't have to store the event handlers
- public override event EventHandler ShouldApplyExtensionsInvalidated {
- add {} remove {}
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultExtension.cs
deleted file mode 100644
index 2d51e2682c..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultExtension.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Base class for extensions that have an parameter-less constructor and are initialized using the
- /// OnInitialize method.
- ///
- public class DefaultExtension : Extension
- {
- DesignItem _extendedItem;
-
- ///
- /// Gets the item that is being extended by the BehaviorExtension.
- ///
- public DesignItem ExtendedItem {
- get {
- if (_extendedItem == null)
- throw new InvalidOperationException("Cannot access BehaviorExtension.ExtendedItem: " +
- "The property is not initialized yet. Please move initialization logic " +
- "that depends on ExtendedItem into the OnInitialized method.");
- return _extendedItem;
- }
- }
-
- ///
- /// Gets the design context of the extended item. "Context" is equivalent to "ExtendedItem.Context".
- ///
- public DesignContext Context {
- get {
- return this.ExtendedItem.Context;
- }
- }
-
- ///
- /// Gets the service container of the extended item. "Services" is equivalent to "ExtendedItem.Services".
- ///
- public ServiceContainer Services {
- get {
- return this.ExtendedItem.Services;
- }
- }
-
- ///
- /// Is called after the ExtendedItem was set.
- /// Override this method to register your behavior with the item.
- ///
- protected virtual void OnInitialized()
- {
- }
-
- ///
- /// Is called when the extension is removed.
- ///
- protected virtual void OnRemove()
- {
- }
-
- internal void CallOnRemove() { OnRemove(); }
-
- internal void InitializeDefaultExtension(DesignItem extendedItem)
- {
- Debug.Assert(this._extendedItem == null);
- Debug.Assert(extendedItem != null);
-
- this._extendedItem = extendedItem;
- OnInitialized();
- }
- }
-
- ///
- /// Base class for extension servers that create extensions that derive from .
- ///
- public abstract class DefaultExtensionServer : ExtensionServer
- {
- ///
- /// Creates an instance of the DefaultExtension and calls OnInitialize on it.
- ///
- public override Extension CreateExtension(Type extensionType, DesignItem extendedItem)
- {
- DefaultExtension ext = (DefaultExtension)Activator.CreateInstance(extensionType);
- ext.InitializeDefaultExtension(extendedItem);
- return ext;
- }
-
- ///
- /// Calls OnRemove() on the DefaultExtension.
- ///
- public override void RemoveExtension(Extension extension)
- {
- DefaultExtension defaultExtension = extension as DefaultExtension;
- Debug.Assert(defaultExtension != null);
- defaultExtension.CallOnRemove();
- }
-
- ///
- /// This event is raised when ShouldApplyExtensions is invalidated for a set of items.
- ///
- public override event EventHandler ShouldApplyExtensionsInvalidated;
-
- ///
- /// Raise the ShouldApplyExtensionsInvalidated event for the specified set of design items.
- ///
- protected void ReapplyExtensions(ICollection items)
- {
- if (ShouldApplyExtensionsInvalidated != null) {
- ShouldApplyExtensionsInvalidated(this, new DesignItemCollectionEventArgs(items));
- }
- }
-
- internal sealed class Permanent : DefaultExtensionServer
- {
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return true;
- }
- }
-
- internal sealed class PermanentWithDesignPanel : DefaultExtensionServer
- {
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return Services.GetService() != null;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultInitializer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultInitializer.cs
deleted file mode 100644
index 8c4d14092e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/DefaultInitializer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Base class for extensions that initialize new controls with default values.
- ///
- [ExtensionServer(typeof(NeverApplyExtensionsExtensionServer))]
- public abstract class DefaultInitializer : Extension
- {
- ///
- /// Initializes the design item to default values.
- ///
- public abstract void InitializeDefaults(DesignItem item);
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs
deleted file mode 100644
index 75fc9ad030..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Base class for all Extensions.
- ///
- ///
- /// The class design in the ICSharpCode.WpfDesign.Extensions namespace was made to match that of Cider
- /// as described in the blog posts:
- /// http://blogs.msdn.com/jnak/archive/2006/04/24/580393.aspx
- /// http://blogs.msdn.com/jnak/archive/2006/08/04/687166.aspx
- ///
- public abstract class Extension
- {
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
deleted file mode 100644
index 01a0ad813e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Attribute to specify that the decorated class is a WPF extension for the specified item type.
- ///
- [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
- public sealed class ExtensionForAttribute : Attribute
- {
- Type _designedItemType;
- Type _overrideExtension;
-
- ///
- /// Gets the type of the item that is designed using this extension.
- ///
- public Type DesignedItemType {
- get { return _designedItemType; }
- }
-
- ///
- /// Gets/Sets the type of another extension that this extension is overriding.
- ///
- public Type OverrideExtension {
- get { return _overrideExtension; }
- set {
- _overrideExtension = value;
- if (value != null) {
- if (!typeof(Extension).IsAssignableFrom(value)) {
- throw new ArgumentException("OverrideExtension must specify the type of an Extension.");
- }
- }
- }
- }
-
- ///
- /// Create a new ExtensionForAttribute that specifies that the decorated class
- /// is a WPF extension for the specified item type.
- ///
- public ExtensionForAttribute(Type designedItemType)
- {
- if (designedItemType == null)
- throw new ArgumentNullException("designedItemType");
- if (!designedItemType.IsClass)
- throw new ArgumentException("designedItemType must be a class");
- _designedItemType = designedItemType;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
deleted file mode 100644
index 23e7c70dc7..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Manages extension creation for a design context.
- ///
- public sealed class ExtensionManager
- {
- readonly DesignContext _context;
-
- internal ExtensionManager(DesignContext context)
- {
- Debug.Assert(context != null);
- this._context = context;
-
- context.Services.RunWhenAvailable(
- delegate(IComponentService componentService) {
- componentService.ComponentRegistered += OnComponentRegistered;
- });
- }
-
- void OnComponentRegistered(object sender, DesignItemEventArgs e)
- {
- e.Item.SetExtensionServers(this, GetExtensionServersForItem(e.Item));
- }
-
- ///
- /// Re-applies extensions from the ExtensionServer to the specified design items.
- ///
- void ReapplyExtensions(IEnumerable items, ExtensionServer server)
- {
- foreach (DesignItem item in items) {
- if (item != null) {
- item.ReapplyExtensionServer(this, server);
- }
- }
- }
-
- #region Manage ExtensionEntries
- sealed class ExtensionEntry
- {
- internal readonly Type ExtensionType;
- internal readonly ExtensionServer Server;
- internal readonly Type OverriddenExtensionType;
-
- public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType)
- {
- this.ExtensionType = extensionType;
- this.Server = server;
- this.OverriddenExtensionType = overriddenExtensionType;
- }
- }
-
- Dictionary> _extensions = new Dictionary>();
-
- void AddExtensionEntry(Type extendedItemType, ExtensionEntry entry)
- {
- List list;
- if (!_extensions.TryGetValue(extendedItemType, out list)) {
- list = _extensions[extendedItemType] = new List();
- }
- list.Add(entry);
- }
-
- List GetExtensionEntries(Type extendedItemType)
- {
- List result;
- if (extendedItemType.BaseType != null)
- result = GetExtensionEntries(extendedItemType.BaseType);
- else
- result = new List();
-
- List list;
- if (_extensions.TryGetValue(extendedItemType, out list)) {
- foreach (ExtensionEntry entry in list) {
- if (entry.OverriddenExtensionType != null) {
- result.RemoveAll(delegate(ExtensionEntry oldEntry) {
- return oldEntry.ExtensionType == entry.OverriddenExtensionType;
- });
- }
- result.Add(entry);
- }
- }
- return result;
- }
-
- ///
- /// Gets all the types of all extensions that are applied to the specified item type.
- ///
- public IEnumerable GetExtensionTypes(Type extendedItemType)
- {
- if (extendedItemType == null)
- throw new ArgumentNullException("extendedItemType");
- foreach (ExtensionEntry entry in GetExtensionEntries(extendedItemType)) {
- yield return entry.ExtensionType;
- }
- }
- #endregion
-
- #region Create Extensions
- static readonly ExtensionEntry[] emptyExtensionEntryArray = new ExtensionEntry[0];
-
- IEnumerable GetExtensionEntries(DesignItem extendedItem)
- {
- if (extendedItem.Component == null)
- return emptyExtensionEntryArray;
- else
- return GetExtensionEntries(extendedItem.ComponentType);
- }
-
- ExtensionServer[] GetExtensionServersForItem(DesignItem item)
- {
- Debug.Assert(item != null);
-
- HashSet servers = new HashSet();
- foreach (ExtensionEntry entry in GetExtensionEntries(item)) {
- servers.Add(entry.Server);
- }
- return servers.ToArray();
- }
-
- internal IEnumerable CreateExtensions(ExtensionServer server, DesignItem item)
- {
- Debug.Assert(server != null);
- Debug.Assert(item != null);
-
- foreach (ExtensionEntry entry in GetExtensionEntries(item)) {
- if (entry.Server == server) {
- yield return server.CreateExtension(entry.ExtensionType, item);
- }
- }
- }
- #endregion
-
- #region RegisterAssembly
- HashSet _registeredAssemblies = new HashSet();
-
- ///
- /// Registers extensions from the specified assembly.
- ///
- public void RegisterAssembly(Assembly assembly)
- {
- if (assembly == null)
- throw new ArgumentNullException("assembly");
-
-// object[] assemblyAttributes = assembly.GetCustomAttributes(typeof(IsWpfDesignerAssemblyAttribute), false);
-// if (assemblyAttributes.Length == 0)
-// return;
-
- if (!_registeredAssemblies.Add(assembly)) {
- // the assembly already is registered, don't try to register it again.
- return;
- }
-
-// IsWpfDesignerAssemblyAttribute isWpfDesignerAssembly = (IsWpfDesignerAssemblyAttribute)assemblyAttributes[0];
-// foreach (Type type in isWpfDesignerAssembly.UsePrivateReflection ? assembly.GetTypes() : assembly.GetExportedTypes()) {
- foreach (Type type in assembly.GetTypes()) {
- object[] extensionForAttributes = type.GetCustomAttributes(typeof(ExtensionForAttribute), false);
- if (extensionForAttributes.Length == 0)
- continue;
-
- foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
- ExtensionServer server = GetServerForExtension(type);
- AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension));
- }
- }
- }
- #endregion
-
- #region Extension Server Creation
- // extension server type => extension server instance
- Dictionary _extensionServers = new Dictionary();
-
- ExtensionServer GetServerForExtension(Type extensionType)
- {
- Debug.Assert(extensionType != null);
-
- object[] extensionServerAttributes = extensionType.GetCustomAttributes(typeof(ExtensionServerAttribute), true);
- if (extensionServerAttributes.Length != 1)
- throw new DesignerException("Extension types must have exactly one [ExtensionServer] attribute.");
-
- return GetExtensionServer((ExtensionServerAttribute)extensionServerAttributes[0]);
- }
-
- ///
- /// Gets the extension server for the specified extension server attribute.
- ///
- public ExtensionServer GetExtensionServer(ExtensionServerAttribute attribute)
- {
- if (attribute == null)
- throw new ArgumentNullException("attribute");
-
- Type extensionServerType = attribute.ExtensionServerType;
-
- ExtensionServer server;
- if (_extensionServers.TryGetValue(extensionServerType, out server))
- return server;
-
- server = (ExtensionServer)Activator.CreateInstance(extensionServerType);
- server.InitializeExtensionServer(_context);
- _extensionServers[extensionServerType] = server;
- server.ShouldApplyExtensionsInvalidated += delegate(object sender, DesignItemCollectionEventArgs e) {
- ReapplyExtensions(e.Items, (ExtensionServer)sender);
- };
- return server;
- }
- #endregion
-
- #region Special extensions (CustomInstanceFactory and DefaultInitializer)
- static readonly object[] emptyObjectArray = new object[0];
-
- ///
- /// Create an instance of the specified type using the specified arguments.
- /// The instance is created using a CustomInstanceFactory registered for the type,
- /// or using reflection if no instance factory is found.
- ///
- public object CreateInstanceWithCustomInstanceFactory(Type instanceType, object[] arguments)
- {
- if (instanceType == null)
- throw new ArgumentNullException("instanceType");
- if (arguments == null)
- arguments = emptyObjectArray;
- foreach (Type extensionType in GetExtensionTypes(instanceType)) {
- if (typeof(CustomInstanceFactory).IsAssignableFrom(extensionType)) {
- CustomInstanceFactory factory = (CustomInstanceFactory)Activator.CreateInstance(extensionType);
- return factory.CreateInstance(instanceType, arguments);
- }
- }
- return CustomInstanceFactory.DefaultInstanceFactory.CreateInstance(instanceType, arguments);
- }
-
- ///
- /// Applies all DefaultInitializer extensions on the design item.
- ///
- public void ApplyDefaultInitializers(DesignItem item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
-
- foreach (ExtensionEntry entry in GetExtensionEntries(item)) {
- if (typeof(DefaultInitializer).IsAssignableFrom(entry.ExtensionType)) {
- DefaultInitializer initializer = (DefaultInitializer)Activator.CreateInstance(entry.ExtensionType);
- initializer.InitializeDefaults(item);
- }
- }
- }
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs
deleted file mode 100644
index c247c488b3..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// An ExtensionServer manages a creating and removing extensions of the specific extension type.
- /// For a given DesignContext, a ExtensionServer is created only once.
- /// The ExtensionServer can handle events raised by services without having to unregister its events
- /// handlers because the ExtensionServer runs for the lifetime of the DesignContext.
- ///
- public abstract class ExtensionServer
- {
- DesignContext _context;
-
- ///
- /// Gets the context this extension server was created for.
- ///
- public DesignContext Context {
- [DebuggerStepThrough]
- get {
- if (_context == null)
- throw new InvalidOperationException("Cannot access ExtensionServer.Context: " +
- "The property is not initialized yet. Please move initialization logic " +
- "that depends on Context into the OnInitialized method.");
- return _context;
- }
- }
-
- ///
- /// Gets the service container of the current context. "x.Services" is equivalent to "x.Context.Services".
- ///
- public ServiceContainer Services {
- [DebuggerStepThrough]
- get { return this.Context.Services; }
- }
-
- internal void InitializeExtensionServer(DesignContext context)
- {
- Debug.Assert(this._context == null);
- Debug.Assert(context != null);
- this._context = context;
- OnInitialized();
- }
-
- ///
- /// Is called after the extension server is initialized and the property has been set.
- ///
- protected virtual void OnInitialized()
- {
- }
-
- ///
- /// Gets if the extension manager should apply the extensions from this server to the specified item.
- /// Is called by the ExtensionManager.
- ///
- public abstract bool ShouldApplyExtensions(DesignItem extendedItem);
-
- ///
- /// Create an extension of the specified type.
- /// Is called by the ExtensionManager.
- ///
- public abstract Extension CreateExtension(Type extensionType, DesignItem extendedItem);
-
- ///
- /// This method is called before an extension is removed from its DesignItem because it should not be applied anymore.
- /// Is called by the ExtensionManager.
- ///
- public abstract void RemoveExtension(Extension extension);
-
- ///
- /// This event is raised when ShouldApplyExtensions is invalidated for a set of items.
- ///
- public abstract event EventHandler ShouldApplyExtensionsInvalidated;
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServerAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServerAttribute.cs
deleted file mode 100644
index 7734f9c6de..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServerAttribute.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Attribute to specify that the decorated class is an extension using the specified extension server.
- ///
- [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
- public sealed class ExtensionServerAttribute : Attribute
- {
- Type _extensionServerType;
-
- ///
- /// Gets the type of the item that is designed using this extension.
- ///
- public Type ExtensionServerType {
- get { return _extensionServerType; }
- }
-
- ///
- /// Create a new ExtensionServerAttribute that specifies that the decorated extension
- /// uses the specified extension server.
- ///
- public ExtensionServerAttribute(Type extensionServerType)
- {
- if (extensionServerType == null)
- throw new ArgumentNullException("extensionServerType");
- if (!typeof(ExtensionServer).IsAssignableFrom(extensionServerType))
- throw new ArgumentException("extensionServerType must derive from ExtensionServer");
- if (extensionServerType.GetConstructor(new Type[0]) == null)
- throw new ArgumentException("extensionServerType must have a parameter-less constructor");
- _extensionServerType = extensionServerType;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs
deleted file mode 100644
index 89e3ffd39b..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Combines two extension servers using a logical OR.
- ///
- public sealed class LogicalOrExtensionServer : DefaultExtensionServer
- where A : ExtensionServer
- where B : ExtensionServer
- {
- ExtensionServer _a;
- ExtensionServer _b;
-
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- _a = Context.Services.ExtensionManager.GetExtensionServer(new ExtensionServerAttribute(typeof(A)));
- _b = Context.Services.ExtensionManager.GetExtensionServer(new ExtensionServerAttribute(typeof(B)));
- _a.ShouldApplyExtensionsInvalidated += OnShouldApplyExtensionsInvalidated;
- _b.ShouldApplyExtensionsInvalidated += OnShouldApplyExtensionsInvalidated;
- }
-
- void OnShouldApplyExtensionsInvalidated(object sender, DesignItemCollectionEventArgs e)
- {
- ReapplyExtensions(e.Items);
- }
-
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return _a.ShouldApplyExtensions(extendedItem) || _b.ShouldApplyExtensions(extendedItem);
- }
- }
-
- ///
- /// Combines two extension servers using a logical AND.
- ///
- public sealed class LogicalAndExtensionServer : DefaultExtensionServer
- where A : ExtensionServer
- where B : ExtensionServer
- {
- ExtensionServer _a;
- ExtensionServer _b;
-
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- _a = Context.Services.ExtensionManager.GetExtensionServer(new ExtensionServerAttribute(typeof(A)));
- _b = Context.Services.ExtensionManager.GetExtensionServer(new ExtensionServerAttribute(typeof(B)));
- _a.ShouldApplyExtensionsInvalidated += OnShouldApplyExtensionsInvalidated;
- _b.ShouldApplyExtensionsInvalidated += OnShouldApplyExtensionsInvalidated;
- }
-
- void OnShouldApplyExtensionsInvalidated(object sender, DesignItemCollectionEventArgs e)
- {
- ReapplyExtensions(e.Items);
- }
-
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return _a.ShouldApplyExtensions(extendedItem) && _b.ShouldApplyExtensions(extendedItem);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs
deleted file mode 100644
index 414777bb23..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.Extensions
-{
- ///
- /// Applies an extension to the selected components.
- ///
- public class SelectionExtensionServer : DefaultExtensionServer
- {
- ///
- /// Is called after the extension server is initialized and the Context property has been set.
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- Services.Selection.SelectionChanged += OnSelectionChanged;
- }
-
- void OnSelectionChanged(object sender, DesignItemCollectionEventArgs e)
- {
- ReapplyExtensions(e.Items);
- }
-
- ///
- /// Gets if the item is selected.
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return Services.Selection.IsComponentSelected(extendedItem);
- }
- }
-
- ///
- /// Applies an extension to the selected components, but not to the primary selection.
- ///
- public class SecondarySelectionExtensionServer : SelectionExtensionServer
- {
- ///
- /// Gets if the item is in the secondary selection.
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return base.ShouldApplyExtensions(extendedItem) && Services.Selection.PrimarySelection != extendedItem;
- }
- }
-
- ///
- /// Applies an extension to the primary selection.
- ///
- public class PrimarySelectionExtensionServer : DefaultExtensionServer
- {
- DesignItem oldPrimarySelection;
-
- ///
- /// Is called after the extension server is initialized and the Context property has been set.
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged;
- }
-
- void OnPrimarySelectionChanged(object sender, EventArgs e)
- {
- DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection;
- if (oldPrimarySelection != newPrimarySelection) {
- if (oldPrimarySelection == null) {
- ReapplyExtensions(new DesignItem[] { newPrimarySelection });
- } else if (newPrimarySelection == null) {
- ReapplyExtensions(new DesignItem[] { oldPrimarySelection });
- } else {
- ReapplyExtensions(new DesignItem[] { oldPrimarySelection, newPrimarySelection });
- }
- oldPrimarySelection = newPrimarySelection;
- }
- }
-
- ///
- /// Gets if the item is the primary selection.
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return Services.Selection.PrimarySelection == extendedItem;
- }
- }
-
- ///
- /// Applies an extension to the parent of the primary selection.
- ///
- public class PrimarySelectionParentExtensionServer : DefaultExtensionServer
- {
- ///
- /// Is called after the extension server is initialized and the Context property has been set.
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged;
- }
-
- DesignItem primarySelection;
- DesignItem primarySelectionParent;
-
- void OnPrimarySelectionChanged(object sender, EventArgs e)
- {
- DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection;
- if (primarySelection != newPrimarySelection) {
- if (primarySelection != null) {
- primarySelection.ParentChanged -= OnParentChanged;
- }
- if (newPrimarySelection != null) {
- newPrimarySelection.ParentChanged += OnParentChanged;
- }
- primarySelection = newPrimarySelection;
- OnParentChanged(sender, e);
- }
- }
-
- void OnParentChanged(object sender, EventArgs e)
- {
- DesignItem newPrimarySelectionParent = primarySelection != null ? primarySelection.Parent : null;
-
- if (primarySelectionParent != newPrimarySelectionParent) {
- DesignItem oldPrimarySelectionParent = primarySelectionParent;
- primarySelectionParent = newPrimarySelectionParent;
- ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent, newPrimarySelectionParent });
- }
- }
-
- ///
- /// Gets if the item is the primary selection.
- ///
- public override bool ShouldApplyExtensions(DesignItem extendedItem)
- {
- return primarySelectionParent == extendedItem;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HashSet.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HashSet.cs
deleted file mode 100644
index 1d40409897..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HashSet.cs
+++ /dev/null
@@ -1,202 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Represents a set of items. The set does not preserve the order of items and does not allow items to
- /// be added twice.
- /// It supports collection change notifications and is cloned by sharing the underlying
- /// data structure and delaying the actual copy until the next change.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public sealed class HashSet : ICollection, ICollection, ICloneable, INotifyCollectionChanged
- where T : class
- {
- Dictionary _dict;
- bool _copyOnWrite;
-
- ///
- /// This event is raised whenever the collection changes.
- ///
- public event NotifyCollectionChangedEventHandler CollectionChanged;
-
- ///
- /// Creates a new, empty set.
- ///
- public HashSet()
- {
- _dict = new Dictionary();
- }
-
- ///
- /// Creates a copy of the existing set.
- ///
- public HashSet(HashSet existingSet)
- {
- existingSet._copyOnWrite = true;
- this._copyOnWrite = true;
- _dict = existingSet._dict;
- }
-
- ///
- /// Adds the item to the set.
- /// Trying to add null will return false without changing the collection.
- ///
- /// True when the item was added, false when it was not added because it already is in the set
- public bool Add(T item)
- {
- if (item == null)
- return false;
- if (_dict.ContainsKey(item)) {
- return false;
- } else {
- CopyIfRequired();
- _dict.Add(item, null);
- if (CollectionChanged != null) {
- CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item));
- }
- return true;
- }
- }
-
- ///
- /// Adds a list of items to the set. This is equivalent to calling for each item in .
- ///
- public void AddRange(IEnumerable items)
- {
- foreach (T item in items) {
- Add(item);
- }
- }
-
- private void CopyIfRequired()
- {
- if (_copyOnWrite) {
- _copyOnWrite = false;
- _dict = new Dictionary(_dict);
- }
- }
-
- ///
- /// Removes all items from the set.
- ///
- public void Clear()
- {
- _dict.Clear();
- }
-
- ///
- /// Tests if this set contains the specified item.
- /// Checking for null always returns false.
- ///
- public bool Contains(T item)
- {
- if (item == null)
- return false;
- else
- return _dict.ContainsKey(item);
- }
-
- ///
- /// Gets the number of items in the collection.
- ///
- public int Count {
- get { return _dict.Count; }
- }
-
- ///
- /// Removes an item from the set.
- /// Trying to remove null will return false without changing the collection.
- ///
- public bool Remove(T item)
- {
- if (item == null)
- return false;
- CopyIfRequired();
- if (_dict.Remove(item)) {
- if (CollectionChanged != null) {
- CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item));
- }
- return true;
- } else {
- return false;
- }
- }
-
- ///
- /// Copy all items to the specified array.
- ///
- void ICollection.CopyTo(T[] array, int arrayIndex)
- {
- _dict.Keys.CopyTo(array, arrayIndex);
- }
-
- void ICollection.Add(T item)
- {
- this.Add(item);
- }
-
- bool ICollection.IsReadOnly {
- get { return false; }
- }
-
- #region IEnumerable Members
- ///
- /// Gets an enumerator to enumerate the items in the set.
- ///
- public IEnumerator GetEnumerator()
- {
- return _dict.Keys.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return _dict.Keys.GetEnumerator();
- }
- #endregion
-
- #region ICollection Members
-
- void ICollection.CopyTo(Array array, int index)
- {
- ((ICollection)_dict).CopyTo(array, index);
- }
-
- bool ICollection.IsSynchronized {
- get { return false; }
- }
-
- object ICollection.SyncRoot {
- get { return null; }
- }
-
- #endregion
-
- #region ICloneable Members
-
- ///
- /// Create a copy of this set.
- ///
- public HashSet Clone()
- {
- return new HashSet(this);
- }
-
- object ICloneable.Clone()
- {
- return this.Clone();
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs
deleted file mode 100644
index d5c29f5bdf..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs
+++ /dev/null
@@ -1,328 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Reflection;
-using System.Collections;
-using System.Windows;
-using System.ComponentModel;
-using System.Diagnostics;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Contains helper methods for retrieving meta data.
- ///
- public static class Metadata
- {
- ///
- /// Gets the full name of a dependency property (OwnerType.FullName + "." + Name).
- ///
- public static string GetFullName(this DependencyProperty p)
- {
- return p.OwnerType.FullName + "." + p.Name;
- }
-
- // TODO: do we really want to store these values in a static dictionary?
- // Why not per-design context (as a service?)
- static Dictionary> standardValues = new Dictionary>();
-
- ///
- /// Registers a set of standard values for a by using the
- /// public static properties of the type .
- ///
- /// Metadata.AddStandardValues(typeof(Brush), typeof(Brushes));
- public static void AddStandardValues(Type type, Type valuesContainer)
- {
- AddStandardValues(type,
- valuesContainer.GetProperties(BindingFlags.Public | BindingFlags.Static)
- .Select(p => p.GetValue(null, null)));
- }
-
- ///
- /// Registers a set of standard for a .
- ///
- /// You can call this method multiple times to add additional standard values.
- public static void AddStandardValues(Type type, IEnumerable values)
- {
- List list;
- lock (standardValues) {
- if (!standardValues.TryGetValue(type, out list)) {
- list = new List();
- standardValues[type] = list;
- }
- foreach (var v in values) {
- list.Add(v);
- }
- }
- }
-
- ///
- /// Retrieves the standard values for the specified .
- ///
- public static IEnumerable GetStandardValues(Type type)
- {
- if (type.IsEnum) {
- return Enum.GetValues(type);
- }
- List values;
- lock (standardValues) {
- if (standardValues.TryGetValue(type, out values)) {
- return values;
- }
- }
- return null;
- }
-
- //static Dictionary categories = new Dictionary();
-
- //public static void AddCategory(DependencyProperty p, string category)
- //{
- // lock (categories) {
- // categories[p.GetFullName()] = category;
- // }
- //}
-
- //public static void AddCategory(Type type, string property, string category)
- //{
- // lock (categories) {
- // categories[type + "." + property] = category;
- // }
- //}
-
- //public static string GetCategory(DesignItemProperty p)
- //{
- // string result;
- // lock (categories) {
- // if (categories.TryGetValue(p.DependencyFullName, out result)) {
- // return result;
- // }
- // }
- // return p.Category;
- //}
-
- //static HashSet advancedProperties = new HashSet();
-
- //public static void AddAdvancedProperty(DependencyProperty p)
- //{
- // lock (advancedProperties) {
- // advancedProperties.Add(p.GetFullName());
- // }
- //}
-
- //public static void AddAdvancedProperty(Type type, string member)
- //{
- // lock (advancedProperties) {
- // advancedProperties.Add(type.FullName + "." + member);
- // }
- //}
-
- //public static bool IsAdvanced(DesignItemProperty p)
- //{
- // lock (advancedProperties) {
- // if (advancedProperties.Contains(p.DependencyFullName)) {
- // return true;
- // }
- // }
- // return p.IsAdvanced;
- //}
-
- static HashSet hiddenProperties = new HashSet();
-
- ///
- /// Hides the specified property (marks it as not browsable).
- ///
- public static void HideProperty(DependencyProperty p)
- {
- lock (hiddenProperties) {
- hiddenProperties.Add(p.GetFullName());
- }
- }
-
- ///
- /// Hides the specified property (marks it as not browsable).
- ///
- public static void HideProperty(Type type, string member)
- {
- lock (hiddenProperties) {
- hiddenProperties.Add(type.FullName + "." + member);
- }
- }
-
- ///
- /// Gets whether the specified property is browsable (should be visible in property grids).
- ///
- public static bool IsBrowsable(DesignItemProperty p)
- {
- lock (hiddenProperties) {
- if (hiddenProperties.Contains(p.DependencyFullName)) {
- return false;
- }
- }
- return true;
- }
-
- //public static string[] CategoryOrder { get; set; }
-
- static HashSet popularProperties = new HashSet();
-
- ///
- /// Registers a popular property (shown first in the property grid).
- ///
- public static void AddPopularProperty(DependencyProperty p)
- {
- lock (popularProperties) {
- popularProperties.Add(p.GetFullName());
- }
- }
-
- ///
- /// Registers a popular property (shown first in the property grid).
- ///
- public static void AddPopularProperty(Type type, string member)
- {
- lock (popularProperties) {
- popularProperties.Add(type.FullName + "." + member);
- }
- }
-
- ///
- /// Gets whether the specified property was registered as popular.
- ///
- public static bool IsPopularProperty(DesignItemProperty p)
- {
- lock (popularProperties) {
- if (popularProperties.Contains(p.DependencyFullName)) {
- return true;
- }
- }
- return false;
- }
-
- static HashSet popularControls = new HashSet();
-
- ///
- /// Registers a popular control (visible in the default toolbox).
- ///
- public static void AddPopularControl(Type t)
- {
- lock (popularControls) {
- popularControls.Add(t);
- }
- }
-
- ///
- /// Gets the list of popular controls.
- ///
- public static IEnumerable GetPopularControls()
- {
- lock (popularControls) {
- return popularControls.ToArray();
- }
- }
-
- ///
- /// Gets whether the specified control was registered as popular.
- ///
- public static bool IsPopularControl(Type t)
- {
- lock (popularControls) {
- return popularControls.Contains(t);
- }
- }
-
- static Dictionary ranges = new Dictionary();
-
- ///
- /// Registers the value range for the property.
- ///
- public static void AddValueRange(DependencyProperty p, double min, double max)
- {
- lock (ranges) {
- ranges[p.GetFullName()] = new NumberRange() { Min = min, Max = max };
- }
- }
-
- ///
- /// Gets the registered value range for the property, or null if no range was registered.
- ///
- public static NumberRange GetValueRange(DesignItemProperty p)
- {
- NumberRange r;
- lock (ranges) {
- if (ranges.TryGetValue(p.DependencyFullName, out r)) {
- return r;
- }
- }
- return null;
- }
-
- static HashSet placementDisabled = new HashSet();
-
- ///
- /// Disables the default placement behaviour (setting the ContentProperty) for the type.
- ///
- public static void DisablePlacement(Type type)
- {
- lock (placementDisabled) {
- placementDisabled.Add(type);
- }
- }
-
- ///
- /// Gets whether thr default placement behaviour (setting the ContentProperty) was disabled for the type.
- ///
- public static bool IsPlacementDisabled(Type type)
- {
- lock (placementDisabled) {
- return placementDisabled.Contains(type);
- }
- }
-
- static Dictionary defaultSizes = new Dictionary();
-
- ///
- /// Registers a default size for new controls of the specified type.
- ///
- public static void AddDefaultSize(Type t, Size s)
- {
- lock (defaultSizes) {
- defaultSizes[t] = s;
- }
- }
-
- ///
- /// Gets the default size for new controls of the specified type,
- /// or new Size(double.NaN, double.NaN) if no default size was registered.
- ///
- public static Size GetDefaultSize(Type t)
- {
- Size s;
- lock (defaultSizes) {
- while (t != null) {
- if (defaultSizes.TryGetValue(t, out s)) {
- return s;
- }
- t = t.BaseType;
- }
- }
- return new Size(double.NaN, double.NaN);
- }
- }
-
- ///
- /// Represets the minimum and maximum valid value for a double property.
- ///
- public class NumberRange
- {
- ///
- /// Gets/Sets the minimum value.
- ///
- public double Min { get; set; }
-
- ///
- /// Gets/Sets the maximum value.
- ///
- public double Max { get; set; }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/MouseInteraction.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/MouseInteraction.cs
deleted file mode 100644
index 94a1b54e4d..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/MouseInteraction.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-using System.Windows.Input;
-
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign
-{
- // Interfaces for mouse interaction on the design surface.
-
- ///
- /// Behavior interface implemented by elements to handle the mouse down event
- /// on them.
- ///
- public interface IHandlePointerToolMouseDown
- {
- ///
- /// Called to handle the mouse down event.
- ///
- void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result);
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementAlignment.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementAlignment.cs
deleted file mode 100644
index 3e2ef60e1b..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementAlignment.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// A combination of HorizontalAlignment/VerticalAlignment.
- ///
- public struct PlacementAlignment : IEquatable
- {
- readonly HorizontalAlignment horizontal;
- readonly VerticalAlignment vertical;
-
- ///
- /// Gets the horizontal component.
- ///
- public HorizontalAlignment Horizontal {
- get { return horizontal; }
- }
-
- ///
- /// Gets the vertical component.
- ///
- public VerticalAlignment Vertical {
- get { return vertical; }
- }
-
- ///
- /// Creates a new instance of the PlacementAlignment structure.
- ///
- public PlacementAlignment(HorizontalAlignment horizontal, VerticalAlignment vertical)
- {
- if (horizontal == HorizontalAlignment.Stretch)
- throw new ArgumentException("Strech is not a valid value", "horizontal");
- if (vertical == VerticalAlignment.Stretch)
- throw new ArgumentException("Strech is not a valid value", "vertical");
- this.horizontal = horizontal;
- this.vertical = vertical;
- }
-
- #region Equals and GetHashCode implementation
- /// Compares this to .
- public override bool Equals(object obj)
- {
- if (obj is PlacementAlignment)
- return Equals((PlacementAlignment)obj); // use Equals method below
- else
- return false;
- }
-
- /// Compares this to .
- public bool Equals(PlacementAlignment other)
- {
- return this.horizontal == other.horizontal && this.vertical == other.vertical;
- }
-
- ///
- /// Gets the hash code.
- ///
- public override int GetHashCode()
- {
- unchecked {
- return horizontal.GetHashCode() * 27 + vertical.GetHashCode();
- }
- }
-
- /// Compares to .
- public static bool operator ==(PlacementAlignment lhs, PlacementAlignment rhs)
- {
- return lhs.Equals(rhs);
- }
-
- /// Compares to .
- public static bool operator !=(PlacementAlignment lhs, PlacementAlignment rhs)
- {
- return !(lhs.Equals(rhs));
- }
- #endregion
-
-
- /// Top left
- public static readonly PlacementAlignment TopLeft = new PlacementAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
- /// Top center
- public static readonly PlacementAlignment Top = new PlacementAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);
- /// Top right
- public static readonly PlacementAlignment TopRight = new PlacementAlignment(HorizontalAlignment.Right, VerticalAlignment.Top);
- /// Center left
- public static readonly PlacementAlignment Left = new PlacementAlignment(HorizontalAlignment.Left, VerticalAlignment.Center);
- /// Center center
- public static readonly PlacementAlignment Center = new PlacementAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
- /// Center right
- public static readonly PlacementAlignment Right = new PlacementAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);
- /// Bottom left
- public static readonly PlacementAlignment BottomLeft = new PlacementAlignment(HorizontalAlignment.Left, VerticalAlignment.Bottom);
- /// Bottom center
- public static readonly PlacementAlignment Bottom = new PlacementAlignment(HorizontalAlignment.Center, VerticalAlignment.Bottom);
- /// Bottom right
- public static readonly PlacementAlignment BottomRight = new PlacementAlignment(HorizontalAlignment.Right, VerticalAlignment.Bottom);
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs
deleted file mode 100644
index af34bd436a..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Behavior interface implemented by container elements to support resizing
- /// child elements.
- ///
- public interface IPlacementBehavior
- {
- ///
- /// Gets if the child element can be resized.
- ///
- bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position);
-
- ///
- /// Starts placement mode for this container.
- ///
- void BeginPlacement(PlacementOperation operation);
-
- ///
- /// Ends placement mode for this container.
- ///
- void EndPlacement(PlacementOperation operation);
-
- ///
- /// Gets the original position of the child item.
- ///
- Rect GetPosition(PlacementOperation operation, DesignItem child);
-
- ///
- /// Is called before SetPosition is called for the placed items.
- ///
- void BeforeSetPosition(PlacementOperation operation);
-
- ///
- /// Updates the placement of the element specified in the placement operation.
- ///
- void SetPosition(PlacementInformation info);
-
- ///
- /// Gets if leaving this container is allowed for the specified operation.
- ///
- bool CanLeaveContainer(PlacementOperation operation);
-
- ///
- /// Remove the placed children from this container.
- ///
- void LeaveContainer(PlacementOperation operation);
-
- ///
- /// Gets if entering this container is allowed for the specified operation.
- ///
- bool CanEnterContainer(PlacementOperation operation);
-
- ///
- /// Let the placed children enter this container.
- ///
- void EnterContainer(PlacementOperation operation);
- }
-
- ///
- /// Behavior interface for root elements (elements where item.Parent is null).
- /// Is used instead of to support resizing the root element.
- ///
- public interface IRootPlacementBehavior : IPlacementBehavior
- {
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementInformation.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementInformation.cs
deleted file mode 100644
index 2e1b97ff06..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementInformation.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Stores information about the placement of an individual item during a .
- ///
- public sealed class PlacementInformation
- {
- Rect originalBounds, bounds;
- readonly DesignItem item;
- readonly PlacementOperation operation;
-
- internal PlacementInformation(DesignItem item, PlacementOperation operation)
- {
- this.item = item;
- this.operation = operation;
- }
-
- ///
- /// The item being placed.
- ///
- public DesignItem Item {
- get { return item; }
- }
-
- ///
- /// The to which this PlacementInformation belongs.
- ///
- public PlacementOperation Operation {
- get { return operation; }
- }
-
- ///
- /// Gets/sets the original bounds.
- ///
- public Rect OriginalBounds {
- get { return originalBounds; }
- set { originalBounds = value; }
- }
-
- ///
- /// Gets/sets the current bounds of the item.
- ///
- public Rect Bounds {
- get { return bounds; }
- set { bounds = value; }
- }
-
- public PlacementAlignment ResizeThumbAlignment { get; set; }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
deleted file mode 100644
index 3d23803894..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Input;
-
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Stores data about a placement operation.
- ///
- public sealed class PlacementOperation
- {
- readonly ChangeGroup changeGroup;
- readonly ReadOnlyCollection placedItems;
- readonly PlacementType type;
- DesignItem currentContainer;
- IPlacementBehavior currentContainerBehavior;
- bool isAborted, isCommitted;
-
- #region Properties
- ///
- /// The items being placed.
- ///
- public ReadOnlyCollection PlacedItems {
- get { return placedItems; }
- }
-
- ///
- /// The type of the placement being done.
- ///
- public PlacementType Type {
- get { return type; }
- }
-
- ///
- /// Gets if the placement operation was aborted.
- ///
- public bool IsAborted {
- get { return isAborted; }
- }
-
- ///
- /// Gets if the placement operation was committed.
- ///
- public bool IsCommitted {
- get { return isCommitted; }
- }
-
- ///
- /// Gets the current container for the placement operation.
- ///
- public DesignItem CurrentContainer {
- get { return currentContainer; }
- }
-
- ///
- /// Gets the placement behavior for the current container.
- ///
- public IPlacementBehavior CurrentContainerBehavior {
- get { return currentContainerBehavior; }
- }
-
- #endregion
-
- #region Container changing
- ///
- /// Make the placed item switch the container.
- /// This method assumes that you already have checked if changing the container is possible.
- ///
- public void ChangeContainer(DesignItem newContainer)
- {
- if (newContainer == null)
- throw new ArgumentNullException("newContainer");
- if (isAborted || isCommitted)
- throw new InvalidOperationException("The operation is not running anymore.");
- if (currentContainer == newContainer)
- return;
-
- if (!currentContainerBehavior.CanLeaveContainer(this))
- throw new NotSupportedException("The items cannot be removed from their parent container.");
-
- try {
- currentContainerBehavior.LeaveContainer(this);
-
- System.Windows.Media.GeneralTransform transform = currentContainer.View.TransformToVisual(newContainer.View);
- foreach (PlacementInformation info in placedItems) {
- info.OriginalBounds = transform.TransformBounds(info.OriginalBounds);
- info.Bounds = transform.TransformBounds(info.Bounds);
- }
-
- currentContainer = newContainer;
- currentContainerBehavior = newContainer.GetBehavior();
-
- Debug.Assert(currentContainerBehavior != null);
- currentContainerBehavior.EnterContainer(this);
- } catch (Exception ex) {
- Debug.WriteLine(ex.ToString());
- Abort();
- throw;
- }
- }
- #endregion
-
- #region Delete Items
- ///
- /// Deletes the items being placed, and commits the placement operation.
- ///
- public void DeleteItemsAndCommit()
- {
- if (isAborted || isCommitted)
- throw new InvalidOperationException("The operation is not running anymore.");
- if (!currentContainerBehavior.CanLeaveContainer(this))
- throw new NotSupportedException("The items cannot be removed from their parent container.");
-
- currentContainerBehavior.LeaveContainer(this);
- Commit();
- }
- #endregion
-
- #region Start
- ///
- /// Starts a new placement operation that changes the placement of .
- ///
- /// The items to be placed.
- /// The type of the placement.
- /// A PlacementOperation object.
- ///
- /// You MUST call either or on the returned PlacementOperation
- /// once you are done with it, otherwise a ChangeGroup will be left open and Undo/Redo will fail to work!
- ///
- public static PlacementOperation Start(ICollection placedItems, PlacementType type)
- {
- if (placedItems == null)
- throw new ArgumentNullException("placedItems");
- if (type == null)
- throw new ArgumentNullException("type");
- DesignItem[] items = placedItems.ToArray();
- if (items.Length == 0)
- throw new ArgumentException("placedItems.Length must be > 0");
-
- PlacementOperation op = new PlacementOperation(items, type);
- try {
- if (op.currentContainerBehavior == null)
- throw new InvalidOperationException("Starting the operation is not supported");
-
- op.currentContainerBehavior.BeginPlacement(op);
- foreach (PlacementInformation info in op.placedItems) {
- info.OriginalBounds = op.currentContainerBehavior.GetPosition(op, info.Item);
- info.Bounds = info.OriginalBounds;
- }
- } catch (Exception ex) {
- Debug.WriteLine(ex.ToString());
- op.changeGroup.Abort();
- throw;
- }
- return op;
- }
- private PlacementOperation(DesignItem[] items, PlacementType type)
- {
- PlacementInformation[] information = new PlacementInformation[items.Length];
- for (int i = 0; i < information.Length; i++) {
- information[i] = new PlacementInformation(items[i], this);
- }
- this.placedItems = new ReadOnlyCollection(information);
- this.type = type;
-
- this.currentContainer = items[0].Parent;
- this.currentContainerBehavior = GetPlacementBehavior(items);
-
- this.changeGroup = items[0].Context.OpenGroup(type.ToString(), items);
- }
-
- ///
- /// Gets the placement behavior associated with the specified items.
- ///
- public static IPlacementBehavior GetPlacementBehavior(ICollection items)
- {
- if (items == null)
- throw new ArgumentNullException("items");
- if (items.Count == 0)
- return null;
- DesignItem parent = items.First().Parent;
- foreach (DesignItem item in items.Skip(1)) {
- if (item.Parent != parent)
- return null;
- }
- if (parent != null)
- return parent.GetBehavior();
- else if (items.Count == 1)
- return items.First().GetBehavior();
- else
- return null;
- }
- #endregion
-
- #region StartInsertNewComponents
- ///
- /// Try to insert new components into the container.
- ///
- /// The container that should become the parent of the components.
- /// The components to add to the container.
- /// The rectangle specifying the position the element should get.
- /// The type
- /// The operation that inserts the new components, or null if inserting is not possible.
- public static PlacementOperation TryStartInsertNewComponents(DesignItem container, IList placedItems, IList positions, PlacementType type)
- {
- if (container == null)
- throw new ArgumentNullException("container");
- if (placedItems == null)
- throw new ArgumentNullException("placedItems");
- if (positions == null)
- throw new ArgumentNullException("positions");
- if (type == null)
- throw new ArgumentNullException("type");
- if (placedItems.Count == 0)
- throw new ArgumentException("placedItems.Count must be > 0");
- if (placedItems.Count != positions.Count)
- throw new ArgumentException("positions.Count must be = placedItems.Count");
-
- DesignItem[] items = placedItems.ToArray();
-
- PlacementOperation op = new PlacementOperation(items, type);
- try {
- for (int i = 0; i < items.Length; i++) {
- op.placedItems[i].OriginalBounds = op.placedItems[i].Bounds = positions[i];
- }
- op.currentContainer = container;
- op.currentContainerBehavior = container.GetBehavior();
- if (op.currentContainerBehavior == null || !op.currentContainerBehavior.CanEnterContainer(op)) {
- op.changeGroup.Abort();
- return null;
- }
- op.currentContainerBehavior.EnterContainer(op);
- } catch (Exception ex) {
- Debug.WriteLine(ex.ToString());
- op.changeGroup.Abort();
- throw;
- }
- return op;
- }
- #endregion
-
- #region ChangeGroup handling
- ///
- /// Gets/Sets the description of the underlying change group.
- ///
- public string Description {
- get { return changeGroup.Title; }
- set { changeGroup.Title = value; }
- }
-
- ///
- /// Aborts the operation.
- /// This aborts the underlying change group, reverting all changes done while the operation was running.
- ///
- public void Abort()
- {
- if (!isAborted) {
- if (isCommitted)
- throw new InvalidOperationException("PlacementOperation is committed.");
- isAborted = true;
- currentContainerBehavior.EndPlacement(this);
- changeGroup.Abort();
- }
- }
-
- ///
- /// Commits the operation.
- /// This commits the underlying change group.
- ///
- public void Commit()
- {
- if (isAborted || isCommitted)
- throw new InvalidOperationException("PlacementOperation is already aborted/committed.");
- isCommitted = true;
- currentContainerBehavior.EndPlacement(this);
- changeGroup.Commit();
- }
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementType.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementType.cs
deleted file mode 100644
index 4430d4abad..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementType.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Describes how a placement is done.
- ///
- public sealed class PlacementType
- {
- ///
- /// Placement is done by resizing an element in a drag'n'drop operation.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly PlacementType Resize = Register("Resize");
-
- ///
- /// Placement is done by moving an element in a drag'n'drop operation.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly PlacementType Move = Register("Move");
-
- ///
- /// Adding an element to a specified position in the container.
- /// AddItem is used when dragging a toolbox item to the design surface.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly PlacementType AddItem = Register("AddItem");
-
- ///
- /// Not a "real" placement, but deleting the element.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
- public static readonly PlacementType Delete = Register("Delete");
-
- readonly string name;
-
- private PlacementType(string name)
- {
- this.name = name;
- }
-
- ///
- /// Creates a new unique PlacementKind.
- ///
- /// The name to return from a ToString() call.
- /// Note that two PlacementTypes with the same name are NOT equal!
- public static PlacementType Register(string name)
- {
- return new PlacementType(name);
- }
-
- ///
- /// Gets the name used to register this PlacementType.
- ///
- public override string ToString()
- {
- return name;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Category.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Category.cs
deleted file mode 100644
index 2ca2918a62..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Category.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using ICSharpCode.WpfDesign.PropertyGrid;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// View-Model class for a property grid category.
- ///
- public class Category : INotifyPropertyChanged
- {
- // don't warn on missing XML comments in View-Model
- #pragma warning disable 1591
-
- public Category(string name)
- {
- Name = name;
- Properties = new PropertyNodeCollection();
- //MoreProperties = new ObservableCollection();
- }
-
- public string Name { get; private set; }
- public PropertyNodeCollection Properties { get; private set; }
- //public ObservableCollection MoreProperties { get; private set; }
-
- bool isExpanded = true;
-
- public bool IsExpanded {
- get {
- return isExpanded;
- }
- set {
- isExpanded = value;
- RaisePropertyChanged("IsExpanded");
- }
- }
-
- //bool showMore;
- //internal bool ShowMoreByFilter;
-
- //public bool ShowMore {
- // get {
- // return showMore;
- // }
- // set {
- // showMore = value;
- // RaisePropertyChanged("ShowMore");
- // }
- //}
-
- bool isVisible;
-
- public bool IsVisible
- {
- get
- {
- return isVisible;
- }
- set
- {
- isVisible = value;
- RaisePropertyChanged("IsVisible");
- }
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
deleted file mode 100644
index 330f4d4d17..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Input;
-using ICSharpCode.WpfDesign.PropertyGrid.Editors;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// Manages registered type and property editors.
- ///
- public static class EditorManager
- {
- // property return type => editor type
- static Dictionary typeEditors = new Dictionary();
- // property full name => editor type
- static Dictionary propertyEditors = new Dictionary();
-
- ///
- /// Creates a property editor for the specified
- ///
- public static FrameworkElement CreateEditor(DesignItemProperty property)
- {
- Type editorType;
- if (!propertyEditors.TryGetValue(property.FullName, out editorType)) {
- var type = property.ReturnType;
- while (type != null) {
- if (typeEditors.TryGetValue(type, out editorType)) {
- break;
- }
- type = type.BaseType;
- }
- if (editorType == null) {
- var standardValues = Metadata.GetStandardValues(property.ReturnType);
- if (standardValues != null) {
- return new ComboBoxEditor() { ItemsSource = standardValues };
- }
- return new TextBoxEditor();
- }
- }
- return (FrameworkElement)Activator.CreateInstance(editorType);
- }
-
- ///
- /// Registers property editors defined in the specified assembly.
- ///
- public static void RegisterAssembly(Assembly assembly)
- {
- if (assembly == null)
- throw new ArgumentNullException("assembly");
-
- foreach (Type type in assembly.GetExportedTypes()) {
- foreach (TypeEditorAttribute editorAttribute in type.GetCustomAttributes(typeof(TypeEditorAttribute), false)) {
- CheckValidEditor(type);
- typeEditors[editorAttribute.SupportedPropertyType] = type;
- }
- foreach (PropertyEditorAttribute editorAttribute in type.GetCustomAttributes(typeof(PropertyEditorAttribute), false)) {
- CheckValidEditor(type);
- string propertyName = editorAttribute.PropertyDeclaringType.FullName + "." + editorAttribute.PropertyName;
- propertyEditors[propertyName] = type;
- }
- }
- }
-
- static void CheckValidEditor(Type type)
- {
- if (!typeof(FrameworkElement).IsAssignableFrom(type)) {
- throw new DesignerException("Editor types must derive from FrameworkElement!");
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml
deleted file mode 100644
index 037a1ad28e..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
deleted file mode 100644
index bef62a96f1..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-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;
-using System.Windows.Controls.Primitives;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
-{
- [TypeEditor(typeof(Enum))]
- public partial class ComboBoxEditor
- {
- ///
- /// Create a new ComboBoxEditor instance.
- ///
- public ComboBoxEditor()
- {
- InitializeComponent();
- }
-
- ///
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- var popup = (Popup)Template.FindName("PART_Popup", this);
- popup.SetValue(FontWeightProperty, FontWeights.Normal);
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml
deleted file mode 100644
index a36db00d81..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
deleted file mode 100644
index 54fd974a86..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-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;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
-{
- public partial class TextBoxEditor
- {
- ///
- /// Creates a new TextBoxEditor instance.
- ///
- public TextBoxEditor()
- {
- InitializeComponent();
- }
-
- ///
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.Key == Key.Enter) {
- BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource();
- SelectAll();
- } else if (e.Key == Key.Escape) {
- BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyEditorAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyEditorAttribute.cs
deleted file mode 100644
index e0c804ae53..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyEditorAttribute.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2254 $
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// Attribute to specify that the decorated class is a editor for the specified property.
- ///
- [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
- public sealed class PropertyEditorAttribute : Attribute
- {
- readonly Type propertyDeclaringType;
- readonly string propertyName;
-
- ///
- /// Creates a new PropertyEditorAttribute that specifies that the decorated class is a editor
- /// for the ".".
- ///
- public PropertyEditorAttribute(Type propertyDeclaringType, string propertyName)
- {
- if (propertyDeclaringType == null)
- throw new ArgumentNullException("propertyDeclaringType");
- if (propertyName == null)
- throw new ArgumentNullException("propertyName");
- this.propertyDeclaringType = propertyDeclaringType;
- this.propertyName = propertyName;
- }
-
- ///
- /// Gets the type that declares the property that the decorated editor supports.
- ///
- public Type PropertyDeclaringType {
- get { return propertyDeclaringType; }
- }
-
- ///
- /// Gets the name of the property that the decorated editor supports.
- ///
- public string PropertyName {
- get { return propertyName; }
- }
- }
-}
-
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs
deleted file mode 100644
index 9c30e60b95..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Windows;
-using System.Windows.Controls;
-using System.Collections.ObjectModel;
-using System.Windows.Data;
-using System.Windows.Media;
-using System.Windows.Markup;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// View-Model class for the property grid.
- ///
- public class PropertyNode : INotifyPropertyChanged
- {
- // don't warn on missing XML comments in View-Model
- #pragma warning disable 1591
-
- static object Unset = new object();
-
- public DesignItemProperty[] Properties { get; private set; }
- bool raiseEvents = true;
- bool hasStringConverter;
-
- public string Name { get { return FirstProperty.Name; } }
- public bool IsEvent { get { return FirstProperty.IsEvent; } }
- public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } }
- public FrameworkElement Editor { get; private set; }
- public DesignItemProperty FirstProperty { get { return Properties[0]; } }
-
- public PropertyNode Parent { get; private set; }
- public int Level { get; private set; }
- public Category Category { get; set; }
- public ObservableCollection Children { get; private set; }
- public ObservableCollection MoreChildren { get; private set; }
-
- bool isExpanded;
-
- public bool IsExpanded {
- get {
- return isExpanded;
- }
- set {
- isExpanded = value;
- UpdateChildren();
- RaisePropertyChanged("IsExpanded");
- }
- }
-
- public bool HasChildren {
- get { return Children.Count > 0 || MoreChildren.Count > 0; }
- }
-
- public object Description {
- get {
- IPropertyDescriptionService s = Services.GetService();
- if (s != null) {
- return s.GetDescription(FirstProperty);
- }
- return null;
- }
- }
-
- public object Value {
- get {
- if (IsAmbiguous) return null;
- var result = FirstProperty.ValueOnInstance;
- if (result == DependencyProperty.UnsetValue) return null;
- return result;
- }
- set {
- SetValueCore(value);
- }
- }
-
- public string ValueString {
- get {
- if (ValueItem == null || ValueItem.Component is MarkupExtension) {
- if (Value == null) return null;
- if (hasStringConverter) {
- return FirstProperty.TypeConverter.ConvertToInvariantString(Value);
- }
- return "(" + Value.GetType().Name + ")";
- }
- return "(" + ValueItem.ComponentType.Name + ")";
- }
- set {
- // TODO: Doesn't work for some reason
- try {
- Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value);
- } catch {
- OnValueOnInstanceChanged();
- }
- }
- }
-
- public bool IsEnabled {
- get {
- return ValueItem == null && hasStringConverter;
- }
- }
-
- public bool IsSet {
- get {
- foreach (var p in Properties) {
- if (p.IsSet) return true;
- }
- return false;
- }
- }
-
- public FontWeight FontWeight {
- get {
- return IsSet ? FontWeights.Bold : FontWeights.Normal;
- }
- }
-
- public Brush NameForeground {
- get {
- if (ValueItem != null) {
- if (ValueItem.Component is BindingBase)
- return Brushes.DarkGoldenrod;
- if (ValueItem.Component is StaticResourceExtension ||
- ValueItem.Component is DynamicResourceExtension)
- return Brushes.DarkGreen;
- }
- return SystemColors.WindowTextBrush;
- }
- }
-
- public DesignItem ValueItem {
- get {
- if (Properties.Length == 1) {
- return FirstProperty.Value;
- }
- return null;
- }
- }
-
- public bool IsAmbiguous {
- get {
- foreach (var p in Properties) {
- if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) {
- return true;
- }
- }
- return false;
- }
- }
-
- bool isVisible;
-
- public bool IsVisible
- {
- get
- {
- return isVisible;
- }
- set
- {
- isVisible = value;
- RaisePropertyChanged("IsVisible");
- }
- }
-
- public bool CanReset {
- get { return IsSet; }
- }
-
- public void Reset()
- {
- SetValueCore(Unset);
- }
-
- public void CreateBinding()
- {
- Value = new Binding();
- IsExpanded = true;
- }
-
- void SetValueCore(object value)
- {
- raiseEvents = false;
- if (value == Unset) {
- foreach (var p in Properties) {
- p.Reset();
- }
- }
- else {
- foreach (var p in Properties) {
- p.SetValue(value);
- }
- }
- raiseEvents = true;
- OnValueChanged();
- }
-
- void OnValueChanged()
- {
- RaisePropertyChanged("IsSet");
- RaisePropertyChanged("Value");
- RaisePropertyChanged("ValueString");
- RaisePropertyChanged("IsAmbiguous");
- RaisePropertyChanged("FontWeight");
- RaisePropertyChanged("IsEnabled");
- RaisePropertyChanged("NameForeground");
-
- UpdateChildren();
- }
-
- void OnValueOnInstanceChanged()
- {
- RaisePropertyChanged("Value");
- RaisePropertyChanged("ValueString");
- }
-
- public PropertyNode()
- {
- Children = new ObservableCollection();
- MoreChildren = new ObservableCollection();
- }
-
- PropertyNode(DesignItemProperty[] properties, PropertyNode parent) : this()
- {
- this.Parent = parent;
- this.Level = parent == null ? 0 : parent.Level + 1;
- Load(properties);
- }
-
- public void Load(DesignItemProperty[] properties)
- {
- if (Properties != null) {
- foreach (var property in Properties) {
- property.ValueChanged -= new EventHandler(property_ValueChanged);
- property.ValueOnInstanceChanged -= new EventHandler(property_ValueOnInstanceChanged);
- }
- }
-
- this.Properties = properties;
-
- foreach (var property in properties) {
- property.ValueChanged += new EventHandler(property_ValueChanged);
- property.ValueOnInstanceChanged += new EventHandler(property_ValueOnInstanceChanged);
- }
-
- if (Editor == null)
- Editor = EditorManager.CreateEditor(FirstProperty);
-
- hasStringConverter =
- FirstProperty.TypeConverter.CanConvertFrom(typeof(string)) &&
- FirstProperty.TypeConverter.CanConvertTo(typeof(string));
-
- OnValueChanged();
- }
-
- void property_ValueOnInstanceChanged(object sender, EventArgs e)
- {
- if (raiseEvents) OnValueOnInstanceChanged();
- }
-
- void property_ValueChanged(object sender, EventArgs e)
- {
- if (raiseEvents) OnValueChanged();
- }
-
- void UpdateChildren()
- {
- Children.Clear();
- MoreChildren.Clear();
-
- if (Parent == null || Parent.IsExpanded) {
- if (ValueItem != null) {
- var list = TypeHelper.GetAvailableProperties(ValueItem.ComponentType)
- .OrderBy(d => d.Name)
- .Select(d => new PropertyNode(new[] { ValueItem.Properties[d.Name] }, this));
-
- foreach (var node in list) {
- if (Metadata.IsBrowsable(node.FirstProperty)) {
- node.IsVisible = true;
- if (Metadata.IsPopularProperty(node.FirstProperty)) {
- Children.Add(node);
- } else {
- MoreChildren.Add(node);
- }
- }
- }
- }
- }
-
- RaisePropertyChanged("HasChildren");
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void RaisePropertyChanged(string name)
- {
- if (PropertyChanged != null) {
- PropertyChanged(this, new PropertyChangedEventArgs(name));
- }
- }
-
- #endregion
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
deleted file mode 100644
index 9197e0e87f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Collections.ObjectModel;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection.
- ///
- public class SortedObservableCollection : ObservableCollection
- {
- ///
- /// Creates a new SortedObservableCollection instance.
- ///
- /// The function to select the sorting key.
- public SortedObservableCollection(Func keySelector)
- {
- this.keySelector = keySelector;
- this.comparer = Comparer.Default;
- }
-
- Func keySelector;
- IComparer comparer;
-
- ///
- /// Adds an item to a sorted collection.
- ///
- public void AddSorted(T item)
- {
- int i = 0;
- int j = Count - 1;
-
- while (i <= j) {
- int n = (i + j) / 2;
- int c = comparer.Compare(keySelector(item), keySelector(this[n]));
-
- if (c == 0) { i = n; break; }
- if (c > 0) i = n + 1;
- else j = n - 1;
- }
-
- Insert(i, item);
- }
- }
-
- ///
- /// A SortedObservableCollection{PropertyNode, string} that sorts by the PropertyNode's Name.
- ///
- public class PropertyNodeCollection : SortedObservableCollection
- {
- ///
- /// Creates a new PropertyNodeCollection instance.
- ///
- public PropertyNodeCollection() : base(n => n.Name)
- {
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeEditorAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeEditorAttribute.cs
deleted file mode 100644
index d61f8c4e56..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeEditorAttribute.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2254 $
-//
-
-using System;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// Attribute to specify that the decorated class is a editor for properties with the specified
- /// return type.
- ///
- [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
- public sealed class TypeEditorAttribute : Attribute
- {
- readonly Type supportedPropertyType;
-
- ///
- /// Creates a new TypeEditorAttribute that specifies that the decorated class is a editor
- /// for properties with the return type "".
- ///
- public TypeEditorAttribute(Type supportedPropertyType)
- {
- if (supportedPropertyType == null)
- throw new ArgumentNullException("supportedPropertyType");
- this.supportedPropertyType = supportedPropertyType;
- }
-
- ///
- /// Gets the supported property type.
- ///
- public Type SupportedPropertyType {
- get { return supportedPropertyType; }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
deleted file mode 100644
index 4a521b99b8..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-
-namespace ICSharpCode.WpfDesign.PropertyGrid
-{
- ///
- /// Helper class with static methods to get the list of available properties/events.
- ///
- public static class TypeHelper
- {
- ///
- /// Gets the available properties common to all input types.
- ///
- /// List of input types. The list must have at least one element.
- public static IEnumerable GetCommonAvailableProperties(IEnumerable types)
- {
- foreach (var pd1 in GetAvailableProperties(types.First())) {
- bool propertyOk = true;
- foreach (var type in types.Skip(1)) {
- bool typeOk = false;
- foreach (var pd2 in GetAvailableProperties(type)) {
- if (pd1 == pd2) {
- typeOk = true;
- break;
- }
- }
- if (!typeOk) {
- propertyOk = false;
- break;
- }
- }
- if (propertyOk) yield return pd1;
- }
- }
-
- ///
- /// Gets the available properties for the type.
- ///
- public static IEnumerable GetAvailableProperties(Type forType)
- {
- foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) {
- if (!p.IsBrowsable) continue;
- if (p.IsReadOnly) continue;
- if (p.Name.Contains(".")) continue;
- yield return p;
- }
- }
-
- ///
- /// Gets the available events for the type.
- ///
- public static IEnumerable GetAvailableEvents(Type forType)
- {
- foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) {
- if (!e.IsBrowsable) continue;
- if (e.Name.Contains(".")) continue;
- yield return e;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
deleted file mode 100644
index 6e758bb2c4..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// The is a built-in service that manages the list of services.
- /// You can only add services to it, removing or replacing services is not supported because
- /// many designers depend on keeping their services available.
- ///
- public sealed class ServiceContainer : IServiceProvider
- {
- readonly Dictionary _services = new Dictionary();
- readonly Dictionary _waitingSubscribers = new Dictionary();
-
- ///
- /// Gets a collection of all registered services.
- ///
- public IEnumerable AllServices {
- get {
- return _services.Values;
- }
- }
-
- ///
- /// Adds a new service to the container.
- ///
- ///
- /// The type of the service interface to use as a key for the service.
- ///
- ///
- /// The service instance implementing that interface.
- ///
- public void AddService(Type serviceInterface, object serviceInstance)
- {
- if (serviceInterface == null)
- throw new ArgumentNullException("serviceInterface");
- if (serviceInstance == null)
- throw new ArgumentNullException("serviceInstance");
-
- _services.Add(serviceInterface, serviceInstance);
-
- Delegate subscriber;
- if (_waitingSubscribers.TryGetValue(serviceInterface, out subscriber)) {
- _waitingSubscribers.Remove(serviceInterface);
- subscriber.DynamicInvoke(serviceInstance);
- }
- }
-
- ///
- /// Gets the service object of the specified type.
- /// Returns null when the service is not available.
- ///
- public object GetService(Type serviceType)
- {
- object instance;
- _services.TryGetValue(serviceType, out instance);
- return instance;
- }
-
- ///
- /// Gets the service object of the type T.
- /// Returns null when the service is not available.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
- public T GetService() where T : class
- {
- return (T)GetService(typeof(T));
- }
-
- ///
- /// Subscribes to the service of type T.
- /// serviceAvailableAction will be called after the service gets available. If the service is already available,
- /// the action will be called immediately.
- ///
- public void RunWhenAvailable(Action serviceAvailableAction) where T : class
- {
- T service = GetService();
- if (service != null) {
- serviceAvailableAction(service);
- } else {
- Type serviceInterface = typeof(T);
- Delegate existingSubscriber;
- if (_waitingSubscribers.TryGetValue(serviceInterface, out existingSubscriber)) {
- _waitingSubscribers[serviceInterface] = Delegate.Combine(existingSubscriber, serviceAvailableAction);
- } else {
- _waitingSubscribers[serviceInterface] = serviceAvailableAction;
- }
- }
- }
-
- T GetServiceOrThrowException() where T : class
- {
- T service = (T)GetService(typeof(T));
- if (service == null) {
- throw new DesignerException("Could not find guaranteed service " + typeof(T).FullName);
- }
- return service;
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public ISelectionService Selection {
- get {
- return GetServiceOrThrowException();
- }
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public IToolService Tool {
- get {
- return GetServiceOrThrowException();
- }
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public IComponentService Component {
- get {
- return GetServiceOrThrowException();
- }
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public ViewService View {
- get {
- return GetServiceOrThrowException();
- }
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public Extensions.ExtensionManager ExtensionManager {
- get {
- return GetServiceOrThrowException();
- }
- }
-
- ///
- /// Gets the .
- /// Throws an exception if the service is not found.
- ///
- public IDesignPanel DesignPanel {
- get {
- return GetServiceOrThrowException();
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
deleted file mode 100644
index cbe9e49874..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-
-namespace ICSharpCode.WpfDesign
-{
- #region ISelectionService
- ///
- /// Defines the type how a selection can be changed.
- ///
- [Flags]
- public enum SelectionTypes
- {
- ///
- /// No selection type specified.
- ///
- None = 0,
- ///
- /// Automatically determine the selection type using the currently pressed
- /// modifier keys.
- ///
- Auto = 1,
- ///
- /// Change the primary selection only.
- ///
- Primary = 2,
- ///
- /// Toggle the selection.
- ///
- Toggle = 4,
- ///
- /// Add to the selection.
- ///
- Add = 8,
- ///
- /// Remove from the selection.
- ///
- Remove = 0x10,
- ///
- /// Replace the selection.
- ///
- Replace = 0x20
- }
-
- ///
- /// Manages selecting components.
- ///
- public interface ISelectionService
- {
- /// Occurs when the current selection is about to change.
- event EventHandler SelectionChanging;
-
- /// Occurs after the current selection has changed.
- event EventHandler SelectionChanged;
-
- /// Occurs when the primary selection is about to change.
- event EventHandler PrimarySelectionChanging;
- /// Occurs after the primary selection has changed.
- event EventHandler PrimarySelectionChanged;
-
- ///
- /// Gets if the specified component is selected.
- ///
- bool IsComponentSelected(DesignItem component);
-
- ///
- /// Gets the collection of selected components.
- /// This is a copy of the actual selected components collection, the returned copy
- /// of the collection will not reflect future changes to the selection.
- ///
- ICollection SelectedItems { get; }
-
- ///
- /// Replaces the current selection with the specified selection.
- ///
- void SetSelectedComponents(ICollection components);
-
- ///
- /// Modifies the current selection using the specified components and selectionType.
- ///
- void SetSelectedComponents(ICollection components, SelectionTypes selectionType);
-
- /// Gets the object that is currently the primary selected object.
- /// The object that is currently the primary selected object.
- DesignItem PrimarySelection { get; }
-
- /// Gets the count of selected objects.
- /// The number of selected objects.
- int SelectionCount { get; }
- }
- #endregion
-
- #region IComponentService
- /// Supports adding and removing components
- public interface IComponentService
- {
- ///
- /// Gets the site of an existing, registered component.
- ///
- ///
- /// The site of the component, or null if the component is not registered.
- ///
- DesignItem GetDesignItem(object component);
-
- /// Registers a component for usage in the designer.
- DesignItem RegisterComponentForDesigner(object component);
-
- /// Event raised whenever a component is registered
- event EventHandler ComponentRegistered;
- }
- #endregion
-
- #region IViewService
- ///
- /// Service for getting the view for a model or the model for a view.
- ///
- public abstract class ViewService
- {
- ///
- /// Gets the model represented by the specified view element.
- ///
- public abstract DesignItem GetModel(DependencyObject view);
-
- ///
- /// Gets the view for the specified model item.
- /// This is equivalent to using model.View.
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
- public DependencyObject GetView(DesignItem model)
- {
- if (model == null)
- throw new ArgumentNullException("model");
- return model.View;
- }
- }
- #endregion
-
- #region IPropertyDescriptionService
- ///
- /// Used to get a description for properties.
- ///
- public interface IPropertyDescriptionService
- {
- ///
- /// Gets a WPF object representing a graphical description of the property.
- ///
- object GetDescription(DesignItemProperty property);
- }
- #endregion
-
- #region IErrorService
- ///
- /// Service for showing error UI.
- ///
- public interface IErrorService
- {
- ///
- /// Shows an error tool tip.
- ///
- void ShowErrorTooltip(FrameworkElement attachTo, UIElement errorElement);
- }
- #endregion
-
- #region IEventHandlerService
- ///
- /// Service for providing the designer with information about available event handlers.
- ///
- public interface IEventHandlerService
- {
- ///
- /// Creates an event handler for the specified event.
- ///
- void CreateEventHandler(DesignItemProperty eventProperty);
-
- ///
- /// Gets the default event of the specified design item.
- ///
- DesignItemProperty GetDefaultEvent(DesignItem item);
- }
- #endregion
-
- #region ITopLevelWindowService
- ///
- /// Represents a top level window.
- ///
- public interface ITopLevelWindow
- {
- ///
- /// Sets child.Owner to the top level window.
- ///
- void SetOwner(Window child);
-
- ///
- /// Activates the window.
- ///
- bool Activate();
- }
-
- ///
- /// Provides a method to get the top-level-window of any UIElement.
- /// If the WPF Designer is hosted inside a Windows.Forms application, the hosting environment
- /// should specify a ITopLevelWindowService implementation that works with both WPF and Windows.Forms
- /// top-level-windows.
- ///
- public interface ITopLevelWindowService
- {
- ///
- /// Gets the top level window that contains the specified element.
- ///
- ITopLevelWindow GetTopLevelWindow(UIElement element);
- }
- #endregion
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
deleted file mode 100644
index 26c9734af2..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-
-using ICSharpCode.WpfDesign.Adorners;
-
-namespace ICSharpCode.WpfDesign
-{
- ///
- /// Describes a tool that can handle input on the design surface.
- /// Modelled after the description on http://urbanpotato.net/Default.aspx/document/2300
- ///
- public interface ITool
- {
- ///
- /// Gets the cursor used by the tool.
- ///
- Cursor Cursor { get; }
-
- ///
- /// Activates the tool, attaching its event handlers to the design panel.
- ///
- void Activate(IDesignPanel designPanel);
-
- ///
- /// Deactivates the tool, detaching its event handlers from the design panel.
- ///
- void Deactivate(IDesignPanel designPanel);
- }
-
- ///
- /// Service that manages tool selection.
- ///
- public interface IToolService
- {
- ///
- /// Gets the 'pointer' tool.
- /// The pointer tool is the default tool for selecting and moving elements.
- ///
- ITool PointerTool { get; }
-
- ///
- /// Gets/Sets the currently selected tool.
- ///
- ITool CurrentTool { get; set; }
-
- ///
- /// Is raised when the current tool changes.
- ///
- event EventHandler CurrentToolChanged;
- }
-
- ///
- /// Interface for the design panel. The design panel is the UIElement containing the
- /// designed elements and is responsible for handling mouse and keyboard events.
- ///
- public interface IDesignPanel : IInputElement
- {
- ///
- /// Gets the design context used by the DesignPanel.
- ///
- DesignContext Context { get; }
-
- ///
- /// Gets/Sets if the design content is visible for hit-testing purposes.
- ///
- bool IsContentHitTestVisible { get; set; }
-
- ///
- /// Gets/Sets if the adorner layer is visible for hit-testing purposes.
- ///
- bool IsAdornerLayerHitTestVisible { get; set; }
-
- ///
- /// Gets the list of adorners displayed on the design panel.
- ///
- ICollection Adorners { get; }
-
- ///
- /// Performs a hit test on the design surface.
- ///
- DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface);
-
- ///
- /// Performs a hit test on the design surface, raising for each match.
- /// Hit testing continues while the callback returns true.
- ///
- void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate callback);
-
- // The following members were missing in , but
- // are supported on the DesignPanel:
-
- ///
- /// Occurs when a mouse button is pressed.
- ///
- event MouseButtonEventHandler MouseDown;
-
- ///
- /// Occurs when a mouse button is released.
- ///
- event MouseButtonEventHandler MouseUp;
-
- ///
- /// Occurs when a drag operation enters the design panel.
- ///
- event DragEventHandler DragEnter;
-
- ///
- /// Occurs when a drag operation is over the design panel.
- ///
- event DragEventHandler DragOver;
-
- ///
- /// Occurs when a drag operation leaves the design panel.
- ///
- event DragEventHandler DragLeave;
-
- ///
- /// Occurs when an element is dropped on the design panel.
- ///
- event DragEventHandler Drop;
- }
-}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
deleted file mode 100644
index 441627854f..0000000000
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
- {66A378A1-E9F4-4AD5-8946-D0EC06C2902F}
- Debug
- AnyCPU
- Library
- ICSharpCode.WpfDesign
- ICSharpCode.WpfDesign
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml
- False
- False
- 4
- false
- True
- ..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk
- False
- File
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- False
- -Microsoft.Globalization#CA1303
- v3.5
-
-
- true
- Full
- True
- DEBUG;TRACE
- False
-
-
- False
- None
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
- False
-
-
- False
-
-
-
- 3.5
-
-
-
-
- False
-
-
-
-
- Configuration\GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ComboBoxEditor.xaml
-
-
- TextBoxEditor.xaml
-
-
-
-
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/WpfDesign.csproj
index 81b214d4cb..098e8f4d46 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/WpfDesign.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/WpfDesign.csproj
@@ -6,7 +6,6 @@
Library
ICSharpCode.WpfDesign
ICSharpCode.WpfDesign
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml
False
False
4
@@ -15,10 +14,11 @@
..\..\..\..\Main\ICSharpCode.SharpDevelop.snk
False
File
- ..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
False
-Microsoft.Globalization#CA1303
v3.5
+ ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
+ ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml
true
@@ -39,15 +39,7 @@
4194304
AnyCPU
4096
-
-
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml
-
-
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml
-
+