Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ButtonBaseAdapter.cs
- ConfigurationSectionGroupCollection.cs
- PrivilegedConfigurationManager.cs
- ButtonStandardAdapter.cs
- Selection.cs
- CopyCodeAction.cs
- EnumConverter.cs
- GroupLabel.cs
- XPathNodeInfoAtom.cs
- DataSourceDescriptorCollection.cs
- StyleSelector.cs
- ItemsControl.cs
- BufferedGraphics.cs
- TextBlockAutomationPeer.cs
- CellQuery.cs
- SatelliteContractVersionAttribute.cs
- TagMapCollection.cs
- NamespaceMapping.cs
- DataErrorValidationRule.cs
- ReaderOutput.cs
- KeyedQueue.cs
- UnsafeNativeMethods.cs
- MemoryRecordBuffer.cs
- StringBuilder.cs
- CryptoHandle.cs
- SubstitutionResponseElement.cs
- TypeConverterHelper.cs
- PackagePartCollection.cs
- followingsibling.cs
- activationcontext.cs
- CurrentTimeZone.cs
- ByteKeyFrameCollection.cs
- BindingOperations.cs
- SiteMapProvider.cs
- ButtonRenderer.cs
- SineEase.cs
- AsyncOperationManager.cs
- Section.cs
- SecureStringHasher.cs
- CodeCommentStatementCollection.cs
- ConfigXmlWhitespace.cs
- NameNode.cs
- ZipIOLocalFileBlock.cs
- SingleConverter.cs
- DbCommandTree.cs
- SqlCacheDependency.cs
- FloatSumAggregationOperator.cs
- ToolStripTextBox.cs
- CustomAttributeBuilder.cs
- DataGridRowHeaderAutomationPeer.cs
- AttributeQuery.cs
- CommentAction.cs
- UITypeEditor.cs
- ServiceModelEnumValidatorAttribute.cs
- Transform.cs
- SelfIssuedSamlTokenFactory.cs
- RtfToXamlReader.cs
- PropertyFilterAttribute.cs
- IPPacketInformation.cs
- UrlMappingsSection.cs
- InvokeMethod.cs
- FontCollection.cs
- WindowVisualStateTracker.cs
- BaseHashHelper.cs
- CellCreator.cs
- PeerTransportElement.cs
- BoundPropertyEntry.cs
- RuntimeHandles.cs
- UndoManager.cs
- CompilationUnit.cs
- HttpException.cs
- Hash.cs
- FontEditor.cs
- WindowsAuthenticationModule.cs
- ListViewInsertEventArgs.cs
- SystemThemeKey.cs
- SchemaImporterExtension.cs
- AlphaSortedEnumConverter.cs
- Speller.cs
- RegistrySecurity.cs
- PolicyException.cs
- Form.cs
- ErrorHandler.cs
- FixedSOMContainer.cs
- TimeSpanStorage.cs
- DataGridColumnHeadersPresenterAutomationPeer.cs
- DataViewSettingCollection.cs
- DecimalAnimationBase.cs
- DescendantOverDescendantQuery.cs
- RegexCompiler.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- StringDictionaryEditor.cs
- OracleBinary.cs
- MultiPageTextView.cs
- ApplicationException.cs
- FormatVersion.cs
- UnregisterInfo.cs
- DirectionalLight.cs
- PropertySet.cs
- ToolboxBitmapAttribute.cs