OYXH\oyxh 2 лет назад
Родитель
Сommit
f261739b64

+ 8 - 2
PDF Office/DataConvert/UnVisivleConvert.cs

@@ -23,7 +23,13 @@ namespace PDF_Office.DataConvert
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotImplementedException();
+            if ((Visibility)value == Visibility.Visible)
+            {
+                return Visibility.Collapsed;
+            }
+            else
+                return Visibility.Visible;
+            //throw new NotImplementedException();
         }
     }
-}
+}

+ 28 - 0
PDF Office/Helper/SetterAction.cs

@@ -0,0 +1,28 @@
+using Microsoft.Xaml.Behaviors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PDF_Office.Helper
+{
+    public class SetterAction : TriggerAction<DependencyObject>
+    {
+        public SetterAction()
+        {
+            Setters = new List<Setter>();
+        }
+
+        public List<Setter> Setters { get; set; }
+
+        protected override void Invoke(object parameter)
+        {
+            foreach (var item in Setters)
+            {
+                AssociatedObject.SetValue(item.Property, item.Value);
+            }
+        }
+    }
+}

+ 3 - 2
PDF Office/Model/ParameterNames.cs

@@ -25,16 +25,17 @@ namespace PDF_Office.Model
 
         public static string ViewContentViewModel = "ViewContentViewModel";
 
-
         public static string InsertType_File = "Insert_File";
 
         public static string InsertType_Blank = "Insert_Blank";
 
         public static string InsertType_Custom = "Insert_Custom";
 
+        public static string Bookmark = "Bookmark";
+
         /// <summary>
         /// 用于弹窗传参的数据模型
         /// </summary>
         public static string DataModel = "Model";
     }
-}
+}

+ 13 - 0
PDF Office/PDF Office.csproj

@@ -214,6 +214,7 @@
     <Compile Include="Helper\PasswordBoxHelper.cs" />
     <Compile Include="Helper\SDKLisenceHelper.cs" />
     <Compile Include="Helper\PictureConverter.cs" />
+    <Compile Include="Helper\SetterAction.cs" />
     <Compile Include="Helper\SettingHelper.cs" />
     <Compile Include="Helper\ToolMethod.cs" />
     <Compile Include="Model\CloudDrive\CloudDriveItem.cs" />
@@ -252,6 +253,7 @@
     <Compile Include="ViewModels\BOTA\BookmarkContentViewModel.cs" />
     <Compile Include="ViewModels\BOTA\BOTAContentViewModel.cs" />
     <Compile Include="ViewModels\BottomToolContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\BOTA\AddBookmarkDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ExtractDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\FullScreenWindowViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModBookletContentViewModel.cs" />
@@ -296,6 +298,9 @@
     <Compile Include="Views\BottomToolContent.xaml.cs">
       <DependentUpon>BottomToolContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\BOTA\AddBookmarkDialog.xaml.cs">
+      <DependentUpon>AddBookmarkDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\FullScreenWindow.xaml.cs">
       <DependentUpon>FullScreenWindow.xaml</DependentUpon>
     </Compile>
@@ -464,6 +469,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\TextBoxStyle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Styles\WindowsStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -484,6 +493,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Dialog\BOTA\AddBookmarkDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\FullScreenWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 8 - 4
PDF Office/Styles/ListBoxStyle.xaml

@@ -27,16 +27,20 @@
                     <Condition Property="Selector.IsSelectionActive" Value="False" />
                     <Condition Property="IsSelected" Value="True" />
                 </MultiTrigger.Conditions>
-                --><!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
-                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />--><!--
+            -->
+            <!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />-->
+            <!--
             </MultiTrigger>
             <MultiTrigger>
                 <MultiTrigger.Conditions>
                     <Condition Property="Selector.IsSelectionActive" Value="True" />
                     <Condition Property="IsSelected" Value="True" />
                 </MultiTrigger.Conditions>
-                --><!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
-                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />--><!--
+            -->
+            <!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />-->
+            <!--
             </MultiTrigger>
             <Trigger Property="IsEnabled" Value="False">
                 <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />

+ 74 - 20
PDF Office/Styles/ListViewStyle.xaml

