1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Globalization ;
3
4
using System . IO ;
4
5
using System . Text . RegularExpressions ;
5
6
using System . Threading . Tasks ;
@@ -176,19 +177,17 @@ public void ViewRevisionFile(Models.Object file)
176
177
if ( IMG_EXTS . Contains ( ext ) )
177
178
{
178
179
var stream = Commands . QueryFileContent . Run ( _repo . FullPath , _commit . SHA , file . Path ) ;
179
- var bitmap = stream . Length > 0 ? new Bitmap ( stream ) : null ;
180
- Dispatcher . UIThread . Invoke ( ( ) =>
181
- {
182
- ViewRevisionFileContent = new Models . RevisionImageFile ( ) { Image = bitmap } ;
183
- } ) ;
180
+ var fileSize = stream . Length ;
181
+ var bitmap = fileSize > 0 ? new Bitmap ( stream ) : null ;
182
+ var imageType = Path . GetExtension ( file . Path ) . TrimStart ( '.' ) . ToUpper ( CultureInfo . CurrentCulture ) ;
183
+ var image = new Models . RevisionImageFile ( ) { Image = bitmap , FileSize = fileSize , ImageType = imageType } ;
184
+ Dispatcher . UIThread . Invoke ( ( ) => ViewRevisionFileContent = image ) ;
184
185
}
185
186
else
186
187
{
187
188
var size = new Commands . QueryFileSize ( _repo . FullPath , file . Path , _commit . SHA ) . Result ( ) ;
188
- Dispatcher . UIThread . Invoke ( ( ) =>
189
- {
190
- ViewRevisionFileContent = new Models . RevisionBinaryFile ( ) { Size = size } ;
191
- } ) ;
189
+ var binary = new Models . RevisionBinaryFile ( ) { Size = size } ;
190
+ Dispatcher . UIThread . Invoke ( ( ) => ViewRevisionFileContent = binary ) ;
192
191
}
193
192
194
193
return ;
@@ -202,7 +201,6 @@ public void ViewRevisionFile(Models.Object file)
202
201
var obj = new Models . RevisionLFSObject ( ) { Object = new Models . LFSObject ( ) } ;
203
202
obj . Object . Oid = matchLFS . Groups [ 1 ] . Value ;
204
203
obj . Object . Size = long . Parse ( matchLFS . Groups [ 2 ] . Value ) ;
205
-
206
204
Dispatcher . UIThread . Invoke ( ( ) => ViewRevisionFileContent = obj ) ;
207
205
}
208
206
else
@@ -220,14 +218,8 @@ public void ViewRevisionFile(Models.Object file)
220
218
if ( commit != null )
221
219
{
222
220
var body = new Commands . QueryCommitFullMessage ( submoduleRoot , file . SHA ) . Result ( ) ;
223
- Dispatcher . UIThread . Invoke ( ( ) =>
224
- {
225
- ViewRevisionFileContent = new Models . RevisionSubmodule ( )
226
- {
227
- Commit = commit ,
228
- FullMessage = body ,
229
- } ;
230
- } ) ;
221
+ var submodule = new Models . RevisionSubmodule ( ) { Commit = commit , FullMessage = body } ;
222
+ Dispatcher . UIThread . Invoke ( ( ) => ViewRevisionFileContent = submodule ) ;
231
223
}
232
224
else
233
225
{
0 commit comments