Exemple #1
0
        public UIAcolorBox(Color clr_in)
            : base()
        {
            dp    = new DockPanel();
            tbC   = new TextBox();
            rectC = new Rectangle();
            Label lbl_clr = new Label();

            clr = new AColor();
            clr.SetFromColor(clr_in);

            lbl_clr.Content = "Цвет";
            tbC.Text        = clr.ToHex();

            tbC.Width         = 65;
            tbC.Height        = 23;
            tbC.TextAlignment = TextAlignment.Center;
            tbC.MaxLength     = 6;

            rectC.Fill            = new SolidColorBrush(clr_in);
            rectC.Stroke          = Brushes.Black;
            rectC.StrokeThickness = 3;

            rectC.Width  = 23;
            rectC.Height = 23;

            rectC.ContextMenu = genContextMenu();

            //rectC.MouseLeftButtonDown +=

            dp.Children.Add(lbl_clr);
            dp.Children.Add(tbC);
            dp.Children.Add(rectC);
            dp.LastChildFill = false;
        }
        private void clickContextMenu(object sender, EventArgs e)
        {
            AColor clr;

            if (sender is MenuItem)
            {
                string header = (sender as MenuItem).Header as string;

                if (AColors.AColorsDict.ContainsKey(header))
                {
                    clr        = AColors.AColorsDict[header];
                    tbC.Text   = clr.ToHex();
                    rectC.Fill = new SolidColorBrush(clr.GetColor());
                }
            }
        }