private void Tooltip_Draw(object sender, DrawToolTipEventArgs e) { using (bm = new QuickBitmap(e.Bounds.Size)) { e.Graphics.Clear(this._tooltip.BackColor); ee = new DrawToolTipEventArgs(bm.Graphics, e.AssociatedWindow, e.AssociatedControl, new Rectangle(0, 0, e.Bounds.Width, e.Bounds.Height), e.ToolTipText, this._tooltip.BackColor, this._tooltip.ForeColor, this._tooltip.Font); ee.Graphics.Clear(Color.Transparent); ee.DrawBorder(); //e.Graphics.CopyFromScreen(new Point(e.Bounds.X + MousePosition.X, e.Bounds.Y + MousePosition.Y), Point.Empty, e.Bounds.Size, CopyPixelOperation.SourceCopy); ee.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; ee.Bounds.Offset(2, 2); ee.Bounds.Inflate(-4, -4); PSO2Plugin _plug = ee.AssociatedControl.Tag as PSO2Plugin; if (_plug != null && !_plug.Managed) { var _stringSize = _plug.GetToolTip(true, this._tooltip.Font, this._tooltip.PreferedSize.Width, TextFormatFlags.Left); Rectangle rect = new Rectangle(ee.Bounds.X, ee.Bounds.Y, _stringSize.Size.Width, _stringSize.Size.Height); TextRenderer.DrawText(ee.Graphics, _stringSize.Result, this._tooltip.Font, rect, this._tooltip.ForeColor, this._tooltip.BackColor, TextFormatFlags.Left); using (Font f = new Font(this._tooltip.Font.FontFamily, this._tooltip.Font.Size, FontStyle.Bold)) { _stringSize = TextRendererWrapper.WrapString(_plug.GetWarningMessage(), this._tooltip.PreferedSize.Width, f, TextFormatFlags.Left); TextRenderer.DrawText(ee.Graphics, _stringSize.Result, f, new Rectangle(ee.Bounds.X, ee.Bounds.Y + rect.Height, _stringSize.Size.Width, _stringSize.Size.Height), Color.Red, this._tooltip.BackColor, TextFormatFlags.Left); } } else { TextRenderer.DrawText(ee.Graphics, ee.ToolTipText, this._tooltip.Font, ee.Bounds, Color.FromArgb(255, 255, 255), Color.FromArgb(17, 17, 17), TextFormatFlags.Left); } e.Graphics.DrawImage(bm.Bitmap, e.Bounds, ee.Bounds, GraphicsUnit.Pixel); } }
protected void OnCellPaint(TableLayoutCellPaintEventArgs e, bool isChecked) { using (QuickBitmap qbm = new QuickBitmap(e.CellBounds.Size)) { qbm.Graphics.Clear(Color.Transparent); Rectangle newBound = new Rectangle(Point.Empty, e.CellBounds.Size); //base.OnCellPaint(new TableLayoutCellPaintEventArgs(qbm.Graphics, e.ClipRectangle, e.CellBounds, e.Column, e.Row)); if (backBuffer != null && !backBuffer.Disposed) { qbm.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; qbm.Graphics.DrawImage(backBuffer.Bitmap, newBound, e.CellBounds, GraphicsUnit.Pixel); qbm.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; } qbm.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; if (this.cellllll.ContainsKey(e.Column) && this.cellllll[e.Column].ContainsKey(e.Row)) { FakeCheckBox fcb = this.GetCheckBox(e.Column, e.Row); if (fcb != null && fcb.Visible) { Rectangle qbmRect; if (this.CellBorderStyle == TableLayoutPanelCellBorderStyle.None) { qbmRect = new Rectangle(Point.Empty, e.CellBounds.Size); } else { qbmRect = new Rectangle(new Point(2, 2), e.CellBounds.Size); } this.DrawCheckBox(qbm.Graphics, newBound, fcb, isChecked); } } e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; e.Graphics.DrawImage(qbm.Bitmap, e.CellBounds, newBound, GraphicsUnit.Pixel); } }
protected override void OnSizeChanged(EventArgs e) { if (this.bgbuffer != null) { this.bgbuffer.Dispose(); } if (!this.Size.IsEmpty) { this.bgbuffer = new QuickBitmap(this.Size); } base.OnSizeChanged(e); }
protected override void OnSizeChanged(EventArgs e) { if (backBuffer != null && !backBuffer.Disposed) { backBuffer.Dispose(); } if (this.ClientSize.Width > 0 && this.ClientSize.Height > 0) { backBuffer = new QuickBitmap(this.ClientSize); } base.OnSizeChanged(e); }
public void GetNewCache() { if (!this.Size.IsEmpty) { this.BackgroundImage = null; if (myBGCache != null) { myBGCache.Dispose(); } myBGCache = new QuickBitmap(this.Width, this.Height); ButtonRenderer.DrawParentBackground(myBGCache.Graphics, this.DisplayRectangle, this); this.BackgroundImage = myBGCache.Bitmap; } }
private void Pso2optionToolTip_Draw(object sender, DrawToolTipEventArgs e) { using (bm = new QuickBitmap(e.Bounds.Size)) { if (e.AssociatedControl.Equals(this.pso2optionTextSize)) { var _stringSize = Leayal.Forms.TextRendererWrapper.WrapString(LanguageManager.GetMessageText("PSO2Option_UIScale", "Set the interface scale. If the screen resolution is lower than the fit width, this setting will be skipped."), this.pso2optionToolTip.PreferedSize.Width, this.pso2optionToolTip.Font, TextFormatFlags.Left); TextRenderer.DrawText(e.Graphics, _stringSize.Result, this.pso2optionToolTip.Font, new Rectangle(e.Bounds.Location, _stringSize.Size), this.pso2optionToolTip.ForeColor, this.pso2optionToolTip.BackColor, TextFormatFlags.Left); Point thePointHuh = new Point(e.Bounds.X, _stringSize.Size.Height); _stringSize = Leayal.Forms.TextRendererWrapper.WrapString(LanguageManager.GetMessageText("PSO2Option_UIScaleWarn", "If you don't know what this is, please leave this at 'Default'."), this.pso2optionToolTip.PreferedSize.Width, this.pso2optionToolTip.Font, TextFormatFlags.Left); TextRenderer.DrawText(e.Graphics, _stringSize.Result, this.pso2optionToolTip.Font, new Rectangle(thePointHuh, TextRenderer.MeasureText(e.Graphics, _stringSize.Result, this.pso2optionToolTip.Font, e.Bounds.Size, TextFormatFlags.Left)), Color.Red, this.pso2optionToolTip.BackColor, TextFormatFlags.Left); } else { TextRenderer.DrawText(e.Graphics, e.ToolTipText, this.pso2optionToolTip.Font, e.Bounds, Color.FromArgb(255, 255, 255), Color.FromArgb(17, 17, 17), TextFormatFlags.Left); } } }
public void GetNewCache() { if (!this.Size.IsEmpty) { base.BackgroundImage = null; if (myBGCache != null) { myBGCache.Dispose(); } myBGCache = new QuickBitmap(this.Width, this.Height); ButtonRenderer.DrawParentBackground(myBGCache.Graphics, this.ClientRectangle, this); /*var myForm = this.FindForm(); * if (myForm != null) * using (QuickBitmap qb = new QuickBitmap(myForm.Size)) * { * Point pa = relative(myForm); * this.InvokePaintBackground(myForm, new PaintEventArgs(qb.Graphics, new Rectangle(pa, this.Size))); * myBGCache.Graphics.DrawImageUnscaled(qb.Bitmap, pa.X * -1, pa.Y * -1);// new Rectangle(relative(myForm), this.ClientSize), asd(myForm), GraphicsUnit.Pixel); * }//*/ base.BackgroundImage = myBGCache.Bitmap; } }
protected override void OnCellPaint(TableLayoutCellPaintEventArgs e) { using (QuickBitmap qbm = new QuickBitmap(e.CellBounds.Size)) { qbm.Graphics.Clear(Color.Transparent); Rectangle newBound = new Rectangle(Point.Empty, e.CellBounds.Size); //base.OnCellPaint(new TableLayoutCellPaintEventArgs(qbm.Graphics, e.ClipRectangle, e.CellBounds, e.Column, e.Row)); if (backBuffer != null && !backBuffer.Disposed) { qbm.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; qbm.Graphics.DrawImage(backBuffer.Bitmap, newBound, e.CellBounds, GraphicsUnit.Pixel); qbm.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; } qbm.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; if (this.cellllll.ContainsKey(e.Column) && this.cellllll[e.Column].ContainsKey(e.Row)) { FakeCheckBox fcb = this.GetCheckBox(e.Column, e.Row); if (fcb != null && fcb.Visible) { if (fcb.Checked) { if (fcb.Enabled) { if (this.lastKnownCoordinate != null && this.lastKnownCoordinate.Value.Column == e.Column && this.lastKnownCoordinate.Value.Row == e.Row) { if (this.isLeftMouseDown) { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.CheckedPressed); } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.CheckedHot); } } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.CheckedNormal); } } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.CheckedDisabled); } } else { if (fcb.Enabled) { if (this.lastKnownCoordinate != null && this.lastKnownCoordinate.Value.Column == e.Column && this.lastKnownCoordinate.Value.Row == e.Row) { if (this.isLeftMouseDown) { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.UncheckedPressed); } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.UncheckedHot); } } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.UncheckedNormal); } } else { this.DrawCheckBox(qbm.Graphics, newBound, fcb, CheckBoxState.UncheckedDisabled); } } } } e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; e.Graphics.DrawImage(qbm.Bitmap, e.CellBounds, newBound, GraphicsUnit.Pixel); } }