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
- CDSsyncETWBCLProvider.cs
- AuthorizationSection.cs
- QuerySubExprEliminator.cs
- PeerContact.cs
- BuildDependencySet.cs
- Identifier.cs
- ProfileInfo.cs
- MethodAccessException.cs
- Int32RectConverter.cs
- CompModSwitches.cs
- ProtocolViolationException.cs
- Soap.cs
- EventLog.cs
- PtsPage.cs
- PointLight.cs
- MatrixAnimationUsingKeyFrames.cs
- Fx.cs
- SafeHandles.cs
- ExpressionEditorAttribute.cs
- NameScope.cs
- _HTTPDateParse.cs
- PrimaryKeyTypeConverter.cs
- RowCache.cs
- BlurEffect.cs
- DeviceSpecificChoiceCollection.cs
- OleDbRowUpdatingEvent.cs
- LinkUtilities.cs
- AdapterUtil.cs
- WorkflowDurableInstance.cs
- ConfigXmlCDataSection.cs
- AnyAllSearchOperator.cs
- IdentityModelDictionary.cs
- ObjectSet.cs
- ColorDialog.cs
- WhileDesigner.cs
- GenericIdentity.cs
- TimeoutTimer.cs
- OLEDB_Util.cs
- TokenBasedSet.cs
- DeferredTextReference.cs
- BitmapEffectDrawingContextWalker.cs
- StylusPointPropertyUnit.cs
- LoginView.cs
- DrawingGroupDrawingContext.cs
- lengthconverter.cs
- IpcManager.cs
- ListParagraph.cs
- EmbeddedMailObjectsCollection.cs
- ContextMenuService.cs
- InheritanceAttribute.cs
- DbConvert.cs
- FlowDocumentScrollViewer.cs
- ReferentialConstraint.cs
- XmlSchemaSimpleContentExtension.cs
- SHA512Managed.cs
- MonthChangedEventArgs.cs
- QilScopedVisitor.cs
- HttpPostClientProtocol.cs
- BinaryMessageEncodingBindingElement.cs
- ACL.cs
- XamlSerializerUtil.cs
- ColumnResult.cs
- SqlAliaser.cs
- CopyAction.cs
- AmbiguousMatchException.cs
- ImageCodecInfo.cs
- WebHttpDispatchOperationSelectorData.cs
- ExecutedRoutedEventArgs.cs
- StringReader.cs
- DBConnection.cs
- RectAnimationBase.cs
- ConfigXmlElement.cs
- ProcessThreadCollection.cs
- SettingsProviderCollection.cs
- StructuredProperty.cs
- ManifestSignatureInformation.cs
- InternalException.cs
- HMACSHA384.cs
- QuaternionAnimation.cs
- DeclaredTypeElement.cs
- OrderByQueryOptionExpression.cs
- TemplateBindingExtensionConverter.cs
- BypassElementCollection.cs
- DesignerAttribute.cs
- BindingSourceDesigner.cs
- SerialStream.cs
- CodeTypeDelegate.cs
- MailFileEditor.cs
- HelpKeywordAttribute.cs
- Label.cs
- MemberListBinding.cs
- ADMembershipUser.cs
- SwitchLevelAttribute.cs
- ControlParameter.cs
- CompilationLock.cs
- WebException.cs
- PeerApplicationLaunchInfo.cs
- SwitchCase.cs
- ViewManager.cs
- CacheOutputQuery.cs