@@ -1,4 +1,7 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+<ResourceDictionary
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
 
     <Style x:Key="FilesListViewStyle" TargetType="{x:Type ListView}">
         <Setter Property="Template">
@@ -16,7 +19,6 @@
                                 <Grid.RowDefinitions>
                                     <RowDefinition Height="Auto" />
                                     <RowDefinition />
-
                                 </Grid.RowDefinitions>
                                 <Grid>
                                     <Grid.ColumnDefinitions>
@@ -68,14 +70,14 @@
         <Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
         <!--<Setter Property="Control.Padding" Value="4,1" />
         <Setter Property="Control.HorizontalContentAlignment">
-            <Setter.Value>
-                <Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
-            </Setter.Value>
+        <Setter.Value>
+        <Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
+        </Setter.Value>
         </Setter>
         <Setter Property="Control.VerticalContentAlignment">
-            <Setter.Value>
-                <Binding Path="VerticalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
-            </Setter.Value>
+        <Setter.Value>
+        <Binding Path="VerticalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
+        </Setter.Value>
         </Setter>-->
         <Setter Property="Panel.Background" Value="#00FFFFFF" />
         <Setter Property="Border.BorderBrush" Value="#00FFFFFF" />
@@ -146,7 +148,6 @@
                                 ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                                 SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                         </Grid>
-
                     </Border>
                     <ControlTemplate.Triggers>
                         <MultiTrigger>
@@ -183,19 +184,18 @@
         </Setter>
     </Style>
 
-
     <Style x:Key="FilesGridItemStyle" TargetType="{x:Type ListViewItem}">
         <Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
         <!--<Setter Property="Control.Padding" Value="4,1" />
         <Setter Property="Control.HorizontalContentAlignment">
-            <Setter.Value>
-                <Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
-            </Setter.Value>
+        <Setter.Value>
+        <Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
+        </Setter.Value>
         </Setter>
         <Setter Property="Control.VerticalContentAlignment">
-            <Setter.Value>
-                <Binding Path="VerticalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
-            </Setter.Value>
+        <Setter.Value>
+        <Binding Path="VerticalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
+        </Setter.Value>
         </Setter>-->
         <Setter Property="Panel.Background" Value="#00FFFFFF" />
         <Setter Property="Border.BorderBrush" Value="#00FFFFFF" />
@@ -257,7 +257,6 @@
                                     Fill="#FFE2E3E6" />
                             </Grid>
                         </Grid>
-
                     </Border>
                     <ControlTemplate.Triggers>
                         <MultiTrigger>
@@ -293,7 +292,6 @@
                         <Trigger Property="UIElement.IsEnabled" Value="False">
                             <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                         </Trigger>
-
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
             </Setter.Value>
@@ -330,11 +328,67 @@
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="ListViewItem">
-                    <ContentControl HorizontalContentAlignment="Stretch" Width="{TemplateBinding Width}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
+                    <ContentControl
+                        Width="{TemplateBinding Width}"
+                        HorizontalContentAlignment="Stretch"
+                        Content="{TemplateBinding Content}"
+                        ContentTemplate="{TemplateBinding ContentTemplate}" />
                 </ControlTemplate>
             </Setter.Value>
         </Setter>
     </Style>
 
-
+    <Style x:Key="ListViewItemGraySelectStyle" TargetType="{x:Type ListViewItem}">
+        <Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
+        <Setter Property="Panel.Background" Value="#F2F2F2" />
+        <Setter Property="Border.BorderBrush" Value="#F2F2F2" />
+        <Setter Property="Control.Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type ListViewItem}">
+                    <Border
+                        Name="Bd"
+                        Background="{TemplateBinding Panel.Background}"
+                        BorderBrush="{TemplateBinding Border.BorderBrush}"
+                        SnapsToDevicePixels="True">
+                        <ContentPresenter
+                            Margin="0"
+                            HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
+                            Content="{TemplateBinding ContentControl.Content}"
+                            ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
+                            ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
+                            SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="UIElement.IsMouseOver" Value="True" />
+                            </MultiTrigger.Conditions>
+                            <Setter TargetName="Bd" Property="Panel.Background" Value="#d9d9d9" />
+                            <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#d9d9d9" />
+                        </MultiTrigger>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="Selector.IsSelectionActive" Value="False" />
+                                <Condition Property="Selector.IsSelected" Value="True" />
+                            </MultiTrigger.Conditions>
+                            <Setter TargetName="Bd" Property="Panel.Background" Value="#F2F2F2" />
+                            <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#F2F2F2" />
+                        </MultiTrigger>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="Selector.IsSelectionActive" Value="True" />
+                                <Condition Property="Selector.IsSelected" Value="True" />
+                            </MultiTrigger.Conditions>
+                            <Setter TargetName="Bd" Property="Panel.Background" Value="#97D7FB" />
+                            <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#97D7FB" />
+                        </MultiTrigger>
+                        <Trigger Property="UIElement.IsEnabled" Value="False">
+                            <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 </ResourceDictionary>

