@@ -164,90 +164,6 @@ private List<RevisionFileTreeNode> GetChildrenOfTreeNode(RevisionFileTreeNode no
164164 }
165165 }
166166
167- public class RevisionImageFileView : Control
168- {
169- public static readonly StyledProperty < Bitmap > SourceProperty =
170- AvaloniaProperty . Register < RevisionImageFileView , Bitmap > ( nameof ( Source ) , null ) ;
171-
172- public Bitmap Source
173- {
174- get => GetValue ( SourceProperty ) ;
175- set => SetValue ( SourceProperty , value ) ;
176- }
177-
178- static RevisionImageFileView ( )
179- {
180- AffectsMeasure < RevisionImageFileView > ( SourceProperty ) ;
181- }
182-
183- public override void Render ( DrawingContext context )
184- {
185- if ( _bgBrush == null )
186- {
187- var maskBrush = new SolidColorBrush ( ActualThemeVariant == ThemeVariant . Dark ? 0xFF404040 : 0xFFBBBBBB ) ;
188- var bg = new DrawingGroup ( )
189- {
190- Children =
191- {
192- new GeometryDrawing ( ) { Brush = maskBrush , Geometry = new RectangleGeometry ( new Rect ( 0 , 0 , 12 , 12 ) ) } ,
193- new GeometryDrawing ( ) { Brush = maskBrush , Geometry = new RectangleGeometry ( new Rect ( 12 , 12 , 12 , 12 ) ) } ,
194- }
195- } ;
196-
197- _bgBrush = new DrawingBrush ( bg )
198- {
199- AlignmentX = AlignmentX . Left ,
200- AlignmentY = AlignmentY . Top ,
201- DestinationRect = new RelativeRect ( new Size ( 24 , 24 ) , RelativeUnit . Absolute ) ,
202- Stretch = Stretch . None ,
203- TileMode = TileMode . Tile ,
204- } ;
205- }
206-
207- context . FillRectangle ( _bgBrush , new Rect ( Bounds . Size ) ) ;
208-
209- var source = Source ;
210- if ( source != null )
211- context . DrawImage ( source , new Rect ( source . Size ) , new Rect ( 8 , 8 , Bounds . Width - 16 , Bounds . Height - 16 ) ) ;
212- }
213-
214- protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
215- {
216- base . OnPropertyChanged ( change ) ;
217-
218- if ( change . Property . Name == "ActualThemeVariant" )
219- {
220- _bgBrush = null ;
221- InvalidateVisual ( ) ;
222- }
223- }
224-
225- protected override Size MeasureOverride ( Size availableSize )
226- {
227- var source = Source ;
228- if ( source == null )
229- return availableSize ;
230-
231- var w = availableSize . Width - 16 ;
232- var h = availableSize . Height - 16 ;
233- var size = source . Size ;
234- if ( size . Width <= w )
235- {
236- if ( size . Height <= h )
237- return new Size ( size . Width + 16 , size . Height + 16 ) ;
238- else
239- return new Size ( h * size . Width / size . Height + 16 , availableSize . Height ) ;
240- }
241- else
242- {
243- var scale = Math . Max ( size . Width / w , size . Height / h ) ;
244- return new Size ( size . Width / scale + 16 , size . Height / scale + 16 ) ;
245- }
246- }
247-
248- private DrawingBrush _bgBrush = null ;
249- }
250-
251167 public class RevisionTextFileView : TextEditor
252168 {
253169 protected override Type StyleKeyOverride => typeof ( TextEditor ) ;
0 commit comments