@@ -77,6 +77,43 @@ internal static Result CreateFolderResult(string title, string subtitle, string
7777 } ;
7878 }
7979
80+ private static string toReadableSize ( long pDrvSize , int pi )
81+ {
82+ int mok = 0 ;
83+ double drvSize = pDrvSize ;
84+ string Space = "Byte" ;
85+ string returnStr = "" ;
86+
87+ while ( drvSize > 1024.0 )
88+ {
89+ drvSize /= 1024.0 ;
90+ mok ++ ;
91+ }
92+
93+ if ( mok == 1 )
94+ Space = "KB" ;
95+ else if ( mok == 2 )
96+ Space = " MB" ;
97+ else if ( mok == 3 )
98+ Space = " GB" ;
99+ else if ( mok == 4 )
100+ Space = " TB" ;
101+
102+ if ( mok != 0 )
103+ if ( pi == 1 )
104+ returnStr = string . Format ( "{0:F1}{1}" , drvSize , Space ) ;
105+ else if ( pi == 2 )
106+ returnStr = string . Format ( "{0:F2}{1}" , drvSize , Space ) ;
107+ else if ( pi == 3 )
108+ returnStr = string . Format ( "{0:F3}{1}" , drvSize , Space ) ;
109+ else
110+ returnStr = string . Format ( "{0}{1}" , Convert . ToInt32 ( drvSize ) , Space ) ;
111+ else
112+ returnStr = string . Format ( "{0}{1}" , Convert . ToInt32 ( drvSize ) , Space ) ;
113+
114+ return returnStr ;
115+ }
116+
80117 internal static Result CreateOpenCurrentFolderResult ( string path , bool windowsIndexed = false )
81118 {
82119 var retrievedDirectoryPath = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( path ) ;
@@ -86,19 +123,32 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
86123 Path . DirectorySeparatorChar
87124 } , StringSplitOptions . None ) . Last ( ) ;
88125
89- if ( retrievedDirectoryPath . EndsWith ( ":\\ " ) )
90- {
91- var driveLetter = path . Substring ( 0 , 1 ) . ToUpper ( ) ;
92- folderName = driveLetter + " drive" ;
93- }
94-
95126 var title = "Open current directory" ;
96127
97128 if ( retrievedDirectoryPath != path )
98129 title = "Open " + folderName ;
99130
100-
101131 var subtitleFolderName = folderName ;
132+ var subtitle = $ "Use > to search within { subtitleFolderName } , " +
133+ $ "* to search for file extensions or >* to combine both searches.";
134+
135+
136+
137+
138+
139+ int ? progressBar = null ;
140+ if ( retrievedDirectoryPath . EndsWith ( ":\\ " ) )
141+ {
142+ title = "" ; // hide title when use progress bar,
143+ var driveLetter = path . Substring ( 0 , 1 ) . ToUpper ( ) ;
144+ folderName = driveLetter + " drive" ;
145+ var driveName = driveLetter + ":\\ " ;
146+ DriveInfo drv = new DriveInfo ( driveLetter ) ;
147+ subtitle = toReadableSize ( drv . AvailableFreeSpace , 2 ) + " free of " + toReadableSize ( drv . TotalSize , 2 ) ;
148+ double UsingSize = ( ( Convert . ToDouble ( drv . TotalSize ) - Convert . ToDouble ( drv . AvailableFreeSpace ) ) / Convert . ToDouble ( drv . TotalSize ) * 100 ) ;
149+ progressBar = Convert . ToInt32 ( UsingSize ) ;
150+ }
151+
102152
103153 // ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)"
104154 if ( folderName . Length > 19 )
@@ -107,11 +157,11 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
107157 return new Result
108158 {
109159 Title = title ,
110- SubTitle = $ "Use > to search within { subtitleFolderName } , " +
111- $ "* to search for file extensions or >* to combine both searches.",
160+ SubTitle = subtitle ,
112161 AutoCompleteText = GetPathWithActionKeyword ( retrievedDirectoryPath , ResultType . Folder ) ,
113162 IcoPath = retrievedDirectoryPath ,
114163 Score = 500 ,
164+ ProgressBar = progressBar ,
115165 Action = c =>
116166 {
117167 Context . API . OpenDirectory ( retrievedDirectoryPath ) ;
@@ -208,4 +258,4 @@ public enum ResultType
208258 Folder ,
209259 File
210260 }
211- }
261+ }
0 commit comments