Example #1
0
        /// <summary>
        /// Determines if the given frequency is at most of the given rank.
        /// </summary>
        /// <param name="commonness">Commonness rank ceiling.</param>
        /// <param name="frequency">Frequency to test.</param>
        /// <returns>True if the matching commonness rank is at most of the given ceiling rank.</returns>
        public static bool IsAtMost(VocabCommonness commonness, int?frequency)
        {
            if (frequency.HasValue)
            {
                return((int)GetRank(frequency) >= (int)commonness);
            }

            return(false);
        }
        /// <summary>
        /// Determines if the given frequency is at most of the given rank.
        /// </summary>
        /// <param name="commonness">Commonness rank ceiling.</param>
        /// <param name="frequency">Frequency to test.</param>
        /// <returns>True if the matching commonness rank is at most of the given ceiling rank.</returns>
        public static bool IsAtMost(VocabCommonness commonness, int? frequency)
        {
            if (frequency.HasValue)
            {
                return ((int)GetRank(frequency) >= (int)commonness);
            }

            return false;
        }
Example #3
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(new SolidColorBrush(Colors.Transparent));
            }

            int?v = value as int?;

            if (v != null)
            {
                VocabCommonness rank = VocabCommonnessHelper.GetRank(v);
                if (rank == VocabCommonness.VeryCommon)
                {
                    return(new SolidColorBrush(Color.FromArgb(100, 255, 255, 0)));
                }
                else if (rank == VocabCommonness.Common)
                {
                    return(new SolidColorBrush(Color.FromArgb(80, 255, 255, 0)));
                }
                else if (rank == VocabCommonness.Unusual)
                {
                    return(new SolidColorBrush(Color.FromArgb(60, 255, 255, 0)));
                }
                else if (rank == VocabCommonness.Rare)
                {
                    return(new SolidColorBrush(Color.FromArgb(40, 255, 255, 0)));
                }
                else if (rank == VocabCommonness.VeryRare)
                {
                    return(new SolidColorBrush(Color.FromArgb(20, 255, 255, 0)));
                }
                else
                {
                    return(new SolidColorBrush(Colors.Transparent));
                }
            }
            else
            {
                throw new ArgumentException("Value must be int?.");
            }
        }
Example #4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            int?v = value as int?;

            if (v != null)
            {
                VocabCommonness rank = VocabCommonnessHelper.GetRank(v);

                switch (rank)
                {
                case VocabCommonness.VeryCommon:
                    return("Very common");

                case VocabCommonness.Common:
                    return("Common");

                case VocabCommonness.Unusual:
                    return("Unusual");

                case VocabCommonness.Rare:
                    return("Rare");

                case VocabCommonness.VeryRare:
                    return("Very rare");

                default:
                    return("No data");
                }
            }
            else
            {
                throw new ArgumentException("Value must be int?.");
            }
        }