Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / Util / UIServiceHelper.cs / 1 / UIServiceHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.Util { using System; using System.Collections; using System.ComponentModel; using System.Design; using System.Drawing; using System.Web.UI.Design; using System.Windows.Forms; using System.Windows.Forms.Design; ////// Helper class to assist control designers with UI services. /// internal static class UIServiceHelper { public 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; } public static IWin32Window GetDialogOwnerWindow(IServiceProvider serviceProvider) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { return uiService.GetDialogOwnerWindow(); } } return null; } public static ToolStripRenderer GetToolStripRenderer(IServiceProvider serviceProvider) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { IDictionary uiStyles = uiService.Styles; if (uiStyles != null) { return (ToolStripRenderer)uiStyles["VsRenderer"]; } } } return null; } public 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, SR.GetString(SR.UIServiceHelper_ErrorCaption), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } /* This method is not currently used. Uncomment it if you need it. public static void ShowError(IServiceProvider serviceProvider, Exception ex) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { uiService.ShowError(ex); return; } } string message = String.Empty; if (ex != null) { message = ex.Message; } RTLAwareMessageBox.Show(null, message, SR.GetString(SR.UIServiceHelper_ErrorCaption), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } */ public static void ShowError(IServiceProvider serviceProvider, Exception ex, string message) { if (ex != null) { message += Environment.NewLine + Environment.NewLine + ex.Message; } if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { // We specifically don't call ShowError(ex, message) because the IUIService // implementation in VS ignores the Exception parameter when the message // parameter is set, and we'd like to show the user both messages. uiService.ShowError(message); return; } } RTLAwareMessageBox.Show(null, message, SR.GetString(SR.UIServiceHelper_ErrorCaption), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } public static void ShowMessage(IServiceProvider serviceProvider, string message) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { uiService.ShowMessage(message); return; } } RTLAwareMessageBox.Show(null, message, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0); } /* This method is not currently used. Uncomment it if you need it. public static void ShowMessage(IServiceProvider serviceProvider, string message, string caption) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { uiService.ShowMessage(message, caption); return; } } RTLAwareMessageBox.Show(null, message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0); } */ public static DialogResult ShowMessage(IServiceProvider serviceProvider, string message, string caption, MessageBoxButtons buttons) { if (serviceProvider != null) { IUIService uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); if (uiService != null) { return uiService.ShowMessage(message, caption, buttons); } } return RTLAwareMessageBox.Show(null, message, caption, buttons, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PropertyTabChangedEvent.cs
- FlowDocumentPageViewerAutomationPeer.cs
- ManagedWndProcTracker.cs
- ListViewInsertionMark.cs
- SelectionBorderGlyph.cs
- SoapServerMessage.cs
- MouseEventArgs.cs
- DispatcherHooks.cs
- ColorTransformHelper.cs
- OleDbConnectionFactory.cs
- ADMembershipUser.cs
- ServiceProviders.cs
- IOThreadScheduler.cs
- ImageBrush.cs
- LogExtentCollection.cs
- ControlParameter.cs
- ScriptingProfileServiceSection.cs
- SignatureGenerator.cs
- FilterElement.cs
- RequiredFieldValidator.cs
- TextRange.cs
- EntityContainerEmitter.cs
- CompositeTypefaceMetrics.cs
- FixedFindEngine.cs
- ContextMarshalException.cs
- DataGridCellsPresenter.cs
- MergeEnumerator.cs
- propertyentry.cs
- AssociationSetEnd.cs
- CheckBoxStandardAdapter.cs
- AdditionalEntityFunctions.cs
- DeviceContexts.cs
- GenericIdentity.cs
- DbSourceParameterCollection.cs
- EventLogEntryCollection.cs
- DesignObjectWrapper.cs
- DataGridLinkButton.cs
- Label.cs
- MissingManifestResourceException.cs
- TypeSystem.cs
- XPathAncestorQuery.cs
- RoleGroup.cs
- CompositeCollection.cs
- XmlBindingWorker.cs
- PackWebResponse.cs
- ConsoleTraceListener.cs
- ParserContext.cs
- BufferModesCollection.cs
- StyleSelector.cs
- IResourceProvider.cs
- SemaphoreSecurity.cs
- CacheAxisQuery.cs
- DesignSurfaceCollection.cs
- WebPartDisplayMode.cs
- NullableBoolConverter.cs
- RuntimeIdentifierPropertyAttribute.cs
- SynchronousReceiveElement.cs
- ProviderConnectionPoint.cs
- TextOnlyOutput.cs
- Intellisense.cs
- InstanceOwnerQueryResult.cs
- XamlVector3DCollectionSerializer.cs
- Range.cs
- localization.cs
- ItemList.cs
- HostedImpersonationContext.cs
- QueryAsyncResult.cs
- TabControlEvent.cs
- LoadRetryAsyncResult.cs
- RemoteCryptoRsaServiceProvider.cs
- EditorPartCollection.cs
- DataViewListener.cs
- MemoryFailPoint.cs
- IntegrationExceptionEventArgs.cs
- ToolStripGrip.cs
- RoutedPropertyChangedEventArgs.cs
- _NtlmClient.cs
- CssTextWriter.cs
- OdbcConnectionOpen.cs
- DependencyPropertyChangedEventArgs.cs
- CookieParameter.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- TaiwanCalendar.cs
- WSHttpBindingCollectionElement.cs
- ADConnectionHelper.cs
- DetailsViewPageEventArgs.cs
- SchemaContext.cs
- DictionaryCustomTypeDescriptor.cs
- HwndHostAutomationPeer.cs
- PrintPreviewDialog.cs
- StreamSecurityUpgradeAcceptorBase.cs
- httpstaticobjectscollection.cs
- WaitHandleCannotBeOpenedException.cs
- HttpsHostedTransportConfiguration.cs
- LineSegment.cs
- ThumbAutomationPeer.cs
- IsolatedStorageException.cs
- GridSplitterAutomationPeer.cs
- Compiler.cs
- ListBase.cs