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
- XPathBuilder.cs
- BindingValueChangedEventArgs.cs
- TextCollapsingProperties.cs
- XPathParser.cs
- ConnectivityStatus.cs
- RichTextBoxConstants.cs
- Semaphore.cs
- DataErrorValidationRule.cs
- PersistenceTypeAttribute.cs
- GPStream.cs
- UriScheme.cs
- Padding.cs
- LayoutUtils.cs
- SqlTypeConverter.cs
- ViewGenResults.cs
- ApplicationManager.cs
- Application.cs
- ExpressionEditorAttribute.cs
- DataBindEngine.cs
- EntityDescriptor.cs
- DelayedRegex.cs
- CompoundFileStorageReference.cs
- SecondaryViewProvider.cs
- SecurityPermission.cs
- SecurityBindingElement.cs
- serverconfig.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- DocobjHost.cs
- ContentPropertyAttribute.cs
- ResourceReader.cs
- TextSchema.cs
- SeverityFilter.cs
- DetailsViewRowCollection.cs
- FrameworkPropertyMetadata.cs
- CachedPathData.cs
- UIHelper.cs
- JpegBitmapDecoder.cs
- FilteredXmlReader.cs
- PrimaryKeyTypeConverter.cs
- NativeMethodsCLR.cs
- SafeNativeMethods.cs
- HiddenField.cs
- HttpCacheVaryByContentEncodings.cs
- COM2IProvidePropertyBuilderHandler.cs
- CompilerGeneratedAttribute.cs
- EdmTypeAttribute.cs
- WebPartConnection.cs
- StringHandle.cs
- HttpRuntime.cs
- EntityDataSourceSelectedEventArgs.cs
- DataGridItem.cs
- dbdatarecord.cs
- InternalsVisibleToAttribute.cs
- InvokeMethod.cs
- StructuredType.cs
- CounterSampleCalculator.cs
- Form.cs
- UserControlDesigner.cs
- CheckBoxBaseAdapter.cs
- ProfileSettings.cs
- BevelBitmapEffect.cs
- AttributeData.cs
- Point3DCollection.cs
- PointIndependentAnimationStorage.cs
- AsyncInvokeContext.cs
- MsmqVerifier.cs
- MappingSource.cs
- VirtualizedItemPattern.cs
- ExpressionBindingCollection.cs
- LicenseException.cs
- FormClosingEvent.cs
- WebPartConnectionsConfigureVerb.cs
- SliderAutomationPeer.cs
- ThousandthOfEmRealPoints.cs
- Drawing.cs
- RegexStringValidatorAttribute.cs
- DelegatingChannelListener.cs
- exports.cs
- SecurityTokenException.cs
- Canvas.cs
- EventlogProvider.cs
- ToolStripPanelDesigner.cs
- OdbcReferenceCollection.cs
- FormDocumentDesigner.cs
- ListViewCancelEventArgs.cs
- RegexGroup.cs
- XmlWriter.cs
- Int32Collection.cs
- GeneralTransform3DTo2DTo3D.cs
- StrongName.cs
- BooleanToVisibilityConverter.cs
- DebugView.cs
- DbConnectionInternal.cs
- ToolStripGrip.cs
- MsmqIntegrationSecurity.cs
- RIPEMD160Managed.cs
- DataView.cs
- XmlRawWriter.cs
- TextParaClient.cs
- XamlStream.cs