@@ -231,7 +231,7 @@ private void LoadConfigToUI(int index)
231
231
var c = Program . Configs [ index ] ;
232
232
233
233
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 ) ) ) ) ;
235
235
C_Name . Text = c . Name ;
236
236
C_AutoCopy . IsChecked = c . AutoCopy ;
237
237
C_AutoUpload . IsChecked = c . AutoUpload ;
@@ -330,22 +330,18 @@ private void AddSMDirButton_Click(object sender, RoutedEventArgs e)
330
330
}
331
331
332
332
// 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 )
338
335
{
339
336
this . ShowMessageAsync ( Translate ( "PermissionAccessError" ) ,
340
- Translate ( "PermissionAcessErrorMessage " ) ,
337
+ Translate ( "PermissionAccessErrorMessage " ) ,
341
338
MessageDialogStyle . Affirmative , Program . MainWindow . MetroDialogOptions ) ;
342
339
}
343
-
344
340
// Add to dirs of that config
345
341
c . SMDirectories . Add ( dialog . FileName ) ;
346
342
347
343
// Add list item
348
- C_SMDir . Items . Add ( CreateDirItem ( dialog . FileName ) ) ;
344
+ C_SMDir . Items . Add ( CreateDirItem ( dialog . FileName , canAccess ) ) ;
349
345
350
346
NeedsSMDefInvalidation = true ;
351
347
}
@@ -780,7 +776,7 @@ await this.ShowMessageAsync(Translate("ErrorSavingConfigs"),
780
776
/// </summary>
781
777
/// <param name="path">Path of the SM Directory to be added</param>
782
778
/// <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 )
784
780
{
785
781
var item = new ListBoxItem ( ) ;
786
782
var stack = new StackPanel ( ) ;
@@ -789,20 +785,46 @@ private ListBoxItem CreateDirItem(string path)
789
785
{
790
786
Text = path
791
787
} ) ;
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
+ }
792
798
if ( File . Exists ( Path . Combine ( path , Constants . SPCompiler ) ) )
793
799
{
794
800
stack . Children . Add ( new Image
795
801
{
796
802
Source = new BitmapImage ( new Uri ( $ "/SPCode;component/Resources/Icons/icon-pawn.png", UriKind . Relative ) ) ,
797
803
Width = 16 ,
798
- Margin = new Thickness ( 5 , 0 , 0 , 0 ) ,
804
+ Margin = new Thickness ( 5 , 0 , 0 , 0 ) ,
799
805
ToolTip = Translate ( "SPCompilerFoundHere" )
800
806
} ) ;
801
807
}
802
808
item . Content = stack ;
803
809
return item ;
804
810
}
805
811
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
+
806
828
private void Language_Translate ( )
807
829
{
808
830
Title = Translate ( "Configs" ) ;
0 commit comments