Forráskód Böngészése

便签 - 添加便签样式

chenrongqian@kdanmobile.com 2 éve
szülő
commit
c5c1aa6c48

+ 7 - 0
PDF Office/PDF Office.csproj

@@ -1030,6 +1030,9 @@
     <Compile Include="Views\PropertyPanel\AnnotPanel\StampAnnotProperty.xaml.cs">
       <DependentUpon>StampAnnotProperty.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\PropertyPanel\AnnotPanel\StickyNotePopup.xaml.cs">
+      <DependentUpon>StickyNotePopup.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\PropertyPanel\AnnotPanel\StickyNoteProperty.xaml.cs">
       <DependentUpon>StickyNoteProperty.xaml</DependentUpon>
     </Compile>
@@ -1787,6 +1790,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\PropertyPanel\AnnotPanel\StickyNotePopup.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Views\PropertyPanel\AnnotPanel\StickyNoteProperty.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 98 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml

@@ -0,0 +1,98 @@
+<annotview:StickyPopupExt x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.StickyNotePopup"
+             xmlns:annotview="clr-namespace:ComPDFKitViewer;assembly=ComPDFKit.Viewer"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
+             mc:Ignorable="d" Background="Transparent"
+             d:DesignHeight="450" d:DesignWidth="800">
+    <annotview:StickyPopupExt.Resources>
+        <DataTemplate x:Key="listboxData">
+            <Ellipse
+                    Width="20"
+                    Height="20"
+                    Fill="{Binding Color}" />
+        </DataTemplate>
+        <Style x:Key="listboxItemStyle" TargetType="{x:Type ListBoxItem}">
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="Height" Value="32" />
+            <Setter Property="Margin" Value="2,0,2,0" />
+        </Style>
+    </annotview:StickyPopupExt.Resources>
+    <Border  x:Name="border" Background="{StaticResource color.sys.layout.anti}" CornerRadius="8" BorderThickness="2" BorderBrush="#ffe49a" MinWidth="240" MinHeight="200" Width="240" Height="200" >
+        <Border.Effect>
+            <DropShadowEffect BlurRadius="8" Direction="0" Opacity="0.16" ShadowDepth="0" Color="#000000" />
+        </Border.Effect>
+        <Grid Name="GridUi" Margin="8">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="32"/>
+                <RowDefinition Height="1"/>
+                <RowDefinition />
+                <RowDefinition Height="32"/>
+            </Grid.RowDefinitions>
+            <Grid >
+                <TextBlock x:Name="AuthorText" Text="test" FontSize="12" Foreground="{StaticResource color.sys.text.neutral.lv2}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
+                <TextBlock x:Name="DateTextui" Text="date time" FontSize="12" Foreground="{StaticResource color.sys.text.neutral.lv2}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
+            </Grid>
+            <Border MouseUp="CloseText_MouseUp"/>
+            <Rectangle Grid.Row="1" Fill="{StaticResource color.sys.layout.divider}" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch"/>
+            <Grid Grid.Row="2" Margin="0,2,0,2">
+                <TextBox Name="ContentText" Grid.Row="2" Margin="4,0,4,0" Background="#CCFFFFFF" BorderThickness="0" 
+                     AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox>
+            </Grid>
+
+            <Grid Grid.Row="3">
+                <ListBox
+            x:Name="ListColor"
+            Background="Transparent"
+            BorderThickness="0"
+            ItemContainerStyle="{StaticResource listboxItemStyle}"
+            ItemTemplate="{StaticResource listboxData}"
+            SelectionChanged="ListColor_SelectionChanged"
+            >
+                    <ListBox.ItemsPanel>
+                        <ItemsPanelTemplate>
+                            <WrapPanel Orientation="Horizontal" />
+                        </ItemsPanelTemplate>
+                    </ListBox.ItemsPanel>
+                </ListBox>
+            </Grid>
+           
+            <!--<Grid.RowDefinitions>
+                <RowDefinition Height="auto"></RowDefinition>
+                <RowDefinition Height="auto"></RowDefinition>
+                <RowDefinition Height="*"></RowDefinition>
+                <RowDefinition Height="auto"></RowDefinition>
+            </Grid.RowDefinitions>
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+                <Path Fill="#000000" Margin="2,2,0,0" Width="20" Height="20">
+                    <Path.Data>M19,2 L19,15 L9.137,15 L4,18.383095 L4,15 L1,15 L1,2 L19,2 Z M18,3 L2,3 L2,14 L5,14 L5,16.616 L8.86150802,14 L18,14 L18,3 Z M15,9 L15,10 L5,10 L5,9 L15,9 Z M11,6 L11,7 L5,7 L5,6 L11,6 Z</Path.Data>
+                </Path>
+                <TextBlock Grid.Column="1" FontFamily="SegoeUI" FontSize="12" VerticalAlignment="Center" LineHeight="16" Margin="2,2,0,0">Note</TextBlock>
+                <TextBlock Name="DateText" Grid.Column="3" Foreground="#000000" VerticalAlignment="Center"  Margin="0,-2,0,0" FontFamily="SegoeUI" FontSize="12" LineHeight="16"></TextBlock>
+                <Border Grid.Column="4" MouseUp="CloseText_MouseUp" Background="#01000000" Margin="0,-8,-3,0">
+                    <Path Fill="#000000" Width="16" Height="16" >
+                        <Path.Data>
+                            M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814 L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
+                        </Path.Data>
+                        <Path.LayoutTransform>
+                            <RotateTransform Angle="45"></RotateTransform>
+                        </Path.LayoutTransform>
+                    </Path>
+                </Border>
+            </Grid>
+            <TextBlock Name="AuthorText" Grid.Row="1" FontFamily="SegoeUI" FontSize="12" LineHeight="16" Margin="2,2,0,0"></TextBlock>
+            <TextBox Name="ContentText" Grid.Row="2" Margin="4,0,4,0" Background="#CCFFFFFF" BorderThickness="0" 
+                     AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox>-->
+            <!--<ResizeGrip Name="GripControl" Grid.Row="3" HorizontalAlignment="Right" Margin="0,2,0,0" Cursor="SizeNWSE" MouseMove="ResizeGrip_MouseMove"></ResizeGrip>-->
+        </Grid>
+    </Border>
+</annotview:StickyPopupExt>