+ 211 - 5
PDF Office/ViewModels/BOTA/BookmarkContentViewModel.cs

@@ -1,12 +1,22 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKitViewer.PdfViewer;
+using ImTools;
+using PDF_Office.Helper;
 using PDF_Office.Model;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
+using System;
 using System.Collections.ObjectModel;
 using System.Linq;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Media;
+using static Dropbox.Api.TeamLog.AdminAlertSeverityEnum;
+using static System.Net.Mime.MediaTypeNames;
 
 namespace PDF_Office.ViewModels.BOTA
 {
@@ -14,6 +24,11 @@ namespace PDF_Office.ViewModels.BOTA
     {
         #region 属性
 
+        private static string hoverColor = "#D9D9D9";
+        private static string defaultColor = "#F2F2F2";
+        private static string selectColcr = "#97D7FB";
+        private static string borderBackground = "#FFFFFF";
+        private static string borderBrush = "#000000";
         private IRegionManager region;
         private IDialogService dialogs;
         public CPDFViewer PDFViewer;
@@ -35,26 +50,216 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
-        private Visibility isEmptyPanelVisibility = Visibility.Visible;
+        private Visibility isEmpty;
 
         public Visibility IsEmptyPanelVisibility
         {
             get
             {
-                return isEmptyPanelVisibility;
+                return isEmpty;
             }
             set
             {
-                SetProperty(ref isEmptyPanelVisibility, value);
+                SetProperty(ref isEmpty, value);
             }
         }
 
         #endregion 属性
 
+        #region 命令
+
+        public DelegateCommand<object> MouseClickCommand { get; set; }
+        public DelegateCommand<object> MouseEnterCommand { get; set; }
+        public DelegateCommand<object> MouseMoveCommand { get; set; }
+
+        public DelegateCommand<object> LostFocusCommand { get; set; }
+
+        public DelegateCommand<object> GotFocusCommand { get; set; }
+
+        public DelegateCommand<object> AddBookmarkCommand { get; set; }
+
+        #endregion 命令
+
         public BookmarkContentViewModel(IRegionManager regionManager, IDialogService dialogService)
         {
             region = regionManager;
             dialogs = dialogService;
+
+            MouseClickCommand = new DelegateCommand<object>(MouseClickEvent);
+            MouseEnterCommand = new DelegateCommand<object>(MouseEnterEvent);
+            LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
+            MouseMoveCommand = new DelegateCommand<object>(MouseMoveEvent);
+            GotFocusCommand = new DelegateCommand<object>(GotFocusEvent);
+            AddBookmarkCommand = new DelegateCommand<object>(AddBookmarkEvent);
+        }
+
+        private void AddBookmarkEvent(object obj)
+        {
+            int index = PDFViewer.CurrentIndex;
+            string mark = string.Format($"第{index}页");
+        }
+
+        private void GotFocusEvent(object obj)
+        {
+            if (obj is RoutedEventArgs)
+            {
+                var mouse = (RoutedEventArgs)obj;
+                if (mouse.Source is TextBox)
+                {
+                    TextBox textBox = (TextBox)mouse.Source;
+                    textBox.Select(textBox.Text.Length, 0);
+                    textBox.SelectAll();
+                }
+            }
+        }
+
+        private void MouseMoveEvent(object obj)
+        {
+            //if (obj is MouseEventArgs)
+            //{
+            //    var mouse = (MouseEventArgs)obj;
+            //    Grid grid = null;
+            //    if (mouse.Source is TextBox)
+            //    {
+            //        TextBox text = (TextBox)mouse.Source;
+            //        if (text != null)
+            //        {
+            //            text.Visibility = Visibility.Collapsed;
+            //            grid = (text.Parent as StackPanel).Parent as Grid;
+            //            grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+            //        }
+            //    }
+            //}
+        }
+
+        private void LostFocusEvent(object obj)
+        {
+            if (obj is RoutedEventArgs)
+            {
+                var mouse = (RoutedEventArgs)obj;
+                Grid grid = null;
+                if (mouse.Source is Grid)
+                {
+                    grid = mouse.Source as Grid;
+                    if (grid != null)
+                    {
+                        TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
+                        if (box != null)
+                        {
+                            box.Visibility = Visibility.Visible;
+                        }
+                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+                    }
+                }
+                if (mouse.Source is TextBox)
+                {
+                    TextBox textBox = (TextBox)mouse.Source;
+                    if (textBox != null)
+                    {
+                        //textBox.Visibility = Visibility.Collapsed;
+                        grid = (textBox.Parent as StackPanel).Parent as Grid;
+                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+                    }
+                }
+            }
+        }
+
+        public void MouseEnterEvent(object obj)
+        {
+            if (obj is MouseEventArgs)
+            {
+                var mouse = (MouseEventArgs)obj;
+                Grid grid = null;
+                if (mouse.Source is Grid)
+                {
+                    grid = mouse.Source as Grid;
+                    if (grid != null)
+                    {
+                        TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
+                        if (box != null)
+                        {
+                            //box.Visibility = Visibility.Visible;
+                        }
+                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
+                    }
+                }
+                if (mouse.Source is TextBlock)
+                {
+                    TextBlock text = (TextBlock)mouse.Source;
+                    if (text != null)
+                    {
+                        //text.Visibility = Visibility.Visible;
+                        grid = (text.Parent as StackPanel).Parent as Grid;
+                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
+                    }
+                }
+                //if (mouse.Source is TextBox)
+                //{
+                //    TextBox text = (TextBox)mouse.Source;
+                //    if (text != null)
+                //    {
+                //        text.Visibility = Visibility.Collapsed;
+                //        grid = (text.Parent as StackPanel).Parent as Grid;
+                //        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
+                //    }
+                //}
+            }
+            else
+            {
+            }
+        }
+
+        public void MouseClickEvent(object obj)
+        {
+            if (obj is MouseButtonEventArgs)
+            {
+                var mouse = (MouseButtonEventArgs)obj;
+                if (mouse.LeftButton == MouseButtonState.Pressed)
+                {
+                    TextBlock box = null;
+                    Grid grid = null;
+                    if (mouse.ClickCount >= 2)
+                    {
+                        if (mouse.Source is Grid)
+                        {
+                            grid = mouse.Source as Grid;
+                            //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
+                            if (grid != null)
+                            {
+                                box = CommonHelper.FindVisualChild<TextBlock>(grid);
+                                grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
+                                if (box != null)
+                                {
+                                    box.Visibility = Visibility.Collapsed;
+                                    //TextBox textBox = CommonHelper.FindVisualChild<TextBox>((box.Parent as StackPanel));
+                                    //FocusManager.SetFocusedElement(box.Parent, textBox);
+                                    //Keyboard.Focus(textBox);
+                                    //textBox.IsHitTestVisible = true;
+                                    //textBox.Focus();
+                                }
+                            }
+                        }
+                        if (mouse.Source is TextBlock)
+                        {
+                            box = (TextBlock)mouse.Source;
+                            grid = (box.Parent as StackPanel).Parent as Grid;
+
+                            grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
+                            if (box != null)
+                            {
+                                box.Visibility = Visibility.Collapsed;
+                                //TextBox textBox = CommonHelper.FindVisualChild<TextBox>((box.Parent as StackPanel));
+                                //FocusManager.SetFocusedElement(box.Parent, textBox);
+                                //Keyboard.Focus(textBox);
+                                //textBox.IsHitTestVisible = true;
+                                //textBox.Focus();
+                            }
+                        }
+                    }
+
+                    //MessageBox.Show("dsafa");
+                }
+            }
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -65,7 +270,7 @@ namespace PDF_Office.ViewModels.BOTA
                 return;
             }
 
-            Bookmarklist = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
+            list = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
             if (Bookmarklist.Count < 1)
             {
                 IsEmptyPanelVisibility = Visibility.Visible;
@@ -73,7 +278,8 @@ namespace PDF_Office.ViewModels.BOTA
             }
             else
             {
-                isEmptyPanelVisibility = Visibility.Collapsed;
+                IsEmptyPanelVisibility = Visibility.Hidden;
+                return;
             }
         }
 

+ 67 - 0
PDF Office/ViewModels/Dialog/BOTA/AddBookmarkDialogViewModel.cs

@@ -0,0 +1,67 @@
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.BOTA
+{
+    public class AddBookmarkDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        private string mark;
+
+        public string Mark
+        {
+            get { return mark; }
+            set
+            {
+                SetProperty(ref mark, value);
+            }
+        }
+
+        public DelegateCommand CancelCommand { get; set; }
+
+        public DelegateCommand CreateCommnad { get; set; }
+
+        public AddBookmarkDialogViewModel()
+        {
+            CancelCommand = new DelegateCommand(CancelEvent);
+            CreateCommnad = new DelegateCommand(CreateEvent);
+        }
+
+        private void CreateEvent()
+        {
+            DialogParameters valuePairs = new DialogParameters();
+            valuePairs.Add(ParameterNames.Bookmark, Mark);
+            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+        }
+
+        private void CancelEvent()
+        {
+            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+            return;
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            return;
+        }
+    }
+}

