protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Color headerBgColorUpper = ControlRenderer.ColorBackground; Color headerBgColorLower = headerBgColorUpper.ScaleBrightness(0.95f); GroupedPropertyEditor.DrawGroupHeaderBackground(e.Graphics, this.rectHeader, headerBgColorUpper, GroupedPropertyEditor.GroupHeaderStyle.Emboss); GroupedPropertyEditor.DrawGroupHeaderBackground(e.Graphics, this.rectPrefab, headerBgColorLower, GroupedPropertyEditor.GroupHeaderStyle.SmoothSunken); if (this.Focused) { ControlRenderer.DrawBorder(e.Graphics, this.ClientRectangle, AdamsLair.WinForms.Drawing.BorderStyle.Simple, BorderState.Normal); } CheckBoxState activeState = CheckBoxState.UncheckedDisabled; if (!this.ReadOnly && this.Enabled) { if (!this.active.HasValue) { if (this.activeCheckPressed) { activeState = CheckBoxState.MixedPressed; } else if (this.activeCheckHovered) { activeState = CheckBoxState.MixedHot; } else { activeState = CheckBoxState.MixedNormal; } } else if (this.active.Value) { if (this.activeCheckPressed) { activeState = CheckBoxState.CheckedPressed; } else if (this.activeCheckHovered) { activeState = CheckBoxState.CheckedHot; } else { activeState = CheckBoxState.CheckedNormal; } } else { if (this.activeCheckPressed) { activeState = CheckBoxState.UncheckedPressed; } else if (this.activeCheckHovered) { activeState = CheckBoxState.UncheckedHot; } else { activeState = CheckBoxState.UncheckedNormal; } } } else { if (!this.active.HasValue) { activeState = CheckBoxState.MixedDisabled; } else if (this.active.Value) { activeState = CheckBoxState.CheckedDisabled; } else { activeState = CheckBoxState.UncheckedDisabled; } } ControlRenderer.DrawCheckBox(e.Graphics, this.rectCheckActive.Location, activeState); Region[] nameLabelRegion = ControlRenderer.MeasureStringLine(e.Graphics, this.displayedName, new[] { new CharacterRange(0, this.displayedName.Length) }, headerNameFont, this.rectLabelName); ControlRenderer.DrawStringLine(e.Graphics, this.displayedName, headerNameFont, this.rectLabelName, SystemColors.ControlText); if (nameLabelRegion.Length > 0) { SizeF nameLabelSize = nameLabelRegion[0].GetBounds(e.Graphics).Size; Rectangle extLabelRect = new Rectangle( this.rectLabelName.X + (int)nameLabelSize.Width, this.rectLabelName.Y, this.rectLabelName.Width - (int)nameLabelSize.Width, this.rectLabelName.Height); ControlRenderer.DrawStringLine(e.Graphics, this.displayedNameExt, headerNameExtFont, extLabelRect, SystemColors.ControlText); } ButtonState buttonStateAdd = ButtonState.Normal; ButtonState buttonStateDefaultAdd = ButtonState.Normal; if (this.curButtonPressed) { buttonStateAdd = ButtonState.Pressed; } else if (this.curButtonHovered) { buttonStateAdd = ButtonState.Hot; } ControlRenderer.DrawButton(e.Graphics, this.rectButtonAddComponent, this.curButton == 4 ? buttonStateAdd : buttonStateDefaultAdd, "+"); ControlRenderer.DrawStringLine(e.Graphics, "PrefabLink", headerPrefabFont, this.rectLabelPrefab, !this.prefabLinked ? SystemColors.GrayText : (this.prefabLinkAvailable ? Color.Blue : Color.DarkRed)); ButtonState buttonState = ButtonState.Disabled; ButtonState buttonStateDefault = ButtonState.Disabled; ButtonState buttonStateDefaultBreak = ButtonState.Disabled; if (!this.ReadOnly && this.Enabled && this.prefabLinked) { if (this.prefabLinkAvailable) { buttonState = ButtonState.Normal; buttonStateDefault = ButtonState.Normal; } buttonStateDefaultBreak = ButtonState.Normal; } if (this.curButtonPressed) { buttonState = ButtonState.Pressed; } else if (this.curButtonHovered) { buttonState = ButtonState.Hot; } ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabShow, this.curButton == 0 ? buttonState : buttonStateDefault, "Show"); ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabRevert, this.curButton == 1 ? buttonState : buttonStateDefault, "Revert"); ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabApply, this.curButton == 2 ? buttonState : buttonStateDefault, "Apply"); ControlRenderer.DrawButton(e.Graphics, this.rectButtonPrefabBreak, this.curButton == 3 ? buttonState : buttonStateDefaultBreak, "Break"); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle rectImage = new Rectangle(this.rectPreview.X + 1, this.rectPreview.Y + 1, this.rectPreview.Width - 2, this.rectPreview.Height - 2); Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224); Color darkChecker = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192); Bitmap img = this.GetPreviewFrame((int)this.subImageSelector.Value); e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage); if (img != null) { Size imgSize = img.Size; float widthForHeight = (float)imgSize.Width / (float)imgSize.Height; if (widthForHeight * (imgSize.Height - rectImage.Height) > imgSize.Width - rectImage.Width) { imgSize.Height = Math.Min(rectImage.Height, imgSize.Height); imgSize.Width = MathF.RoundToInt(widthForHeight * imgSize.Height); } else { imgSize.Width = Math.Min(rectImage.Width, imgSize.Width); imgSize.Height = MathF.RoundToInt(imgSize.Width / widthForHeight); } e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImage(img, rectImage.X + rectImage.Width / 2 - imgSize.Width / 2, rectImage.Y + rectImage.Height / 2 - imgSize.Height / 2, imgSize.Width, imgSize.Height); e.Graphics.InterpolationMode = InterpolationMode.Default; } ControlRenderer.DrawBorder(e.Graphics, this.rectPreview, BorderStyle.Simple, !this.Enabled ? BorderState.Disabled : BorderState.Normal); bool focusBg = this.Focused || (this is IPopupControlHost && (this as IPopupControlHost).IsDropDownOpened); Color headerBgColor = this.ControlRenderer.ColorBackground; if (focusBg) { headerBgColor = headerBgColor.ScaleBrightness(this.ControlRenderer.FocusBrightnessScale); } GroupedPropertyEditor.DrawGroupHeaderBackground( e.Graphics, this.rectHeader, headerBgColor, GroupedPropertyEditor.GroupHeaderStyle.SmoothSunken); if (this.subImageSelector.Rect.Width > 0) { this.ControlRenderer.DrawStringLine(e.Graphics, "Frame Index", SystemFonts.DefaultFont, this.rectLabelName, !this.Enabled ? this.ControlRenderer.ColorGrayText : this.ControlRenderer.ColorText, StringAlignment.Far); this.subImageSelector.OnPaint(e, this.Enabled && !this.subImageSelector.ReadOnly, false); } }