Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DtcInterfaces.cs
- UserValidatedEventArgs.cs
- RoleBoolean.cs
- ObjectStateManager.cs
- ArgumentNullException.cs
- ListItemParagraph.cs
- NativeMethods.cs
- SimpleFileLog.cs
- ConfigurationValidatorAttribute.cs
- DbConnectionPoolIdentity.cs
- WebResourceAttribute.cs
- EntitySetBase.cs
- TimelineClockCollection.cs
- CatalogPartChrome.cs
- EnumBuilder.cs
- AnnotationHighlightLayer.cs
- EmulateRecognizeCompletedEventArgs.cs
- ValidatorCompatibilityHelper.cs
- Currency.cs
- SHA256Managed.cs
- RawStylusInputReport.cs
- AliasGenerator.cs
- DesignerActionVerbItem.cs
- ListenerServiceInstallComponent.cs
- EdmConstants.cs
- DesignDataSource.cs
- PersonalizationProvider.cs
- ImageConverter.cs
- ConfigsHelper.cs
- Table.cs
- DeclarativeCatalogPart.cs
- DirectionalLight.cs
- SystemIcmpV4Statistics.cs
- ByteStreamMessageEncodingElement.cs
- XmlValidatingReader.cs
- COM2EnumConverter.cs
- base64Transforms.cs
- DockingAttribute.cs
- GenericPrincipal.cs
- ResourceProperty.cs
- XmlNodeChangedEventArgs.cs
- SchemaImporter.cs
- XmlDomTextWriter.cs
- ResourcesChangeInfo.cs
- OleStrCAMarshaler.cs
- DmlSqlGenerator.cs
- SoapObjectWriter.cs
- CornerRadius.cs
- ConnectionPointGlyph.cs
- OdbcConnection.cs
- XmlDataProvider.cs
- QuaternionKeyFrameCollection.cs
- CompModSwitches.cs
- PathGradientBrush.cs
- ScrollItemProviderWrapper.cs
- COM2TypeInfoProcessor.cs
- Message.cs
- Formatter.cs
- XamlClipboardData.cs
- ProtocolsConfiguration.cs
- VisualTreeHelper.cs
- NumericUpDownAcceleration.cs
- MimeObjectFactory.cs
- ServiceOperationListItemList.cs
- Propagator.ExtentPlaceholderCreator.cs
- ExceptionValidationRule.cs
- CommonProperties.cs
- TagPrefixInfo.cs
- StateMachine.cs
- TimeoutException.cs
- RemotingAttributes.cs
- SQLMembershipProvider.cs
- Registry.cs
- RectKeyFrameCollection.cs
- ActivityCompletionCallbackWrapper.cs
- HandlerBase.cs
- RectangleF.cs
- ConfigurationStrings.cs
- TextHidden.cs
- HttpModuleCollection.cs
- FontStyleConverter.cs
- DBCommandBuilder.cs
- TextFormatterImp.cs
- SingleKeyFrameCollection.cs
- XmlnsCache.cs
- TextServicesDisplayAttributePropertyRanges.cs
- BulletedListEventArgs.cs
- DataGridParentRows.cs
- DriveInfo.cs
- VisualStyleTypesAndProperties.cs
- WebPartZone.cs
- JsonQueryStringConverter.cs
- CheckedListBox.cs
- PtsHost.cs
- FixedPage.cs
- Image.cs
- FixedSOMPageElement.cs
- TreeViewImageKeyConverter.cs
- GridViewDeleteEventArgs.cs
- ComponentRenameEvent.cs