Browse Source

首页 - 最近列表删除文件提示弹窗,空状态、文件不存在逻辑

chenrongqian@kdanmobile.com 2 years ago
parent
commit
56c9d532aa

+ 1 - 0
PDF Office/CustomControl/AlertsMessage.xaml

@@ -58,6 +58,7 @@
                     <ColumnDefinition />
                     <ColumnDefinition />
                 </Grid.ColumnDefinitions>
+                <CheckBox x:Name="ChbDonotAskAgain" Content="Don't ask again" Visibility="Collapsed" Checked="ChbDonotAskAgain_Checked" Unchecked="ChbDonotAskAgain_Unchecked"/>
                 <Button
                     x:Name="CancelBtn"
                     Grid.Column="2"

+ 51 - 1
PDF Office/CustomControl/AlertsMessage.xaml.cs

@@ -28,7 +28,7 @@ namespace PDF_Office.CustomControl
     public partial class AlertsMessage : Window
     {
         public ContentResult result = ContentResult.Cancel;
-
+        public bool isChecked = false;
         private Window ownerWindow;
         public AlertsMessage()
         {
@@ -37,6 +37,46 @@ namespace PDF_Office.CustomControl
             ownerWindow = App.Current.MainWindow;
         }
 
+        public void ShowAskAgainCheck()
+        {
+            ChbDonotAskAgain.Visibility = Visibility.Visible;
+        }
+
+        /// <summary>
+        /// 两个按钮弹窗
+        /// </summary>
+        public void HaveCheckBoxShow(string title, string content,string contentCheckBox, string cancelBtn, string okBtn)
+        {
+            TitleText.Text = title;
+            ContentText.Text = content;
+            CancelBtn.Visibility = Visibility.Collapsed;
+            MiddleCancelBtn.Content = cancelBtn;
+            OkBtn.Content = okBtn;
+            ChbDonotAskAgain.Content = contentCheckBox;
+            ChbDonotAskAgain.Visibility = Visibility.Visible;
+            Width = 408;
+
+            Grid.SetColumn(MiddleCancelBtn, 2);
+            Grid.SetColumn(OkBtn, 1);
+            Grid.SetColumn(ChbDonotAskAgain, 0);
+
+            BtnGrid.ColumnDefinitions.Clear();
+            var column = new ColumnDefinition();
+            var column2 = new ColumnDefinition();
+            var column0 = new ColumnDefinition();
+
+            column.Width = new GridLength(1, GridUnitType.Star);
+            column2.Width = new GridLength(1, GridUnitType.Star);
+            column0.Width = new GridLength(2, GridUnitType.Star);
+
+            BtnGrid.ColumnDefinitions.Add(column0);
+            BtnGrid.ColumnDefinitions.Add(column);
+            BtnGrid.ColumnDefinitions.Add(column2);
+
+            ShowDialog();
+        }
+
+
         /// <summary>
         /// 一个按钮弹窗
         /// </summary>
@@ -237,5 +277,15 @@ namespace PDF_Office.CustomControl
         {
             this.DragMove();
         }
+
+        private void ChbDonotAskAgain_Checked(object sender, RoutedEventArgs e)
+        {
+            isChecked = true;
+        }
+
+        private void ChbDonotAskAgain_Unchecked(object sender, RoutedEventArgs e)
+        {
+            isChecked = false;
+        }
     }
 }

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -1953,6 +1953,7 @@
     </Resource>
     <Resource Include="Resources\BOTA\no_outline.png" />
     <Resource Include="Resources\PropertyPanel\nosign.png" />
+    <Resource Include="Resources\HomeIcon\add.png" />
     <Content Include="source\AnalysisWord\Res\word\_rels\document.xml.rels">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

BIN
PDF Office/Resources/HomeIcon/add.png


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

@@ -129,7 +129,7 @@
                             </Grid>
                             <ContentPresenter
                                 Grid.Column="1"
-                                Margin="15,0,0,0"
+                                Margin="0,0,0,0"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
                                 Content="{TemplateBinding ContentControl.Content}"

+ 31 - 15
PDF Office/ViewModels/HomePanel/RecentFiles/RecentFilesContentViewModel.cs

@@ -66,6 +66,7 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
 
         #endregion
 
+        #region Command
         public DelegateCommand<object> RemoveFileItemCommand { get; set; }
         public DelegateCommand<object> RemoveFilesFromContainerCommand { get; set; }
         public DelegateCommand<object> OpenRecentFilesCommand { get; set; }
@@ -76,6 +77,8 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         public DelegateCommand<object> ExplorerFileCommand { get; set; }
 
         public event EventHandler<bool> RecentFilesSelectionHandler;
