Browse Source

Path Handler Extension

pull/637/head
jkuehner 11 years ago
parent
commit
a18f1f7821
  1. 74
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/MultiPointResizeThumb.cs
  2. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
  3. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs

74
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/MultiPointResizeThumb.cs

@ -1,13 +1,22 @@
/* // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
* Created by SharpDevelop. //
* User: trubra // Permission is hereby granted, free of charge, to any person obtaining a copy of this
* Date: 2014-12-22 // software and associated documentation files (the "Software"), to deal in the Software
* Time: 11:06 // without restriction, including without limitation the rights to use, copy, modify, merge,
* // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* To change this template use Tools | Options | Coding | Edit Standard Headers. // to whom the Software is furnished to do so, subject to the following conditions:
*/ //
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Windows;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
@ -17,33 +26,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// Description of MultiPointResizeThumb. /// Description of MultiPointResizeThumb.
/// </summary> /// </summary>
sealed class MultiPointResizeThumb: ResizeThumb sealed class MultiPointResizeThumb: ResizeThumb
{ {
private int _index; private int _index;
public int Index public int Index
{ {
get { return _index; } get { return _index; }
set set
{ {
_index = value; _index = value;
PointTrackerPlacementSupport p = AdornerPlacement as PointTrackerPlacementSupport; var p = AdornerPlacement as PointTrackerPlacementSupport;
if (p != null) if (p != null)
p.Index = value; p.Index = value;
} }
} }
public void Invalidate()
{
PointTrackerPlacementSupport p = AdornerPlacement as PointTrackerPlacementSupport;
}
private AdornerPlacement _adornerPlacement;
public AdornerPlacement AdornerPlacement private AdornerPlacement _adornerPlacement;
{ public AdornerPlacement AdornerPlacement
get { return _adornerPlacement; } {
set { _adornerPlacement = value; } get { return _adornerPlacement; }
} set { _adornerPlacement = value; }
}
} }
} }

35
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs

@ -36,7 +36,7 @@ using ICSharpCode.WpfDesign.Designer.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
/// <summary> /// <summary>
/// Description of PolyLineHandlerExtension. /// Description of PathHandlerExtension.
/// </summary> /// </summary>
[ExtensionFor(typeof(Path))] [ExtensionFor(typeof(Path))]
internal class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp internal class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
@ -181,25 +181,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
if (operation != null) if (operation != null)
{ {
PointCollection points; // foreach (int i in _selectedThumbs.Keys)
Polygon pg = ExtendedItem.View as Polygon; // {
Polyline pl = ExtendedItem.View as Polyline; // _selectedThumbs[i].X = points[i].X;
if (pl == null) // _selectedThumbs[i].Y = points[i].Y;
{ // }
points = pg.Points;
//ExtendedItem.Properties.GetProperty(pl != null ? Polyline.PointsProperty : Polygon.PointsProperty).SetValue(points);
}
else
{
points = pl.Points;
}
foreach (int i in _selectedThumbs.Keys)
{
_selectedThumbs[i].X = points[i].X;
_selectedThumbs[i].Y = points[i].Y;
}
ExtendedItem.Properties.GetProperty(pl != null ? Polyline.PointsProperty : Polygon.PointsProperty).SetValue(points);
operation.Commit(); operation.Commit();
operation = null; operation = null;
@ -346,10 +335,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
#endregion #endregion
List<Point> GetPoints() List<Point> GetPoints()
{
return GetPoints(this.ExtendedItem.View as Path);
}
public static List<Point> GetPoints(Path path)
{ {
var retVal = new List<Point>(); var retVal = new List<Point>();
var path = this.ExtendedItem.View as Path;
var geometry = path.Data as PathGeometry; var geometry = path.Data as PathGeometry;
if (geometry!=null) { if (geometry!=null) {
var figure = geometry.Figures[0] as PathFigure; var figure = geometry.Figures[0] as PathFigure;

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs

@ -49,9 +49,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Point p = new Point(0, 0); Point p = new Point(0, 0);
double thumbsize = 7; double thumbsize = 7;
double distance = 0; double distance = 0;
if (shape as Line != null) if (shape is Line)
{ {
Line s = shape as Line; var s = shape as Line;
double x, y; double x, y;
if (alignment == PlacementAlignment.BottomRight) if (alignment == PlacementAlignment.BottomRight)
@ -65,20 +65,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
y = s.Y1; y = s.Y1;
} }
p = new Point(x, y); p = new Point(x, y);
} } else if (shape is Polygon) {
if (Index > 0)
Polygon pg = shape as Polygon; {
Polyline pl = shape as Polyline; var pg = shape as Polygon;
if (pg != null || pl != null) p = pg.Points[Index];
{ }
} else if (shape is Polygon) {
if (Index > 0) if (Index > 0)
{ {
p = pl != null ? pl.Points[Index] : pg.Points[Index]; var pg = shape as Polygon;
p = pg.Points[Index];
var transform = shape.RenderedGeometry.Transform; }
p = transform.Transform(p); } else if (shape is Path) {
if (Index > 0)
{
var path = shape as Path;
var points = PathHandlerExtension.GetPoints(path);
p = points[Index];
} }
} }
var transform = shape.RenderedGeometry.Transform;
p = transform.Transform(p);
adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, thumbsize, thumbsize)); //thumbsize, thumbsize))); adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, thumbsize, thumbsize)); //thumbsize, thumbsize)));
} }

Loading…
Cancel
Save