コード例 #1
0
ファイル: HuePropEditor.cs プロジェクト: mbnunes/GumpStudio
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value == null)
            {
                value = Hues.GetHue(0);
            }

            if (!(value is Hue hue))
            {
                return(value);
            }

            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc == null)
            {
                return(value);
            }

            HuePickerControl huePickerControl = new HuePickerControl(hue);

            huePickerControl.ValueChanged += new HuePickerControl.ValueChangedEventHandler(ValueSelected);

            edSvc.DropDownControl(huePickerControl);
            if (ReturnValue != null)
            {
                huePickerControl.Dispose();
                return(ReturnValue);
            }
            huePickerControl.Dispose();
            return(value);
        }
コード例 #2
0
        private void lstHue_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics graphics1 = e.Graphics;

            graphics1.FillRectangle(Brushes.White, e.Bounds);
            if ((e.State & DrawItemState.Selected) > DrawItemState.None)
            {
                Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, 50, this.lstHue.ItemHeight);
                graphics1.FillRectangle(SystemBrushes.Highlight, rect);
            }
            else
            {
                Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, 50, this.lstHue.ItemHeight);
                graphics1.FillRectangle(SystemBrushes.Window, rect);
            }
            float     num1      = (float)(e.Bounds.Width - 35) / 32f;
            Hue       hue       = (Hue)this.lstHue.Items[e.Index];
            Graphics  graphics2 = graphics1;
            string    s         = hue.Index.ToString();
            Font      font      = e.Font;
            Brush     black     = Brushes.Black;
            Rectangle bounds1   = e.Bounds;
            double    num2      = (double)(bounds1.X + 3);

            bounds1 = e.Bounds;
            double y1 = (double)bounds1.Y;

            graphics2.DrawString(s, font, black, (float)num2, (float)y1);
            int num3 = 0;

            foreach (short color in hue.Colors)
            {
                Rectangle bounds2 = e.Bounds;
                int       x       = bounds2.X + 35 + (int)Math.Round((double)num3 * (double)num1);
                bounds2 = e.Bounds;
                int y2    = bounds2.Y;
                int width = (int)Math.Round((double)num1 + 1.0);
                bounds2 = e.Bounds;
                int       height = bounds2.Height;
                Rectangle rect   = new Rectangle(x, y2, width, height);
                graphics1.FillRectangle((Brush) new SolidBrush(HuePickerControl.Convert555ToARGB(color)), rect);
                ++num3;
            }
        }
コード例 #3
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (value == null)
     {
         value = (object)Hues.GetHue(0);
     }
     if (value.GetType() == typeof(Hue))
     {
         this.edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (this.edSvc != null)
         {
             HuePickerControl huePickerControl = new HuePickerControl((Hue)value);
             huePickerControl.ValueChanged += new HuePickerControl.ValueChangedEventHandler(this.ValueSelected);
             this.edSvc.DropDownControl((Control)huePickerControl);
             if (this.ReturnValue != null)
             {
                 huePickerControl.Dispose();
                 return((object)this.ReturnValue);
             }
             huePickerControl.Dispose();
         }
     }
     return(value);
 }