示例#1
0
        public static IGroupContainer <T, CustomDescription> Custom <T>(this IGroupContainer <T> root, String displayName, Type controlType, Action <FrameworkElementFactory> action)
        {
            var item = new CustomDescription(
                displayName,
                controlType,
                action);

            return(root.AddDescription(item));
        }
        /// <summary>
        /// Compare this instance with another for sorting purposes.
        /// </summary>
        /// <param name="category">The other instance.</param>
        /// <param name="keyName">The name of the key to compare on.</param>
        /// <returns>Zero if the instances are equal, Greater than 0 if this instance is greater; less than zero otherwise.</returns>
        public int CompareForSorting(CustomProgramCategory category, string keyName)
        {
            switch (keyName)
            {
            case "CategoryTag":
                if (categoryTag == category.CategoryTag)
                {
                    return(CustomDescription.CompareTo(category.CustomDescription));
                }
                else
                {
                    return(categoryTag.CompareTo(category.CategoryTag));
                }

            case "Description":
                if (CustomDescription == category.CustomDescription)
                {
                    return(categoryTag.CompareTo(category.CategoryTag));
                }
                else
                {
                    return(CustomDescription.CompareTo(category.CustomDescription));
                }

            case "WMCDescription":
                string thisWMCDescription;
                string otherWMCDescription;

                if (WMCDescription != null)
                {
                    thisWMCDescription = WMCDescription;
                }
                else
                {
                    thisWMCDescription = string.Empty;
                }

                if (category.WMCDescription != null)
                {
                    otherWMCDescription = category.WMCDescription;
                }
                else
                {
                    otherWMCDescription = string.Empty;
                }

                if (thisWMCDescription == otherWMCDescription)
                {
                    return(categoryTag.CompareTo(category.CategoryTag));
                }
                else
                {
                    return(thisWMCDescription.CompareTo(otherWMCDescription));
                }

            case "DVBLogicDescription":
                string thisLogicDescription;
                string otherLogicDescription;

                if (DVBLogicDescription != null)
                {
                    thisLogicDescription = DVBLogicDescription;
                }
                else
                {
                    thisLogicDescription = string.Empty;
                }

                if (category.DVBLogicDescription != null)
                {
                    otherLogicDescription = category.DVBLogicDescription;
                }
                else
                {
                    otherLogicDescription = string.Empty;
                }

                if (thisLogicDescription == otherLogicDescription)
                {
                    return(categoryTag.CompareTo(category.CategoryTag));
                }
                else
                {
                    return(thisLogicDescription.CompareTo(otherLogicDescription));
                }

            case "DVBViewerDescription":
                string thisViewerDescription;
                string otherViewerDescription;

                if (DVBViewerDescription != null)
                {
                    thisViewerDescription = DVBViewerDescription;
                }
                else
                {
                    thisViewerDescription = string.Empty;
                }

                if (category.DVBViewerDescription != null)
                {
                    otherViewerDescription = category.DVBViewerDescription;
                }
                else
                {
                    otherViewerDescription = string.Empty;
                }

                if (thisViewerDescription == otherViewerDescription)
                {
                    return(categoryTag.CompareTo(category.CategoryTag));
                }
                else
                {
                    return(thisViewerDescription.CompareTo(otherViewerDescription));
                }

            default:
                return(0);
            }
        }