Exemple #1
0
        /// <summary>
        /// Convert between different units of screen resolutions.
        /// </summary>
        /// <param name="inputUnit"></param>
        /// <param name="inputValue"></param>
        /// <param name="outputUnit"></param>
        /// <returns></returns>
        public override double Convert(Itemkey inputUnit, double inputValue, Itemkey outputUnit)
        {
            switch (inputUnit)
            {
            case Itemkey.ScreenFontPoints:
                return(ScreenFontPoints.ToUnit(inputValue, outputUnit, OneHundredPercentFontSize));

            case Itemkey.ScreenPercent:
                return(ScreenPercent.ToUnit(inputValue, outputUnit, OneHundredPercentFontSize));

            default:
                throw new NotImplementedException(outputUnit.ToString());
            }
        }
        /// <summary>
        /// Convert a font size to other values.
        /// </summary>
        /// <param name="targetUnit"></param>
        /// <returns></returns>
        public double ToUnit(Itemkey targetUnit)
        {
            switch (targetUnit)
            {
            case Itemkey.ScreenPercent:
                return(this.mValue * (100 / ScreenConverter.OneHundretPercentFont));

            case Itemkey.ScreenFontPoints:
                return(this.mValue);

            default:
                throw new NotImplementedException(targetUnit.ToString());
            }
        }
Exemple #3
0
        /// <summary>
        /// Convert a font size to other values.
        /// </summary>
        /// <param name="inputValue"></param>
        /// <param name="targetUnit"></param>
        /// <param name="oneHundredPercentFontSize"></param>
        /// <returns></returns>
        public static double ToUnit(double inputValue, Itemkey targetUnit, double oneHundredPercentFontSize)
        {
            switch (targetUnit)
            {
            case Itemkey.ScreenPercent:
                return(inputValue * (100 / oneHundredPercentFontSize));

            case Itemkey.ScreenFontPoints:
                return(inputValue);

            default:
                throw new NotImplementedException(targetUnit.ToString());
            }
        }
        /// <summary>
        /// Convert between different units of screen resolutions.
        /// </summary>
        /// <param name="inputUnit"></param>
        /// <param name="inputValue"></param>
        /// <param name="outputUnit"></param>
        /// <returns></returns>
        public override double Convert(Itemkey inputUnit, double inputValue, Itemkey outputUnit)
        {
            switch (inputUnit)
              {
            case Itemkey.ScreenFontPoints:
              return ScreenFontPoints.ToUnit(inputValue, outputUnit);

            case Itemkey.ScreenPercent:
              return ScreenPercent.ToUnit(inputValue, outputUnit);

            default:
              throw new NotImplementedException(outputUnit.ToString());
               }
        }
        /// <summary>
        /// Convert a font size to other values.
        /// </summary>
        /// <param name="targetUnit"></param>
        /// <returns></returns>
        public double ToUnit(Itemkey targetUnit)
        {
            switch (targetUnit)
              {
            case Itemkey.ScreenPercent:
              return this.mValue * (100 / ScreenConverter.OneHundretPercentFont);

            case Itemkey.ScreenFontPoints:
              return this.mValue;

            default:
              throw new NotImplementedException(targetUnit.ToString());
              }
        }
Exemple #6
0
        private static string SetUnitRangeMessage(Itemkey unit)
        {
            switch (unit)
            {
            // Implement a minimum value of 2 in any way (no matter what the unit is)
            case Itemkey.ScreenFontPoints:
                return(FontSizeErrorTip());

            // Implement a minimum value of 2 in any way (no matter what the unit is)
            case Itemkey.ScreenPercent:
                return(PercentSizeErrorTip());

            default:
                throw new System.NotSupportedException(unit.ToString());
            }
        }
        private string SetUnitRangeMessage(Itemkey unit)
        {
            switch (unit)
              {
            // Implement a minimum value of 2 in any way (no matter what the unit is)
            case Itemkey.ScreenFontPoints:
              return this.FontSizeErrorTip();

              // Implement a minimum value of 2 in any way (no matter what the unit is)
              case Itemkey.ScreenPercent:
              return this.PercentSizeErrorTip();

              default:
              throw new System.NotSupportedException(unit.ToString());
               }
        }