1 //------------------------------------------------------------------------------
2 // <copyright file="GenericUI.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
7 namespace System.Web.UI.Design.MobileControls.Util
10 using System.Collections;
11 using System.ComponentModel;
13 using System.Diagnostics;
14 using System.Windows.Forms;
15 using System.Windows.Forms.Design;
19 System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
20 Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)
22 [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
23 internal class GenericUI
25 // Internal type should not be instantiated.
29 internal static readonly Bitmap SortDownIcon =
30 new Icon(typeof(MobileControlDesigner), "SortDown.ico").ToBitmap();
32 internal static readonly Bitmap SortUpIcon =
33 new Icon(typeof(MobileControlDesigner), "SortUp.ico").ToBitmap();
35 internal static readonly Bitmap DeleteIcon =
36 new Icon(typeof(MobileControlDesigner), "Delete.ico").ToBitmap();
38 internal static readonly Bitmap ErrorIcon =
39 new Icon(typeof(MobileContainerDesigner), "Error.ico").ToBitmap();
41 internal static readonly Bitmap InfoIcon =
42 new Icon(typeof(MobileContainerDesigner), "Info.ico").ToBitmap();
44 internal static void InitDialog(
48 dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
50 dialog.MaximizeBox = false;
51 dialog.MinimizeBox = false;
52 dialog.ShowInTaskbar = false;
53 dialog.StartPosition = FormStartPosition.CenterParent;
54 dialog.AutoScaleBaseSize = new Size(5, 14);
55 dialog.Font = GetVS7Font(site);
58 internal static Font GetVS7Font(ISite site)
60 System.Drawing.Font vsfont = Control.DefaultFont;
63 IUIService uiService = (IUIService) site.GetService(
66 if (uiService != null)
68 vsfont = (Font) uiService.Styles["DialogFont"];
74 // This version of InitDialog() handles merged UIs
75 internal static int InitDialog(
77 IDeviceSpecificDesigner designer,
80 InitDialog(dialog, designer.UnderlyingControl.Site);
82 designer.InitHeader(mergingContext);
83 Control header = designer.Header;
86 // (6, 5) = Windows standard positioning
87 header.Location = new Point(6, 5);
88 dialog.Controls.Add(header);
89 // +6 = 6px space between header and first control
90 dialog.Height += header.Height + 6;
91 tabOffset = GenericUI.GetMaxContainedTabIndex(header);
92 // Changing the header width is going to magically
93 // cause everything to be repositioned vertically
94 // -10 = 5px padding on each side of the client area
95 header.Width = dialog.ClientSize.Width - 10;
100 internal static int GetMaxContainedTabIndex(Control control)
102 int maxTabIndex = control.TabIndex;
104 foreach(Control child in control.Controls)
106 int maxChildTabIndex = GetMaxContainedTabIndex(child);
107 if(maxChildTabIndex > maxTabIndex)
109 maxTabIndex = maxChildTabIndex;
115 internal static void ShowErrorMessage(String title, String message)
117 RTLAwareMessageBox.Show(
121 MessageBoxButtons.OK,
122 MessageBoxIcon.Error,
123 MessageBoxDefaultButton.Button1,
128 internal static String BuildCommaDelimitedList(ICollection stringList)
130 StringBuilder delimitedString = new StringBuilder();
132 foreach (String str in stringList)
134 if(delimitedString.Length > 0)
136 delimitedString.Append(", ");
138 delimitedString.Append(str);
140 return delimitedString.ToString();
143 internal static void ShowWarningMessage(String title, String message)
145 RTLAwareMessageBox.Show(
149 MessageBoxButtons.OK,
150 MessageBoxIcon.Exclamation,
151 MessageBoxDefaultButton.Button1,
156 internal static bool ConfirmYesNo(String title, String message)
158 DialogResult result = RTLAwareMessageBox.Show(
162 MessageBoxButtons.YesNo,
163 MessageBoxIcon.Exclamation,
164 MessageBoxDefaultButton.Button1,
167 return result == DialogResult.Yes;
171 // Copied from ndp\fx\src\Designer\[....]\System\[....]\Design\RTLAwareMessageBox.cs
172 [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
173 internal sealed class RTLAwareMessageBox {
175 // Private helper class shouldn't be instantiated.
176 private RTLAwareMessageBox() {
179 /// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show6"]/*' />
182 /// Displays a message box with specified text, caption, and style.
183 /// Makes the dialog RTL if the resources for this dll have been localized to a RTL language.
186 public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
187 MessageBoxDefaultButton defaultButton, MessageBoxOptions options) {
188 if (RTLAwareMessageBox.IsRTLResources) {
189 options |= (MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
191 return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
195 /// Tells whether the current resources for this dll have been
196 /// localized for a RTL language.
198 public static bool IsRTLResources {
200 // Set RightToLeft mode based on resource file
201 string rtlText = SR.GetString(SR.RTL);
203 return !String.Equals(rtlText, "RTL_False", StringComparison.Ordinal);