AnnotationStyling批注样式

1、实现效果

  1. 可以选择不同便笺样式,对所有批注应用样式
  2. 选择文本后实现对批注的文本、墨迹便笺创建、删除
  3. 对选择文本的部分创建高亮不同颜色的批注,及实现清除命令

2、关注词

  1. StickyNoteControl+自定义样式类

3、静态组织
流文档页面浏览器的资源字典设定,可作为ComboBox的绑定源参数

<FlowDocumentPageViewer.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="DefaultStickyNoteStyle.xaml"/><ResourceDictionary Source="StylingUsingProperties.xaml"/><ResourceDictionary Source="AdvancedStyling.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary>
</FlowDocumentPageViewer.Resources>

ComboBox的绑定设置:

  1. ItemsSource绑定源为文档的资源字典,通过转换获取Collection<StyleMetaData>数据项
  2. 子项模板绑定为上述数据项的其Key值来显示
  3. 新建高亮批注按钮绑定到批注服务AnnotationService的路由命令字段。同时传递不同颜色的命令参数CommandParameter
<!-- Annotations Toolbar -->
<ToolBar><GroupBox Header="StickyNote Style"><ComboBox Name="StyleCombo" Width="Auto"ItemsSource="{Binding ElementName=Viewer,Path=Resources.MergedDictionaries,Converter={StaticResource ResourceConverter}}"ItemTemplate="{StaticResource StyleOptionTemplate}"SelectionChanged="OnStyleSelected"/></GroupBox><Button Content="Text" Width="30"Command="annotations:AnnotationService.CreateTextStickyNoteCommand" /><Button Content="Ink" Width="30"Command="annotations:AnnotationService.CreateInkStickyNoteCommand" /><Button Content="Delete" Width="50"Command="annotations:AnnotationService.DeleteStickyNotesCommand" /><Button Background="Yellow" Style="{StaticResource HighlightColorButtonStyle}"Command="annotations:AnnotationService.CreateHighlightCommand"CommandParameter="{StaticResource YellowHighlight}" /><Button Background="Green" Style="{StaticResource HighlightColorButtonStyle}"Command="annotations:AnnotationService.CreateHighlightCommand"CommandParameter="{StaticResource GreenHighlight}" />.....

ResourceConverter资源字典转换为自定义Collection<StyleMetaData>:

  1. 获取选定项的类型Collection<ResourceDictionary>及新建要返回的类型Collection<StyleMetaData>
  2. 找到字典中对应的类型StickyNoteControl(Type.TargetType.Equals())
  3. 循环复制键值对到自定义类StyleMetaData
[ValueConversion(typeof (Collection<StyleMetaData>),typeof (Collection<ResourceDictionary>))]
public class ResourceEntryToComboItemConverter : IValueConverter
{// ----------------------------- Convert ------------------------------/// <summary>///     Parses a collection of ResourceDictionaries and///     extracts all StickyNote styles./// </summary>/// <returns>///     A list of Styles and their associated///     keys (for identification)./// </returns>public object Convert(object value, Type targetType,object parameter, CultureInfo culture){var unfiltered =value as Collection<ResourceDictionary>;var filtered =new Collection<StyleMetaData>();foreach (var dict in unfiltered){foreach (string key in dict.Keys){var aStyle = dict[key] as Style;if (aStyle != null && aStyle.TargetType.Equals(typeof (StickyNoteControl)))filtered.Add(new StyleMetaData(key, aStyle));}}return filtered;} // end:Convert// --------------------------- ConvertBack ----------------------------public object ConvertBack(object value, Type targetType,object parameter, CultureInfo culture) => null;
}

自定义类StyleMetaData:
此类需要继承依赖性,注册Key依赖属性,方便ComboBox子项数据模板绑定Text="{binding Path=Key}"

/// <summary>
///     Provides a simple wrapper that associates a
///     Style with its ResourceDictionary key.
/// </summary>
public class StyleMetaData : DependencyObject
{public static DependencyProperty KeyProperty =DependencyProperty.Register("Key", typeof (string), typeof (StyleMetaData));public Style Value;public StyleMetaData(string key, Style value){Key = key;Value = value;}public string Key{get { return (string) GetValue(KeyProperty); }set { SetValue(KeyProperty, value); }}
}

4、运行流程
当选择ComboBox不同选择项时:

  1. 获取选定项及其对应样式实例new Style(),继承此样式即可得新样式
  2. 清除文档的资源,添加新建的样式资源
  3. 重新加载批注,因此批注会自动应用新便笺样式
