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 @@ @@ -1,13 +1,22 @@
/*
* Created by SharpDevelop.
* User: trubra
* Date: 2014-12-22
* Time: 11:06
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// 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 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.Windows;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
@ -17,33 +26,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -17,33 +26,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// Description of MultiPointResizeThumb.
/// </summary>
sealed class MultiPointResizeThumb: ResizeThumb
{
private int _index;
public int Index
{
get { return _index; }
set
{
_index = value;
PointTrackerPlacementSupport p = AdornerPlacement as PointTrackerPlacementSupport;
if (p != null)
p.Index = value;
}
}
public void Invalidate()
{
PointTrackerPlacementSupport p = AdornerPlacement as PointTrackerPlacementSupport;
}
private AdornerPlacement _adornerPlacement;
{
private int _index;
public int Index
{
get { return _index; }
set
{
_index = value;
var p = AdornerPlacement as PointTrackerPlacementSupport;
if (p != null)
p.Index = value;
}
}
public AdornerPlacement AdornerPlacement
{
get { return _adornerPlacement; }
set { _adornerPlacement = value; }
}
private AdornerPlacement _adornerPlacement;
public AdornerPlacement AdornerPlacement
{
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; @@ -36,7 +36,7 @@ using ICSharpCode.WpfDesign.Designer.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
/// Description of PolyLineHandlerExtension.
/// Description of PathHandlerExtension.
/// </summary>
[ExtensionFor(typeof(Path))]
internal class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
@ -181,25 +181,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -181,25 +181,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
if (operation != null)
{
PointCollection points;
Polygon pg = ExtendedItem.View as Polygon;
Polyline pl = ExtendedItem.View as Polyline;
if (pl == null)
{
points = pg.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);
// 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 = null;
@ -346,10 +335,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -346,10 +335,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
#endregion
List<Point> GetPoints()
{
return GetPoints(this.ExtendedItem.View as Path);
}
public static List<Point> GetPoints(Path path)
{
var retVal = new List<Point>();
var path = this.ExtendedItem.View as Path;
var geometry = path.Data as PathGeometry;
if (geometry!=null) {
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 @@ -49,9 +49,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Point p = new Point(0, 0);
double thumbsize = 7;
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;
if (alignment == PlacementAlignment.BottomRight)
@ -65,20 +65,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -65,20 +65,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
y = s.Y1;
}
p = new Point(x, y);
}
Polygon pg = shape as Polygon;
Polyline pl = shape as Polyline;
if (pg != null || pl != null)
{
} else if (shape is Polygon) {
if (Index > 0)
{
var pg = shape as Polygon;
p = pg.Points[Index];
}
} else if (shape is Polygon) {
if (Index > 0)
{
p = pl != null ? pl.Points[Index] : pg.Points[Index];
var transform = shape.RenderedGeometry.Transform;
p = transform.Transform(p);
var pg = shape as Polygon;
p = pg.Points[Index];
}
} 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)));
}

Loading…
Cancel
Save