Пример #1
0
            public override object EditValue(
                ITypeDescriptorContext context,
                IServiceProvider provider,
                object value)
            {
                IWindowsFormsEditorService editorService = null;

                if (provider != null)
                {
                    editorService =
                        provider.GetService(
                            typeof(IWindowsFormsEditorService))
                        as IWindowsFormsEditorService;
                }

                if (editorService != null)
                {
                    GoodColorControl selectionControl = new GoodColorControl();

                    Type t = value.GetType();

                    if (t == typeof(ARGBPixel))
                    {
                        selectionControl.Color = (Color)(ARGBPixel)value;
                    }
                    else if (t == typeof(RGBAPixel))
                    {
                        selectionControl.Color = (Color)(RGBAPixel)value;
                    }
                    else if (t == typeof(GXColorS10))
                    {
                        selectionControl.Color = (Color)(GXColorS10)value;
                    }

                    editorService.DropDownControl(selectionControl);

                    if (t == typeof(ARGBPixel))
                    {
                        value = (ARGBPixel)selectionControl.Color;
                    }
                    else if (t == typeof(RGBAPixel))
                    {
                        value = (RGBAPixel)(ARGBPixel)selectionControl.Color;
                    }
                    else if (t == typeof(GXColorS10))
                    {
                        value = (GXColorS10)(ARGBPixel)selectionControl.Color;
                    }
                }

                return(value);
            }
 private void InitializeComponent()
 {
     this.btnOkay = new System.Windows.Forms.Button();
     this.btnCancel = new System.Windows.Forms.Button();
     this.pnlColors = new System.Windows.Forms.Panel();
     this.pnlNew = new System.Windows.Forms.BufferedPanel();
     this.pnlOld = new System.Windows.Forms.BufferedPanel();
     this.lblOld = new System.Windows.Forms.Label();
     this.lblNew = new System.Windows.Forms.Label();
     this.chkAlpha = new System.Windows.Forms.CheckBox();
     this.goodColorControl1 = new System.Windows.Forms.GoodColorControl();
     this.pnlColors.SuspendLayout();
     this.SuspendLayout();
     //
     // btnOkay
     //
     this.btnOkay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnOkay.Location = new System.Drawing.Point(200, 221);
     this.btnOkay.Name = "btnOkay";
     this.btnOkay.Size = new System.Drawing.Size(59, 24);
     this.btnOkay.TabIndex = 0;
     this.btnOkay.Text = "Okay";
     this.btnOkay.UseVisualStyleBackColor = true;
     this.btnOkay.Click += new System.EventHandler(this.btnOkay_Click);
     //
     // btnCancel
     //
     this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.Location = new System.Drawing.Point(265, 221);
     this.btnCancel.Name = "btnCancel";
     this.btnCancel.Size = new System.Drawing.Size(59, 24);
     this.btnCancel.TabIndex = 1;
     this.btnCancel.Text = "Cancel";
     this.btnCancel.UseVisualStyleBackColor = true;
     this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
     //
     // pnlColors
     //
     this.pnlColors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                 | System.Windows.Forms.AnchorStyles.Left)));
     this.pnlColors.Controls.Add(this.pnlNew);
     this.pnlColors.Controls.Add(this.pnlOld);
     this.pnlColors.Location = new System.Drawing.Point(14, 207);
     this.pnlColors.Name = "pnlColors";
     this.pnlColors.Size = new System.Drawing.Size(180, 37);
     this.pnlColors.TabIndex = 3;
     //
     // pnlNew
     //
     this.pnlNew.Dock = System.Windows.Forms.DockStyle.Fill;
     this.pnlNew.Location = new System.Drawing.Point(90, 0);
     this.pnlNew.Name = "pnlNew";
     this.pnlNew.Size = new System.Drawing.Size(90, 37);
     this.pnlNew.TabIndex = 6;
     this.pnlNew.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlNew_Paint);
     //
     // pnlOld
     //
     this.pnlOld.Dock = System.Windows.Forms.DockStyle.Left;
     this.pnlOld.Location = new System.Drawing.Point(0, 0);
     this.pnlOld.Name = "pnlOld";
     this.pnlOld.Size = new System.Drawing.Size(90, 37);
     this.pnlOld.TabIndex = 5;
     this.pnlOld.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlOld_Paint);
     //
     // lblOld
     //
     this.lblOld.BackColor = System.Drawing.Color.White;
     this.lblOld.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblOld.Location = new System.Drawing.Point(9, 198);
     this.lblOld.Name = "lblOld";
     this.lblOld.Size = new System.Drawing.Size(35, 15);
     this.lblOld.TabIndex = 4;
     this.lblOld.Text = "Old";
     this.lblOld.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // lblNew
     //
     this.lblNew.BackColor = System.Drawing.Color.White;
     this.lblNew.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblNew.Location = new System.Drawing.Point(99, 198);
     this.lblNew.Name = "lblNew";
     this.lblNew.Size = new System.Drawing.Size(35, 15);
     this.lblNew.TabIndex = 5;
     this.lblNew.Text = "New";
     this.lblNew.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // chkAlpha
     //
     this.chkAlpha.Checked = true;
     this.chkAlpha.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkAlpha.Location = new System.Drawing.Point(221, 200);
     this.chkAlpha.Name = "chkAlpha";
     this.chkAlpha.Size = new System.Drawing.Size(90, 18);
     this.chkAlpha.TabIndex = 6;
     this.chkAlpha.Text = "Show Alpha";
     this.chkAlpha.UseVisualStyleBackColor = true;
     this.chkAlpha.CheckedChanged += new System.EventHandler(this.chkAlpha_CheckedChanged);
     //
     // goodColorControl1
     //
     this.goodColorControl1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
     this.goodColorControl1.Location = new System.Drawing.Point(12, 10);
     this.goodColorControl1.MinimumSize = new System.Drawing.Size(310, 186);
     this.goodColorControl1.Name = "goodColorControl1";
     this.goodColorControl1.ShowAlpha = true;
     this.goodColorControl1.Size = new System.Drawing.Size(310, 186);
     this.goodColorControl1.TabIndex = 2;
     this.goodColorControl1.ColorChanged += new System.EventHandler(this.goodColorControl1_ColorChanged);
     //
     // GoodColorDialog
     //
     this.ClientSize = new System.Drawing.Size(335, 253);
     this.Controls.Add(this.chkAlpha);
     this.Controls.Add(this.lblNew);
     this.Controls.Add(this.lblOld);
     this.Controls.Add(this.pnlColors);
     this.Controls.Add(this.goodColorControl1);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnOkay);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
     this.MaximizeBox = false;
     this.MinimizeBox = false;
     this.Name = "GoodColorDialog";
     this.ShowInTaskbar = false;
     this.Text = "Color Selector";
     this.pnlColors.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Пример #3