+ 129 - 32
PDF Office/Views/BOTA/BookmarkContent.xaml

@@ -6,6 +6,8 @@
     xmlns:convert="clr-namespace:PDF_Office.DataConvert"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:data="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
+    xmlns:helper="clr-namespace:PDF_Office.Helper"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
     xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
@@ -15,9 +17,16 @@
     prism:ViewModelLocator.AutoWireViewModel="True"
     mc:Ignorable="d">
     <UserControl.Resources>
-        <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="/Styles/ListViewStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+
+            <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
+            <convert:UnVisivleConvert x:Key="UnVisivleConvert" />
+        </ResourceDictionary>
     </UserControl.Resources>
-    <Grid>
+    <Grid Background="#F2F2F2">
         <Grid.RowDefinitions>
             <RowDefinition Height="40" />
             <RowDefinition />
@@ -32,17 +41,19 @@
                 FontWeight="SemiBold"
                 Text="Bookmarks" />
             <Button
-                Name="BtnSort"
+                Name="BtnAddBookmark"
                 Width="40"
                 Height="40"
                 Margin="0,0,0,0"
                 HorizontalAlignment="Right"
-                Content="添加" />
+                Content="添加" Command="{Binding AddBookmarkCommand}">
+            </Button>
         </Grid>
         <Grid Grid.Row="1">
             <ListView
                 Name="BookMarkListView"
                 HorizontalContentAlignment="Stretch"
