OYXH\oyxh před 2 roky
rodič
revize
168651f84f

+ 2 - 2
PDF Office/Styles/ListViewStyle.xaml

@@ -379,8 +379,8 @@
                                 <Condition Property="Selector.IsSelectionActive" Value="False" />
                                 <Condition Property="Selector.IsSelected" Value="True" />
                             </MultiTrigger.Conditions>
-                            <Setter TargetName="Bd" Property="Panel.Background" Value="#d9d9d9" />
-                            <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#d9d9d9" />
+                            <Setter TargetName="Bd" Property="Panel.Background" Value="#F2F2F2" />
+                            <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#F2F2F2" />
                         </MultiTrigger>
 
                         <MultiTrigger>

+ 59 - 36
PDF Office/ViewModels/BOTA/BookmarkContentViewModel.cs

@@ -21,6 +21,7 @@ using System.Windows.Input;
 using System.Windows.Media;
 using static Dropbox.Api.TeamLog.AdminAlertSeverityEnum;
 using static System.Net.Mime.MediaTypeNames;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 using ListViewItem = System.Windows.Controls.ListViewItem;
 using TextBox = System.Windows.Controls.TextBox;
 
@@ -150,7 +151,7 @@ namespace PDF_Office.ViewModels.BOTA
                 if (parameter.Parameter is TextBox)
                 {
                     TextBox textBox = (TextBox)parameter.Parameter;
-                    textBox.PreviewMouseDown += new MouseButtonEventHandler(TxtTitleInput_PreviewMouseLeftButtonDown);
+                    //textBox.PreviewMouseDown += new MouseButtonEventHandler(TxtTitleInput_PreviewMouseLeftButtonDown);
 
                     var item = CommonHelper.FindVisualParent<ListViewItem>(textBox);
                     if (item != null)
@@ -188,30 +189,39 @@ namespace PDF_Office.ViewModels.BOTA
                     if (mouse.LeftButton == MouseButtonState.Pressed)
                     {
                         TextBlock box = null;
-                        Grid grid = null;
+                        StackPanel stackPanel = null;
+                        ListBoxItem listBoxItem = (objs[0] as ListBoxItem);
                         if (mouse.ClickCount >= 2)
                         {
                             if (mouse.OriginalSource is TextBlock)
                             {
                                 box = (TextBlock)mouse.OriginalSource;
-                                grid = (box.Parent as StackPanel).Parent as Grid;
+                                stackPanel = (box.Parent as Grid).Parent as StackPanel;
 
-                                //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
                                 if (box != null)
                                 {
+                                    listBoxItem.IsSelected = true;
+                                    listBoxItem.Focus();
                                     box.Visibility = Visibility.Collapsed;
-                                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(grid);
-                                    textBox.PreviewMouseDown += new MouseButtonEventHandler(TxtTitleInput_PreviewMouseLeftButtonDown);
-                                    TxtTitleInput_PreviewMouseLeftButtonDown(textBox, mouse);
+                                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(stackPanel);
+                                    textBox.Dispatcher.BeginInvoke(new Action(() =>
+                                                                                                                                                {
+                                                                                                                                                    textBox.Focus();
+                                                                                                                                                    textBox.SelectAll();
+                                                                                                                                                }));
+                                    //textBox.PreviewMouseDown += new MouseButtonEventHandler(TxtTitleInput_PreviewMouseLeftButtonDown);
+                                    //TxtTitleInput_PreviewMouseLeftButtonDown(textBox, mouse);
                                     isSelete = true;
                                 }
                             }
                         }
                         if (mouse.ClickCount == 1)
                         {
-                            ListBoxItem listBoxItem = (objs[0] as ListBoxItem);
                             if (listBoxItem != null)
                             {
+                                box = CommonHelper.FindVisualChild<TextBlock>(listBoxItem);
+                                //box.Background = listBoxItem.Background;
+                                //box.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
                                 int index = (listBoxItem.DataContext as CPDFBookmark).PageIndex;
                                 PDFViewer.GoToPage(index);
                                 isSelete = false;
@@ -235,11 +245,20 @@ namespace PDF_Office.ViewModels.BOTA
                     {
                         TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
 
-                        if (box != null)
-                        {
-                            box.Visibility = Visibility.Visible;
-                        }
                         ListBoxItem myListBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(grid);
+                        box.Visibility = Visibility.Visible;
+                        //if (myListBoxItem.IsSelected == true)
+                        //{
+                        //    box.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+                        //}
+                        //if (myListBoxItem.IsMouseOver == true)
+                        //{
+                        //    box.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+                        //}
+                        //else
+                        //{
+                        //    box.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
+                        //}
                         //myListBoxItem.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
                         //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(defaultColor));
                     }
@@ -258,11 +277,14 @@ namespace PDF_Office.ViewModels.BOTA
                     if (grid != null)
                     {
                         TextBlock box = CommonHelper.FindVisualChild<TextBlock>(grid);
+                        ListBoxItem listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(grid);
                         if (box != null)
                         {
                             box.Visibility = Visibility.Visible;
+                            //box.Background = listBoxItem.Background;
+                            //box.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
                         }
-                        ListBoxItem myListBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(grid);
+
                         //myListBoxItem.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
                         //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hoverColor));
                     }
@@ -292,7 +314,8 @@ namespace PDF_Office.ViewModels.BOTA
                     //Grid grid = CommonHelper.FindVisualChild<Grid>(myListBoxItem);
                     myListBoxItem.IsSelected = true;
                     myListBoxItem.Focus();
-                    listView.SelectedItem = myListBoxItem;
+
+                    //listView.SelectedItem = myListBoxItem;
 
                     //myListBoxItem.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
                     return;
@@ -302,26 +325,26 @@ namespace PDF_Office.ViewModels.BOTA
             value.Add(ParameterNames.Bookmark, mark);
             value.Add(ParameterNames.Title, "创建一个新的书签");
             dialogs.ShowDialog(DialogNames.AddBookmarkDialog, value, e =>
-            {
-                if (e.Result == ButtonResult.OK && e.Parameters != null)
-                {
-                    if (e.Parameters.ContainsKey(ParameterNames.Bookmark))
-                    {
-                        mark = e.Parameters.GetValue<string>(ParameterNames.Bookmark).ToString();
-                        CPDFBookmark bookmark = new CPDFBookmark();
-                        bookmark.Title = mark;
-                        bookmark.Date = DateTime.Now.ToString(@"yyyyMMddHHmmsszzz\'").Replace(':', '\'') + "\n";
-                        bookmark.PageIndex = PDFViewer.CurrentIndex;
-
-                        if (PDFViewer.Document.AddBookmark(bookmark))
-                        {
-                            PDFViewer.UndoManager.CanSave = true;
-
-                            Bookmarklist = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
-                        }
-                    }
-                }
-            });
+                                                                                                                                                                {
+                                                                                                                                                                    if (e.Result == ButtonResult.OK && e.Parameters != null)
+                                                                                                                                                                    {
+                                                                                                                                                                        if (e.Parameters.ContainsKey(ParameterNames.Bookmark))
+                                                                                                                                                                        {
+                                                                                                                                                                            mark = e.Parameters.GetValue<string>(ParameterNames.Bookmark).ToString();
+                                                                                                                                                                            CPDFBookmark bookmark = new CPDFBookmark();
+                                                                                                                                                                            bookmark.Title = mark;
+                                                                                                                                                                            bookmark.Date = DateTime.Now.ToString(@"yyyyMMddHHmmsszzz\'").Replace(':', '\'') + "\n";
+                                                                                                                                                                            bookmark.PageIndex = PDFViewer.CurrentIndex;
+
+                                                                                                                                                                            if (PDFViewer.Document.AddBookmark(bookmark))
+                                                                                                                                                                            {
+                                                                                                                                                                                PDFViewer.UndoManager.CanSave = true;
+
+                                                                                                                                                                                Bookmarklist = new ObservableCollection<CPDFBookmark>(PDFViewer.Document.GetBookmarkList().OrderBy(d => d.Title));
+                                                                                                                                                                            }
+                                                                                                                                                                        }
+                                                                                                                                                                    }
+                                                                                                                                                                });
         }
 
         public void MouseClickEvent(object obj)
@@ -342,7 +365,7 @@ namespace PDF_Office.ViewModels.BOTA
                             if (grid != null)
                             {
                                 box = CommonHelper.FindVisualChild<TextBlock>(grid);
-                                grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
+                                //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
                                 if (box != null)
                                 {
                                     box.Visibility = Visibility.Collapsed;
@@ -359,7 +382,7 @@ namespace PDF_Office.ViewModels.BOTA
                             box = (TextBlock)mouse.Source;
                             grid = (box.Parent as StackPanel).Parent as Grid;
 
-                            grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
+                            //grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(selectColcr));
                             if (box != null)
                             {
                                 box.Visibility = Visibility.Collapsed;

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

@@ -27,60 +27,58 @@
             <convert:ObjectConvert x:Key="ObjectConvert" />
 
             <DataTemplate x:Key="myDataTemplate" DataType="{x:Type data:CPDFBookmark}">
-                <Grid
-                    Name="Grid"
+                <StackPanel
+                    Name="StackPanel"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch">
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="40" />
-                    </Grid.RowDefinitions>
-                    <StackPanel
-                        Name="StackPanel"
-                        Margin="15,5"
-                        Orientation="Horizontal">
+
+                    <Grid Name="Grid" Margin="15,5">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="10*" />
+                            <ColumnDefinition Width="90*" />
+                        </Grid.ColumnDefinitions>
                         <Image
-                            Width="20"
-                            Height="20"
+                            Grid.Column="0"
+                            Width="16"
+                            Height="16"
                             Source="\Resources\BOTA\empty_bookmark.png" />
 
                         <!--  IsHitTestVisible="False"  -->
-                        <TextBlock
-                            Name="TxbTitle"
-                            Width="180"
-                            Padding="5"
-                            Background="Transparent"
-                            FontSize="14"
-                            Text="{Binding Title}"
-                            Visibility="Visible" />
 
                         <TextBox
                             Name="TxtTitleInput"
-                            Width="180"
+                            Grid.Column="1"
                             Padding="5"
+                            HorizontalContentAlignment="Left"
                             Background="White"
                             BorderThickness="1"
                             FontSize="14"
                             Text="{Binding Title}"
-                            TextWrapping="Wrap"
-                            Visibility="{Binding ElementName=TxbTitle, Path=Visibility, Converter={StaticResource UnVisivleConvert}, Mode=TwoWay}">
+                            TextWrapping="Wrap">
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="LostFocus">
                                     <helper:AdvancedInvokeCommandAction
                                         Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
                                         CommandParameter="{Binding ElementName=TxtTitleInput}"
                                         PassEventArgsToCommand="True" />
-                                    <!--<i:InvokeCommandAction Command="{Binding DataContext.LostFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
-                                </i:EventTrigger>
-                                <i:EventTrigger EventName="GotFocus">
-                                    <helper:AdvancedInvokeCommandAction
-                                        Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
-                                        CommandParameter="{Binding ElementName=TxtTitleInput}"
-                                        PassEventArgsToCommand="True" />
-                                    <!--<i:InvokeCommandAction Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
                                 </i:EventTrigger>
+                                <!--<i:EventTrigger EventName="GotFocus">
+                                <helper:AdvancedInvokeCommandAction
+                                Command="{Binding DataContext.GotFocusCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
+                                CommandParameter="{Binding ElementName=TxtTitleInput}"
+                                PassEventArgsToCommand="True" />
+                                </i:EventTrigger>-->
                             </i:Interaction.Triggers>
                         </TextBox>
-                    </StackPanel>
+                        <TextBlock
+                            Name="TxbTitle"
+                            Grid.Column="1"
+                            Padding="5"
+                            Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=Background}"
+                            FontSize="14"
+                            Text="{Binding Title}"
+                            Visibility="Visible" />
+                    </Grid>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="MouseEnter">
                             <!--  绑定两个或多个参数  -->
@@ -123,7 +121,7 @@
                             <!--<i:InvokeCommandAction Command="{Binding DataContext.MouseLeaveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />-->
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
-                </Grid>
+                </StackPanel>
             </DataTemplate>
         </ResourceDictionary>
     </UserControl.Resources>
@@ -173,6 +171,7 @@
                 <ListView.ItemContainerStyle>
                     <Style BasedOn="{StaticResource ListViewItemGraySelectStyle}" TargetType="ListViewItem">
                         <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_MouseLeftButtonDown" />
+                        <EventSetter Event="LostFocus" Handler="ListViewItem_LostFocus" />
                         <!--<EventSetter Event="PreviewMouseMove" Handler="ListViewItem_PreviewMouseMove" />
                         <EventSetter Event="MouseLeave" Handler="ListViewItem_MouseLeave" />-->
                         <!--<EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->

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

@@ -1,4 +1,5 @@
-using PDF_Office.ViewModels.BOTA;
+using PDF_Office.Helper;
+using PDF_Office.ViewModels.BOTA;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -44,5 +45,16 @@ namespace PDF_Office.Views.BOTA
             object[] objects = new object[] { sender, e };
             vm.ListViewItemMouseDownCommand.Execute(objects);
         }
+
+        private void ListViewItem_LostFocus(object sender, RoutedEventArgs e)
+        {
+            ListBoxItem listItem = sender as ListBoxItem;
+            if (listItem != null)
+            {
+                TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listItem);
+                if (textBox.Visibility != Visibility.Visible)
+                    listItem.IsSelected = false;
+            }
+        }
     }
 }