+ 158 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -0,0 +1,158 @@
+using ComPDFKitViewer;
+using PDF_Office.CustomControl.CompositeControl;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.Views.PropertyPanel.AnnotPanel
+{
+    /// <summary>
+    /// StickyNotePopup.xaml 的交互逻辑
+    /// </summary>
+    public partial class StickyNotePopup : StickyPopupExt
+    {
+        private ObservableCollection<ColorItem> colors = new ObservableCollection<ColorItem>();
+        private Point PressPoint;
+        public Point OffsetParent;
+        private byte saveOpacity = 1;
+        public bool CanMove { get; set; } = true;
+        public StickyNotePopup()
+        {
+            InitializeComponent();
+            AddHandler(MouseUpEvent, new MouseButtonEventHandler(StickyPopupControl_MouseUp), true);
+            ContentText.AddHandler(MouseDownEvent, new MouseButtonEventHandler(StickyPopupControl_MouseDown), true);
+            Loaded += StickyPopupControl_Loaded;
+            Unloaded += StickyPopupControl_Unloaded;
+            ContentText.GotFocus += ContentText_GotFocus;
+            ContentText.LostFocus += ContentText_LostFocus;
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0x10, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0xFF, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0x70, 0xFF)));
+            ListColor.ItemsSource = colors;
+        }
+
+
+        private void ContentText_LostFocus(object sender, RoutedEventArgs e)
+        {
+            e.Handled = true;
+            Color bkColor = (border.BorderBrush as SolidColorBrush).Color;
+            bkColor.A = saveOpacity;
+            border.BorderBrush = new SolidColorBrush(bkColor);
+            CloseText_MouseUp(this, null);
+            border.BorderBrush = this.Background;
+            this.Background = new SolidColorBrush(Colors.Transparent);
+            AuthorText.Text = this.Author;
+            DateTextui.Text = this.DateText;
+        }
+
+        private void ContentText_GotFocus(object sender, RoutedEventArgs e)
+        {
+            Color bkColor = (border.BorderBrush as SolidColorBrush).Color;
+            saveOpacity = bkColor.A;
+            bkColor.A = 255;
+            border.BorderBrush = new SolidColorBrush(bkColor);
+
+            border.BorderBrush = this.Background;
+            this.Background = new SolidColorBrush(Colors.Transparent);
+            AuthorText.Text = this.Author;
+            DateTextui.Text = this.DateText;
+        }
+
+        private void StickyPopupControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            ContentText.Focus();
+            ContentText.CaretIndex = ContentText.Text.Length;
+            ContentText.Text = this.StickyNote;
+           
+        }
+
+        private void StickyPopupControl_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            PressPoint = new Point(0, 0);
+        }
+
+        private void StickyPopupControl_MouseUp(object sender, MouseButtonEventArgs e)
+        {
+            CanMove = true;
+        }
+
+        public string StickyText
+        {
+            get
+            {
+                return ContentText.Text;
+            }
+            set
+            {
+                ContentText.Text = value;
+            }
+        }
+
+        public string StickyAuthor
+        {
+            get
+            {
+                return AuthorText.Text;
+            }
+            set
+            {
+                AuthorText.Text = value;
+            }
+        }
+
+        public string StickyDate
+        {
+            get
+            {
+                return DateTextui.Text;
+            }
+            set
+            {
+                DateTextui.Text = value;
+            }
+        }
+
+
+        private void CloseText_MouseUp(object sender, MouseButtonEventArgs e)
+        {
+            if (e != null)
+            {
+                e.Handled = true;
+            }
+            PlaceChange = null;
+            RemoveFromLayer();
+            if (Closed != null)
+            {
+                Closed.Invoke(sender, EventArgs.Empty);
+            }
+        }
+
+        private void ListColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var color = ListColor.SelectedItem as ColorItem;
+            if(color != null)
+            {
+                this.SetStickyColor((color.Color as SolidColorBrush).Color);
+            }
+        }
+
+        private void StickyPopupControl_Unloaded(object sender, RoutedEventArgs e)
+        {
+            if (StickyNote != ContentText.Text)
+                this.SetStickyNote(ContentText.Text);
+        }
+    }
+}