/// <summary> /// 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. /// </summary> internal static string EditMask(ITypeDiscoveryService discoverySvc, IUIService uiSvc, MaskedTextBox instance, IHelpService helpService) { Debug.Assert(instance != null, "Null masked text box."); string mask = null; // Launching modal dialog in System aware mode. MaskDesignerDialog dlg = DpiHelper.CreateInstanceInSystemAwareContext(() => new MaskDesignerDialog(instance, helpService)); try { dlg.DiscoverMaskDescriptors(discoverySvc); // fine if service is null. // Show dialog from VS. 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); }
internal static string EditMask(ITypeDiscoveryService discoverySvc, IUIService uiSvc, MaskedTextBox instance, IHelpService helpService) { string mask = null; using (MaskDesignerDialog dialog = new MaskDesignerDialog(instance, helpService)) { dialog.DiscoverMaskDescriptors(discoverySvc); DialogResult result = (uiSvc != null) ? uiSvc.ShowDialog(dialog) : dialog.ShowDialog(); if (result == DialogResult.OK) { mask = dialog.Mask; if (dialog.ValidatingType != instance.ValidatingType) { instance.ValidatingType = dialog.ValidatingType; } } } return mask; }
internal static string EditMask(ITypeDiscoveryService discoverySvc, IUIService uiSvc, MaskedTextBox instance, IHelpService helpService) { string mask = null; using (MaskDesignerDialog dialog = new MaskDesignerDialog(instance, helpService)) { dialog.DiscoverMaskDescriptors(discoverySvc); DialogResult result = (uiSvc != null) ? uiSvc.ShowDialog(dialog) : dialog.ShowDialog(); if (result == DialogResult.OK) { mask = dialog.Mask; if (dialog.ValidatingType != instance.ValidatingType) { instance.ValidatingType = dialog.ValidatingType; } } } return(mask); }