// ------------------------- OnStyleSelected --------------------------
/// <summary>
///     Replaces the default StickyNote style when a new
///     style is selected from the drop down combo box.
/// </summary>
protected void OnStyleSelected(object sender, SelectionChangedEventArgs e)
{// Extract the selected style.var source = (ComboBox) e.Source;var selectedStyle = (StyleMetaData) source.SelectedItem;var newStyle = new Style(typeof (StickyNoteControl)) {BasedOn = selectedStyle.Value};// Replace the default StickyNote style with the one that was just selected.var defaultKey = typeof (StickyNoteControl);if (Viewer.Resources.Contains(defaultKey))Viewer.Resources.Remove(defaultKey);Viewer.Resources.Add(defaultKey, newStyle);// Re-load annotations so that they pickup new style.var service = AnnotationService.GetService(Viewer);service.Disable();service.Enable(service.Store);
}

主窗口加载时:获取存储的批注便笺并加载

/// <summary>
///     Turns Annotations on.
/// </summary>
protected void OnLoaded(object sender, RoutedEventArgs e)
{// Make sure that an AnnotationService isn�t already enabled.var service = AnnotationService.GetService(Viewer);if (service == null){// (a) Create a Stream for the annotations to be stored in._annotationStream =new FileStream("annotations.xml", FileMode.OpenOrCreate);// (b) Create an AnnotationService on our// FlowDocumentPageViewer.service = new AnnotationService(Viewer);// (c) Create an AnnotationStore and give it the stream we// created. (Autoflush == false)AnnotationStore store = new XmlStreamStore(_annotationStream);// (d) "Turn on annotations". Annotations will be persisted in// the stream created at (a).service.Enable(store);}
} 

关闭主窗口时:保存批注编辑信息,把缓冲区数据写入xmlw文件存储

/// <summary>
///     Turns Annotations off.
/// </summary>
protected void OnUnloaded(object sender, RoutedEventArgs e)
{// (a) Check that an AnnotationService// actually existed and was Enabled.var service = AnnotationService.GetService(Viewer);if (service != null && service.IsEnabled){// (b) Flush changes to annotations to our stream.service.Store.Flush();// (c) Turn off annotations.service.Disable();// (d) Close our stream._annotationStream.Close();}
}

最后样式便笺样式xaml:
StylingUsingProperties.xaml:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><!-- Change the background of a StickyNote.--><Style x:Key="OverrideBackground" TargetType="{x:Type StickyNoteControl}"><Setter Property="Background" Value="Yellow"/></Style><!-- Change the behavior of a StickyNote. --><Style x:Key="OverrideSimpleBehavior" TargetType="{x:Type StickyNoteControl}"><!-- Set a default transform on the note. --><Setter Property="RenderTransform"><Setter.Value><ScaleTransform ScaleX=".5" ScaleY=".5"/></Setter.Value></Setter><!-- Add a trigger that changes the default transform when clicked in. --><Style.Triggers><Trigger Property="StickyNoteControl.IsActive" Value="True"><Setter Property="RenderTransform"><Setter.Value><ScaleTransform ScaleX="1" ScaleY="1"/></Setter.Value></Setter></Trigger></Style.Triggers></Style>

AdvancedStyling.xaml:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><!-- Here is an example of the absolute minimum style that can be defined for a StickyNoteControl --><Style x:Key="MinimumStyle" TargetType="{x:Type StickyNoteControl}"><!-- Override default style completely --><Setter Property="OverridesDefaultStyle" Value="true" /><Setter Property="Width" Value="100" /><Setter Property="Height" Value ="100" /><Style.Triggers><Trigger Property="StickyNoteControl.StickyNoteType" Value="{x:Static StickyNoteType.Ink}"><!-- Custom template that only contains required controls --><Setter Property="Template"><Setter.Value><ControlTemplate><InkCanvas Name="PART_ContentControl" Background="LightYellow" /></ControlTemplate></Setter.Value></Setter></Trigger><Trigger Property="StickyNoteControl.StickyNoteType" Value="{x:Static StickyNoteType.Text}"><Setter Property="Template"><Setter.Value><ControlTemplate><RichTextBox Name="PART_ContentControl" Background="LightYellow"/></ControlTemplate></Setter.Value></Setter></Trigger></Style.Triggers></Style><!--Example of how you could override the expanded and iconified appearance of a noteand maintain the behavior of being able to toggle between modes.--><Style x:Key="CustomizedExpandableNote" TargetType="{x:Type StickyNoteControl}"><Style.Triggers><Trigger Property="StickyNoteControl.StickyNoteType" Value="{x:Static StickyNoteType.Ink}"><Setter Property="Template"><Setter.Value><ControlTemplate><Grid Background="Green" Name="TheGrid"><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition /></Grid.RowDefinitions><Menu><CheckBox Name="CB" Width="20" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true}" /></Menu><InkCanvas Grid.Row="1" Name="PART_ContentControl" Background="LightYellow" /></Grid></ControlTemplate></Setter.Value></Setter></Trigger><Trigger Property="StickyNoteControl.StickyNoteType" Value="{x:Static StickyNoteType.Text}"><Setter Property="Template"><Setter.Value><ControlTemplate><Grid Background="Green" Name="TheGrid"><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition /></Grid.RowDefinitions><Menu><CheckBox Name="CB" Width="20" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true}" /></Menu><RichTextBox Grid.Row="1" Name="PART_ContentControl" Background="LightYellow"/></Grid></ControlTemplate></Setter.Value></Setter></Trigger><Trigger Property="StickyNoteControl.IsExpanded" Value="False"><Setter Property="Control.Template"><Setter.Value><ControlTemplate><DockPanel Background="Blue"><CheckBox IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true}" /></DockPanel></ControlTemplate></Setter.Value></Setter></Trigger></Style.Triggers></Style>
</ResourceDictionary>

