Browse Source

fix some issues:

- formatting and indentation in some files
- do not catch and mute all exceptions in some cases
- use RhinoMocks to mock required services in tests
pull/54/merge
Siegfried Pammer 12 years ago
parent
commit
1ab1d4be4c
  1. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  2. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs
  3. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
  4. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs
  5. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
  6. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

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

@ -189,30 +189,42 @@ namespace ICSharpCode.WpfDesign.Designer
/// Enables / Disables the Snapline Placement /// Enables / Disables the Snapline Placement
/// </summary> /// </summary>
private bool _useSnaplinePlacement = true; private bool _useSnaplinePlacement = true;
public bool UseSnaplinePlacement public bool UseSnaplinePlacement {
{
get { return _useSnaplinePlacement; } get { return _useSnaplinePlacement; }
set { _useSnaplinePlacement = value; OnPropertyChanged("UseSnaplinePlacement"); } set {
if (_useSnaplinePlacement != value) {
_useSnaplinePlacement = value;
OnPropertyChanged("UseSnaplinePlacement");
}
}
} }
/// <summary> /// <summary>
/// Enables / Disables the Raster Placement /// Enables / Disables the Raster Placement
/// </summary> /// </summary>
private bool _useRasterPlacement = false; private bool _useRasterPlacement = false;
public bool UseRasterPlacement public bool UseRasterPlacement {
{
get { return _useRasterPlacement; } get { return _useRasterPlacement; }
set { _useRasterPlacement = value; OnPropertyChanged("UseRasterPlacement"); } set {
if (_useRasterPlacement != value) {
_useRasterPlacement = value;
OnPropertyChanged("UseRasterPlacement");
}
}
} }
/// <summary> /// <summary>
/// Sets the with of the Raster when using Raster Placement /// Sets the with of the Raster when using Raster Placement
/// </summary> /// </summary>
private int _rasterWidth = 5; private int _rasterWidth = 5;
public int RasterWidth public int RasterWidth {
{
get { return _rasterWidth; } get { return _rasterWidth; }
set { _rasterWidth = value; OnPropertyChanged("RasterWidth"); } set {
if (_rasterWidth != value) {
_rasterWidth = value;
OnPropertyChanged("RasterWidth");
}
}
} }
#endregion #endregion

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs

@ -13,21 +13,18 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
public class RasterPlacementBehavior : DefaultPlacementBehavior public class RasterPlacementBehavior : DefaultPlacementBehavior
{ {
int raster = 5;
Canvas surface; Canvas surface;
AdornerPanel adornerPanel; AdornerPanel adornerPanel;
private bool rasterDrawn = false; bool rasterDrawn = false;
int raster = 5;
public override void BeginPlacement(PlacementOperation operation) public override void BeginPlacement(PlacementOperation operation)
{ {
base.BeginPlacement(operation); base.BeginPlacement(operation);
try { DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
raster = ((DesignPanel) ExtendedItem.Services.DesignPanel).RasterWidth; if (designPanel != null)
} raster = designPanel.RasterWidth;
catch (Exception ex)
{ }
CreateSurface(operation); CreateSurface(operation);
} }
@ -79,7 +76,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
base.BeforeSetPosition(operation); base.BeforeSetPosition(operation);
if (surface == null) return; if (surface == null) return;
if (!((DesignPanel) ExtendedItem.Services.DesignPanel).UseRasterPlacement) DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
if (designPanel == null || !designPanel.UseRasterPlacement)
return; return;
if (Keyboard.IsKeyDown(Key.LeftCtrl)) if (Keyboard.IsKeyDown(Key.LeftCtrl))

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

@ -59,7 +59,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
base.BeforeSetPosition(operation); base.BeforeSetPosition(operation);
if (surface == null) return; if (surface == null) return;
if (!((DesignPanel)ExtendedItem.Services.DesignPanel).UseSnaplinePlacement) DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
if (designPanel == null || !designPanel.UseSnaplinePlacement)
return; return;
surface.Children.Clear(); surface.Children.Clear();

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs

@ -10,9 +10,11 @@ using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using NUnit.Framework; using NUnit.Framework;
using ICSharpCode.WpfDesign.Designer; using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using Rhino.Mocks;
namespace ICSharpCode.WpfDesign.Tests.Designer namespace ICSharpCode.WpfDesign.Tests.Designer
{ {
@ -35,6 +37,11 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
context.Services.Component.ComponentUnregistered += delegate(object sender, DesignItemEventArgs e) { context.Services.Component.ComponentUnregistered += delegate(object sender, DesignItemEventArgs e) {
log.AppendLine("Unregister " + ItemIdentity(e.Item)); log.AppendLine("Unregister " + ItemIdentity(e.Item));
};*/ };*/
// create required service mocks
var designPanel = MockRepository.GenerateStub<IDesignPanel>();
designPanel.Stub(dp => dp.Adorners).Return(new System.Collections.Generic.List<AdornerPanel>());
context.Services.AddService(typeof(IDesignPanel), designPanel);
return context; return context;
} }

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -43,6 +43,9 @@
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="Rhino.Mocks">
<HintPath>..\..\..\..\..\Libraries\RhinoMocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>

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

@ -180,7 +180,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (hasStringConverter && XamlObject.GetContentPropertyName(elementType) != null) { if (hasStringConverter && XamlObject.GetContentPropertyName(elementType) != null) {
xml.InnerText = c.ConvertToInvariantString(instance); xml.InnerText = c.ConvertToInvariantString(instance);
} else if (instance is Brush) { //Todo: this is a hacky fix, because Brush Editor don't edit Design Items and so we have no XML, only the Brush Object and we need to Parse the Brush to XAML! } else if (instance is Brush) { // TODO: this is a hacky fix, because Brush Editor doesn't
// edit Design Items and so we have no XML, only the Brush
// object and we need to parse the Brush to XAML!
var s = new MemoryStream(); var s = new MemoryStream();
XamlWriter.Save(instance, s); XamlWriter.Save(instance, s);
s.Seek(0, SeekOrigin.Begin); s.Seek(0, SeekOrigin.Begin);

Loading…
Cancel
Save