1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
//------------------------------------------------------------------------------
// <copyright file="UIHelper.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//
// @owner [....]
// @backupOwner [....]
//
// Helper methods for UI functionality like displaying dialogs
//------------------------------------------------------------------------------
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace System.Web.UI.Design.WebControls.Util
{
internal static class UIHelper
{
internal static Font GetDialogFont(IServiceProvider serviceProvider)
{
if (serviceProvider != null)
{
IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
if (uiService != null)
{
IDictionary uiStyles = uiService.Styles;
if (uiStyles != null)
{
return (Font)uiStyles["DialogFont"];
}
}
}
return null;
}
internal static DialogResult ShowDialog(IServiceProvider serviceProvider, Form form)
{
if (serviceProvider != null)
{
IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
if (uiService != null)
{
return uiService.ShowDialog(form);
}
}
return form.ShowDialog();
}
public static void ShowError(IServiceProvider serviceProvider, string message)
{
if (serviceProvider != null)
{
IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
if (uiService != null)
{
uiService.ShowError(message);
return;
}
}
RTLAwareMessageBox.Show(null, message, Strings.UIHelper_ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
public static void ShowWarning(IServiceProvider serviceProvider, string message)
{
if (serviceProvider != null)
{
IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
if (uiService != null)
{
uiService.ShowError(message);
return;
}
}
RTLAwareMessageBox.Show(null, message, Strings.UIHelper_WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, 0);
}
}
}
|