示例#1
0
        /// <summary>
        /// Descriptive user interface core for cloning the Content
        /// </summary>
        /// <param name="key">漢字色名</param>
        /// <param name="name">読み</param>
        /// <param name="brush">色SolidColorBrush</param>
        /// <returns></returns>
        protected virtual UIElement plateOf(string key, string name, Brush brush)
        {
            SolidColorBrush B    = brush as SolidColorBrush;
            CMYK            cmyk = new CMYK(B.Color);
            HSL             hsl  = new HSL(B.Color);
            HSV             hsv  = new HSV(B.Color);
            TextBlock       one  = new TextBlock();
            TextBlock       two  = new TextBlock();
            TextBlock       san  = new TextBlock();
            TextBlock       yon  = new TextBlock();
            TextBlock       goh  = new TextBlock();
            TextBlock       txl  = new TextBlock();
            TextBlock       txv  = new TextBlock();

            one.Text = key;
            two.Text = name;
            //san.Text=rgb(B.Color);
            san.Inlines.Add(ofR(B.Color));
            san.Inlines.Add(new Run(","));
            san.Inlines.Add(ofG(B.Color));
            san.Inlines.Add(new Run(","));
            san.Inlines.Add(ofB(B.Color));
            //yon.Text=rgb(B.Color,true);
            yon.Inlines.Add(new Run("#"));
            yon.Inlines.Add(ofR(B.Color, true));
            yon.Inlines.Add(ofG(B.Color, true));
            yon.Inlines.Add(ofB(B.Color, true));
            goh.Text = cmyk.ToString(false);
            txl.Text = hsl.ToString(false);
            txv.Text = hsv.ToString(false);
            switch (NamedSolidColorBrush.howCompare)
            {
            case NamedSolidColorBrush.HowCompare.Kanji:
                one.FontWeight = FontWeights.Bold;
                break;

            case NamedSolidColorBrush.HowCompare.Yomi:
                two.FontWeight = FontWeights.Bold;
                break;

            case NamedSolidColorBrush.HowCompare.R:
                int i = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (i == 0)
                    {
                        iline.FontWeight = FontWeights.Bold;
                        break;
                    }
                    ++i;
                }
                int yi = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (yi == 1)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++yi;
                }
                break;

            case NamedSolidColorBrush.HowCompare.nR:
                int iR = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (iR == 2 || iR == 4)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++iR;
                }
                int yiR = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (yiR == 2 || yiR == 3)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++yiR;
                }
                break;

            case NamedSolidColorBrush.HowCompare.G:
                int ii = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (ii == 2)
                    {
                        iline.FontWeight = FontWeights.Bold;
                        break;
                    }
                    ++ii;
                }
                int iG = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (iG == 2)
                    {
                        iline.FontWeight = FontWeights.Bold;
                        break;
                    }
                    ++iG;
                }
                break;

            case NamedSolidColorBrush.HowCompare.nG:
                int siG = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (siG == 0 || siG == 4)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++siG;
                }
                int yiG = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (yiG == 1 || yiG == 3)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++yiG;
                }
                break;

            case NamedSolidColorBrush.HowCompare.B:
                int iii = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (iii == 4)
                    {
                        iline.FontWeight = FontWeights.Bold;
                        break;
                    }
                    ++iii;
                }
                int iB = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (iB == 3)
                    {
                        iline.FontWeight = FontWeights.Bold;
                        break;
                    }
                    ++iB;
                }
                break;

            case NamedSolidColorBrush.HowCompare.nB:
                int siB = 0;
                foreach (Inline iline in san.Inlines)
                {
                    if (siB == 0 || siB == 2)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++siB;
                }
                int yiB = 0;
                foreach (Inline iline in yon.Inlines)
                {
                    if (yiB == 1 || yiB == 2)
                    {
                        iline.FontWeight = FontWeights.Bold;
                    }
                    ++yiB;
                }
                break;

            case NamedSolidColorBrush.HowCompare.RGB:
                san.FontWeight = yon.FontWeight = FontWeights.Bold;
                break;

            case NamedSolidColorBrush.HowCompare.CMYK:
                goh.FontWeight = FontWeights.Bold;
                break;

            case NamedSolidColorBrush.HowCompare.HSL:
                txl.FontWeight = FontWeights.Bold;
                break;

            case NamedSolidColorBrush.HowCompare.HSV:
                txv.FontWeight = FontWeights.Bold;
                break;
            }
            UniformGrid ug = new UniformGrid {
                Background = brush
            };

            ug.Children.Add(one);
            ug.Children.Add(two);
            ug.Children.Add(san);
            ug.Children.Add(yon);
            ug.Children.Add(goh);
            ug.Children.Add(txl);
            ug.Children.Add(txv);
            one.TextAlignment = TextAlignment.Right;
            two.TextAlignment = TextAlignment.Left;
            //san.FontWeight=FontWeights.Bold;
            ug.Columns = ug.Children.Count;
            //ug.HorizontalAlignment=HorizontalAlignment.Stretch;
            one.Foreground = two.Foreground = san.Foreground = yon.Foreground = goh.Foreground = txl.Foreground = txv.Foreground = invert(brush);
            one.Margin     = two.Margin = san.Margin = yon.Margin = goh.Margin = txl.Margin = txv.Margin = new Thickness(6);
            ug.Tag         = one.Text;
            return(ug);
        }