DefaultStickeyNoteStyle.xaml:

<!--
This is the full default StickyNote Style definition.
-->
<ResourceDictionary     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:sys="clr-namespace:System;assembly=mscorlib"><!-- Define default hight and width. --><sys:Double x:Key="StickyNoteDefaultIconWidth">40.0</sys:Double><sys:Double x:Key="ResourceId=StickyNoteDefaultIconHeight">30.0</sys:Double><!-- Style Root: this is the main portion of the StickyNote style, it configures all the defaultsand defines the overall behavior of the note by referencing other sub-styles.--><Style x:Key="DefaultStickyNoteStyle" TargetType="{x:Type StickyNoteControl}"><Setter Property="Width" Value="16" /><Setter Property="Height" Value="16" /><Setter Property="Cursor" Value="Arrow" /><Setter Property="FontFamily" Value="Verdana" /><Setter Property="KeyboardNavigation.TabNavigation" Value="Cycle" /><Setter Property="KeyboardNavigation.ControlTabNavigation" Value="Once" /><!-- 12(point size) * 96.0 / 72.0 --><Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MessageFontSizeKey}}" /><Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MessageFontStyleKey}}" /><Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MessageFontWeightKey}}" /><Setter Property="CaptionFontFamily" Value="Segoe UI,Arial" /><Setter Property="CaptionFontSize" Value="9.0" /><Setter Property="CaptionFontStyle" Value="{DynamicResource {x:Static SystemFonts.MessageFontStyleKey}}" /><Setter Property="CaptionFontWeight" Value="{DynamicResource {x:Static SystemFonts.MessageFontWeightKey}}" /><Setter Property="BorderThickness" Value="2" /><Setter Property="BorderBrush" Value="#FF008000" /><Setter Property="Background"><Setter.Value><DrawingBrush><DrawingBrush.Drawing><!-- Drawing a rotated linear gradient rectangle: Angle 20, Width 400 Height 300 --><GeometryDrawing><GeometryDrawing.Brush><LinearGradientBrush StartPoint="0,0" EndPoint="163.650855,449.627030" MappingMode="Absolute"><LinearGradientBrush.GradientStops><GradientStop Color="#FFD3F4D3" Offset="0.0" /><GradientStop Color="#FFAFEBAF" Offset="1.0" /></LinearGradientBrush.GradientStops></LinearGradientBrush></GeometryDrawing.Brush><GeometryDrawing.Geometry><RectangleGeometry Rect="0,0, 400, 300" /></GeometryDrawing.Geometry></GeometryDrawing></DrawingBrush.Drawing></DrawingBrush></Setter.Value></Setter><Setter Property="Template" Value="{DynamicResource StickyNoteIconTemplate}" /><Style.Triggers><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsExpanded" Value="true" /><Condition Property="StickyNoteType" Value="{x:Static StickyNoteType.Ink}" /></MultiTrigger.Conditions><Setter Property="Control.Template" Value="{DynamicResource StickyNoteExpandedInkTemplate}" /></MultiTrigger><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsExpanded" Value="true" /><Condition Property="StickyNoteType" Value="{x:Static StickyNoteType.Text}" /></MultiTrigger.Conditions><Setter Property="Control.Template" Value="{DynamicResource StickyNoteExpandedTextTemplate}" /></MultiTrigger><Trigger Property="IsExpanded" Value="true"><Setter Property="Width" Value="220" /><Setter Property="Height" Value="169" /><Setter Property="MinWidth" Value="190.0" /><Setter Property="MinHeight" Value="73.0" /></Trigger><Trigger Property="IsActive" Value="false"><Setter Property="Background" Value="#FFE1F5E1" /></Trigger></Style.Triggers></Style><!-- Text Template: Style which defines the basic appearance of a Text StickyNoteControl.--><ControlTemplate x:Key="StickyNoteExpandedTextTemplate"><ControlTemplate.Resources><!-- StickyNote's RichTextBox Style --><Style TargetType="{x:Type RichTextBox}"><Setter Property="Background" Value="Transparent" /><Setter Property="BorderThickness" Value="0" /><Setter Property="AcceptsReturn" Value="true" /><Setter Property="IsReadOnly" Value="false" /><Setter Property="TabIndex" Value="0" /><Setter Property="IsTabStop" Value="true" /><Setter Property="KeyboardNavigation.TabNavigation" Value="Once" /><Setter Property="Padding" Value="0,0,0,0" /><Setter Property="Margin" Value="0,0,0,0" /><Style.Resources><Style TargetType="{x:Type Paragraph}"><Setter Property="Margin" Value="0" /></Style></Style.Resources></Style></ControlTemplate.Resources><Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"><Border x:Name="NoteBorder" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="{TemplateBinding Background}" BorderThickness="1,1,1,1" BorderBrush="Transparent" CornerRadius="6,6,6,6" /><Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="6,6,6,6"  xml:lang="en-US"><Grid KeyboardNavigation.TabNavigation="Local"><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="Auto" /><RowDefinition Height="*" /><RowDefinition Height="Auto" /></Grid.RowDefinitions><Thumb x:Name="PART_TitleThumb" Grid.Row="0" Style="{DynamicResource StickyNoteTitleThumbStyleKey}"/><Button x:Name="PART_CloseButton" TabIndex="2" Style="{DynamicResource StickyNoteCloseButtonStyleKey}"/><!-- 9(point size) * 96.0 / 72.0 --><Border Name="MenuBorder" Background="#FFDFF7DF" BorderThickness="0,1,0,1" BorderBrush="#FF2DB32D" Grid.Row="1"><Menu Padding="0" x:Name="Menu" FontFamily="{TemplateBinding StickyNoteControl.CaptionFontFamily}" FontSize="{TemplateBinding StickyNoteControl.CaptionFontSize}" FontStyle="{TemplateBinding StickyNoteControl.CaptionFontStyle}" FontWeight="{TemplateBinding StickyNoteControl.CaptionFontWeight}" FontStretch="{TemplateBinding StickyNoteControl.CaptionFontStretch}" Foreground="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" Background="Transparent" KeyboardNavigation.TabNavigation="Continue"><MenuItem Padding="6,0,6,0" x:Name="EditMenuItem" Header="Edit" TabIndex="1"><MenuItem x:Name="PART_CopyMenuItem" Header="_Copy" Command="ApplicationCommands.Copy" CommandTarget="{Binding ElementName=PART_ContentControl}" /><MenuItem x:Name="PART_PasteMenuItem" Header="_Paste" Command="ApplicationCommands.Paste" CommandTarget="{Binding ElementName=PART_ContentControl}" /><Separator x:Name="PART_ClipboardSeparator" /><MenuItem x:Name="PART_DeleteMenuItem" Header="_Delete Note" Command="StickyNoteControl.DeleteNoteCommand" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /></MenuItem></Menu></Border><RichTextBox x:Name="PART_ContentControl" Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled"><FlowDocument FlowDirection="{TemplateBinding FlowDirection}" /></RichTextBox><Border x:Name="TitleBorder" Grid.Row="3" CornerRadius="0,0,6,6" Background="Transparent" BorderThickness="0,1,0,0" BorderBrush="#FF2DB32D"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><TextBlock x:Name="AuthorTextBlock" Grid.Column="0" Margin="3,0,3,0" Opacity="0.5" TextElement.FontFamily="{TemplateBinding StickyNoteControl.CaptionFontFamily}" TextElement.FontSize="{TemplateBinding StickyNoteControl.CaptionFontSize}" TextElement.FontStyle="{TemplateBinding StickyNoteControl.CaptionFontStyle}" TextElement.FontWeight="{TemplateBinding StickyNoteControl.CaptionFontWeight}" TextElement.FontStretch="{TemplateBinding StickyNoteControl.CaptionFontStretch}" TextElement.Foreground="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" TextAlignment="Left" TextWrapping="NoWrap" Text="{TemplateBinding StickyNoteControl.Author}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" /><Thumb x:Name="PART_ResizeBottomRightThumb" VerticalAlignment="Bottom" Grid.Column="1" Style="{DynamicResource StickyNoteResizeBottomRightThumbStyleKey}"/></Grid></Border></Grid></Border></Canvas><ControlTemplate.Triggers><Trigger Property="StickyNoteControl.IsActive" Value="false"><Setter TargetName="MenuBorder" Property="Visibility" Value="Hidden" /><Setter TargetName="NoteBorder" Property="Control.BorderThickness" Value="1" /><Setter TargetName="TitleBorder" Property="BorderBrush" Value="Transparent" /></Trigger><EventTrigger RoutedEvent="ButtonBase.Click" SourceName="PART_CloseButton"><EventTrigger.Actions><BeginStoryboard Name="HideNoteTimeline"><BeginStoryboard.Storyboard><Storyboard TargetProperty="(UIElement.Opacity)"><DoubleAnimation From="0.0" To="1.0" Duration="0:0:0.3" FillBehavior="HoldEnd" /></Storyboard></BeginStoryboard.Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></ControlTemplate.Triggers></ControlTemplate><!-- Ink Template: Style which defines the basic appearance of an Ink StickyNoteControl--><ControlTemplate x:Key="StickyNoteExpandedInkTemplate"><ControlTemplate.Resources><!-- StickyNote's InkCanvas Style --><Style TargetType="{x:Type InkCanvas}"><Setter Property="MinWidth" Value="0" /><Setter Property="MinHeight" Value="0" /><Setter Property="Control.TabIndex" Value="0" /><Setter Property="Control.IsTabStop" Value="true" /><Setter Property="Background"><Setter.Value><DrawingBrush Viewbox="0,0,1,32" ViewboxUnits="Absolute" Viewport="0,0,1,32" ViewportUnits="Absolute" AlignmentX="Left" AlignmentY="Top" TileMode="Tile" Stretch="None"><DrawingBrush.Drawing><GeometryDrawing Geometry="M 0, 31.5 L 1, 31.5"><GeometryDrawing.Pen><Pen Brush="#40000000" Thickness="1" /></GeometryDrawing.Pen></GeometryDrawing></DrawingBrush.Drawing></DrawingBrush></Setter.Value></Setter><Style.Triggers><Trigger Property="StickyNoteControl.IsActive" Value="false"><Setter Property="Background" Value="Transparent" /></Trigger></Style.Triggers></Style></ControlTemplate.Resources><Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"><Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="{TemplateBinding Background}" BorderThickness="1,1,1,1" BorderBrush="Transparent" CornerRadius="6,6,6,6" /><Border x:Name="NoteBorder" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="6,6,6,6"  xml:lang="en-US"><Grid KeyboardNavigation.TabNavigation="Local"><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="Auto" /><RowDefinition Height="*" /><RowDefinition Height="Auto" /></Grid.RowDefinitions><Thumb x:Name="PART_TitleThumb" Style="{DynamicResource StickyNoteTitleThumbStyleKey}" Grid.Row="0" /><Button x:Name="PART_CloseButton" Style="{DynamicResource StickyNoteCloseButtonStyleKey}" TabIndex="2" /><Border Name="MenuBorder" Background="#FFDFF7DF" BorderThickness="0,1,0,1" BorderBrush="#FF2DB32D" Grid.Row="1"><Menu Padding="0" x:Name="Menu" FontFamily="{TemplateBinding StickyNoteControl.CaptionFontFamily}" FontSize="{TemplateBinding StickyNoteControl.CaptionFontSize}" FontStyle="{TemplateBinding StickyNoteControl.CaptionFontStyle}" FontWeight="{TemplateBinding StickyNoteControl.CaptionFontWeight}" FontStretch="{TemplateBinding StickyNoteControl.CaptionFontStretch}" Foreground="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" Background="Transparent" KeyboardNavigation.TabNavigation="Continue"><MenuItem Padding="6,0,6,0" x:Name="EditMenuItem" Header="Edit" TabIndex="1"><MenuItem x:Name="PART_CopyMenuItem" Header="_Copy" Command="ApplicationCommands.Copy" CommandTarget="{Binding ElementName=PART_ContentControl}" /><MenuItem  x:Name="PART_PasteMenuItem" Header="_Paste" Command="ApplicationCommands.Paste"  CommandTarget="{Binding ElementName=PART_ContentControl}"/><Separator  x:Name="PART_ClipboardSeparator" /><MenuItem  x:Name="PART_DeleteMenuItem" Header="_Delete Note" Command="StickyNoteControl.DeleteNoteCommand" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /><Separator  x:Name="InkMenuItemsSeparator" /><MenuItem x:Name="PART_InkMenuItem" Header="_Ink" Command="StickyNoteControl.InkCommand" CommandParameter="{x:Static InkCanvasEditingMode.Ink}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /><MenuItem  x:Name="PART_SelectMenuItem" Header="_Select" Command="StickyNoteControl.InkCommand" CommandParameter="{x:Static InkCanvasEditingMode.Select}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /><MenuItem x:Name="PART_EraseMenuItem" Header="_Erase" Command="StickyNoteControl.InkCommand" CommandParameter="{x:Static InkCanvasEditingMode.EraseByStroke}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /></MenuItem></Menu></Border><ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Grid.Row="2" Margin="3,0,3,0"><InkCanvas x:Name="PART_ContentControl" FlowDirection="LeftToRight" /></ScrollViewer><Border x:Name="TitleBorder" Grid.Row="3" CornerRadius="0,0,6,6" Background="Transparent" BorderThickness="0,1,0,0" BorderBrush="#FF2DB32D"><Grid ><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><TextBlock x:Name="AuthorTextBlock" Grid.Column="0" Margin="3,0,3,0" Opacity="0.5" TextElement.FontFamily="{TemplateBinding StickyNoteControl.CaptionFontFamily}" TextElement.FontSize="{TemplateBinding StickyNoteControl.CaptionFontSize}" TextElement.FontStyle="{TemplateBinding StickyNoteControl.CaptionFontStyle}" TextElement.FontWeight="{TemplateBinding StickyNoteControl.CaptionFontWeight}" TextElement.FontStretch="{TemplateBinding StickyNoteControl.CaptionFontStretch}" TextElement.Foreground="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" TextAlignment="Left" TextWrapping="NoWrap" Text="{TemplateBinding StickyNoteControl.Author}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" /><Thumb Style="{DynamicResource StickyNoteResizeBottomRightThumbStyleKey}" x:Name="PART_ResizeBottomRightThumb" VerticalAlignment="Bottom" Grid.Column="1" /></Grid></Border></Grid></Border></Canvas><ControlTemplate.Triggers><Trigger Property="StickyNoteControl.IsActive" Value="false"><Setter TargetName="MenuBorder" Property="Visibility" Value="Hidden" /><Setter TargetName="NoteBorder" Property="Control.BorderThickness" Value="1" /><Setter TargetName="TitleBorder" Property="BorderBrush" Value="Transparent" /><Setter TargetName="ScrollViewer" Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" /><Setter TargetName="ScrollViewer" Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" /></Trigger><Trigger Property="StickyNoteControl.IsActive" Value="true"><Setter TargetName="PART_ContentControl" Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /></Trigger><EventTrigger RoutedEvent="ButtonBase.Click" SourceName="PART_CloseButton"><EventTrigger.Actions><BeginStoryboard Name="HideNoteTimeline"><BeginStoryboard.Storyboard><Storyboard TargetProperty="(UIElement.Opacity)"><DoubleAnimation From="0.0" To="1.0" Duration="0:0:0.3" FillBehavior="HoldEnd" /></Storyboard></BeginStoryboard.Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></ControlTemplate.Triggers></ControlTemplate><!-- Title Thumb Style: Controls the appearance of the StickyNoteControl TitleBar.--><Style x:Key="StickyNoteTitleThumbStyleKey" TargetType="{x:Type Thumb}"><Setter Property="Height" Value="20" /><Setter Property="Background"><Setter.Value><LinearGradientBrush StartPoint="0,0" EndPoint="0,1"><GradientBrush.GradientStops><GradientStopCollection x:Uid="GradientStopCollection_78"><GradientStop Color="#FFC1EFC1" Offset="0" /><GradientStop Color="#FF6CDA6C" Offset="1" /></GradientStopCollection></GradientBrush.GradientStops></LinearGradientBrush></Setter.Value></Setter><Setter Property="Template"><Setter.Value><ControlTemplate x:Uid="ControlTemplate_21"><Border Background="{TemplateBinding Background}" CornerRadius="5,5,0,0"><Border Margin="0,3,0,0" Width="40" Height="4" Background="{TemplateBinding Foreground}" VerticalAlignment="Top" HorizontalAlignment="Center" /></Border></ControlTemplate></Setter.Value></Setter><Setter Property="Foreground"><Setter.Value><DrawingBrush Viewbox="0,0,1,1" Viewport="0,0,4,4" TileMode="Tile" ViewportUnits="Absolute" AlignmentX="Left" AlignmentY="Top"><DrawingBrush.Drawing><DrawingGroup><DrawingGroup.Children><GeometryDrawing Brush="White" Geometry="M 0.6 0.3 A 0.7 0.7 0 1 0 0.6 0.61  z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 0 0 A 0.6 0.6 0 1 0 0 0.01  z" /></DrawingGroup.Children></DrawingGroup></DrawingBrush.Drawing></DrawingBrush></Setter.Value></Setter><Style.Triggers><Trigger Property="IsMouseOver" Value="true"><Setter Property="Background"><Setter.Value><LinearGradientBrush x:Uid="LinearGradientBrush_79" StartPoint="0,0" EndPoint="0,1"><GradientBrush.GradientStops><GradientStopCollection x:Uid="GradientStopCollection_79"><GradientStop Color="#FFA4E8A4" Offset="0" /><GradientStop Color="#FF28A028" Offset="1" /></GradientStopCollection></GradientBrush.GradientStops></LinearGradientBrush></Setter.Value></Setter></Trigger><MultiTrigger ><MultiTrigger.Conditions><Condition Property="IsMouseOver" Value="false" /><Condition Property="StickyNoteControl.IsActive" Value="false" /></MultiTrigger.Conditions><Setter Property="Background"><Setter.Value><LinearGradientBrush StartPoint="0,0" EndPoint="0,1"><GradientBrush.GradientStops><GradientStopCollection x:Uid="GradientStopCollection_80"><GradientStop Color="#FFECF9EC" Offset="0" /><GradientStop Color="#FFC3EBC3" Offset="1" /></GradientStopCollection></GradientBrush.GradientStops></LinearGradientBrush></Setter.Value></Setter></MultiTrigger></Style.Triggers></Style><!-- Resize Thumb Style: Controls the appearance of the StickyNoteControl resize thumb.--><Style x:Key="StickyNoteResizeBottomRightThumbStyleKey" TargetType="{x:Type Thumb}"><Setter Property="Template"><Setter.Value><ControlTemplate><Border Background="{TemplateBinding Background}" /></ControlTemplate></Setter.Value></Setter><Setter Property="Cursor" Value="SizeNWSE" /><Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" /><Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}" /><Setter Property="Background"><Setter.Value><DrawingBrush AlignmentX="Center" AlignmentY="Center" TileMode="None" Stretch="None"><DrawingBrush.Drawing><DrawingGroup><DrawingGroup.Children><GeometryDrawing Brush="White" Geometry="M 5.8 12.8 A 0.8 0.8 0 1 0 5.8 12.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 5 12 A 0.7 0.7 0 1 0 5 12.1 z" /><GeometryDrawing Brush="White" Geometry="M 9.8 8.8 A 0.8 0.8 0 1 0 9.8 8.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 9 8 A 0.7 0.7 0 1 0 9 8.1 z" /><GeometryDrawing Brush="White" Geometry="M 13.8 4.8 A 0.8 0.8 0 1 0 13.8 4.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 13 4 A 0.7 0.7 0 1 0 13 4.1 z" /><GeometryDrawing Brush="White" Geometry="M 9.8 12.8 A 0.8 0.8 0 1 0 9.8 12.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 9 12 A 0.7 0.7 0 1 0 9 12.1 z" /><GeometryDrawing Brush="White" Geometry="M 13.8 8.8 A 0.8 0.8 0 1 0 13.8 8.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 13 8 A 0.7 0.7 0 1 0 13 8.1 z" /><GeometryDrawing Brush="White" Geometry="M 13.8 12.8 A 0.8 0.8 0 1 0 13.8 12.9 z" /><GeometryDrawing Brush="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Geometry="M 13 12 A 0.7 0.7 0 1 0 13 12.1 z" /></DrawingGroup.Children></DrawingGroup></DrawingBrush.Drawing></DrawingBrush></Setter.Value></Setter><Style.Triggers><Trigger Property="FlowDirection" Value="{x:Static FlowDirection.RightToLeft}"><Setter Property="Cursor" Value="SizeNESW" /></Trigger></Style.Triggers></Style><!-- StickyNote's Button Style: Baseline style for all buttons that are used inside StickyNoteControl.--><Style x:Key="StickyNoteButtonStyleKey" BasedOn="{x:Null}" TargetType="{x:Type Button}"><Setter Property="OverridesDefaultStyle" Value="true" /><Setter Property="Template"><Setter.Value><ControlTemplate ><Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"><Border Background="{TemplateBinding Foreground}" /></Border></ControlTemplate></Setter.Value></Setter></Style><!--Close Button Style: Controls the appearance of the StickyNoteControl Close button.--><Style x:Key="StickyNoteCloseButtonStyleKey" BasedOn="{StaticResource StickyNoteButtonStyleKey}" TargetType="{x:Type Button}"><Setter Property="Width" Value="24" /><Setter Property="Height" Value="18" /><Setter Property="VerticalAlignment" Value="Center" /><Setter Property="HorizontalAlignment" Value="Right" /><Setter Property="BorderBrush" Value="#FF60BB60" /><Setter Property="BorderThickness" Value="1,1,1,1" /><Setter Property="Background"><Setter.Value><LinearGradientBrush StartPoint="0,0" EndPoint="0,1"><GradientBrush.GradientStops><GradientStopCollection><GradientStop Color="#FFD8F5D8" Offset="0" /><GradientStop Color="#FFADEBAD" Offset="1" /></GradientStopCollection></GradientBrush.GradientStops></LinearGradientBrush></Setter.Value></Setter><Setter Property="Margin" Value="0,0,3,0" /><Setter Property="Foreground"><Setter.Value><DrawingBrush ViewboxUnits="Absolute" Viewbox="0,0,24,18" Viewport="0,0,1,1" TileMode="Tile"><DrawingBrush.Drawing><GeometryDrawing Geometry="M 6, 12 L 18, 12"><GeometryDrawing.Pen><Pen Brush="Black" Thickness="1.5" StartLineCap="Round" EndLineCap="Round" /></GeometryDrawing.Pen></GeometryDrawing></DrawingBrush.Drawing></DrawingBrush></Setter.Value></Setter></Style>
</ResourceDictionary>

