Browse Source

Better support of Point Thumbs

pull/633/head
jogibear9988 11 years ago
parent
commit
262b3347e6
  1. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs
  3. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs
  4. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs

36
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml

@ -76,6 +76,42 @@ @@ -76,6 +76,42 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:PointThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:PointThumb}">
<Grid>
<Rectangle Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="Black" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Ellipse Name="thumbElipse" Stroke="Blue" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" />
<Menu Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" >
<MenuItem Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}">
<MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White" />
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray" />
</Trigger>
<Trigger Property="IsEllipse" Value="True">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
<Setter TargetName="thumbElipse" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="ThumbVisible" Value="False">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
<Setter TargetName="thumbElipse" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:RotateThumb}">
<Setter Property="Template">
<Setter.Value>

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs

@ -25,8 +25,26 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -25,8 +25,26 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// Description of MultiPointThumb.
/// </summary>
internal class PointThumb : DesignerThumb
public class PointThumb : DesignerThumb
{
public bool IsEllipse
{
get { return (bool)GetValue(IsEllipseProperty); }
set { SetValue(IsEllipseProperty, value); }
}
// Using a DependencyProperty as the backing store for IsEllipse. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsEllipseProperty =
DependencyProperty.Register("IsEllipse", typeof(bool), typeof(PointThumb), new PropertyMetadata(false));
static PointThumb()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(PointThumb), new FrameworkPropertyMetadata(typeof(PointThumb)));
}
public PointThumb(Point point)
{
this.AdornerPlacement = new PointPlacementSupport(point);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -25,7 +25,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// Resize thumb that automatically disappears if the adornered element is too small.
/// </summary>
sealed class ResizeThumb : DesignerThumb
public sealed class ResizeThumb : DesignerThumb
{
bool checkWidth, checkHeight;

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

@ -78,6 +78,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -78,6 +78,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public object ParentObject { get; private set; }
public int PolyLineIndex { get; set; }
public PathPoint TargetPathPoint { get; set; }
}
protected class PathThumb : PointThumb
@ -125,6 +127,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -125,6 +127,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
designerThumb.OperationMenu = segmentContextMenu;
}
if (pathpoint.TargetPathPoint != null)
designerThumb.IsEllipse = true;
AdornerPanel.SetPlacement(designerThumb, designerThumb.AdornerPlacement);
adornerPanel.Children.Add(designerThumb);
@ -493,13 +498,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -493,13 +498,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
else if (s is BezierSegment) {
list.Add(new PathPoint(((BezierSegment)s).Point1, s, figure, (p) => ((BezierSegment)s).Point1 = p));
list.Add(new PathPoint(((BezierSegment)s).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p));
list.Add(new PathPoint(((BezierSegment)s).Point3, s, figure, (p) => ((BezierSegment)s).Point3 = p));
var pathp = new PathPoint(((BezierSegment)s).Point3, s, figure, (p) => ((BezierSegment)s).Point3 = p);
list.Add(new PathPoint(((BezierSegment)s).Point1, s, figure, (p) => ((BezierSegment)s).Point1 = p) { TargetPathPoint = pathp});
list.Add(new PathPoint(((BezierSegment)s).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p) { TargetPathPoint = pathp });
list.Add(pathp);
}
else if (s is QuadraticBezierSegment) {
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p));
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point2, s, figure, (p) => ((QuadraticBezierSegment)s).Point2 = p));
var pathp = new PathPoint(((QuadraticBezierSegment)s).Point2, s, figure, (p) => ((QuadraticBezierSegment)s).Point2 = p);
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p) { TargetPathPoint = pathp });
list.Add(pathp);
}
else if (s is ArcSegment)
list.Add(new PathPoint(((ArcSegment)s).Point, s, figure, (p) => ((ArcSegment)s).Point = p));

Loading…
Cancel
Save