/// <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));
        }
Example #2
0
        /// <summary>
        /// Select node and adds icon to it
        /// </summary>
        /// <param name="rowData"><see cref="TreeListRowData"/></param>
        /// <returns>ImageSource</returns>
        public override ImageSource Select(TreeListRowData rowData)
        {
            var thingStatus = ((IHaveThingStatus)rowData.Row).ThingStatus;

            if (rowData.Row is ParameterOrOverrideBaseRowViewModel parameterOrOverrideBaseRow)
            {
                var productTreeIconConverter = new ProductTreeIconUriConverter();
                var productTreeIcon          = productTreeIconConverter.Convert(new object[] { thingStatus, parameterOrOverrideBaseRow.Usage }, null, null, CultureInfo.InvariantCulture);
                return(productTreeIcon as ImageSource);
            }

            var converter = new ThingToIconUriConverter();
            var icon      = converter.Convert(new object[] { thingStatus }, null, null, CultureInfo.InvariantCulture);

            return(icon as ImageSource);
        }
        /// <summary>
        /// Select node and adds icon to it
        /// </summary>
        /// <param name="rowData"><see cref="TreeListRowData"/></param>
        /// <returns>ImageSource</returns>
        public override ImageSource Select(TreeListRowData rowData)
        {
            var   thingStatus = ((IHaveThingStatus)rowData.Row).ThingStatus;
            Thing thing       = null;

            if (rowData.Row is ParametricConstraintsFolderRowViewModel parametricConstraintsFolderRow)
            {
                thing = parametricConstraintsFolderRow.Thing;
            }
            else if (rowData.Row is ParametricConstraintRowViewModel parametricConstraintRow)
            {
                thing = parametricConstraintRow.Thing;
            }

            var converter = new ThingToIconUriConverter();

            var image = converter.Convert(new object[] { thing, thingStatus }, null, null, CultureInfo.InvariantCulture);

            return(image as ImageSource);
        }