+        #endregion
+
         public RecentFilesContentViewModel()
         {
             InitVariables();
@@ -98,12 +101,12 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
 
         private void InitCommands()
         {
-            RemoveFilesFromContainerCommand = new DelegateCommand<object>(RemoveFilesFromContainer_Command);
-            RemoveFileItemCommand = new DelegateCommand<object>(RemoveFileItem_Command);
-            OpenRecentFilesCommand = new DelegateCommand<object>(OpenRecentFiles_Command);
+            RemoveFilesFromContainerCommand = new DelegateCommand<object>(RemoveFilesFromContainer_BtnClick);
+            RemoveFileItemCommand = new DelegateCommand<object>(RemoveFileItem_MenuItemClick);
+            OpenRecentFilesCommand = new DelegateCommand<object>(OpenRecentFiles_MouseDoubleClick);
             ListModeCheckedCommand = new DelegateCommand<object>(ListMode_Checked);
-            OpenFilesCommand = new DelegateCommand<object>(OpenFiles_Command);
-            ExplorerFileCommand = new DelegateCommand<object>(ExplorerFile_Command);
+            OpenFilesCommand = new DelegateCommand<object>(OpenFiles_EmptyListsClick);
+            ExplorerFileCommand = new DelegateCommand<object>(ExplorerFile_MenuItemClick);
         }
 
         private void InitEvents()
@@ -159,13 +162,20 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         /// 移除文件记录:单个文件
         /// </summary>
         /// <param name="obj"></param>
-        private void RemoveFileItem_Command(object obj)
+        private void RemoveFileItem_MenuItemClick(object obj)
         {
             var openFileInfo = obj as OpenFileInfo;
             if (openFileInfo != null)
             {
-                SettingHelper.RemoveRecentOpenFile(openFileInfo.FilePath);
-                RecentFilesGroup.Remove(openFileInfo);
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.HaveCheckBoxShow("提示", "删除文件", "不再提示", "取消", "OK");
+
+                if (alertsMessage.result == ContentResult.Ok)
+                {
+                    SettingHelper.RemoveRecentOpenFile(openFileInfo.FilePath);
+                    RecentFilesGroup.Remove(openFileInfo);
+                }
+                  
             }
         }
 
@@ -173,7 +183,7 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         /// 删除按钮触发事件:选中的文件
         /// </summary>
         /// <param name="obj">选中的文档</param>
-        private void RemoveFilesFromContainer_Command(object obj)
+        private void RemoveFilesFromContainer_BtnClick(object obj)
         {
             System.Collections.IList items = (System.Collections.IList)obj;
             if (items == null || items.Cast<OpenFileInfo>() == null)
@@ -206,8 +216,9 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
                     SelectedItemsType = 2;
                 }
 
-                winform.DialogResult result = MessageBoxEx.Show(msg, "", winform.MessageBoxButtons.OKCancel, winform.MessageBoxIcon.Question);
-                if (result == winform.DialogResult.OK)
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.HaveCheckBoxShow("提示", msg,"不再提示", "取消", "OK");
+                if (alertsMessage.result == ContentResult.Ok)
                 {
                     RemoveRecentFilesFrom(SelectedItemsType, openFileInfo);
                 }
@@ -247,7 +258,7 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         /// <summary>
         /// 空状态时,点击文件浏览器弹窗,打开文件
         /// </summary>
-        private void OpenFiles_Command(object obj)
+        private void OpenFiles_EmptyListsClick(object obj)
         {
             var dlg = new OpenFileDialog();
             dlg.Multiselect = true;
@@ -262,7 +273,7 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         /// <summary>
         /// 打开文件路径
         /// </summary>
-        private void ExplorerFile_Command(object obj)
+        private void ExplorerFile_MenuItemClick(object obj)
         {
             try
             {
@@ -273,9 +284,11 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
                     {
                         if (!File.Exists(fileInfo.FilePath))
                         {
-                            MessageBoxEx.Show("文件不存在");
+                            AlertsMessage alertsMessage = new AlertsMessage();
+                            alertsMessage.ShowDialog("提示", "文件不存在", "OK");
                             SettingHelper.RemoveRecentOpenFile(fileInfo.FilePath);
                             RecentFilesGroup.Remove(fileInfo);
+
                         }
                         else
                         {
@@ -295,7 +308,7 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
         /// 从最近列表里,打开文档
         /// </summary>
         /// <param name="obj"></param>
-        private void OpenRecentFiles_Command(object obj)
+        private void OpenRecentFiles_MouseDoubleClick(object obj)
         {
             var fileInfo = obj as OpenFileInfo;
             if (fileInfo != null)
@@ -308,8 +321,11 @@ namespace PDF_Office.ViewModels.HomePanel.RecentFiles
                 }
                 else
                 {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("提示", "文件不存在", "OK");
                     SettingHelper.RemoveRecentOpenFile(fileInfo.FilePath);
                     RecentFilesGroup.Remove(fileInfo);
+
                 }
 
             }

File diff suppressed because it is too large
+ 12 - 8
PDF Office/Views/HomePanel/RecentFiles/DocItemListViewControl.xaml


+ 12 - 8
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml

@@ -74,7 +74,7 @@
             <Style x:Key="SubFilesListViewItemStyle" BasedOn="{StaticResource FilesListViewItemStyle}" TargetType="{x:Type ListViewItem}">
                 <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}" />
                 <Setter Property="HorizontalContentAlignment" Value="Center" />
-                <Setter Property="Margin" Value="12,0,0,0" />
+                <Setter Property="Margin" Value="0,0,0,0" />
                 <EventSetter Event="PreviewMouseRightButtonDown"
                              Handler="ListViewItem_PreviewMouseRightButtonDown" />
                 <EventSetter Event="PreviewMouseDoubleClick"
@@ -211,16 +211,20 @@
 
             <StackPanel x:Name="BlankContentPanel" Grid.Row="1" Grid.RowSpan="2"  HorizontalAlignment="Center" VerticalAlignment="Center"
                         Visibility="{Binding IsEmpty,Converter={StaticResource BoolToVisible}}">
-                <!--<Image Source="../../Resources/Image/Home/empty_recent2x.png" Width="140" Height="140" Stretch="Uniform" VerticalAlignment="Center" />-->
+
+
+                <Button x:Name="BtnAddFiles" MaxHeight="128" Width="128" Height="128" Background="Transparent" BorderThickness="0"
+                           
+                            Command="{Binding OpenFilesCommand}" 
+                            Style="{StaticResource OnlyContentBtn}" Foreground="#6B6F7D">
+                    <Grid Width="128" Height="128">
+                        <Image Source="../../../Resources/HomeIcon/add.png" Width="128" Height="128" Stretch="Uniform" VerticalAlignment="Center" />
+                    </Grid>
+                </Button>
+
                 <TextBlock x:Name="NoFilesText" Text="No documents" TextAlignment="Center"  HorizontalAlignment="Center" FontSize="16" LineHeight="22" Foreground="#FF333333" FontFamily="Segoe UI" />
                 <StackPanel Orientation="Horizontal" Margin="0,12,0,0">
                     <TextBlock x:Name="clickFileText" Text="Drop documents here or click the '" Foreground="#FF999999" VerticalAlignment="Center" FontSize="14" />
-                    <TextBlock  Margin="2,0,2,0" VerticalAlignment="Center" FontSize="15">
-                        <Hyperlink  Command="{Binding OpenFilesCommand}">
-                            <TextBlock x:Name="OpenFilesLinkText" Text="Open Files" />
-                        </Hyperlink>
-                    </TextBlock>
-                    <TextBlock x:Name="dropFileText" Text="' button in the Sidebar" Foreground="#FF999999" VerticalAlignment="Center" FontSize="14" />
                 </StackPanel>
             </StackPanel>
         </Grid>

+ 16 - 3
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml.cs

@@ -83,6 +83,12 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
         {
             try
             {
+                ListView listView;
+                if (BtnListMode.IsChecked == true)
+                    listView = RecentFilesList;
+                else
+                    listView = GridRecentFilesList;
+
                 var contexMenu = sender as ContextMenu;
                 if (contexMenu != null)
                 {
@@ -92,7 +98,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
                         menuitem.Visibility = Visibility.Visible;
                     }
                 }
-                if (RecentFilesList.SelectedItems.Count >= 2)
+                if (listView.SelectedItems.Count >= 2)
                 {
                     foreach (var item in contexMenu.Items)
                     {
@@ -125,7 +131,14 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
         /// </summary>
         private void DeleteMenuItem_Click(object sender, RoutedEventArgs e)
         {
-            if (RecentFilesList.SelectedItems == null || RecentFilesList.SelectedItems.Count == 0)
+            ListView listView;
+            if (BtnListMode.IsChecked == true)
+                listView = RecentFilesList;
+            else
+                listView = GridRecentFilesList;
+
+
+            if (listView.SelectedItems == null || listView.SelectedItems.Count == 0)
             {
                 var item = (sender as MenuItem).DataContext as OpenFileInfo;
                 if (item != null)
@@ -135,7 +148,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
             }
             else
             {
-                ViewModel?.RemoveFilesFromContainerCommand.Execute(RecentFilesList.SelectedItems);
+                ViewModel?.RemoveFilesFromContainerCommand.Execute(listView.SelectedItems);
             }
 
         }