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
- MemberMemberBinding.cs
- CacheVirtualItemsEvent.cs
- GenericTextProperties.cs
- HuffModule.cs
- CompilerCollection.cs
- DataGridDesigner.cs
- Vector3D.cs
- HMACRIPEMD160.cs
- ScriptControlManager.cs
- ConditionedDesigner.cs
- FormsAuthenticationCredentials.cs
- PrimaryKeyTypeConverter.cs
- WebPartEditorApplyVerb.cs
- EntityConnectionStringBuilder.cs
- InstanceLockQueryResult.cs
- ToolStripSettings.cs
- XmlSchemaFacet.cs
- TdsParserStateObject.cs
- TextTreeNode.cs
- HandlerBase.cs
- CodeNamespaceImportCollection.cs
- SingleSelectRootGridEntry.cs
- QueryPageSettingsEventArgs.cs
- DuplexClientBase.cs
- LoadedOrUnloadedOperation.cs
- StrokeFIndices.cs
- PropertyValueUIItem.cs
- CssClassPropertyAttribute.cs
- DataGridViewColumnHeaderCell.cs
- CodeSnippetTypeMember.cs
- _LocalDataStore.cs
- Number.cs
- Compiler.cs
- TextParagraph.cs
- ReliableMessagingHelpers.cs
- StorageEndPropertyMapping.cs
- PersonalizationProviderCollection.cs
- PersistenceTypeAttribute.cs
- PolicyLevel.cs
- SafeIUnknown.cs
- FileIOPermission.cs
- ObjectItemLoadingSessionData.cs
- DoubleConverter.cs
- StateRuntime.cs
- TraceLevelStore.cs
- Pipe.cs
- ManualResetEvent.cs
- PhysicalFontFamily.cs
- ScaleTransform.cs
- Bind.cs
- OpenTypeCommon.cs
- PixelShader.cs
- HtmlInputSubmit.cs
- RuntimeArgument.cs
- BindUriHelper.cs
- CodePageUtils.cs
- ExtendedProperty.cs
- MethodExpression.cs
- HScrollBar.cs
- Transaction.cs
- TypefaceMetricsCache.cs
- SqlCacheDependencyDatabase.cs
- LayoutEditorPart.cs
- TextTreeTextElementNode.cs
- TextEffectCollection.cs
- Char.cs
- ToolStrip.cs
- TableRowCollection.cs
- FileVersion.cs
- DoubleKeyFrameCollection.cs
- ListBase.cs
- ConfigsHelper.cs
- DesignerActionKeyboardBehavior.cs
- HeaderUtility.cs
- ProtocolElement.cs
- _SafeNetHandles.cs
- CharacterBufferReference.cs
- SafePipeHandle.cs
- HtmlUtf8RawTextWriter.cs
- BaseCollection.cs
- ToolStripContentPanel.cs
- KeyFrames.cs
- DataKey.cs
- TextTreeTextBlock.cs
- UpDownBaseDesigner.cs
- StringExpressionSet.cs
- UnmanagedMarshal.cs
- DataTableReaderListener.cs
- StreamMarshaler.cs
- MenuScrollingVisibilityConverter.cs
- XmlAggregates.cs
- Oid.cs
- TemplatePropertyEntry.cs
- XmlNamespaceMapping.cs
- Convert.cs
- RolePrincipal.cs
- GcSettings.cs
- LicenseManager.cs
- ChangeTracker.cs
- ProcessingInstructionAction.cs