2828
2929#endregion
3030
31+ using Com . Couchcoding . GuiLibrary . Helper ;
3132using System . ComponentModel ;
3233using System . Drawing ;
3334using System . Windows . Forms ;
@@ -41,16 +42,6 @@ public class DialogForm : Form
4142 {
4243 #region Private Consts
4344
44- /// <summary>
45- /// Defines the default horizontal resolution.
46- /// </summary>
47- protected const float DEFAULT_DPI_Y = 96.0f ;
48-
49- /// <summary>
50- /// Defines the defualt vertical resolution.
51- /// </summary>
52- protected const float DEFAULT_DPI_X = 96.0f ;
53-
5445 /// <summary>
5546 /// Defines the height of the button area within the dialog.
5647 /// </summary>
@@ -65,8 +56,6 @@ public class DialogForm : Form
6556
6657 #region Private Fields
6758
68- private static SizeF mDpiSize = new SizeF ( 96.0f , 96.0f ) ;
69-
7059 private bool mShowHeaderArea = true ;
7160 private bool mShowFooterArea = true ;
7261 private Color mContentColor = SystemColors . Control ;
@@ -341,46 +330,11 @@ protected void RecalculatePadding()
341330 {
342331 Padding = new Padding (
343332 5
344- , mShowHeaderArea ? RescaleByDpiY ( HEADER_AREA_HEIGHT ) + 5 : 5
333+ , mShowHeaderArea ? HEADER_AREA_HEIGHT + 5 : 5
345334 , 5
346335 , 5 ) ;
347336 }
348337
349- /// <summary>
350- /// Reloads the current DPI-Settings of the system.
351- /// </summary>
352- /// <param name="ctrl">The <see cref="Control"/> to use the <see cref="Graphics"/> object from.</param>
353- protected static void ReloadDpiSettings ( Control ctrl )
354- {
355- if ( ctrl != null )
356- {
357- using ( Graphics grfx = ctrl . CreateGraphics ( ) )
358- {
359- mDpiSize = new SizeF ( grfx . DpiX , grfx . DpiY ) ;
360- }
361- }
362- }
363-
364- /// <summary>
365- /// Rescales the given value by the currently used DPI-Settings.
366- /// </summary>
367- /// <param name="value">The value to rescale.</param>
368- /// <returns>The rescaled value.</returns>
369- protected static int RescaleByDpiY ( int value )
370- {
371- return ( int ) ( ( value / DEFAULT_DPI_Y ) * mDpiSize . Height ) ;
372- }
373-
374- /// <summary>
375- /// Rescales the given value by the currently used DPI-Settings.
376- /// </summary>
377- /// <param name="value">The value to rescale.</param>
378- /// <returns>The rescaled value.</returns>
379- protected static int RescaleByDpiX ( int value )
380- {
381- return ( int ) ( ( value / DEFAULT_DPI_X ) * mDpiSize . Width ) ;
382- }
383-
384338 /// <summary>
385339 /// Draws the dialog as a default MSR dialog.
386340 /// </summary>
@@ -389,7 +343,7 @@ protected virtual void DrawDialogBackground(Graphics grfx)
389343 {
390344 if ( mShowHeaderArea && Width > 0 && Height > 0 )
391345 {
392- int headerHeight = RescaleByDpiY ( HEADER_AREA_HEIGHT ) ;
346+ int headerHeight = DpiHelper . RescaleByDpiY ( HEADER_AREA_HEIGHT ) ;
393347
394348 if ( mHeaderColor != Color . Transparent && mHeaderColor != mContentColor )
395349 {
@@ -439,8 +393,8 @@ protected virtual void DrawDialogBackground(Graphics grfx)
439393 , captionFont
440394 , captionBrush
441395 , new Point (
442- RescaleByDpiY ( 12 )
443- , RescaleByDpiY ( 8 ) ) ) ;
396+ DpiHelper . RescaleByDpiY ( 12 )
397+ , DpiHelper . RescaleByDpiY ( 8 ) ) ) ;
444398 }
445399 }
446400 }
@@ -458,10 +412,10 @@ protected virtual void DrawDialogBackground(Graphics grfx)
458412 , Font
459413 , textBrush
460414 , new RectangleF (
461- RescaleByDpiY ( 24 )
462- , RescaleByDpiY ( 30 )
463- , ClientRectangle . Width - imgSpaceLeft - RescaleByDpiX ( 30 )
464- , headerHeight - RescaleByDpiY ( 22 ) )
415+ DpiHelper . RescaleByDpiY ( 24 )
416+ , DpiHelper . RescaleByDpiY ( 30 )
417+ , ClientRectangle . Width - imgSpaceLeft - DpiHelper . RescaleByDpiX ( 30 )
418+ , headerHeight - DpiHelper . RescaleByDpiY ( 22 ) )
465419 , sFormat ) ;
466420 }
467421 }
@@ -477,7 +431,7 @@ protected override void OnPaint(PaintEventArgs e)
477431 {
478432 base . OnPaint ( e ) ;
479433
480- int buttonHeight = mShowFooterArea ? RescaleByDpiY ( BUTTON_AREA_HEIGHT ) : 0 ;
434+ int buttonHeight = mShowFooterArea ? DpiHelper . RescaleByDpiY ( BUTTON_AREA_HEIGHT ) : 0 ;
481435
482436 using ( Brush contentBrush = new SolidBrush ( ContentColor ) )
483437 {
@@ -524,9 +478,7 @@ protected DialogForm()
524478 SetStyle ( ControlStyles . OptimizedDoubleBuffer , true ) ;
525479 SetStyle ( ControlStyles . ResizeRedraw , true ) ;
526480
527- AutoScaleMode = AutoScaleMode . Dpi ;
528- Font = SystemFonts . MessageBoxFont ;
529-
481+ Font = SystemFonts . MessageBoxFont ;
530482 ContentColor = SystemColors . Control ;
531483 HeaderColor = Color . White ;
532484 HeaderDescriptionColor = Color . DimGray ;
@@ -537,7 +489,6 @@ protected DialogForm()
537489 ShowInTaskbar = false ;
538490 StartPosition = FormStartPosition . CenterParent ;
539491
540- ReloadDpiSettings ( this ) ;
541492 RecalculatePadding ( ) ;
542493 }
543494
0 commit comments