Exemple #1
0
        private System.Windows.Media.Color GetColorFromHex(string hex)
        {
            var color   = ColorTranslator.FromHtml(hex);
            var toColor = new System.Windows.Media.Color();

            toColor.R = color.R;
            toColor.G = color.G;
            toColor.B = color.B;
            toColor.A = color.A;
            return(toColor);
        }
Exemple #2
0
        public static float GetSaturation(this System.Windows.Media.Color c)
        {
            var color = System.Drawing.Color.FromArgb(c.A, c.R, c.G, c.B);

            return(color.GetSaturation());
        }
 static public System.Drawing.Color ConvertColor(System.Windows.Media.Color color)
 {
     return(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B));
 }
        private static Shape CreateTextShape(string text, double placeX, double placeY, double fontSize, System.Windows.Media.Color color)
        {
            Shape textShape;

            System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily("Times New Roman");
            Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Bold, new FontStretch());

            FormattedText fText = new FormattedText(text, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, System.Windows.Media.Brushes.Black);

            System.Windows.Point textPosition1;
            textPosition1 = new System.Windows.Point(placeX, placeY);
            Path path = new Path();

            path.Data = fText.BuildGeometry(textPosition1);
            path.Fill = new SolidColorBrush(color);
            textShape = path;
            return(textShape);
        }
        /// <summary>
        /// scale values of 0 - 1000 will be used to calculate the right placement of true display values
        /// </summary>
        /// <param name="size"></param>
        /// <param name="text"></param>
        /// <param name="scaleX"></param>
        /// <param name="scaleY"></param>
        /// <param name="scaleFontSize"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private static Shape CreateTextShape(Size size, string text, double scaleX, double scaleY, double scaleFontSize, System.Windows.Media.Color color)
        {
            //Debug.WriteLine(text + " paint size (" + size.Height + "," + size.Width + ")");
            double x        = (size.Width * scaleX) / 1000;
            double y        = (size.Height * scaleY) / 1000;
            double fontsize = (size.Height * scaleFontSize) / 1000;

            if (fontsize < 7)
            {
                fontsize = 12;
            }

            return(CreateTextShape(text, x, y, fontsize, color));
        }
        /// <summary>
        /// scale values of 0 - 1000 will be used to calculate the right placement of true display values
        /// </summary>
        /// <param name="size"></param>
        /// <param name="text"></param>
        /// <param name="scaleX"></param>
        /// <param name="scaleY"></param>
        /// <param name="scaleFontSize"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private Shape CreateTextShape(Size size, string text, double scaleX, double scaleY, double scaleFontSize, System.Windows.Media.Color color)
        {
            double x        = (size.Width * scaleX) / 1000;
            double y        = (size.Height * scaleY) / 1000;
            double fontsize = (size.Height * scaleFontSize) / 1000;

            return(CreateTextShape(text, x, y, fontsize, color));
        }