Browse Source

- improved WPF designer in some areas

- added missing implementations of methods in VBNetFormattingStrategy

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4823 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
19406653ea
  1. 2
      samples/XamlDesigner/Document.cs
  2. 1
      samples/XamlDesigner/DocumentView.xaml.cs
  3. 2
      samples/XamlDesigner/MainWindow.xaml.cs
  4. 2
      samples/XamlDesigner/NewFileTemplate.xaml
  5. 14
      samples/XamlDesigner/XamlDesigner.csproj
  6. 7
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  7. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  8. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  9. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs
  10. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelInstanceFactory.cs
  11. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
  12. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  13. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs
  14. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
  15. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  16. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
  17. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ExtensionMethods.cs
  18. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementInformation.cs
  19. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  20. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

2
samples/XamlDesigner/Document.cs

@ -195,14 +195,12 @@ namespace ICSharpCode.XamlDesigner @@ -195,14 +195,12 @@ namespace ICSharpCode.XamlDesigner
void UpdateXaml()
{
if (DesignContext.CanSave && UndoService.CanUndo) {
var sb = new StringBuilder();
using (var xmlWriter = XmlWriter.Create(sb)) {
DesignSurface.SaveDesigner(xmlWriter);
Text = XamlFormatter.Format(sb.ToString());
}
}
}
void UpdateDesign()
{

1
samples/XamlDesigner/DocumentView.xaml.cs

@ -27,6 +27,7 @@ namespace ICSharpCode.XamlDesigner @@ -27,6 +27,7 @@ namespace ICSharpCode.XamlDesigner
uxTextEditor.SetHighlighting("XML");
uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
Document.Mode = DocumentMode.Design;
}
public Document Document { get; private set; }

2
samples/XamlDesigner/MainWindow.xaml.cs

@ -39,6 +39,8 @@ namespace ICSharpCode.XamlDesigner @@ -39,6 +39,8 @@ namespace ICSharpCode.XamlDesigner
LoadSettings();
ProcessPaths(App.Args);
ApplicationCommands.New.Execute(null, this);
}
public static MainWindow Instance;

2
samples/XamlDesigner/NewFileTemplate.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas />
</Window>

14
samples/XamlDesigner/XamlDesigner.csproj

@ -14,10 +14,13 @@ @@ -14,10 +14,13 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<ApplicationManifest>Configuration\app.manifest</ApplicationManifest>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
@ -32,6 +35,15 @@ @@ -32,6 +35,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="AvalonDock, Version=1.1.1231.0, Culture=neutral, PublicKeyToken=85a1e0ada7ec13e4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

7
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -851,7 +851,12 @@ namespace VBNetBinding @@ -851,7 +851,12 @@ namespace VBNetBinding
public override void IndentLine(ITextEditor editor, IDocumentLine line)
{
base.IndentLine(editor, line);
IndentLines(editor, line.LineNumber, line.LineNumber);
}
public override void SurroundSelectionWithComment(ITextEditor editor)
{
SurroundSelectionWithSingleLineComment(editor, "'");
}
#region SearchBracket

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -141,8 +141,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -141,8 +141,7 @@ namespace ICSharpCode.WpfDesign.Designer
public DesignPanel()
{
this.Focusable = true;
this.AllowDrop = false;
this.ClipToBounds = true;
this.Margin = new Thickness(16);
DesignerProperties.SetIsInDesignMode(this, true);
_eatAllHitTestRequests = new EatAllHitTestRequests();

15
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -12,7 +12,8 @@ using System.Windows.Media; @@ -12,7 +12,8 @@ using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionFor(typeof(UIElement))]
[ExtensionFor(typeof(Panel))]
[ExtensionFor(typeof(ContentControl))]
public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior
{
protected override void OnInitialized()
@ -72,11 +73,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -72,11 +73,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual bool CanEnterContainer(PlacementOperation operation)
{
if (ExtendedItem.ContentProperty.IsCollection &&
CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType,
operation.PlacedItems.Select(p => p.Item.Component)))
if (ExtendedItem.ContentProperty.IsCollection)
return CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType,
operation.PlacedItems.Select(p => p.Item.Component));
if (!ExtendedItem.ContentProperty.IsSet)
return true;
return !ExtendedItem.ContentProperty.IsSet;
object value = ExtendedItem.ContentProperty.ValueOnInstance;
// don't overwrite non-primitive values like bindings
return ExtendedItem.ContentProperty.Value == null && (value is string && string.IsNullOrEmpty(value as string));
}
public virtual void EnterContainer(PlacementOperation operation)

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
}
}
[ExtensionFor(typeof(HeaderedContentControl))]
[ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
public class HeaderedContentControlInitializer : DefaultInitializer
{
public override void InitializeDefaults(DesignItem item)
@ -35,6 +35,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers @@ -35,6 +35,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
if (headerProperty.ValueOnInstance == null) {
headerProperty.SetValue(item.ComponentType.Name);
}
DesignItemProperty contentProperty = item.Properties["Content"];
if (contentProperty.ValueOnInstance == null) {
contentProperty.SetValue(new PanelInstanceFactory().CreateInstance(typeof(Canvas)));
}
}
}

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PanelInstanceFactory.cs

