Browse Source

Fixed some FxCop warnings in WPF designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5479 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
947f9ae4db
  1. 2
      clean.bat
  2. 2
      debugbuild.bat
  3. 2
      releasebuild.bat
  4. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  5. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
  6. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml
  7. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  8. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
  9. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
  10. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  11. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs
  12. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  13. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs
  14. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs
  15. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
  16. 48
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  17. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs
  18. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  19. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
  20. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs
  21. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs
  22. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/CodeAnalysisDictionary.xml
  23. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  24. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs
  25. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  26. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs
  27. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
  28. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  29. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

2
clean.bat

@ -1,2 +1,2 @@ @@ -1,2 +1,2 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m /t:clean SharpDevelop.sln "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU"
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /t:clean "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 PAUSE

2
debugbuild.bat

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Debug "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU"
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Debug "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err
@exit /B 0
:err

2
releasebuild.bat

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m /property:Configuration=Release SharpDevelop.sln "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU"
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Release "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err
@exit /B 0
:err

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -5,24 +5,26 @@ @@ -5,24 +5,26 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -39,6 +41,13 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -39,6 +41,13 @@ namespace ICSharpCode.WpfDesign.AddIn
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged;
}
static WpfViewContent()
{
DragDropExceptionHandler.UnhandledException += delegate(object sender, ThreadExceptionEventArgs e) {
ICSharpCode.Core.MessageService.ShowException(e.Exception);
};
}
DesignSurface designer;
List<Task> tasks = new List<Task>();
@ -56,7 +65,6 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -56,7 +65,6 @@ namespace ICSharpCode.WpfDesign.AddIn
if (designer == null) {
// initialize designer on first load
DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowException;
designer = new DesignSurface();
this.UserContent = designer;
InitPropertyEditor();

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs

@ -19,9 +19,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -19,9 +19,9 @@ namespace ICSharpCode.WpfDesign.Designer
string methodName;
public override object ProvideValue(IServiceProvider sp)
public override object ProvideValue(IServiceProvider serviceProvider)
{
var t = (IProvideValueTarget)sp.GetService(typeof(IProvideValueTarget));
var t = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
return new CallCommand(t.TargetObject as FrameworkElement, methodName);
}
}

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<?xml version="1.0"?>
<Dictionary>
<Words>
<Recognized>
<!-- add words specific to your application here -->
<Word>Headered</Word> <!-- HeaderedContentControl -->
<Word>Snapline</Word>
</Recognized>
<Unrecognized>
<!-- Disable Lineup as a single word - LineUp is the spelling used in WPF -->
<Word>Lineup</Word>
</Unrecognized>
<Deprecated>
<!-- Use this section to deprecate terms -->
<Term PreferredAlternate="Best">Bestest</Term>
</Deprecated>
</Words>
<Acronyms>
<CasingExceptions>
<!-- Use this section to tell FxCop the correct casing of acronyms. -->
<Acronym>WiX</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs

