11using System ;
22using System . Collections . Generic ;
3+ using System . Globalization ;
34using System . IO ;
45using System . Text . RegularExpressions ;
56using System . Threading . Tasks ;
@@ -176,19 +177,17 @@ public void ViewRevisionFile(Models.Object file)
176177 if ( IMG_EXTS . Contains ( ext ) )
177178 {
178179 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 ) ;
184185 }
185186 else
186187 {
187188 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 ) ;
192191 }
193192
194193 return ;
@@ -202,7 +201,6 @@ public void ViewRevisionFile(Models.Object file)
202201 var obj = new Models . RevisionLFSObject ( ) { Object = new Models . LFSObject ( ) } ;
203202 obj . Object . Oid = matchLFS . Groups [ 1 ] . Value ;
204203 obj . Object . Size = long . Parse ( matchLFS . Groups [ 2 ] . Value ) ;
205-
206204 Dispatcher . UIThread . Invoke ( ( ) => ViewRevisionFileContent = obj ) ;
207205 }
208206 else
@@ -220,14 +218,8 @@ public void ViewRevisionFile(Models.Object file)
220218 if ( commit != null )
221219 {
222220 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 ) ;
231223 }
232224 else
233225 {
0 commit comments