Beispiel #1
0
            private void OnButtonClick(object sender, EventArgs e)
            {
                DialogResult dialogResult = colorDialog.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    var   col = colorDialog.Color;
                    float r   = (float)col.R / 255.0f;
                    float g   = (float)col.G / 255.0f;
                    float b   = (float)col.B / 255.0f;
                    float a   = (float)col.A / 255.0f;

                    RayTracerNet.Color color = new RayTracerNet.Color(r, g, b, a);
                    property.SetValue(propertyTarget, color);
                    System.Drawing.Color syscolor = color.ToSystemColor();
                    this.propertyButton.Text      = syscolor.Name;
                    this.propertyButton.ForeColor = syscolor;
                }
            }
Beispiel #2
0
            public override int SetProperty(object propertyTarget, PropertyInfo property, Attribute attribute, int height)
            {
                this.property       = property;
                this.propertyTarget = propertyTarget;

                RayTracerNet.Color color = (RayTracerNet.Color)property.GetValue(propertyTarget);

                System.Drawing.Color syscolor = color.ToSystemColor();

                this.propertyNameLabel.Visible  = true;
                this.propertyNameLabel.Location = new System.Drawing.Point(7, height + 6);
                this.propertyNameLabel.Name     = "propertyLabel_" + propertyTarget.GetHashCode();
                this.propertyNameLabel.Size     = new System.Drawing.Size(53, 12);
                this.propertyNameLabel.Text     = ((RayTracerNet.ColorPropertyDisplayAttribute)attribute).propertyName + ":";

                this.propertyButton.Visible   = true;
                this.propertyButton.Location  = new System.Drawing.Point(35, height + 24);
                this.propertyButton.Name      = "propertyButton_" + propertyTarget.GetHashCode();
                this.propertyButton.Size      = new System.Drawing.Size(192, 20);
                this.propertyButton.Text      = syscolor.Name;
                this.propertyButton.ForeColor = syscolor;

                return(height + 50);
            }