Code:
/ DotNET / DotNET / 8.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
- TdsParserSafeHandles.cs
- WebPartConnectionsDisconnectVerb.cs
- SHA256.cs
- ServiceMemoryGates.cs
- WebPartDeleteVerb.cs
- XmlDataSourceNodeDescriptor.cs
- ElementProxy.cs
- XmlSchemaInferenceException.cs
- RuntimeConfigurationRecord.cs
- StringFreezingAttribute.cs
- PersonalizationState.cs
- HtmlShimManager.cs
- RSACryptoServiceProvider.cs
- ToolBar.cs
- Vector3DAnimationBase.cs
- ApplicationActivator.cs
- ScriptServiceAttribute.cs
- EntityDescriptor.cs
- ListViewDeleteEventArgs.cs
- BamlVersionHeader.cs
- _HeaderInfoTable.cs
- FileSystemEventArgs.cs
- EdmScalarPropertyAttribute.cs
- PackageRelationshipCollection.cs
- DataGridColumnCollection.cs
- SignerInfo.cs
- ProviderException.cs
- ThaiBuddhistCalendar.cs
- RTLAwareMessageBox.cs
- CodeDelegateCreateExpression.cs
- IsolatedStorageFile.cs
- SizeValueSerializer.cs
- TextProperties.cs
- WebPartCollection.cs
- CompilationLock.cs
- SQLMoneyStorage.cs
- AppDomainProtocolHandler.cs
- InstalledVoice.cs
- X509WindowsSecurityToken.cs
- MaterializeFromAtom.cs
- StaticFileHandler.cs
- HttpResponse.cs
- FileChangesMonitor.cs
- CultureInfo.cs
- StylusTouchDevice.cs
- Translator.cs
- ProtocolsSection.cs
- MailDefinition.cs
- Error.cs
- BasePattern.cs
- PeerChannelFactory.cs
- AppDomain.cs
- DispatchChannelSink.cs
- Brushes.cs
- _DomainName.cs
- DownloadProgressEventArgs.cs
- LiteralControl.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- DefaultValidator.cs
- CryptoApi.cs
- commandenforcer.cs
- XmlTextReader.cs
- BindingListCollectionView.cs
- ListCardsInFileRequest.cs
- XmlSchemaSimpleTypeRestriction.cs
- PropertyPushdownHelper.cs
- DSASignatureDeformatter.cs
- Group.cs
- SqlDataSourceCache.cs
- InheritanceAttribute.cs
- ProfileService.cs
- LongMinMaxAggregationOperator.cs
- VariantWrapper.cs
- EntityConnectionStringBuilder.cs
- RemoteWebConfigurationHostServer.cs
- ServiceDescriptionSerializer.cs
- DataGridViewSortCompareEventArgs.cs
- ZipIOCentralDirectoryFileHeader.cs
- ContainerActivationHelper.cs
- InvokeHandlers.cs
- DocumentPageView.cs
- DataColumnMappingCollection.cs
- StreamedWorkflowDefinitionContext.cs
- TrackingConditionCollection.cs
- IsolatedStorageSecurityState.cs
- assertwrapper.cs
- EntityDataSourceView.cs
- Opcode.cs
- SystemWebSectionGroup.cs
- ServiceReference.cs
- WorkflowServiceBehavior.cs
- HttpClientCertificate.cs
- GridLengthConverter.cs
- ControlBuilderAttribute.cs
- SharedMemory.cs
- ExtensibleClassFactory.cs
- ExpressionBuilder.cs
- DeclarativeCatalogPart.cs
- CompilerScope.Storage.cs
- CancelEventArgs.cs