+                Background="#F2F2F2"
                 BorderThickness="0"
                 ItemsSource="{Binding Bookmarklist}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
@@ -57,39 +68,125 @@
                 </ListView.ItemsPanel>
                 <ListView.ItemTemplate>
                     <DataTemplate DataType="{x:Type data:CPDFBookmark}">
-                        <Grid Name="ItemGrid">
+                        <Grid
+                            Name="itemGrid"
+                            HorizontalAlignment="Stretch"
+                            VerticalAlignment="Stretch"
+                            Background="#F2F2F2">
                             <Grid.RowDefinitions>
-                                <RowDefinition Height="26" />
+                                <RowDefinition Height="40" />
                             </Grid.RowDefinitions>
-                            <TextBox
-                                Name="TitleInput"
-                                Grid.Row="0"
-                                Padding="0,0,18,0"
-                                VerticalAlignment="Top"
-                                BorderBrush="Transparent"
-                                BorderThickness="2"
-                                FontSize="14"
-                                Text="{Binding Title}"
-                                Visibility="Visible" />
-                            <TextBlock
-                                x:Name="btnClear"
-                                Grid.Row="0"
-                                Width="16"
-                                Height="16"
-                                Margin="0,0,3,0"
-                                HorizontalAlignment="Right"
-                                Visibility="{Binding ElementName=TitleInput, Path=IsFocused, Converter={StaticResource BoolToVisibleConvert}}" />
+                            <StackPanel Name="StackPanel" Margin="15,5">
+                                <!--  IsHitTestVisible="False"  -->
+                                <TextBlock
+                                    Name="TextBlockTitle"
+                                    Padding="5"
+                                    Background="Transparent"
+                                    FontSize="14"
+                                    Text="{Binding Title}"
+                                    Visibility="Visible" />
+                                <TextBox
+                                    Name="TitleInput"
+                                    Padding="5"
+                                    Background="White"
+                                    BorderThickness="1"
+                                    FontSize="14"
+                                    IsVisibleChanged="TitleInput_IsVisibleChanged"
+                                    Text="{Binding Title}"
+                                    TextWrapping="Wrap"
+                                    Visibility="{Binding ElementName=TextBlockTitle, Path=Visibility, Converter={StaticResource UnVisivleConvert}, Mode=TwoWay}">
+                                    <i:Interaction.Triggers>
+                                        <i:EventTrigger EventName="LostFocus">
+                                            <i:InvokeCommandAction Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                        </i:EventTrigger>
+                                        <i:EventTrigger EventName="GotFocus">
+                                            <i:InvokeCommandAction Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                        </i:EventTrigger>
+                                        <i:EventTrigger EventName="MouseEnter">
+                                            <i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                        </i:EventTrigger>
+                                    </i:Interaction.Triggers>
+                                    <!--<TextBox.Resources>
+                                    <Style TargetType="{x:Type Border}">
+                                    <Setter Property="CornerRadius" Value="2" />
+                                    <Setter Property="BorderThickness" Value="1" />
+                                    <Setter Property="BorderBrush" Value="#000000" />
+                                    </Style>
+                                    </TextBox.Resources>-->
+                                    <!--<i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="MouseDoubleClick">
+                                    <helper:SetterAction>
+                                    <helper:SetterAction.Setters>
+                                    <Setter Property="TextBox.IsReadOnly" Value="False" />
+                                    <Setter Property="TextBox.Background" Value="#FFFFFF" />
+                                    <Setter Property="TextBox.BorderBrush" Value="#000000" />
+                                    <Setter Property="TextBox.BorderThickness" Value="1px" />
+                                    </helper:SetterAction.Setters>
+                                    </helper:SetterAction>
+                                    </i:EventTrigger>
+                                    <i:EventTrigger EventName="MouseEnter">
+                                    <i:EventTrigger.Actions>
+                                    <helper:SetterAction>
+                                    <helper:SetterAction.Setters>
+                                    <Setter Property="TextBox.IsReadOnly" Value="true" />
+                                    <Setter Property="TextBox.Background" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderBrush" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderThickness" Value="0px" />
+                                    </helper:SetterAction.Setters>
+                                    </helper:SetterAction>
+                                    </i:EventTrigger.Actions>
+                                    </i:EventTrigger>
+                                    <i:EventTrigger EventName="MouseLeave">
+                                    <i:EventTrigger.Actions>
+                                    <helper:SetterAction>
+                                    <helper:SetterAction.Setters>
+                                    <Setter Property="TextBox.IsReadOnly" Value="true" />
+                                    <Setter Property="TextBox.Background" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderBrush" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderThickness" Value="0px" />
+                                    </helper:SetterAction.Setters>
+                                    </helper:SetterAction>
+                                    </i:EventTrigger.Actions>
+                                    </i:EventTrigger>
+                                    <i:EventTrigger EventName="LostFocus">
+                                    <i:EventTrigger.Actions>
+                                    <helper:SetterAction>
+                                    <helper:SetterAction.Setters>
+                                    <Setter Property="TextBox.IsReadOnly" Value="true" />
+                                    <Setter Property="TextBox.Background" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderBrush" Value="Transparent" />
+                                    <Setter Property="TextBox.BorderThickness" Value="0px" />
+                                    </helper:SetterAction.Setters>
+                                    </helper:SetterAction>
+                                    </i:EventTrigger.Actions>
+                                    </i:EventTrigger>
+                                    </i:Interaction.Triggers>-->
+                                </TextBox>
+                            </StackPanel>
+                            <i:Interaction.Triggers>
+                                <i:EventTrigger EventName="MouseDown">
+                                    <i:InvokeCommandAction Command="{Binding DataContext.MouseClickCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                </i:EventTrigger>
+                                <i:EventTrigger EventName="MouseEnter">
+                                    <i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                </i:EventTrigger>
+                                <i:EventTrigger EventName="MouseMove">
+                                    <i:InvokeCommandAction Command="{Binding DataContext.MouseMoveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                </i:EventTrigger>
+                                <!--<i:EventTrigger EventName="LostFocus">
+                                <i:InvokeCommandAction Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
+                                </i:EventTrigger>-->
+                            </i:Interaction.Triggers>
                         </Grid>
                     </DataTemplate>
                 </ListView.ItemTemplate>
