Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Input / Command / RoutedUICommand.cs / 1 / RoutedUICommand.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; // for TypeConverter using System.Windows; using System.Windows.Markup; using System.Windows.Media; namespace System.Windows.Input { ////// RoutedCommand with added UI Information. /// [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + Microsoft.Internal.BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + Microsoft.Internal.BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] public class RoutedUICommand : RoutedCommand { ////// Default Constructor - needed to allow markup creation /// public RoutedUICommand() : base() { _text = String.Empty; } ////// Creates an instance of this class. /// /// Descriptive and localizable text for the command /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property public RoutedUICommand(string text, string name, Type ownerType) : this(text, name, ownerType, null) { } ////// Creates an instance of this class. /// /// Descriptive and localizable text for the command /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property /// Default Input Gestures associated public RoutedUICommand(string text, string name, Type ownerType, InputGestureCollection inputGestures) : base(name, ownerType, inputGestures) { if (text == null) { throw new ArgumentNullException("text"); } _text = text; } ////// Creates an instance of this class. Allows lazy initialization of InputGestureCollection and Text properties. /// /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property /// An identifier assigned by the owning type to the command internal RoutedUICommand(string name, Type ownerType, byte commandId):base(name, ownerType, commandId) { } ////// Descriptive and localizable text for the command. /// public string Text { get { if(_text == null) { _text = GetText(); } return _text; } set { if (value == null) { throw new ArgumentNullException("value"); } _text = value; } } ////// Fetches the text by invoking the GetUIText function on the owning type. /// ///The text for the command private string GetText() { if(OwnerType == typeof(ApplicationCommands)) { return ApplicationCommands.GetUIText(CommandId); } else if(OwnerType == typeof(NavigationCommands)) { return NavigationCommands.GetUIText(CommandId); } else if(OwnerType == typeof(MediaCommands)) { return MediaCommands.GetUIText(CommandId); } else if(OwnerType == typeof(ComponentCommands)) { return ComponentCommands.GetUIText(CommandId); } return null; } private string _text; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; // for TypeConverter using System.Windows; using System.Windows.Markup; using System.Windows.Media; namespace System.Windows.Input { ////// RoutedCommand with added UI Information. /// [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + Microsoft.Internal.BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + Microsoft.Internal.BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] public class RoutedUICommand : RoutedCommand { ////// Default Constructor - needed to allow markup creation /// public RoutedUICommand() : base() { _text = String.Empty; } ////// Creates an instance of this class. /// /// Descriptive and localizable text for the command /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property public RoutedUICommand(string text, string name, Type ownerType) : this(text, name, ownerType, null) { } ////// Creates an instance of this class. /// /// Descriptive and localizable text for the command /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property /// Default Input Gestures associated public RoutedUICommand(string text, string name, Type ownerType, InputGestureCollection inputGestures) : base(name, ownerType, inputGestures) { if (text == null) { throw new ArgumentNullException("text"); } _text = text; } ////// Creates an instance of this class. Allows lazy initialization of InputGestureCollection and Text properties. /// /// Declared Name of the RoutedCommand for Serialization /// Type that is registering the property /// An identifier assigned by the owning type to the command internal RoutedUICommand(string name, Type ownerType, byte commandId):base(name, ownerType, commandId) { } ////// Descriptive and localizable text for the command. /// public string Text { get { if(_text == null) { _text = GetText(); } return _text; } set { if (value == null) { throw new ArgumentNullException("value"); } _text = value; } } ////// Fetches the text by invoking the GetUIText function on the owning type. /// ///The text for the command private string GetText() { if(OwnerType == typeof(ApplicationCommands)) { return ApplicationCommands.GetUIText(CommandId); } else if(OwnerType == typeof(NavigationCommands)) { return NavigationCommands.GetUIText(CommandId); } else if(OwnerType == typeof(MediaCommands)) { return MediaCommands.GetUIText(CommandId); } else if(OwnerType == typeof(ComponentCommands)) { return ComponentCommands.GetUIText(CommandId); } return null; } private string _text; } } // 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
- DynamicValidator.cs
- XomlCompilerResults.cs
- TrustManager.cs
- ColorContext.cs
- MediaPlayerState.cs
- CheckBox.cs
- RandomDelayQueuedSendsAsyncResult.cs
- ReadOnlyCollectionBase.cs
- RotationValidation.cs
- XmlElementAttribute.cs
- CodeIdentifiers.cs
- SwitchLevelAttribute.cs
- RowToParametersTransformer.cs
- ReverseInheritProperty.cs
- CompiledELinqQueryState.cs
- StreamInfo.cs
- MultilineStringConverter.cs
- SqlDataSourceCommandParser.cs
- SerTrace.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- CannotUnloadAppDomainException.cs
- TemplateKeyConverter.cs
- MDIWindowDialog.cs
- _ChunkParse.cs
- IfJoinedCondition.cs
- PerformanceCounterLib.cs
- XPathNavigatorReader.cs
- KeyEventArgs.cs
- StrokeCollection2.cs
- BulletDecorator.cs
- RegexMatchCollection.cs
- EntityCommandExecutionException.cs
- ReadOnlyState.cs
- DataServiceRequest.cs
- ParallelTimeline.cs
- AtomServiceDocumentSerializer.cs
- TextShapeableCharacters.cs
- SvcMapFileSerializer.cs
- StylusLogic.cs
- CodeDOMUtility.cs
- ProjectionCamera.cs
- DataKey.cs
- GeneralTransform3DTo2DTo3D.cs
- ObjectListSelectEventArgs.cs
- SimpleColumnProvider.cs
- StringReader.cs
- ApplicationFileParser.cs
- LicenseManager.cs
- DataSysAttribute.cs
- SourceItem.cs
- KeyGestureValueSerializer.cs
- SchemaElementDecl.cs
- IndexerNameAttribute.cs
- TemplateControlCodeDomTreeGenerator.cs
- CompilerTypeWithParams.cs
- AutoResetEvent.cs
- CheckBox.cs
- ThemeableAttribute.cs
- ErrorFormatterPage.cs
- ImageConverter.cs
- SqlNodeTypeOperators.cs
- WindowsListViewGroup.cs
- DictionaryTraceRecord.cs
- XmlElementAttribute.cs
- EntityDataSourceWrapper.cs
- DbQueryCommandTree.cs
- BaseCodeDomTreeGenerator.cs
- IsolatedStorageFileStream.cs
- PropertyTabAttribute.cs
- TraceRecords.cs
- ServicePoint.cs
- ListControl.cs
- ThreadStaticAttribute.cs
- GroupByQueryOperator.cs
- DataViewSettingCollection.cs
- URLAttribute.cs
- TerminatorSinks.cs
- MemberHolder.cs
- StatusBar.cs
- CanonicalXml.cs
- XmlTextReader.cs
- DesignerTextViewAdapter.cs
- AudioStateChangedEventArgs.cs
- IncrementalReadDecoders.cs
- XmlBoundElement.cs
- ConcurrentQueue.cs
- CustomAttributeBuilder.cs
- ActivityCodeDomReferenceService.cs
- RepeatButtonAutomationPeer.cs
- AuthenticationModulesSection.cs
- DataTablePropertyDescriptor.cs
- HtmlTextArea.cs
- LineVisual.cs
- UniqueIdentifierService.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- FileSystemWatcher.cs
- DBConcurrencyException.cs
- Transform.cs
- SecureUICommand.cs
- HtmlMeta.cs