0
 private void InitializeComponent()
 {
     btnOkay           = new Button();
     btnCancel         = new Button();
     pnlColors         = new Panel();
     lblOld            = new Label();
     lblNew            = new Label();
     chkAlpha          = new CheckBox();
     pnlNew            = new BufferedPanel();
     pnlOld            = new BufferedPanel();
     goodColorControl1 = new GoodColorControl();
     pnlColors.SuspendLayout();
     SuspendLayout();
     //
     // btnOkay
     //
     btnOkay.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
     btnOkay.Location = new Drawing.Point(200, 221);
     btnOkay.Name     = "btnOkay";
     btnOkay.Size     = new Drawing.Size(59, 24);
     btnOkay.TabIndex = 0;
     btnOkay.Text     = "Okay";
     btnOkay.UseVisualStyleBackColor = true;
     btnOkay.Click += btnOkay_Click;
     //
     // btnCancel
     //
     btnCancel.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
     btnCancel.Location = new Drawing.Point(267, 221);
     btnCancel.Name     = "btnCancel";
     btnCancel.Size     = new Drawing.Size(59, 24);
     btnCancel.TabIndex = 1;
     btnCancel.Text     = "Cancel";
     btnCancel.UseVisualStyleBackColor = true;
     btnCancel.Click += btnCancel_Click;
     //
     // pnlColors
     //
     pnlColors.Anchor = AnchorStyles.Top | AnchorStyles.Bottom
                        | AnchorStyles.Left;
     pnlColors.Controls.Add(pnlNew);
     pnlColors.Controls.Add(pnlOld);
     pnlColors.Location = new Drawing.Point(14, 207);
     pnlColors.Name     = "pnlColors";
     pnlColors.Size     = new Drawing.Size(180, 37);
     pnlColors.TabIndex = 3;
     //
     // lblOld
     //
     lblOld.BackColor   = Color.White;
     lblOld.BorderStyle = BorderStyle.FixedSingle;
     lblOld.Location    = new Drawing.Point(9, 198);
     lblOld.Name        = "lblOld";
     lblOld.Size        = new Drawing.Size(35, 15);
     lblOld.TabIndex    = 4;
     lblOld.Text        = "Old";
     lblOld.TextAlign   = ContentAlignment.MiddleCenter;
     //
     // lblNew
     //
     lblNew.BackColor   = Color.White;
     lblNew.BorderStyle = BorderStyle.FixedSingle;
     lblNew.Location    = new Drawing.Point(99, 198);
     lblNew.Name        = "lblNew";
     lblNew.Size        = new Drawing.Size(35, 15);
     lblNew.TabIndex    = 5;
     lblNew.Text        = "New";
     lblNew.TextAlign   = ContentAlignment.MiddleCenter;
     //
     // chkAlpha
     //
     chkAlpha.Checked    = true;
     chkAlpha.CheckState = CheckState.Checked;
     chkAlpha.Location   = new Drawing.Point(221, 200);
     chkAlpha.Name       = "chkAlpha";
     chkAlpha.Size       = new Drawing.Size(90, 18);
     chkAlpha.TabIndex   = 6;
     chkAlpha.Text       = "Show Alpha";
     chkAlpha.UseVisualStyleBackColor = true;
     chkAlpha.CheckedChanged         += chkAlpha_CheckedChanged;
     //
     // pnlNew
     //
     pnlNew.Dock     = DockStyle.Fill;
     pnlNew.Location = new Drawing.Point(90, 0);
     pnlNew.Name     = "pnlNew";
     pnlNew.Size     = new Drawing.Size(90, 37);
     pnlNew.TabIndex = 6;
     pnlNew.Paint   += new PaintEventHandler(pnlNew_Paint);
     //
     // pnlOld
     //
     pnlOld.Dock     = DockStyle.Left;
     pnlOld.Location = new Drawing.Point(0, 0);
     pnlOld.Name     = "pnlOld";
     pnlOld.Size     = new Drawing.Size(90, 37);
     pnlOld.TabIndex = 5;
     pnlOld.Paint   += new PaintEventHandler(pnlOld_Paint);
     //
     // goodColorControl1
     //
     goodColorControl1.Color         = Color.FromArgb(0, 0, 0, 0);
     goodColorControl1.Location      = new Drawing.Point(12, 10);
     goodColorControl1.MinimumSize   = new Drawing.Size(310, 186);
     goodColorControl1.Name          = "goodColorControl1";
     goodColorControl1.ShowAlpha     = true;
     goodColorControl1.Size          = new Drawing.Size(314, 186);
     goodColorControl1.TabIndex      = 2;
     goodColorControl1.ColorChanged += goodColorControl1_ColorChanged;
     //
     // GoodColorControl2
     //
     Controls.Add(chkAlpha);
     Controls.Add(lblNew);
     Controls.Add(lblOld);
     Controls.Add(pnlColors);
     Controls.Add(goodColorControl1);
     Controls.Add(btnCancel);
     Controls.Add(btnOkay);
     Name = "GoodColorControl2";
     Size = new Drawing.Size(335, 253);
     pnlColors.ResumeLayout(false);
     ResumeLayout(false);
 }
