소스 검색

其他-代码优化

OYXH\oyxh 1 년 전
부모
커밋
4baeb042e0
1개의 변경된 파일26개의 추가작업 그리고 28개의 파일을 삭제
  1. 26 28
      PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml.cs

+ 26 - 28
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml.cs

@@ -23,12 +23,14 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
     public partial class RecentFilesContent : UserControl
     {
         private RecentFilesContentViewModel ViewModel => DataContext as RecentFilesContentViewModel;
+
         public RecentFilesContent()
         {
             InitializeComponent();
         }
 
         #region 初始化
+
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
             InitVariables();
@@ -43,14 +45,17 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             if (GridRecentFilesList.SelectedItems != null)
                 GridRecentFilesList.SelectedItems.Clear();
         }
+
         private void InitEvents()
         {
             ViewModel.RecentFilesSelectionHandler -= ViewModel_RecentFilesSelection;
             ViewModel.RecentFilesSelectionHandler += ViewModel_RecentFilesSelection;
         }
-        #endregion
+
+        #endregion 初始化
 
         #region UI操作
+
         private void ViewModel_RecentFilesSelection(object sender, bool e)
         {
             //if (e)
@@ -111,7 +116,7 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
                         if (menuitem.Name == "FilePathMenuItem")
                             menuitem.Visibility = Visibility.Collapsed;
 
-                        if(menuitem.Name == "MenuOpenFile")
+                        if (menuitem.Name == "MenuOpenFile")
                         {
                             menuitem.Visibility = Visibility.Visible;
                         }
@@ -128,8 +133,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
                         }
                     }
                 }
-
-     
             }
             catch { }
         }
@@ -143,12 +146,10 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             e.Handled = true;
         }
 
-        #endregion
-
+        #endregion UI操作
 
         #region Events
 
-
         /// <summary>
         /// 右键菜单:删除文件记录
         /// </summary>
@@ -160,7 +161,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             else
                 listView = GridRecentFilesList;
 
-
             if (listView.SelectedItems == null || listView.SelectedItems.Count == 0)
             {
                 var item = (sender as MenuItem).DataContext as OpenFileInfo;
@@ -173,7 +173,6 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             {
                 ViewModel?.RemoveFilesFromContainerCommand.Execute(listView.SelectedItems);
             }
-
         }
 
         /// <summary>
@@ -200,12 +199,11 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             if (item != null && (item.DataContext as OpenFileInfo) != null)
             {
                 var fileInfo = item.DataContext as OpenFileInfo;
-                if(fileInfo != null)
+                if (fileInfo != null)
                 {
                     ViewModel?.OpenRecentFilesCommand.Execute(fileInfo);
                 }
             }
-
         }
 
         /// <summary>
@@ -232,23 +230,23 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             }
         }
 
-        #endregion
+        #endregion Events
 
         private void UserControl_KeyDown(object sender, KeyEventArgs e)
         {
-            if (e.Key == Key.Escape)
-            {
-                //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
-                //点击ESC取消选中
-                //if (GridRecentFilesList.Visibility == Visibility.Visible)
-                //{
-                //    GridRecentFilesList.SelectedIndex = -1;
-                //}
-                //else
-                //{
-                //    RecentFilesList.SelectedIndex = -1;
-                //}
-            }
+            //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
+            //if (e.Key == Key.Escape)
+            //{
+            //点击ESC取消选中
+            //if (GridRecentFilesList.Visibility == Visibility.Visible)
+            //{
+            //    GridRecentFilesList.SelectedIndex = -1;
+            //}
+            //else
+            //{
+            //    RecentFilesList.SelectedIndex = -1;
+            //}
+            //}
         }
 
         private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
@@ -259,7 +257,7 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
             else
                 listView = GridRecentFilesList;
 
-            if (listView.SelectedItems.Count >=2)
+            if (listView.SelectedItems.Count >= 2)
             {
                 List<string> files = new List<string>();
                 foreach (OpenFileInfo item in listView.SelectedItems)
@@ -281,10 +279,10 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
         private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
             //已经加载后,切换页签时,确认是否要刷新数据源
-            if(IsLoaded&&(bool)e.NewValue)
+            if (IsLoaded && (bool)e.NewValue)
             {
                 ViewModel.UpdateItemSoucre();
             }
         }
     }
-}
+}