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
- LineProperties.cs
- DataGridRowHeaderAutomationPeer.cs
- ProcessingInstructionAction.cs
- Connector.cs
- hresults.cs
- TypeLoadException.cs
- baseshape.cs
- CornerRadius.cs
- DictionaryTraceRecord.cs
- InternalBufferManager.cs
- httpapplicationstate.cs
- MarkupCompilePass2.cs
- NativeMethods.cs
- SwitchDesigner.xaml.cs
- ToReply.cs
- httpstaticobjectscollection.cs
- PropertyDescriptorComparer.cs
- XmlAttributeProperties.cs
- CatalogZoneBase.cs
- SqlDataReader.cs
- Messages.cs
- NonVisualControlAttribute.cs
- DirectoryNotFoundException.cs
- CacheAxisQuery.cs
- StrokeNodeData.cs
- OracleConnectionFactory.cs
- ContainerUIElement3D.cs
- DecimalStorage.cs
- SiteOfOriginPart.cs
- ReachSerializerAsync.cs
- WebPartVerbCollection.cs
- NestPullup.cs
- PropertyEmitter.cs
- _SSPIWrapper.cs
- xml.cs
- TextRangeEditTables.cs
- ClassHandlersStore.cs
- keycontainerpermission.cs
- FileEnumerator.cs
- PriorityRange.cs
- Timer.cs
- ForwardPositionQuery.cs
- ClockGroup.cs
- UnmanagedMarshal.cs
- MenuScrollingVisibilityConverter.cs
- WebSysDefaultValueAttribute.cs
- DBPropSet.cs
- TraceListeners.cs
- CodeAccessPermission.cs
- ToolboxComponentsCreatingEventArgs.cs
- WorkflowTraceTransfer.cs
- ArraySegment.cs
- HMACSHA256.cs
- SystemColors.cs
- ExceptionHandlers.cs
- EntityStoreSchemaGenerator.cs
- Stylesheet.cs
- HScrollProperties.cs
- HtmlGenericControl.cs
- ComponentSerializationService.cs
- OdbcDataReader.cs
- StorageEntityTypeMapping.cs
- SqlBulkCopyColumnMappingCollection.cs
- BitmapEffectGeneralTransform.cs
- ResolveCompletedEventArgs.cs
- MissingMemberException.cs
- UInt64.cs
- _HeaderInfo.cs
- ISFTagAndGuidCache.cs
- LocalFileSettingsProvider.cs
- VisualBrush.cs
- TableRow.cs
- SessionIDManager.cs
- BitmapEffectInputData.cs
- ObjectConverter.cs
- WorkflowOwnershipException.cs
- CustomAttributeSerializer.cs
- ErrorStyle.cs
- XmlSchemaAny.cs
- ConfigUtil.cs
- TextElement.cs
- UnaryNode.cs
- DurableInstanceProvider.cs
- VisualState.cs
- ProcessHostServerConfig.cs
- DependencyPropertyKind.cs
- HtmlControl.cs
- BasicKeyConstraint.cs
- ColumnPropertiesGroup.cs
- ContourSegment.cs
- ProviderIncompatibleException.cs
- SponsorHelper.cs
- SystemWebExtensionsSectionGroup.cs
- NGCSerializer.cs
- SocketStream.cs
- OleDbMetaDataFactory.cs
- JsonFormatMapping.cs
- EventItfInfo.cs
- DropSource.cs
- StatusBar.cs