Code:
                         / FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / MaskPropertyEditor.cs / 1 / MaskPropertyEditor.cs
                        
                        
                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//  
//----------------------------------------------------------------------------- 
namespace System.Windows.Forms.Design 
{ 
    using System;
    using System.Design; 
    using System.Drawing.Design;
    using System.Collections;
    using System.ComponentModel;
    using System.ComponentModel.Design; 
    using System.Windows.Forms;
    using System.Diagnostics; 
 
    /// 
    ///     Design time editing class for the Mask property of the MaskedTextBox control. 
    ///  
    internal class MaskPropertyEditor : UITypeEditor
    {
        ///  
        ///     Constructor.
        ///   
        public MaskPropertyEditor() 
        {
        } 
        /// 
        ///     Gets the mask property value fromt the MaskDesignerDialog.
        ///     The IUIService is used to show the mask designer dialog within VS so it doesn't get blocked if focus 
        ///     is moved to anoter app.
        ///   
        internal static string EditMask(ITypeDiscoveryService discoverySvc, IUIService uiSvc, MaskedTextBox instance, IHelpService helpService) { 
            Debug.Assert( instance != null, "Null masked text box." );
 
            string mask = null;
            MaskDesignerDialog dlg = new MaskDesignerDialog(instance, helpService);
            try 
            {
                dlg.DiscoverMaskDescriptors( discoverySvc );  // fine if service is null. 
 
                // Show dialog from VS.
                // Debug.Assert( uiSvc != null, "Expected IUIService, defaulting to an intrusive way to show the dialog..." ); 
                DialogResult dlgResult = uiSvc != null ? uiSvc.ShowDialog( dlg ) : dlg.ShowDialog();
                if ( dlgResult == DialogResult.OK) 
                {
                    mask = dlg.Mask; 
 
                    // ValidatingType is not browsable so we don't need to set the property through the designer.
                    if (dlg.ValidatingType != instance.ValidatingType) 
                    {
                        instance.ValidatingType = dlg.ValidatingType;
                    }
                } 
            }
            finally 
            { 
                dlg.Dispose();
            } 
            // Will return null if dlgResult != OK.
            return mask;
        } 
        ///  
        ///     Edits the Mask property of the MaskedTextBox control from the PropertyGrid. 
        ///  
 
        // This should be okay since System.Design only runs in FullTrust.
        // SECREVIEW: Isn't that true
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) 
        {
            if (context != null && provider != null) 
            { 
                ITypeDiscoveryService discoverySvc = (ITypeDiscoveryService) provider.GetService(typeof(ITypeDiscoveryService));  // fine if service is not found.
                IUIService uiSvc = (IUIService) provider.GetService(typeof(IUIService)); 
                IHelpService helpService = (IHelpService)provider.GetService(typeof(IHelpService));
                string mask = MaskPropertyEditor.EditMask(discoverySvc, uiSvc, context.Instance as MaskedTextBox, helpService);
                if( mask != null ) 
                {
                    return mask; 
                } 
            }
 
            return value;
        }
        ///  
        ///     Painting a representation of the Mask value is not supported.
        ///   
 
        // This should be okay since System.Design only runs in FullTrust.
        // SECREVIEW: Isn't that true 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
        {
            return false; 
        }
 
        ///  
        ///     Gets the edit style of the type editor.
        ///   
        // This should be okay since System.Design only runs in FullTrust.
        // SECREVIEW: Isn't that true
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        { 
            return UITypeEditorEditStyle.Modal; 
        }
 
    }
}
// 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
- PerfCounterSection.cs
- Point.cs
- RegistryKey.cs
- DebugController.cs
- State.cs
- NameScope.cs
- RC2CryptoServiceProvider.cs
- ScrollChangedEventArgs.cs
- webeventbuffer.cs
- RtfControls.cs
- CharacterMetrics.cs
- AsyncCompletedEventArgs.cs
- DispatchWrapper.cs
- JsonGlobals.cs
- MapPathBasedVirtualPathProvider.cs
- UInt16Storage.cs
- CustomPeerResolverService.cs
- IHttpResponseInternal.cs
- DatePicker.cs
- SQLGuidStorage.cs
- MailMessageEventArgs.cs
- DescendantQuery.cs
- Padding.cs
- PlacementWorkspace.cs
- DoubleLink.cs
- DataBinder.cs
- CalendarDateRangeChangingEventArgs.cs
- SqlCaseSimplifier.cs
- TransformConverter.cs
- DataListAutoFormat.cs
- KeyedHashAlgorithm.cs
- StatementContext.cs
- CryptoKeySecurity.cs
- UnsafeNativeMethodsTablet.cs
- TrackingRecord.cs
- QilFactory.cs
- RoutedEventConverter.cs
- VisualProxy.cs
- RowToParametersTransformer.cs
- DataControlCommands.cs
- ModelTreeEnumerator.cs
- COM2FontConverter.cs
- WindowsPen.cs
- EventlogProvider.cs
- DrawListViewItemEventArgs.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- XmlSchemaComplexContent.cs
- PeerNameResolver.cs
- TextFormatter.cs
- TextOnlyOutput.cs
- EntityDataSourceEntityTypeFilterItem.cs
- AuthenticationService.cs
- XPathNavigator.cs
- cookie.cs
- GradientSpreadMethodValidation.cs
- ComponentResourceKeyConverter.cs
- __TransparentProxy.cs
- SQLByteStorage.cs
- SmiContextFactory.cs
- UrlMappingsModule.cs
- CounterCreationDataConverter.cs
- XmlEventCache.cs
- StylusPointPropertyId.cs
- SafeLocalMemHandle.cs
- COM2ColorConverter.cs
- SynchronizationLockException.cs
- ButtonColumn.cs
- ConstraintEnumerator.cs
- Int32AnimationUsingKeyFrames.cs
- TabPage.cs
- TypedOperationInfo.cs
- TextDecorationCollectionConverter.cs
- TemplatePagerField.cs
- AttributeCallbackBuilder.cs
- DeviceSpecificDesigner.cs
- ErrorTableItemStyle.cs
- MergablePropertyAttribute.cs
- HttpCookiesSection.cs
- StatusBar.cs
- SqlDataSourceCache.cs
- LineGeometry.cs
- dataprotectionpermission.cs
- validationstate.cs
- SpellerInterop.cs
- XmlEncodedRawTextWriter.cs
- selecteditemcollection.cs
- TreeView.cs
- WebPart.cs
- RegularExpressionValidator.cs
- wpf-etw.cs
- TextEditorParagraphs.cs
- FloaterParagraph.cs
- ReaderWriterLockSlim.cs
- DateRangeEvent.cs
- TextViewSelectionProcessor.cs
- PagesSection.cs
- XmlSchemaAny.cs
- ArraySortHelper.cs
- ComContractElementCollection.cs
- Knowncolors.cs