Пример #4
0
 private void InitializeComponent()
 {
     this.btnOkay           = new System.Windows.Forms.Button();
     this.btnCancel         = new System.Windows.Forms.Button();
     this.pnlColors         = new System.Windows.Forms.Panel();
     this.lblOld            = new System.Windows.Forms.Label();
     this.lblNew            = new System.Windows.Forms.Label();
     this.chkAlpha          = new System.Windows.Forms.CheckBox();
     this.pnlNew            = new System.Windows.Forms.BufferedPanel();
     this.pnlOld            = new System.Windows.Forms.BufferedPanel();
     this.goodColorControl1 = new System.Windows.Forms.GoodColorControl();
     this.pnlColors.SuspendLayout();
     this.SuspendLayout();
     //
     // btnOkay
     //
     this.btnOkay.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnOkay.Location = new System.Drawing.Point(200, 221);
     this.btnOkay.Name     = "btnOkay";
     this.btnOkay.Size     = new System.Drawing.Size(59, 24);
     this.btnOkay.TabIndex = 0;
     this.btnOkay.Text     = "Okay";
     this.btnOkay.UseVisualStyleBackColor = true;
     this.btnOkay.Click += new System.EventHandler(this.btnOkay_Click);
     //
     // btnCancel
     //
     this.btnCancel.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.Location = new System.Drawing.Point(267, 221);
     this.btnCancel.Name     = "btnCancel";
     this.btnCancel.Size     = new System.Drawing.Size(59, 24);
     this.btnCancel.TabIndex = 1;
     this.btnCancel.Text     = "Cancel";
     this.btnCancel.UseVisualStyleBackColor = true;
     this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
     //
     // pnlColors
     //
     this.pnlColors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                   | System.Windows.Forms.AnchorStyles.Left)));
     this.pnlColors.Controls.Add(this.pnlNew);
     this.pnlColors.Controls.Add(this.pnlOld);
     this.pnlColors.Location = new System.Drawing.Point(14, 207);
     this.pnlColors.Name     = "pnlColors";
     this.pnlColors.Size     = new System.Drawing.Size(180, 37);
     this.pnlColors.TabIndex = 3;
     //
     // lblOld
     //
     this.lblOld.BackColor   = System.Drawing.Color.White;
     this.lblOld.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblOld.Location    = new System.Drawing.Point(9, 198);
     this.lblOld.Name        = "lblOld";
     this.lblOld.Size        = new System.Drawing.Size(35, 15);
     this.lblOld.TabIndex    = 4;
     this.lblOld.Text        = "Old";
     this.lblOld.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // lblNew
     //
     this.lblNew.BackColor   = System.Drawing.Color.White;
     this.lblNew.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblNew.Location    = new System.Drawing.Point(99, 198);
     this.lblNew.Name        = "lblNew";
     this.lblNew.Size        = new System.Drawing.Size(35, 15);
     this.lblNew.TabIndex    = 5;
     this.lblNew.Text        = "New";
     this.lblNew.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // chkAlpha
     //
     this.chkAlpha.Checked    = true;
     this.chkAlpha.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkAlpha.Location   = new System.Drawing.Point(221, 200);
     this.chkAlpha.Name       = "chkAlpha";
     this.chkAlpha.Size       = new System.Drawing.Size(90, 18);
     this.chkAlpha.TabIndex   = 6;
     this.chkAlpha.Text       = "Show Alpha";
     this.chkAlpha.UseVisualStyleBackColor = true;
     this.chkAlpha.CheckedChanged         += new System.EventHandler(this.chkAlpha_CheckedChanged);
     //
     // pnlNew
     //
     this.pnlNew.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.pnlNew.Location = new System.Drawing.Point(90, 0);
     this.pnlNew.Name     = "pnlNew";
     this.pnlNew.Size     = new System.Drawing.Size(90, 37);
     this.pnlNew.TabIndex = 6;
     this.pnlNew.Paint   += new System.Windows.Forms.PaintEventHandler(this.pnlNew_Paint);
     //
     // pnlOld
     //
     this.pnlOld.Dock     = System.Windows.Forms.DockStyle.Left;
     this.pnlOld.Location = new System.Drawing.Point(0, 0);
     this.pnlOld.Name     = "pnlOld";
     this.pnlOld.Size     = new System.Drawing.Size(90, 37);
     this.pnlOld.TabIndex = 5;
     this.pnlOld.Paint   += new System.Windows.Forms.PaintEventHandler(this.pnlOld_Paint);
     //
     // goodColorControl1
     //
     this.goodColorControl1.Color         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
     this.goodColorControl1.Location      = new System.Drawing.Point(12, 10);
     this.goodColorControl1.MinimumSize   = new System.Drawing.Size(310, 186);
     this.goodColorControl1.Name          = "goodColorControl1";
     this.goodColorControl1.ShowAlpha     = true;
     this.goodColorControl1.Size          = new System.Drawing.Size(314, 186);
     this.goodColorControl1.TabIndex      = 2;
     this.goodColorControl1.ColorChanged += new System.EventHandler(this.goodColorControl1_ColorChanged);
     //
     // GoodColorControl2
     //
     this.Controls.Add(this.chkAlpha);
     this.Controls.Add(this.lblNew);
     this.Controls.Add(this.lblOld);
     this.Controls.Add(this.pnlColors);
     this.Controls.Add(this.goodColorControl1);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnOkay);
     this.Name = "GoodColorControl2";
     this.Size = new System.Drawing.Size(335, 253);
     this.pnlColors.ResumeLayout(false);
     this.ResumeLayout(false);
 }
            public override object EditValue(
                ITypeDescriptorContext context,
                IServiceProvider provider,
                object value)
            {
                IWindowsFormsEditorService editorService = null;
                if (provider != null)
                {
                    editorService =
                        provider.GetService(
                        typeof(IWindowsFormsEditorService))
                        as IWindowsFormsEditorService;
                }

                if (editorService != null)
                {
                    GoodColorControl selectionControl = new GoodColorControl();

                    Type t = value.GetType();

                    if (t == typeof(ARGBPixel))
                        selectionControl.Color = (Color)(ARGBPixel)value;
                    else if (t == typeof(RGBAPixel))
                        selectionControl.Color = (Color)(RGBAPixel)value;
                    else if (t == typeof(GXColorS10))
                        selectionControl.Color = (Color)(GXColorS10)value;

                    editorService.DropDownControl(selectionControl);

                    if (t == typeof(ARGBPixel))
                        value = (ARGBPixel)selectionControl.Color;
                    else if (t == typeof(RGBAPixel))
                        value = (RGBAPixel)(ARGBPixel)selectionControl.Color;
                    else if (t == typeof(GXColorS10))
                        value = (GXColorS10)(ARGBPixel)selectionControl.Color;
                }

                return value;
            }