using System; using System.ComponentModel; using System.Runtime.InteropServices; using System.Drawing.Text; using System.Windows.Forms; namespace DevComponents.DotNetBar.Layout { /// /// Represents class with static functions that provide commonly used utility functions when working with /// Bar objects and items hosted by Bar object. /// internal class BarUtilities { /// /// Gets or sets whether StringFormat internally used by all DotNetBar controls to render text is GenericDefault. Default value is false /// which indicates that GenericTypographic is used. /// public static bool UseGenericDefaultStringFormat { get { return TextDrawing.UseGenericDefault; } set { TextDrawing.UseGenericDefault = value; } } /// /// Gets or sets the anti-alias text rendering hint that will be used to render text on controls that have AntiAlias property set to true. /// public static TextRenderingHint AntiAliasTextRenderingHint { get { return DisplayHelp.AntiAliasTextRenderingHint; } set { DisplayHelp.AntiAliasTextRenderingHint = value; } } #if FRAMEWORK20 /// /// Gets or sets whether .NET Framework TextRenderer class is used for text rendering instead of Graphics.DrawString. /// Default value is false. /// Using TextRenderer will disable the Fade and Animation effects on controls because of issues in TextRenderer when drawing text on transparent /// surfaces. /// public static bool UseTextRenderer { get { return TextDrawing.UseTextRenderer; } set { TextDrawing.UseTextRenderer = value; } } #endif private static bool _AlwaysGenerateAccessibilityFocusEvent = false; /// /// Gets or sets whether items always generate the Focus accessibility event when mouse enters the item. Default value is false which indicates /// that focus event will be raised only when item is on menu bar. /// public static bool AlwaysGenerateAccessibilityFocusEvent { get { return _AlwaysGenerateAccessibilityFocusEvent; } set { _AlwaysGenerateAccessibilityFocusEvent = value; } } internal static bool IsModalFormOpen { get { #if (FRAMEWORK20) for (int i = 0; i < System.Windows.Forms.Application.OpenForms.Count; i++) { System.Windows.Forms.Form form = System.Windows.Forms.Application.OpenForms[i]; if (form.Modal) return true; } #endif return false; } } private static bool _AutoRemoveMessageFilter = false; /// /// Gets or sets whether Application Message Filter that is registered by popup controls /// is automatically unregistered when last control is disposed. Default value is false and /// in most cases should not be changed. /// public static bool AutoRemoveMessageFilter { get { return _AutoRemoveMessageFilter; } set { _AutoRemoveMessageFilter = value; } } private static int _TextMarkupCultureSpecific = 3; /// /// Get or sets the text-markup padding for text measurement when running on Japanese version of Windows. /// public static int TextMarkupCultureSpecificPadding { get { return _TextMarkupCultureSpecific; } set { _TextMarkupCultureSpecific = value; } } private static bool _DisposeItemImages = false; /// /// Gets or sets whether Image and Icon resources assigned to items and controls are automatically disposed when /// control or item is disposed. Default value is false. /// public static bool DisposeItemImages { get { return _DisposeItemImages; } set { _DisposeItemImages = value; } } /// /// Disposes image reference and sets it to null. /// /// Reference to image to dispose. internal static void DisposeImage(ref System.Drawing.Image image) { if (image == null) return; image.Dispose(); image = null; } /// /// Disposes image reference and sets it to null. /// /// Reference to image to dispose. internal static void DisposeImage(ref System.Drawing.Icon icon) { if (icon == null) return; icon.Dispose(); icon = null; } #region Delayed Invoke /// /// Invokes the method asynchronously using the WinForms Timer. /// /// Method to invoke. public static void InvokeDelayed(MethodInvoker method) { InvokeDelayed(method, 10); } /// /// Invokes the method asynchronously using the WinForms Timer. /// /// Method to invoke. /// Time in milliseconds after which method is invoked. public static void InvokeDelayed(MethodInvoker method, int delayInterval) { Timer delayedInvokeTimer = new Timer(); delayedInvokeTimer = new Timer(); delayedInvokeTimer.Tag = method; delayedInvokeTimer.Interval = delayInterval; delayedInvokeTimer.Tick += new EventHandler(DelayedInvokeTimerTick); delayedInvokeTimer.Start(); } private static void DelayedInvokeTimerTick(object sender, EventArgs e) { Timer timer = (Timer)sender; MethodInvoker method = (MethodInvoker)timer.Tag; timer.Stop(); timer.Dispose(); method.Invoke(); } #endregion } internal class BarPropertyBagKeys { public static string AutoHideSetting="autohide"; } }