Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Web.Entity.Design / System / Data / WebControls / Design / Util / UIHelper.cs
blobca925042fc341140b04ef1c65cfc26c0c408d8ea
1 //------------------------------------------------------------------------------
2 // <copyright file="UIHelper.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //
6 // @owner Microsoft
7 // @backupOwner Microsoft
8 //
9 // Helper methods for UI functionality like displaying dialogs
10 //------------------------------------------------------------------------------
12 using System.Collections;
13 using System.Drawing;
14 using System.Windows.Forms;
15 using System.Windows.Forms.Design;
17 namespace System.Web.UI.Design.WebControls.Util
19 internal static class UIHelper
21 internal static Font GetDialogFont(IServiceProvider serviceProvider)
23 if (serviceProvider != null)
25 IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
26 if (uiService != null)
28 IDictionary uiStyles = uiService.Styles;
29 if (uiStyles != null)
31 return (Font)uiStyles["DialogFont"];
35 return null;
38 internal static DialogResult ShowDialog(IServiceProvider serviceProvider, Form form)
40 if (serviceProvider != null)
42 IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
43 if (uiService != null)
45 return uiService.ShowDialog(form);
49 return form.ShowDialog();
52 public static void ShowError(IServiceProvider serviceProvider, string message)
54 if (serviceProvider != null)
56 IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
57 if (uiService != null)
59 uiService.ShowError(message);
60 return;
64 RTLAwareMessageBox.Show(null, message, Strings.UIHelper_ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
67 public static void ShowWarning(IServiceProvider serviceProvider, string message)
69 if (serviceProvider != null)
71 IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
72 if (uiService != null)
74 uiService.ShowError(message);
75 return;
79 RTLAwareMessageBox.Show(null, message, Strings.UIHelper_WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, 0);