@ -44,6 +44,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -44,6 +44,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
[ExtensionFor(typeof(HeaderedContentControl))]
public sealed class HeaderedContentControlInstanceFactory : CustomInstanceFactory
{
Brush _transparentBrush = new SolidColorBrush(Colors.Transparent);
/// <summary>
/// Creates an instance of the specified type, passing the specified arguments to its constructor.
/// </summary>
public override object CreateInstance(Type type, params object[] arguments)
{
object instance = base.CreateInstance(type, arguments);
Control control = instance as Control;
if (control != null) {
if (control.Background == null) {
control.Background = _transparentBrush;
}
TypeDescriptionProvider provider = new DummyValueInsteadOfNullTypeDescriptionProvider(
TypeDescriptor.GetProvider(control), "Background", _transparentBrush);
TypeDescriptor.AddProvider(provider, control);
}
return instance;
}
}
sealed class DummyValueInsteadOfNullTypeDescriptionProvider : TypeDescriptionProvider
{
// By using a TypeDescriptionProvider, we can intercept all access to the property that is

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs

@ -104,7 +104,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -104,7 +104,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
result.Width = newWidth;
result.Height = newHeight;
info.Bounds = result;
info.Bounds = result.Round();
info.ResizeThumbAlignment = alignment;
operation.CurrentContainerBehavior.BeforeSetPosition(operation);
operation.CurrentContainerBehavior.SetPosition(info);

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

@ -150,7 +150,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -150,7 +150,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container,
new DesignItem[] { createdItem },
new Rect[] { new Rect(position, size) },
new Rect[] { new Rect(position, size).Round() },
PlacementType.AddItem
);
if (operation != null) {
@ -212,7 +212,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -212,7 +212,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
{
operation = PlacementOperation.TryStartInsertNewComponents(container,
new DesignItem[] { createdItem },
new Rect[] { GetStartToEndRect(e) },
new Rect[] { GetStartToEndRect(e).Round() },
PlacementType.Resize);
if (operation != null) {
services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
@ -224,7 +224,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -224,7 +224,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
base.OnMouseMove(sender, e);
if (operation != null) {
foreach (PlacementInformation info in operation.PlacedItems) {
info.Bounds = GetStartToEndRect(e);
info.Bounds = GetStartToEndRect(e).Round();
operation.CurrentContainerBehavior.SetPosition(info);
}
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs

@ -65,8 +65,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -65,8 +65,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
foreach (PlacementInformation info in operation.PlacedItems) {
info.Bounds = new Rect(info.OriginalBounds.Left + v.X,
info.OriginalBounds.Top + v.Y,
info.Bounds = new Rect(info.OriginalBounds.Left + Math.Round(v.X, PlacementInformation.BoundsPrecision),
info.OriginalBounds.Top + Math.Round(v.Y, PlacementInformation.BoundsPrecision),
info.OriginalBounds.Width,
info.OriginalBounds.Height);
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs

@ -28,8 +28,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -28,8 +28,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary>
/// The namespace used for the WPF schema.
/// Value: "http://schemas.microsoft.com/netfx/2007/xaml/presentation"
/// Value: "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
/// </summary>
public const string PresentationNamespace = "http://schemas.microsoft.com/netfx/2007/xaml/presentation";
public const string PresentationNamespace = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
}
}

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -261,6 +261,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -261,6 +261,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (propertyName == null)
throw new ArgumentNullException("propertyName");
// if (propertyName == ContentPropertyName)
// return
foreach (XamlProperty p in properties) {
if (!p.IsAttached && p.PropertyName == propertyName)
return p;

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -267,6 +267,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -267,6 +267,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
return;
}
if (_propertyElement == null) {
if (PropertyName == parentObject.ContentPropertyName) {
parentObject.XmlElement.InsertBefore(newChildNode, parentObject.XmlElement.FirstChild);
return;
}
_propertyElement = parentObject.OwnerDocument.XmlDocument.CreateElement(
this.PropertyTargetType.Name + "." + this.PropertyName,
parentObject.OwnerDocument.GetNamespaceFor(this.PropertyTargetType)
@ -281,7 +285,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -281,7 +285,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
Debug.Assert(index >= 0 && index <= collectionElements.Count);
XmlElement collection = _propertyElement;
if (collection == null) {
if (collectionElements.Count == 0) {
if (collectionElements.Count == 0 && this.PropertyName != this.ParentObject.ContentPropertyName) {
// we have to create the collection element
_propertyElement = parentObject.OwnerDocument.XmlDocument.CreateElement(
this.PropertyTargetType.Name + "." + this.PropertyName,

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ExtensionMethods.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
namespace ICSharpCode.WpfDesign
{
/// <summary>
/// Description of ExtensionMethods.
/// </summary>
public static class ExtensionMethods
{
public static Rect Round(this Rect rect)
{
return new Rect(
Math.Round(rect.X, PlacementInformation.BoundsPrecision),
Math.Round(rect.Y, PlacementInformation.BoundsPrecision),
Math.Round(rect.Width, PlacementInformation.BoundsPrecision),
Math.Round(rect.Height, PlacementInformation.BoundsPrecision)
);
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementInformation.cs

@ -15,6 +15,8 @@ namespace ICSharpCode.WpfDesign @@ -15,6 +15,8 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public sealed class PlacementInformation
{
public const int BoundsPrecision = 8;
Rect originalBounds, bounds;
readonly DesignItem item;
readonly PlacementOperation operation;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.WpfDesign @@ -99,7 +99,7 @@ namespace ICSharpCode.WpfDesign
foreach (PlacementInformation info in placedItems) {
info.OriginalBounds = TransformRectByMiddlePoint(transform, info.OriginalBounds);
info.Bounds = TransformRectByMiddlePoint(transform, info.Bounds);
info.Bounds = TransformRectByMiddlePoint(transform, info.Bounds).Round();
}
currentContainer = newContainer;

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -68,6 +68,7 @@ @@ -68,6 +68,7 @@
<Compile Include="Adorners\AdornerProvider.cs" />
<Compile Include="Adorners\AdornerProviderClasses.cs" />
<Compile Include="Adorners\RelativePlacement.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="Metadata.cs" />
<Compile Include="PlacementInformation.cs" />
<Compile Include="PlacementBehavior.cs" />

Loading…
Cancel
Save