WPF:Documents文档--Annomation批注(3)相关推荐

  1. WPF:Documents文档--Annomation批注(1)

    AnnotatedDocumentViewer批注文档浏览 1.实现功能: 文档右键菜单创建和删除批注命令 ListBox显示批注创建时间(排序)和内容 选定一个批注,流文档显示到对应批注锚定 2.关 ...

  2. 如何利用Word 2016为文档添加批注

    在日常工作中,某些文件需要领导审阅或者经过大家讨论后才能够执行,所以就需要在这些文件上进行一些批示.修改.办公软件提供了批注.修订.更改等审阅工具,大大提高了办公效率.在使用Word 2016编辑文档 ...

  3. Java代码清除Word文档的批注和修订 (Aspose.Words) Java老铁们,亲测有效!

    项目里面要求Word文档接受修订,并要去掉批注,常见的工具库有POI和JXL,但有些功能不太强大,用起来也啰嗦,这里用Aspose.Words这个类库来实现一下. 文档链接 在这里 : https:/ ...

  4. 安卓PDF阅读器使用技巧Ⅱ:PDF文档添加批注、添加下划线及删除技巧

    如何更好地使你的PDF文档便于使用?以确保你在后续的阅读/编辑中可以更加得心应手?如果手头只有一部手机的情况下,我们可以借助PDF阅读器的的编辑功能,通过高亮显示.增加下划线等操作,来完成你对文档的重 ...

  5. word文档添加批注

    插入->批注

  6. WPF中使用流文档灵活地显示内容

    WPF中使用流文档灵活地显示内容                             by: Markus Egger                             form: http ...

  7. mongodb 基本概念:文档(Documents)

    mongodb将数据存为BSON 文档格式,BSON 是json文档的二进制格式,但是比json支持更多数据类型,详见:bsonspec.org 1.数据结构 mongodb文档由键值对组成 {fie ...

  8. 如何批量设置 Word 文档仅允许批注或修订?

    概要:在 Word 文档中文档的保护有多种不同的级别.可以设置 Word 文档的打开密码,也可以设置 Word 文档的只读密码,还可以限制 Word 的编辑.并且限制编辑的同时也可以允许批注或者允许批 ...

  9. 实施文档_Word 2010文档处理案例教程

    Word 2010文档处理案例教程 ISBN:978-7-80243-928-3/02 作者:黄桂林 江义火 郭燕 定价:38.00元 出版社:航空工业出版社 适用层次:通用 出版日期:2019-10 ...

最新文章

  1. Twitter在超分辨率技术上取得新进展,能还原打码图片
  2. CSS魔法堂:重拾Border之——图片作边框
  3. 开发函数计算的正确姿势 —— 爬虫
  4. ALV 动态显示列Demo
  5. TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'的解决方法等
  6. 【linux笔记】linux权限命令
  7. 在docker中配置apt工具与python的源均为国内源
  8. java怎么编译_java怎么编译运行?java有哪些编译方法?
  9. 飞盘比赛(入门oj Problem 5961)
  10. STL 格式解析--文本以及二进制格式
  11. C# 中Session的用法
  12. 如何下载B站高清视频
  13. 计算机网络的作用拓展图,拓扑图介绍及相关功能
  14. C#之AutoCAD图层样式定义
  15. aix 下创建vg和lv
  16. 超级详细的HTML5讲解
  17. 数据压缩课程作业——LZW压缩算法完整仿真代码和分析
  18. 微信小程序 原生开发 实现弹窗遮罩层 并且在遮罩层内使用scroll-view实现滚动内容(包括图片)
  19. c语言会议安排编程,我院召开《C语言程序设计》课程教学研讨会
  20. 数据处理(1):十万加SHP数据重载导入标准字段图层

热门文章

  1. 在XMPP的JAVA开源实现Openfire中,增加LBS 附近的人功能
  2. Tomcat安全加固
  3. Activity Service 数据相互操作
  4. c# winform编程之多线程ui界面资源修改总结篇
  5. 生活问题 | 对华为畅玩手机5X进行升级
  6. @ResponseBody 和 @RequestBody 的作用
  7. 前端每日实战:108# 视频演示如何用 CSS 和 D3 创作一个抽象的黑白交叠动画
  8. linux学习之sed grep
  9. H5拍照、预览、压缩、上传采坑记录
  10. Java 收集的代码 transient