Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / View / BreadCrumbTextConverter.cs / 1305376 / BreadCrumbTextConverter.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Activities.Presentation.View { using System.Windows.Data; using System.Activities.Presentation.Model; internal class BreadCrumbTextConverter : IMultiValueConverter { const int MaxDisplayNameLength = 20; double pixelsPerChar = 6.5; internal double PixelsPerChar { get { return this.pixelsPerChar; } set { this.pixelsPerChar = Math.Max(5.0, value); } } public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int actualDisplayNameLength = MaxDisplayNameLength; ModelItem boundModelItem = values[0] as ModelItem; // default to root item's typename string breadCrumbText = (null != boundModelItem ? boundModelItem.ItemType.Name : ""); // if there is a display name property on root use that as the file name. if (values[1] is ModelItem) { ModelItem displayNameProperty = (ModelItem)values[1]; if (typeof(string) == displayNameProperty.ItemType) { values[1] = displayNameProperty.GetCurrentValue(); } } if (values[1] is string) { string displayName = (string)values[1]; if (!displayName.Equals(string.Empty)) { breadCrumbText = displayName; } } if (values.Length == 3 && values[2] is double) { double actualControlWidth = (double)values[2]; actualDisplayNameLength = (int)Math.Max(MaxDisplayNameLength, actualControlWidth / pixelsPerChar); } if (breadCrumbText.Length > actualDisplayNameLength) { breadCrumbText = breadCrumbText.Substring(0, actualDisplayNameLength - 3) + "..."; } return breadCrumbText; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw FxTrace.Exception.AsError(new InvalidOperationException()); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Activities.Presentation.View { using System.Windows.Data; using System.Activities.Presentation.Model; internal class BreadCrumbTextConverter : IMultiValueConverter { const int MaxDisplayNameLength = 20; double pixelsPerChar = 6.5; internal double PixelsPerChar { get { return this.pixelsPerChar; } set { this.pixelsPerChar = Math.Max(5.0, value); } } public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int actualDisplayNameLength = MaxDisplayNameLength; ModelItem boundModelItem = values[0] as ModelItem; // default to root item's typename string breadCrumbText = (null != boundModelItem ? boundModelItem.ItemType.Name : " "); // if there is a display name property on root use that as the file name. if (values[1] is ModelItem) { ModelItem displayNameProperty = (ModelItem)values[1]; if (typeof(string) == displayNameProperty.ItemType) { values[1] = displayNameProperty.GetCurrentValue(); } } if (values[1] is string) { string displayName = (string)values[1]; if (!displayName.Equals(string.Empty)) { breadCrumbText = displayName; } } if (values.Length == 3 && values[2] is double) { double actualControlWidth = (double)values[2]; actualDisplayNameLength = (int)Math.Max(MaxDisplayNameLength, actualControlWidth / pixelsPerChar); } if (breadCrumbText.Length > actualDisplayNameLength) { breadCrumbText = breadCrumbText.Substring(0, actualDisplayNameLength - 3) + "..."; } return breadCrumbText; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw FxTrace.Exception.AsError(new InvalidOperationException()); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ExceptionCollection.cs
- IndexerNameAttribute.cs
- OleDbInfoMessageEvent.cs
- AbstractDataSvcMapFileLoader.cs
- WebServiceResponseDesigner.cs
- PhysicalOps.cs
- MulticastDelegate.cs
- ParseChildrenAsPropertiesAttribute.cs
- ControlPropertyNameConverter.cs
- OverflowException.cs
- TextCompositionEventArgs.cs
- BindableTemplateBuilder.cs
- MultiplexingFormatMapping.cs
- HtmlWindow.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- UDPClient.cs
- SqlClientWrapperSmiStreamChars.cs
- SecurityPermission.cs
- DbgUtil.cs
- KerberosSecurityTokenAuthenticator.cs
- StateWorkerRequest.cs
- _BasicClient.cs
- Size.cs
- TextMarkerSource.cs
- CharConverter.cs
- AnonymousIdentificationSection.cs
- IntSumAggregationOperator.cs
- ReadOnlyCollection.cs
- SectionInformation.cs
- InternalControlCollection.cs
- EditorAttribute.cs
- SmtpReplyReader.cs
- ThemeableAttribute.cs
- DBPropSet.cs
- HttpListenerRequest.cs
- SortFieldComparer.cs
- CommandBinding.cs
- HttpInputStream.cs
- ObjectListDesigner.cs
- HttpFileCollectionBase.cs
- DataBindingHandlerAttribute.cs
- DeviceOverridableAttribute.cs
- NetPipeSectionData.cs
- SortQuery.cs
- DataMemberAttribute.cs
- CompoundFileDeflateTransform.cs
- WmpBitmapDecoder.cs
- WebScriptMetadataFormatter.cs
- ExtensionDataReader.cs
- CommandCollectionEditor.cs
- XmlSchemaSimpleContent.cs
- KoreanLunisolarCalendar.cs
- BuildManager.cs
- ExtendedPropertyInfo.cs
- DeclarativeCatalogPart.cs
- ProcessHostMapPath.cs
- Constants.cs
- ObjectQueryProvider.cs
- DataGridItemEventArgs.cs
- Win32.cs
- ListViewItem.cs
- Binding.cs
- ObjectHelper.cs
- NumberSubstitution.cs
- TableProviderWrapper.cs
- ViewValidator.cs
- RegexMatch.cs
- CounterSampleCalculator.cs
- _Semaphore.cs
- TextureBrush.cs
- TCEAdapterGenerator.cs
- ListChangedEventArgs.cs
- SmiGettersStream.cs
- Normalization.cs
- DataStorage.cs
- Form.cs
- SecurityDescriptor.cs
- CodeGenerator.cs
- BaseCollection.cs
- AnnotationResourceCollection.cs
- SoapElementAttribute.cs
- UpdateCompiler.cs
- ReturnEventArgs.cs
- Transform3D.cs
- OutputWindow.cs
- ComplexTypeEmitter.cs
- ChangeConflicts.cs
- PassportIdentity.cs
- StateChangeEvent.cs
- TypeValidationEventArgs.cs
- TextTreeDeleteContentUndoUnit.cs
- EventHandlersStore.cs
- OleDbWrapper.cs
- WorkflowWebService.cs
- InheritanceContextChangedEventManager.cs
- GridViewAutoFormat.cs
- StateInitializationDesigner.cs
- FormsIdentity.cs
- ValueQuery.cs
- _NegoState.cs