-                <!--<ListView.ItemContainerStyle>
-                <Style TargetType="ListViewItem">
-                -->
-                <!--<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDown" />
-                <EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->
-                <!--
-                </Style>
-                </ListView.ItemContainerStyle>-->
+                <ListView.ItemContainerStyle>
+
+                    <Style BasedOn="{StaticResource ListViewItemGraySelectStyle}" TargetType="ListViewItem">
+                        <!--<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDown" />
+                        <EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->
+                    </Style>
+                </ListView.ItemContainerStyle>
             </ListView>
         </Grid>
         <StackPanel

+ 10 - 1
PDF Office/Views/BOTA/BookmarkContent.xaml.cs

@@ -24,5 +24,14 @@ namespace PDF_Office.Views.BOTA
         {
             InitializeComponent();
         }
+
+        private void TitleInput_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+        {
+            if (sender is TextBox)
+            {
+                TextBox textBox = sender as TextBox;
+                textBox.Focus();
+            }
+        }
     }
-}
+}

+ 57 - 0
PDF Office/Views/Dialog/BOTA/AddBookmarkDialog.xaml

@@ -0,0 +1,57 @@
+<UserControl
+    x:Class="PDF_Office.Views.Dialog.BOTA.AddBookmarkDialog"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:addBookmark="clr-namespace:PDF_Office.ViewModels.Dialog.BOTA"
+    xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:local="clr-namespace:PDF_Office.Views.Dialog.BOTA"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    Width="445"
+    Height="180"
+    d:DataContext="{d:DesignInstance Type=addBookmark:AddBookmarkDialogViewModel}"
+    prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
+    <cus:DialogContent Header="创建一个新的书签">
+        <cus:DialogContent.Content>
+            <StackPanel Height="50" HorizontalAlignment="Center">
+                <TextBox
+                    Name="TxtInput"
+                    Width="390"
+                    Height="30"
+                    Margin="15"
+                    HorizontalContentAlignment="Left"
+                    VerticalContentAlignment="Center"
+                    FontFamily="微软雅黑"
+                    FontSize="14"
+                    Text="{Binding Mark}" />
+            </StackPanel>
+        </cus:DialogContent.Content>
+        <cus:DialogContent.BottmBar>
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="50*" />
+                    <ColumnDefinition Width="50*" />
+                </Grid.ColumnDefinitions>
+                <Button
+                    Grid.Column="0"
+                    Width="150"
+                    Height="32"
+                    Margin="25,0,0,0"
+                    HorizontalAlignment="Left"
+                    Command="{Binding CreateCommnad}"
+                    Content="创建" />
+                <Button
+                    Grid.Column="1"
+                    Width="150"
+                    Height="32"
+                    Margin="0,0,25,0"
+                    HorizontalAlignment="Right"
+                    Command="{Binding CancelCommand}"
+                    Content="取消" />
+            </Grid>
+        </cus:DialogContent.BottmBar>
+    </cus:DialogContent>
+</UserControl>

+ 28 - 0
PDF Office/Views/Dialog/BOTA/AddBookmarkDialog.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Dialog.BOTA
+{
+    /// <summary>
+    /// AddBookmarkDialog.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddBookmarkDialog : UserControl
+    {
+        public AddBookmarkDialog()
+        {
+            InitializeComponent();
+        }
+    }
+}