@@ -231,7 +231,7 @@ private void LoadConfigToUI(int index)
231231 var c = Program . Configs [ index ] ;
232232
233233 C_SMDir . Items . Clear ( ) ;
234- c . SMDirectories . ForEach ( x => C_SMDir . Items . Add ( CreateDirItem ( x ) ) ) ;
234+ c . SMDirectories . ForEach ( x => C_SMDir . Items . Add ( CreateDirItem ( x , DirUtils . CanAccess ( x ) ) ) ) ;
235235 C_Name . Text = c . Name ;
236236 C_AutoCopy . IsChecked = c . AutoCopy ;
237237 C_AutoUpload . IsChecked = c . AutoUpload ;
@@ -330,22 +330,18 @@ private void AddSMDirButton_Click(object sender, RoutedEventArgs e)
330330 }
331331
332332 // Test for access permissions and flag as rejected directory if necessary
333- try
334- {
335- Directory . GetAccessControl ( dialog . FileName ) ;
336- }
337- catch ( UnauthorizedAccessException )
333+ var canAccess = DirUtils . CanAccess ( dialog . FileName ) ;
334+ if ( ! canAccess )
338335 {
339336 this . ShowMessageAsync ( Translate ( "PermissionAccessError" ) ,
340- Translate ( "PermissionAcessErrorMessage " ) ,
337+ Translate ( "PermissionAccessErrorMessage " ) ,
341338 MessageDialogStyle . Affirmative , Program . MainWindow . MetroDialogOptions ) ;
342339 }
343-
344340 // Add to dirs of that config
345341 c . SMDirectories . Add ( dialog . FileName ) ;
346342
347343 // Add list item
348- C_SMDir . Items . Add ( CreateDirItem ( dialog . FileName ) ) ;
344+ C_SMDir . Items . Add ( CreateDirItem ( dialog . FileName , canAccess ) ) ;
349345
350346 NeedsSMDefInvalidation = true ;
351347 }
@@ -780,7 +776,7 @@ await this.ShowMessageAsync(Translate("ErrorSavingConfigs"),
780776 /// </summary>
781777 /// <param name="path">Path of the SM Directory to be added</param>
782778 /// <returns>The ListBoxItem that will be added to the SM Directories list</returns>
783- private ListBoxItem CreateDirItem ( string path )
779+ private ListBoxItem CreateDirItem ( string path , bool canAccess = false )
784780 {
785781 var item = new ListBoxItem ( ) ;
786782 var stack = new StackPanel ( ) ;
@@ -789,20 +785,46 @@ private ListBoxItem CreateDirItem(string path)
789785 {
790786 Text = path
791787 } ) ;
788+ if ( ! canAccess )
789+ {
790+ stack . Children . Add ( new Image
791+ {
792+ Source = new BitmapImage ( new Uri ( $ "/SPCode;component/Resources/Icons/icon-error.png", UriKind . Relative ) ) ,
793+ Width = 16 ,
794+ Margin = new Thickness ( 5 , 0 , 0 , 0 ) ,
795+ ToolTip = Translate ( "PermissionAccessError" )
796+ } ) ;
797+ }
792798 if ( File . Exists ( Path . Combine ( path , Constants . SPCompiler ) ) )
793799 {
794800 stack . Children . Add ( new Image
795801 {
796802 Source = new BitmapImage ( new Uri ( $ "/SPCode;component/Resources/Icons/icon-pawn.png", UriKind . Relative ) ) ,
797803 Width = 16 ,
798- Margin = new Thickness ( 5 , 0 , 0 , 0 ) ,
804+ Margin = new Thickness ( 5 , 0 , 0 , 0 ) ,
799805 ToolTip = Translate ( "SPCompilerFoundHere" )
800806 } ) ;
801807 }
802808 item . Content = stack ;
803809 return item ;
804810 }
805811
812+ private void SidebarColumn_SizeChanged ( object sender , SizeChangedEventArgs e )
813+ {
814+ if ( e . NewSize . Width < 200 )
815+ {
816+ AddButtonText . Visibility = Visibility . Collapsed ;
817+ CopyButtonText . Visibility = Visibility . Collapsed ;
818+ RemoveButtonText . Visibility = Visibility . Collapsed ;
819+ }
820+ else
821+ {
822+ AddButtonText . Visibility = Visibility . Visible ;
823+ CopyButtonText . Visibility = Visibility . Visible ;
824+ RemoveButtonText . Visibility = Visibility . Visible ;
825+ }
826+ }
827+
806828 private void Language_Translate ( )
807829 {
808830 Title = Translate ( "Configs" ) ;
0 commit comments