绘图区使用MahApps.Metro提供的MetroAnimatedSingleRowTabControl控件来管理绘图区的文档列表。
每个文档都是一个包含许多组件的ItemsControl控件,为方便起见,新建一个GravixCSDiagram控件。
/// <summary>
/// GravixCS文档专用控件
/// </summary>
class GravixCSDiagram:MultiSelector
{
static GravixCSDiagram()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(GravixCSDiagram), new FrameworkPropertyMetadata(typeof(GravixCSDiagram)));
}
public GravixCSDiagram()
{
}
/// <summary>
///重写封装器
/// </summary>
/// <returns></returns>
protected override DependencyObject GetContainerForItemOverride()
{
return new GravixCSDiagramItem();
}
/// <summary>
///重写封装器
/// </summary>
/// <returns></returns>
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is GravixCSDiagramItem;
}
/// <summary>
/// 是否显示网格
/// </summary>
public bool ShowGrid
{
get { return (bool)GetValue(ShowGridProperty); }
set { SetValue(ShowGridProperty, value); }
}
/// <summary>
/// 是否显示网格
/// </summary>
public static readonly DependencyProperty ShowGridProperty =
DependencyProperty.Register("ShowGrid", typeof(bool), typeof(GravixCSDiagram), new PropertyMetadata(true));
/// <summary>
/// 最大比例
/// </summary>
public double MaxScale
{
get { return (double)GetValue(MaxScaleProperty); }
set { SetValue(MaxScaleProperty, value); }
}
/// <summary>
/// 最大比例
/// </summary>
public static readonly DependencyProperty MaxScaleProperty = DependencyProperty.Register("MaxScale", typeof(double), typeof(GravixCSDiagram), new FrameworkPropertyMetadata(5.0d,OnMaxScaleChanged,CoerceMaxScale));
private static void OnMaxScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
GravixCSDiagram ctl = d as GravixCSDiagram;
ctl.CoerceValue(GravixCSDiagram.ScaleProperty);
}
private static object CoerceMaxScale(DependencyObject d, object value)
{
GravixCSDiagram ctl = d as GravixCSDiagram;
double max = (double)value;
return max < ctl.MinScale ? ctl.MinScale : max;
}
/// <summary>
/// 最小比例
/// </summary>
public double MinScale
{
get { return (double)GetValue(MinScaleProperty); }
set { SetValue(MinScaleProperty, value); }
}
/// <summary>
/// 最小比例
/// </summary>
public static readonly DependencyProperty MinScaleProperty = DependencyProperty.Register("MinScale", typeof(double), typeof(GravixCSDiagram), new FrameworkPropertyMetadata(0.1d,OnMinScaleChanged));
private static void OnMinScaleChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
{
GravixCSDiagram ctl = d as GravixCSDiagram;
ctl.CoerceValue(GravixCSDiagram.MaxScaleProperty);
ctl.CoerceValue(GravixCSDiagram.ScaleProperty);
}
/// <summary>
/// 缩放比例
/// </summary>
public double Scale
{
get { return (double)GetValue(ScaleProperty); }
set { SetValue(ScaleProperty, value); }
}
/// <summary>
/// 缩放比例
/// </summary>
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register("Scale", typeof(double), typeof(GravixCSDiagram), new FrameworkPropertyMetadata(1.0d,null,CoerceScale));
private static object CoerceScale(DependencyObject d, object value)
{
double scale = (double)value;
GravixCSDiagram ctl = d as GravixCSDiagram;
double min = ctl.MinScale;
if (scale < min) return min;
double max = ctl.MaxScale;
if (scale > max) return max;
return scale;
}
/// <summary>
/// 背景模板
/// </summary>
public UIElement GravixCSFrame
{
get { return (UIElement)GetValue(GravixCSFrameProperty); }
set { SetValue(GravixCSFrameProperty, value); }
}
/// <summary>
/// 背景模板
/// </summary>
public static readonly DependencyProperty GravixCSFrameProperty = DependencyProperty.Register("GravixCSFrame", typeof(UIElement), typeof(GravixCSDiagram));
}
class GravixCSDiagramItem: ContentControl
{
}
默认样式:
<Style TargetType="local:GravixCSDiagram">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="White">
<ContentControl IsHitTestVisible="False"
Width="{Binding Width, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Height="{Binding Height, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Content="{Binding Path=GravixCSFrame, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<ItemsPresenter/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
然后把文档控件GravixCSDiagram放到MetroAnimatedSingleRowTabControl的模板当中显示。
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Resources/Controls/GravixCSDiagramStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="mah:MetroAnimatedSingleRowTabControl" x:Key="documentListStyle">
<Setter Property="mah:TabControlHelper.UnderlineSelectedBrush" Value="Teal"/>
<Setter Property="mah:TabControlHelper.Underlined" Value="TabItems"/>
<Setter Property="mah:TabControlHelper.Transition" Value="Default"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="mah:MetroTabItem">
<Setter Property="CloseButtonEnabled" Value="True"/>
<Setter Property="CloseButtonMargin" Value="1"/>
<Setter Property="CloseTabCommand" Value="{Binding DataContext.CloseDocumentCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type mah:MetroWindow}}}"/>
<Setter Property="CloseTabCommandParameter" Value="{Binding .}"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding CabinetLayer,StringFormat={}+.{0}}"
FontSize="12" FontWeight="Bold" Foreground="DarkRed" Margin="2 0 8 0"/>
<TextBlock Text="{Binding DocumentDescription}" FontSize="12"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<xceed:Zoombox Grid.Row="0" Background="WhiteSmoke"
MaxScale="{Binding Path=MaxScale,ElementName=diagram,Mode=OneWay}"
MinScale="{Binding Path=MinScale,ElementName=diagram,Mode=OneWay}"
Scale="{Binding Path=Scale,ElementName=diagram,Mode=OneWay}"
Position="100 100" ZoomModifiers="Ctrl" RelativeZoomModifiers="Ctrl" ZoomOrigin="0.5 0.5">
<ctl:GravixCSDiagram x:Name="diagram" Style="{StaticResource GravixCSDiagramStyle}"/>
</xceed:Zoombox>
<Rectangle Stroke="Black" StrokeThickness="1" Grid.Row="0"/>
<TextBlock Grid.Row="1" Text="zoombox"/>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
还有两个问题:
1. 工程文档都有一定的相对固定的模板,此模板与文档的大小尺寸等,都由DocumentPageBase类的Page属性来定义。Page为DocumentPageBase类,PageWidth和PageHeight对应文档页面的大小,而PageFrame属性用来定义模板。
2. 实际绘图过程中都会有过大或过小的图形,用户会对文档进行缩放。使用DocumentPageBase类的Page属性来管理缩放比例:PageMaxScale,PageMinScale控制最大最小比例;PageScale来控制打开文档时的默认比例。而控件则选择Extended.Wpf.Toolkit提供的Zoombox来控制。
<xceed:Zoombox Grid.Row="0" Background="WhiteSmoke"
MaxScale="{Binding Path=MaxScale,ElementName=diagram,Mode=OneWay}"
MinScale="{Binding Path=MinScale,ElementName=diagram,Mode=OneWay}"
Scale="{Binding Path=Scale,ElementName=diagram,Mode=OneWay}"
Position="100 100" ZoomModifiers="Ctrl" RelativeZoomModifiers="Ctrl" ZoomOrigin="0.5 0.5">
<ctl:GravixCSDiagram x:Name="diagram" Style="{StaticResource GravixCSDiagramStyle}"/>
</xceed:Zoombox>
/// <summary>
/// 文档页
/// </summary>
public abstract class DocumentPageBase
{
public DocumentPageBase(Guid guid)
{
PageMinScale = 0.4d;
PageMaxScale = 5.0d;
PageScale = 1.0d;
}
/// <summary>
/// 页面框架
/// </summary>
public UIElement PageFrame { get;protected set; }
/// <summary>
/// 页面宽
/// </summary>
public double PageWidth { get; protected set; }
/// <summary>
/// 页面高
/// </summary>
public double PageHeight { get; protected set; }
/// <summary>
/// 页面显示比例
/// </summary>
public abstract double PageScale { get; set; }
/// <summary>
/// 页面显示最大比例
/// </summary>
public abstract double PageMaxScale { get; set; }
/// <summary>
/// 页面显示最小比例
/// </summary>
public abstract double PageMinScale { get; set; }
}
先定义一个默认页面如下:
/// <summary>
/// 默认页面
/// </summary>
class DefaultDocumentPage : DocumentPageBase,INotifyPropertyChanged
{
public DefaultDocumentPage(Guid guid) : base(guid)
{
//默认为横向A4页面,假定96dpi
PageWidth = 1123.0d;
PageHeight = 794.0d;
ResourceDictionary dic = new ResourceDictionary();
dic.Source = new Uri("pack://application:,,,/GravixCS;component/Themes/Resources/PageFrame/DefaultDocumentPage.xaml");
PageFrame = dic["defaultDocFrame"] as UIElement;
}
private double pageScale;
public override double PageScale
{
get
{
return pageScale;
}
set
{
pageScale = value;
OnPropertyChanged();
}
}
private double pageMaxScale;
public override double PageMaxScale
{
get
{
return pageMaxScale;
}
set
{
pageMaxScale = value;
OnPropertyChanged();
}
}
private double pageMinScale;
public override double PageMinScale
{
get
{
return pageMinScale;
}
set
{
pageMinScale = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
<Grid x:Key="defaultDocFrame" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.Resources>
<Style TargetType="Rectangle">
<Setter Property="Stroke" Value="Black"/>
<Setter Property="StrokeThickness" Value="1"/>
</Style>
</Grid.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15*"/>
<RowDefinition Height="763*"/>
<RowDefinition Height="15*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="1093*"/>
<ColumnDefinition Width="15*"/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="10"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style TargetType="mah:Underline">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Placement" Value="Bottom"/>
</Style>
</Grid.Resources>
<!--四角黑色三角形-->
<Grid Grid.Row="0" Grid.Column="0" >
<Polygon Points="0,0 0,15 15,0"/>
</Grid>
<Grid Grid.Row="2" Grid.Column="0" >
<Polygon Points="0,0 15,15 0,15"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="2" >
<Polygon Points="0,0 15,0 15,15" />
</Grid>
<Grid Grid.Row="2" Grid.Column="2" >
<Polygon Points="0,15 15,15 15,0"/>
</Grid>
<!--四围分区小框架8*6-->
<UniformGrid Rows="6" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0">
<Grid>
<TextBlock>A</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>B</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>C</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>D</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>E</TextBlock>
<mah:Underline/>
</Grid>
<TextBlock>F</TextBlock>
</UniformGrid>
<UniformGrid Rows="6" Grid.Row="0" Grid.RowSpan="3" Grid.Column="2">
<Grid>
<TextBlock>A</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>B</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>C</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>D</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>E</TextBlock>
<mah:Underline/>
</Grid>
<TextBlock>F</TextBlock>
</UniformGrid>
<UniformGrid Columns="8" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<UniformGrid.Resources>
<Style TargetType="mah:Underline">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Placement" Value="Right"/>
</Style>
</UniformGrid.Resources>
<Grid>
<TextBlock>1</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>2</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>3</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>4</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>5</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>6</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>7</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>8</TextBlock>
</Grid>
</UniformGrid>
<UniformGrid Columns="8" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<UniformGrid.Resources>
<Style TargetType="mah:Underline">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Placement" Value="Right"/>
</Style>
</UniformGrid.Resources>
<Grid>
<TextBlock>1</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>2</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>3</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>4</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>5</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>6</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>7</TextBlock>
<mah:Underline/>
</Grid>
<Grid>
<TextBlock>8</TextBlock>
</Grid>
</UniformGrid>
<!--大框架-->
<Grid Grid.Row="1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="570*"/>
<RowDefinition Height="36*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32*"/>
<ColumnDefinition Width="834*"/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="8"/>
<Setter Property="Margin" Value="1"/>
</Style>
</Grid.Resources>
<Rectangle Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2"/>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32*"/>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="34*"/>
<ColumnDefinition Width="18*"/>
<ColumnDefinition Width="23*"/>
<ColumnDefinition Width="54*"/>
<ColumnDefinition Width="172*"/>
<ColumnDefinition Width="91*"/>
<ColumnDefinition Width="146*"/>
<ColumnDefinition Width="215*"/>
<ColumnDefinition Width="32*"/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="mah:Underline">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Placement" Value="Right"/>
</Style>
</Grid.Resources>
<mah:Underline Placement="Top" Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Grid.ColumnSpan="11"/>
<mah:Underline Placement="Bottom" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="6"/>
<mah:Underline Placement="Bottom" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="6"/>
<mah:Underline Placement="Bottom" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="8"/>
<mah:Underline Grid.Column="0" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="1" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="2" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="3" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="4" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="5" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="6" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="7" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="8" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Grid.Column="9" Grid.Row="0" Grid.RowSpan="4"/>
<mah:Underline Placement="Bottom" Grid.Row="0" Grid.Column="10"/>
<mah:Underline Placement="Bottom" Grid.Row="1" Grid.Column="9" Grid.ColumnSpan="2"/>
<mah:Underline Placement="Bottom" Grid.Row="2" Grid.Column="10"/>
<!--Revision-->
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding RevisionIndex1}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding RevisionText1}"/>
<TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding RevisionDate1}"/>
<TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding RevisionName1}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding RevisionIndex2}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding RevisionText2}"/>
<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding RevisionDate2}"/>
<TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding RevisionName2}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{Binding RevisionIndex3}"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding RevisionText3}"/>
<TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding RevisionDate3}"/>
<TextBlock Grid.Row="2" Grid.Column="3" Text="{Binding RevisionName3}"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Rev." FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="Note" FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="2" Text="Date" FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="3" Text="Name" FontWeight="Medium" FontSize="7"/>
<!--Info-->
<TextBlock Grid.Row="0" Grid.Column="4" Text="Date" FontWeight="Medium"/>
<TextBlock Grid.Row="0" Grid.Column="5" Text="{Binding CreatedDate}"/>
<TextBlock Grid.Row="1" Grid.Column="4" Text="Author" FontWeight="Medium"/>
<TextBlock Grid.Row="1" Grid.Column="5" Text="{Binding CreatedBy}"/>
<TextBlock Grid.Row="2" Grid.Column="4" Text="Check" FontWeight="Medium"/>
<TextBlock Grid.Row="2" Grid.Column="5" Text="{Binding ReviewedBy}"/>
<TextBlock Grid.Row="3" Grid.Column="4" Text="Standard" FontWeight="Medium" FontSize="6.5"/>
<TextBlock Grid.Row="3" Grid.Column="5" Text="{Binding Owner.Owner.Owner.Standard}"/>
<!--PlantInfo-->
<TextBlock Grid.Row="0" Grid.Column="6" Text="{Binding Owner.Owner.Owner.Customer}"/>
<TextBlock Grid.Row="1" Grid.Column="6" Text="{Binding Owner.Owner.Owner.Purchaser}"/>
<TextBlock Grid.Row="2" Grid.Column="6" Text="{Binding Owner.Owner.Owner.ProjectName}"/>
<TextBlock Grid.Row="4" Grid.Column="6" Text="-"/>
<!--LOGO-->
<TextBlock Grid.Row="0" Grid.RowSpan="3" Grid.Column="7" Text="SIEMENS" HorizontalAlignment="Center"
FontWeight="ExtraBold" FontSize="20"/>
<TextBlock Grid.Row="3" Grid.Column="7" Text="-"/>
<!--DocumentInfo-->
<TextBlock Grid.Row="0" Grid.Column="8" Text="{Binding Owner.CabinetDescription}" FontWeight="Medium"/>
<TextBlock Grid.Row="1" Grid.Column="8" Text="{Binding DocumentDescription}" FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="8" Text="{Binding DocumentType.DocumentTypeDescription}"/>
<!--Page-->
<TextBlock Grid.Row="0" Grid.Column="10" Text="{Binding DocumentPageIndex}"/>
<Grid Grid.Row="2" Grid.Column="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Page "/>
<TextBlock Grid.Column="1" Text="{Binding PageNumber}"/>
</Grid>
<Grid Grid.Row="3" Grid.Column="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Pages}"/>
<TextBlock Grid.Column="1" Text="Pg "/>
</Grid>
<Grid Grid.Row="3" Grid.Column="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="97*"/>
<ColumnDefinition Width="75*"/>
</Grid.ColumnDefinitions>
<mah:Underline Grid.Column="0"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="9" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="101*"/>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="94*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<mah:Underline Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Margin="0 0 0 1"/>
<mah:Underline Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Margin="0 0 0 1"/>
<mah:Underline Placement="Bottom" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"/>
<!--Unit, Cabinet, Layer-->
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Owner.Owner.Owner.ProjectID}"/>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Owner.Owner.UnitName}" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DocumentType.DocumentTypeName,StringFormat={}&{0}}"/>
<Grid Grid.Row="0" Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="="/>
<TextBlock Grid.Column="1" Text="{Binding Owner.CabinetName}"/>
</Grid>
<Grid Grid.Row="1" Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="+"/>
<TextBlock Grid.Column="1" Text="{Binding Owner.CabinetName}"/>
<TextBlock Grid.Column="2" Text="{Binding CabinetLayer,StringFormat={}+.{0}}"/>
</Grid>
</Grid>
<Grid Grid.Row="2" Grid.Column="9" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="65*"/>
<ColumnDefinition Width="150*"/>
</Grid.ColumnDefinitions>
<mah:Underline Grid.Column="0" Grid.Row="0" Margin="0 -1 0 1"/>
</Grid>
</Grid>
<Grid Grid.Column="0" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="298*"/>
<RowDefinition Height="296*"/>
<RowDefinition Height="240*"/>
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5 2"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="6"/>
<Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
<Setter Property="LineHeight" Value="6"/>
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="mah:Underline">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Placement" Value="Right"/>
</Style>
</Grid.Resources>
<mah:Underline Grid.Row="0" Grid.Column="0" Grid.RowSpan="3"/>
<TextBlock Grid.Row="0">
<Run>Weitergabe sowie Vervielfältigung, Verbreitung und/oder Bearbeitung</Run>
<LineBreak/>
<Run>dieses Dokumentes,Verwertung und Mitteilung seines Inhaltes sind</Run>
<LineBreak/>
<Run>verboten, soweit nicht ausdrücklich gestattet. Zuwiderhandlungen ver-</Run>
<LineBreak/>
<Run>pflichten zu Schadenersatz. Alle Rechte für den Fall der Patenterteilung,</Run>
<LineBreak/>
<Run>Gebrauchsmuster- oder Geschmacksmustereintragung vorbehalten.</Run>
</TextBlock>
<TextBlock Grid.Row="1">
<Run>Transmittal, reproduction, dissemination and/or editing of this</Run>
<LineBreak/>
<Run>document as well as utilization of its contents and communication</Run>
<LineBreak/>
<Run>thereof to others without express authorization are prohibited. Offenders</Run>
<LineBreak/>
<Run>will be held liable for payment of damages. All rights created by patent</Run>
<LineBreak/>
<Run>grant or registration of a utility model or design patent are reserved.</Run>
</TextBlock>
<TextBlock Grid.Row="2">
<Run FontWeight="Bold">AL: N ECCN: N</Run>
<LineBreak/>
<Run>Copyright © Siemens Energy All Rights Reserved</Run>
</TextBlock>
</Grid>
</Grid>
</Grid>
</Grid>
在GravixCSDiagrams样式中关联Binding如下:
<Style TargetType="local:GravixCSDiagram" x:Key="GravixCSDiagramStyle">
<Setter Property="Width" Value="{Binding Page.PageWidth}"/>
<Setter Property="Height" Value="{Binding Page.PageHeight}"/>
<Setter Property="GravixCSFrame" Value="{Binding Page.PageFrame}"/>
<Setter Property="MaxScale" Value="{Binding Page.PageMaxScale}"/>
<Setter Property="MinScale" Value="{Binding Page.PageMinScale}"/>
<Setter Property="Scale" Value="{Binding Page.PageScale}"/>
</Style>
把旧图纸翻出来输入数据,效果如下:
页面模板实现如下: