Browse Source

Add margin display in the handle

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/wpfdesigner@5877 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Kumar Devvrat 15 years ago
parent
commit
aaf0463086
  1. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs
  3. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

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

@ -1,10 +1,11 @@ @@ -1,10 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls">
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters">
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Converters:LevelConverter x:Key="FormatDoubleConverter" />
<Style TargetType="{x:Type Controls:PanelMoveAdorner}">
<Setter Property="Template">
<Setter.Value>
@ -340,24 +341,42 @@ @@ -340,24 +341,42 @@
StrokeThickness="0.5"
Data="M0,0 L0,1 1,0.5 z" Grid.Column="0" />
<!-- Wrap the handle-line and endArrow in this grid. It's visiblity is subjected to HandleLength -->
<Grid Grid.Column="1" Name="lineArrow">
<Grid Height="8" Grid.Column="1" Name="lineArrow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
</Grid.ColumnDefinitions>
<Path Name="line"
<Path Name="line1"
Stretch="Fill"
Stroke="#FF333333"
StrokeThickness="1.5"
Grid.Row="2"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="0"/>
<Path Name="endArrow"
<TextBlock Grid.Column="1"
Text="{Binding Path=HandleLength, Mode=OneWay, Converter={x:Static Converters:FormatDoubleConverter.Instance }, RelativeSource={RelativeSource Mode=TemplatedParent}}"
FontSize="9"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="1,1,1,1">
<TextBlock.LayoutTransform>
<RotateTransform Angle="{Binding Path=TextTransform, RelativeSource={RelativeSource Mode=TemplatedParent}}" CenterX="0.5" CenterY="0.5">
</RotateTransform>
</TextBlock.LayoutTransform>
</TextBlock>
<Path Name="line2"
Stretch="Fill"
Stroke="#FF333333"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="2"/>
<Path Name="arrow2"
Fill="#FF333333"
Stretch="Fill"
Stroke="{TemplateBinding Panel.Background}"
StrokeThickness="0.5"
Data="M0,0 L0,1 1,0.5 z" Grid.Column="1" />
Data="M0,0 L0,1 1,0.5 z" Grid.Column="3" />
</Grid>
<!-- Rotate the handle and angle of rotation being set by the Margin type. See enum HandleOrientation -->
<Grid.LayoutTransform>

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs

@ -55,10 +55,24 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -55,10 +55,24 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
MarginStub marginStub;
/// <summary>
/// Gets/Sets tha angle by which handle rotates.
/// Gets/Sets the angle by which handle rotates.
/// </summary>
public double Angle { get; set; }
/// <summary>
/// Gets/Sets the angle by which the Margin display has to be rotated
/// </summary>
public double TextTransform{
get{
if((double)orientation==90 || (double)orientation == 180)
return 180;
if ((double)orientation == 270)
return 0;
return (double)orientation;
}
set{ }
}
/// <summary>
/// Decides the visiblity of handle/stub when <see cref="HandleLength"/> changes
/// </summary>
@ -133,7 +147,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -133,7 +147,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
marginStub.Visibility = handleLength == 0.0 ? Visibility.Visible : Visibility.Hidden;
this.Visibility = handleLength != 0.0 ? Visibility.Visible : Visibility.Hidden;
if (this.lineArrow != null){
lineArrow.Visibility = handleLength < 20 ? Visibility.Hidden : Visibility.Visible;
lineArrow.Visibility = handleLength < 23 ? Visibility.Hidden : Visibility.Visible;
}
}

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

@ -147,4 +147,19 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -147,4 +147,19 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
return value;
}
}
public class FormatDoubleConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FormatDoubleConverter Instance=new FormatDoubleConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Math.Round((double)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

Loading…
Cancel
Save