/// <summary> /// The get icon for parameter override. /// </summary> /// <param name="thingStatus"> /// The parameter or override. /// </param> /// <returns> /// The <see cref="object"/>. /// </returns> private object GetIconForParameterOverride(ThingStatus thingStatus, ParameterUsageKind usage) { Uri uri = null; switch (usage) { case ParameterUsageKind.Unused: uri = new Uri("pack://application:,,,/CDP4Composition;component/Resources/Images/orangeball.jpg"); break; case ParameterUsageKind.SubscribedByOthers: uri = new Uri("pack://application:,,,/CDP4Composition;component/Resources/Images/blueball.gif"); break; case ParameterUsageKind.Subscribed: uri = new Uri("pack://application:,,,/CDP4Composition;component/Resources/Images/whiteball.jpg"); break; } if (uri == null) { return(null); } return(thingStatus.HasError ? IconUtilities.WithErrorOverlay(uri) : thingStatus.HasRelationship ? IconUtilities.WithOverlay(uri, IconUtilities.RelationshipOverlayUri, OverlayPositionKind.TopRight) : new BitmapImage(uri)); }
/// <summary> /// Returns an GetImage (icon) based on the <see cref="Thing" /> that is provided /// </summary> /// <param name="value">An instance of <see cref="Thing" /> for which an Icon needs to be returned</param> /// <param name="targetType">The parameter is not used.</param> /// <param name="parameter">The <see cref="ClassKind" /> of the overlay to use</param> /// <param name="culture">The parameter is not used.</param> /// <returns> /// A <see cref="Uri" /> to an GetImage /// </returns> public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture) { var genericConverter = new ThingToIconUriConverter(); var thingStatus = value.SingleOrDefault() as ThingStatus; var parameterBase = thingStatus?.Thing as ParameterBase; ClassKind valuesetRowType; if (parameterBase == null || parameter == null || !Enum.TryParse(parameter.ToString(), out valuesetRowType)) { return(genericConverter.Convert(value, targetType, parameter, culture)); } var isCompound = parameterBase.ParameterType is CompoundParameterType; // Value set row // row representing an option if (valuesetRowType == ClassKind.Option) { var optionUri = new Uri(IconUtilities.ImageUri(valuesetRowType).ToString()); if (parameterBase.StateDependence != null || isCompound) { return(new BitmapImage(optionUri)); } var uri = new Uri(IconUtilities.ImageUri(parameterBase.ClassKind).ToString()); return(IconUtilities.WithOverlay(uri, optionUri)); } // row representing a component if (valuesetRowType == ClassKind.ParameterTypeComponent) { var componentUri = new Uri(IconUtilities.ImageUri(valuesetRowType).ToString()); return(new BitmapImage(componentUri)); } // Row representing state var stateUri = new Uri(IconUtilities.ImageUri(ClassKind.ActualFiniteState).ToString()); if (isCompound) { return(new BitmapImage(stateUri)); } var baseUri = new Uri(IconUtilities.ImageUri(parameterBase.ClassKind).ToString()); return(IconUtilities.WithOverlay(baseUri, stateUri)); }
/// <summary> /// Queries the <see cref="BitmapSource"/> with an icon overlayed from the cache if the cache contains it else the <see cref="BitmapSource"/> /// is created, added to the cache and then returned. /// </summary> /// <param name="uri"> /// The uri of the <see cref="BitmapSource"/> /// </param> /// <param name="overlayUri"> /// The uri of the overlay <see cref="BitmapSource"/> /// </param> /// <returns> /// An instance of <see cref="BitmapSource"/> /// </returns> public BitmapSource QueryOverlayBitmapSource(Uri uri, Uri overlayUri, OverlayPositionKind overlayPosition = OverlayPositionKind.TopLeft) { return(IconUtilities.WithOverlay(uri, overlayUri, overlayPosition)); }