@ -97,7 +97,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -97,7 +97,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
int _totalAdornerCount;
#endif
internal AdornerLayer(UIElement designPanel)
{
this._designPanel = designPanel;
@ -193,7 +192,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -193,7 +192,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
int i = 0;
for (i = 0; i < children.Count; i++) {
AdornerPanel p = (AdornerPanel)children[i];
if (p.Order.CompareTo(adornerPanel.Order) > 0) {
if (p.Order > adornerPanel.Order) {
break;
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -28,6 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs

@ -170,7 +170,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -170,7 +170,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
}
}
void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
static void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
out GridLength newLength1, out GridLength newLength2)
{
if (oldLength.IsAuto) {

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -48,6 +48,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -48,6 +48,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DialogResultConverter))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public bool? DialogResult {
get {
return null;
@ -176,41 +177,49 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -176,41 +177,49 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Activated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closed { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closing { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler ContentRendered { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Deactivated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler LocationChanged { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler SourceInitialized { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler StateChanged { add {} remove {} }
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs

@ -39,9 +39,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -39,9 +39,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
static Cursor PanToolCursor;
static Cursor PanToolCursorMouseDown;
public static double ZoomFactor = 1.1;
public static double Minimum = 0.1;
public static double Maximum = 10;
public const double ZoomFactor = 1.1;
public const double Minimum = 0.1;
public const double Maximum = 10;
double startHorizontalOffset;
double startVericalOffset;

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -11,6 +11,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -11,6 +11,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
{
public class IntFromEnumConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly IntFromEnumConverter Instance = new IntFromEnumConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -26,6 +27,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -26,6 +27,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class HiddenWhenFalse : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly HiddenWhenFalse Instance = new HiddenWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -41,6 +43,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -41,6 +43,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class CollapsedWhenFalse : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenFalse Instance = new CollapsedWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -56,6 +59,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -56,6 +59,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class LevelConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly LevelConverter Instance = new LevelConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -71,6 +75,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -71,6 +75,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class CollapsedWhenZero : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenZero Instance = new CollapsedWhenZero();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -89,6 +94,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -89,6 +94,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class FalseWhenNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FalseWhenNull Instance = new FalseWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -104,6 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -104,6 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class BoldWhenTrue : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly BoldWhenTrue Instance = new BoldWhenTrue();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -120,6 +127,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -120,6 +127,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
// Boxed int throw exception without converter (wpf bug?)
public class DummyConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly DummyConverter Instance = new DummyConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs

@ -43,6 +43,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -43,6 +43,15 @@ namespace ICSharpCode.WpfDesign.Designer
this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);
#if DEBUG || CODE_ANALYSIS
if (_designPanel == null) {
Environment.FailFast("designpanel should be initialized earlier");
// Fake call to DesignPanel constructor because FxCop doesn't look inside XAML files
// and we'd get tons of warnings about uncalled private code.
_designPanel = new DesignPanel();
}
#endif
}
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs

@ -6,19 +6,36 @@ @@ -6,19 +6,36 @@
// </file>
using System;
using System.Threading;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// 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.
/// Applications hosting the designer should listen to the event and provide their own exception handling
/// method. If no event listener is registered, exceptions will call Environment.FailFast.
/// </summary>
public static class DragDropExceptionHandler
{
public static Action<Exception> HandleException = delegate(Exception ex) {
Environment.FailFast(ex.ToString());
};
/// <summary>
/// Event that occors when an unhandled exception occurs during drag'n'drop operators.
/// </summary>
public static event ThreadExceptionEventHandler UnhandledException;
/// <summary>
/// Raises the UnhandledException event, or calls Environment.FailFast if no event handlers are present.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Justification = "We're raising an event")]
public static void RaiseUnhandledException(Exception exception)
{
if (exception == null)
throw new ArgumentNullException("exception");
ThreadExceptionEventHandler eh = UnhandledException;
if (eh != null)
eh(null, new ThreadExceptionEventArgs(exception));
else
Environment.FailFast(exception.ToString());
}
}
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs

@ -13,9 +13,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -13,9 +13,9 @@ namespace ICSharpCode.WpfDesign.Designer
{
public static class ExtensionMethods
{
public static double Coerce(this double d, double min, double max)
public static double Coerce(this double value, double min, double max)
{
return Math.Max(Math.Min(d, max), min);
return Math.Max(Math.Min(value, max), min);
}
public static void AddRange<T>(this ICollection<T> col, IEnumerable<T> items)
@ -31,15 +31,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -31,15 +31,15 @@ namespace ICSharpCode.WpfDesign.Designer
}
/// <summary>
/// Gets all ancestors in the visual tree (including d itself).
/// Returns an empty list if d is null or not a visual.
/// Gets all ancestors in the visual tree (including <paramref name="visual"/> itself).
/// Returns an empty list if <paramref name="visual"/> is null or not a visual.
/// </summary>
public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject d)
public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject visual)
{
if (IsVisual(d)) {
while (d != null) {
yield return d;
d = VisualTreeHelper.GetParent(d);
if (IsVisual(visual)) {
while (visual != null) {
yield return visual;
visual = VisualTreeHelper.GetParent(visual);
}
}
}

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

@ -20,7 +20,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -20,7 +20,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
public class CreateComponentTool : ITool
{
readonly Type componentType;
MoveLogic moveLogic;
MoveLogic moveLogic;
ChangeGroup changeGroup;
Point createPoint;
@ -49,22 +49,22 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -49,22 +49,22 @@ namespace ICSharpCode.WpfDesign.Designer.Services
{
designPanel.MouseDown += OnMouseDown;
//designPanel.DragEnter += designPanel_DragOver;
designPanel.DragOver += designPanel_DragOver;
designPanel.Drop += designPanel_Drop;
designPanel.DragLeave += designPanel_DragLeave;
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;
designPanel.DragOver -= designPanel_DragOver;
designPanel.Drop -= designPanel_Drop;
designPanel.DragLeave -= designPanel_DragLeave;
}
void designPanel_DragOver(object sender, DragEventArgs e)
{
void designPanel_DragOver(object sender, DragEventArgs e)
{
try {
IDesignPanel designPanel = (IDesignPanel)sender;
e.Effects = DragDropEffects.Copy;
@ -89,18 +89,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -89,18 +89,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
} else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded) {
if (moveLogic.Operation == null) {
moveLogic.Start(createPoint);
moveLogic.Start(createPoint);
} else {
moveLogic.Move(p);
moveLogic.Move(p);
}
}
} catch (Exception x) {
DragDropExceptionHandler.HandleException(x);
DragDropExceptionHandler.RaiseUnhandledException(x);
}
}
}
void designPanel_Drop(object sender, DragEventArgs e)
{
void designPanel_Drop(object sender, DragEventArgs e)
{
try {
if (moveLogic != null) {
moveLogic.Stop();
@ -112,12 +112,12 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -112,12 +112,12 @@ namespace ICSharpCode.WpfDesign.Designer.Services
changeGroup.Commit();
}
} catch (Exception x) {
DragDropExceptionHandler.HandleException(x);
DragDropExceptionHandler.RaiseUnhandledException(x);
}
}
}
void designPanel_DragLeave(object sender, DragEventArgs e)
{
void designPanel_DragLeave(object sender, DragEventArgs e)
{
try {
if (moveLogic != null) {
moveLogic.Cancel();
@ -128,9 +128,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -128,9 +128,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
} catch (Exception x) {
DragDropExceptionHandler.HandleException(x);
DragDropExceptionHandler.RaiseUnhandledException(x);
}
}
}
/// <summary>
/// Is called to create the item used by the CreateComponentTool.
@ -211,9 +211,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -211,9 +211,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services
protected override void OnDragStarted(MouseEventArgs e)
{
operation = PlacementOperation.TryStartInsertNewComponents(container,
new DesignItem[] { createdItem },
new Rect[] { GetStartToEndRect(e).Round() },
PlacementType.Resize);
new DesignItem[] { createdItem },
new Rect[] { GetStartToEndRect(e).Round() },
PlacementType.Resize);
if (operation != null) {
services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs

@ -131,6 +131,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -131,6 +131,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We rethrow the original exception, not the follow-up error.")]
public void Redo()
{
AssertState(TransactionState.Undone);
@ -157,6 +159,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -157,6 +159,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We avoid throwing exceptions here because a disposed transaction" +
" indicates another exception happened earlier.")]
protected override void Dispose()
{
if (_state == TransactionState.Open) {

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -15,6 +15,12 @@ @@ -15,6 +15,12 @@
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1810;-Microsoft.Performance#CA1822</CodeAnalysisRules>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@ -303,4 +309,7 @@ @@ -303,4 +309,7 @@
<Resource Include="Images\ZoomIn.png" />
<Resource Include="Images\ZoomOut.png" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>
</Project>

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -7,9 +7,11 @@ @@ -7,9 +7,11 @@
using System;
using System.Collections.Generic;
using ICSharpCode.WpfDesign.XamlDom;
using System.Runtime.CompilerServices;
using System.Windows.Markup;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
sealed class XamlComponentService : IComponentService
@ -21,7 +23,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -21,7 +23,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
int IEqualityComparer<object>.GetHashCode(object obj)
{
return obj.GetHashCode();
return RuntimeHelpers.GetHashCode(obj);
}
bool IEqualityComparer<object>.Equals(object x, object y)

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs

@ -197,5 +197,29 @@ namespace ICSharpCode.WpfDesign.Adorners @@ -197,5 +197,29 @@ namespace ICSharpCode.WpfDesign.Adorners
{
return leftHandSide.i != rightHandSide.i;
}
/// <summary/>
public static bool operator <(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i < rightHandSide.i;
}
/// <summary/>
public static bool operator <=(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i <= rightHandSide.i;
}
/// <summary/>
public static bool operator >(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i > rightHandSide.i;
}
/// <summary/>
public static bool operator >=(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i >= rightHandSide.i;
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.WpfDesign @@ -40,6 +40,7 @@ namespace ICSharpCode.WpfDesign
protected abstract void Dispose();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly")]
void IDisposable.Dispose()
{
Dispose();

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/CodeAnalysisDictionary.xml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<?xml version="1.0"?>
<Dictionary>
<Words>
<Recognized>
<!-- add words specific to your application here -->
<Word>lhs</Word>
<Word>rhs</Word>
</Recognized>
<Unrecognized>
<!-- Disable Lineup as a single word - LineUp is the spelling used in WPF -->
<Word>Lineup</Word>
</Unrecognized>
<Deprecated>
<!-- Use this section to deprecate terms -->
<Term PreferredAlternate="Best">Bestest</Term>
</Deprecated>
</Words>
<Acronyms>
<CasingExceptions>
<!-- Use this section to tell FxCop the correct casing of acronyms. -->
<Acronym>WiX</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -181,16 +181,16 @@ namespace ICSharpCode.WpfDesign @@ -181,16 +181,16 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Adds a bevahior extension object to this design item.
/// </summary>
public void AddBehavior(Type bevahiorInterface, object behaviorImplementation)
public void AddBehavior(Type behaviorInterface, object behaviorImplementation)
{
if (bevahiorInterface == null)
throw new ArgumentNullException("bevahiorInterface");
if (behaviorInterface == null)
throw new ArgumentNullException("behaviorInterface");
if (behaviorImplementation == null)
throw new ArgumentNullException("behaviorImplementation");
if (!bevahiorInterface.IsInstanceOfType(behaviorImplementation))
if (!behaviorInterface.IsInstanceOfType(behaviorImplementation))
throw new ArgumentException("behaviorImplementation must implement bevahiorInterface", "behaviorImplementation");
_behaviorObjects.Add(bevahiorInterface, behaviorImplementation);
_behaviorObjects.Add(behaviorInterface, behaviorImplementation);
}
/// <summary>

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs

@ -12,6 +12,8 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -12,6 +12,8 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary>
/// Combines two extension servers using a logical OR.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
public sealed class LogicalOrExtensionServer<A, B> : DefaultExtensionServer
where A : ExtensionServer
where B : ExtensionServer
@ -44,6 +46,8 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -44,6 +46,8 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary>
/// Combines two extension servers using a logical AND.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
public sealed class LogicalAndExtensionServer<A, B> : DefaultExtensionServer
where A : ExtensionServer
where B : ExtensionServer

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

@ -41,6 +41,7 @@ namespace ICSharpCode.WpfDesign @@ -41,6 +41,7 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// The type of the placement being done.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public PlacementType Type {
get { return type; }
}

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs

@ -149,12 +149,13 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -149,12 +149,13 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
return "(" + ValueItem.ComponentType.Name + ")";
}
set {
// TODO: Doesn't work for some reason
try {
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value);
} catch {
OnValueOnInstanceChanged();
}
// make sure we only catch specific exceptions
// and/or show the error message to the user
//try {
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value);
//} catch {
// OnValueOnInstanceChanged();
//}
}
}

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs

@ -9,20 +9,20 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -9,20 +9,20 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
/// <summary>
/// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection.
/// </summary>
public class SortedObservableCollection<T, K> : ObservableCollection<T>
public class SortedObservableCollection<T, TKey> : ObservableCollection<T>
{
/// <summary>
/// Creates a new SortedObservableCollection instance.
/// </summary>
/// <param name="keySelector">The function to select the sorting key.</param>
public SortedObservableCollection(Func<T, K> keySelector)
public SortedObservableCollection(Func<T, TKey> keySelector)
{
this.keySelector = keySelector;
this.comparer = Comparer<K>.Default;
this.comparer = Comparer<TKey>.Default;
}
Func<T, K> keySelector;
IComparer<K> comparer;
Func<T, TKey> keySelector;
IComparer<TKey> comparer;
/// <summary>
/// Adds an item to a sorted collection.

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

@ -151,7 +151,7 @@ namespace ICSharpCode.WpfDesign @@ -151,7 +151,7 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Gets a WPF object representing a graphical description of the property.
/// </summary>
object GetDescription(DesignItemProperty property);
object GetDescription(DesignItemProperty designProperty);
}
#endregion

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

@ -127,4 +127,7 @@ @@ -127,4 +127,7 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>
</Project>
Loading…
Cancel
Save