Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Rules / Design / Dialogs / RenameRuleObjectDialog.cs / 1305376 / RenameRuleObjectDialog.cs
#region Using directives using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Text; using System.Windows.Forms; using System.Windows.Forms.Design; #endregion namespace System.Workflow.Activities.Rules.Design { internal partial class RenameRuleObjectDialog : Form { public delegate bool NameValidatorDelegate(string name); private string name; private IServiceProvider serviceProvider; private NameValidatorDelegate nameValidator; private BasicBrowserDialog parent; public RenameRuleObjectDialog(IServiceProvider serviceProvider, string oldName, NameValidatorDelegate nameValidator, BasicBrowserDialog parent) { if (oldName == null) throw (new ArgumentNullException("oldName")); if (serviceProvider == null) throw (new ArgumentNullException("serviceProvider")); if (nameValidator == null) throw (new ArgumentNullException("nameValidator")); this.serviceProvider = serviceProvider; this.name = oldName; this.nameValidator = nameValidator; this.parent = parent; InitializeComponent(); this.ruleNameTextBox.Text = oldName; this.Text = parent.RenameTitleText; this.newNamelabel.Text = parent.NewNameLabelText; this.Icon = null; //Set dialog fonts IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) this.Font = (Font)uisvc.Styles["DialogFont"]; } public string RuleObjectName { get { return this.name; } } private void OnCancel(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void OnOk(object sender, EventArgs e) { string newName = this.ruleNameTextBox.Text; if (newName.Trim().Length == 0) { string errorMessage = parent.EmptyNameErrorText; IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) uisvc.ShowError(errorMessage); else MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender)); this.DialogResult = DialogResult.None; } else if (this.name != newName && !nameValidator(newName)) { string errorMessage = parent.DuplicateNameErrorText; IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) uisvc.ShowError(errorMessage); else MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender)); this.DialogResult = DialogResult.None; } else { this.name = newName; this.DialogResult = DialogResult.OK; this.Close(); } } private static MessageBoxOptions DetermineOptions(object sender) { MessageBoxOptions options = (MessageBoxOptions)0; Control someControl = sender as Control; RightToLeft rightToLeftValue = RightToLeft.Inherit; while ((rightToLeftValue == RightToLeft.Inherit) && (someControl != null)) { rightToLeftValue = someControl.RightToLeft; someControl = someControl.Parent; } if (rightToLeftValue == RightToLeft.Yes) { options = MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign; } return options; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #region Using directives using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Text; using System.Windows.Forms; using System.Windows.Forms.Design; #endregion namespace System.Workflow.Activities.Rules.Design { internal partial class RenameRuleObjectDialog : Form { public delegate bool NameValidatorDelegate(string name); private string name; private IServiceProvider serviceProvider; private NameValidatorDelegate nameValidator; private BasicBrowserDialog parent; public RenameRuleObjectDialog(IServiceProvider serviceProvider, string oldName, NameValidatorDelegate nameValidator, BasicBrowserDialog parent) { if (oldName == null) throw (new ArgumentNullException("oldName")); if (serviceProvider == null) throw (new ArgumentNullException("serviceProvider")); if (nameValidator == null) throw (new ArgumentNullException("nameValidator")); this.serviceProvider = serviceProvider; this.name = oldName; this.nameValidator = nameValidator; this.parent = parent; InitializeComponent(); this.ruleNameTextBox.Text = oldName; this.Text = parent.RenameTitleText; this.newNamelabel.Text = parent.NewNameLabelText; this.Icon = null; //Set dialog fonts IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) this.Font = (Font)uisvc.Styles["DialogFont"]; } public string RuleObjectName { get { return this.name; } } private void OnCancel(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void OnOk(object sender, EventArgs e) { string newName = this.ruleNameTextBox.Text; if (newName.Trim().Length == 0) { string errorMessage = parent.EmptyNameErrorText; IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) uisvc.ShowError(errorMessage); else MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender)); this.DialogResult = DialogResult.None; } else if (this.name != newName && !nameValidator(newName)) { string errorMessage = parent.DuplicateNameErrorText; IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService)); if (uisvc != null) uisvc.ShowError(errorMessage); else MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender)); this.DialogResult = DialogResult.None; } else { this.name = newName; this.DialogResult = DialogResult.OK; this.Close(); } } private static MessageBoxOptions DetermineOptions(object sender) { MessageBoxOptions options = (MessageBoxOptions)0; Control someControl = sender as Control; RightToLeft rightToLeftValue = RightToLeft.Inherit; while ((rightToLeftValue == RightToLeft.Inherit) && (someControl != null)) { rightToLeftValue = someControl.RightToLeft; someControl = someControl.Parent; } if (rightToLeftValue == RightToLeft.Yes) { options = MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign; } return options; } } } // 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
- WmlLiteralTextAdapter.cs
- DataGridRelationshipRow.cs
- WindowsToolbarAsMenu.cs
- WebBrowserEvent.cs
- IsolatedStorageFilePermission.cs
- WmlLinkAdapter.cs
- KeyedHashAlgorithm.cs
- DomainUpDown.cs
- WSDualHttpBindingCollectionElement.cs
- PagesChangedEventArgs.cs
- Blend.cs
- SelectionItemPattern.cs
- BuiltInExpr.cs
- OdbcTransaction.cs
- SectionXmlInfo.cs
- AnnotationService.cs
- XmlSchemaValidationException.cs
- NavigatorInput.cs
- ReadOnlyPropertyMetadata.cs
- EmbeddedMailObjectCollectionEditor.cs
- SafeSecurityHelper.cs
- PermissionSetTriple.cs
- ToolStripHighContrastRenderer.cs
- ApplicationManager.cs
- HighlightComponent.cs
- SourceFilter.cs
- ChtmlCalendarAdapter.cs
- CompressEmulationStream.cs
- UnionExpr.cs
- TextParagraphCache.cs
- DataBoundControlHelper.cs
- Relationship.cs
- SqlUdtInfo.cs
- EncoderFallback.cs
- DocumentViewerConstants.cs
- ConfigurationSectionGroup.cs
- DefaultAsyncDataDispatcher.cs
- HtmlAnchor.cs
- BasePattern.cs
- DependencyObjectProvider.cs
- RegistryKey.cs
- CompilerGlobalScopeAttribute.cs
- ComponentResourceKey.cs
- WebHttpBinding.cs
- ItemsPresenter.cs
- FormCollection.cs
- DictionaryEntry.cs
- EmbeddedObject.cs
- PropertyGridView.cs
- WebPartDisplayModeCancelEventArgs.cs
- SHA1.cs
- WindowsEditBoxRange.cs
- UniqueConstraint.cs
- FileNameEditor.cs
- DecoratedNameAttribute.cs
- XmlObjectSerializerContext.cs
- DetailsViewPageEventArgs.cs
- XmlWellformedWriter.cs
- Peer.cs
- OpenFileDialog.cs
- BaseDataList.cs
- InvokeWebService.cs
- Window.cs
- HttpWebRequestElement.cs
- DBParameter.cs
- MatrixCamera.cs
- ItemCheckedEvent.cs
- ContextMarshalException.cs
- BooleanAnimationUsingKeyFrames.cs
- XmlAttributeProperties.cs
- EncryptedKeyIdentifierClause.cs
- FormClosingEvent.cs
- PointAnimationUsingPath.cs
- DesignerValidatorAdapter.cs
- Models.cs
- Crc32.cs
- XXXInfos.cs
- ActivityExecutorSurrogate.cs
- WebSysDescriptionAttribute.cs
- WorkflowDefinitionDispenser.cs
- PagePropertiesChangingEventArgs.cs
- SelectionRange.cs
- ViewPort3D.cs
- ThemeDirectoryCompiler.cs
- DataGridViewCellCancelEventArgs.cs
- IPEndPointCollection.cs
- ObjectDataSourceDisposingEventArgs.cs
- COM2PictureConverter.cs
- EventDescriptorCollection.cs
- EFTableProvider.cs
- RowBinding.cs
- ProtectedConfiguration.cs
- InvalidComObjectException.cs
- SystemIPv4InterfaceProperties.cs
- DesignerTransaction.cs
- DataServiceRequestException.cs
- MethodAccessException.cs
- DateTimeFormat.cs
- WindowsFormsHostAutomationPeer.cs
- UnlockCardRequest.cs