Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have created the required general transparency control, the solution was a detailed breakdown of the control and all of its siblings in the parent, and preparing a recursive drawing routine on the OnPaintBackground() method relying on the InvokePaint() and InvokePaintBackground() methods. By defining successively smaller clips and intersecting with lower controls, this method minimises drawing overhead.</p> <ul> <li><p>The complete control includes a method of detecting and responding to sibling controls' Invalidate methods, efficiently drawing the stack of transparent controls and effectively allowing full alpha channel overlays on animated underlying controls.</p></li> <li><p>The control can be interleaved with all permutations of child and parent controls while giving visually accurate transparency.</p></li> <li><p>Hit testing has not been considered in the control.</p></li> <li><p>This control will not overdraw controls whose drawing is not performed during paint events. This is a big limitation.</p></li> <li><p>To use the control one simply inherits from the base and overrides the OnPaint method to perform custom drawing. It is also possible to override the OnPaintBackground method so long as a call to the base method is called first.</p></li> </ul> <p>Finally, if anyone would like the full code including invalidation handling, let me know. If you have a solution to system drawn components let me know that too. Also if you have a more trivial solution that implies I wasted a bunch of time on this, I wouldn't be upset about receiving that either!</p> <p><img src="https://i.stack.imgur.com/v6o6L.png" alt="enter image description here"></p> <p>An excerpt of the control on the OnPaintBackground method is presented:</p> <pre><code>''' &lt;summary&gt; ''' Recursively paint all underlying controls in their relevant regions, stacking drawing operations as necessary. ''' &lt;/summary&gt; ''' &lt;param name="pevent"&gt;&lt;/param&gt; ''' &lt;remarks&gt;&lt;/remarks&gt; Protected Overrides Sub OnPaintBackground(pevent As System.Windows.Forms.PaintEventArgs) 'Store clip and transform for reversion Dim initialClip As Region = pevent.Graphics.Clip Dim initialTransform As Drawing2D.Matrix = pevent.Graphics.Transform 'Develop list of underlying controls Dim submarinedControls As New List(Of Control) For Each Control As Control In m_Siblings If Control.Visible AndAlso Above(Control) AndAlso Me.ClientRectangle.IntersectsWith(Control.RelativeClientRectangle(Me)) Then submarinedControls.Add(Control) Next 'Prepare clip for parent draw Dim parentClip As System.Drawing.Region = New System.Drawing.Region(initialClip.GetRegionData) For Each Control As Control In submarinedControls parentClip.Exclude(Control.RelativeClientRectangle(Me)) Next pevent.Graphics.Clip = parentClip 'Evaluate control relationship to parent, temporarily adjusting transformation for parent redraw. This translation must be relative since the incoming graphics may already have a meaningful transform applied. Dim translation As Point = Parent.RelationTo(Me) pevent.Graphics.Transform = New Drawing2D.Matrix(1, 0, 0, 1, initialTransform.OffsetX + translation.X, initialTransform.OffsetY + translation.Y) 'Fully draw parent background InvokePaintBackground(Parent, pevent) InvokePaint(Parent, pevent) 'Reset transform for sibling drawing pevent.Graphics.Transform = initialTransform 'Develop initial clip of submarined siblings Dim siblingClip As System.Drawing.Region = New System.Drawing.Region(initialClip.GetRegionData) siblingClip.Exclude(parentClip) For Each Control As Control In submarinedControls 'Define relative position of submarined sibling to self translation = Control.RelationTo(Me) 'Define and apply clip *before* transformation Dim intersectionClip As New Region(Control.RelativeClientRectangle(Me)) intersectionClip.Intersect(siblingClip) pevent.Graphics.Clip = intersectionClip 'Apply transformation pevent.Graphics.Transform = New Drawing2D.Matrix(1, 0, 0, 1, initialTransform.OffsetX + translation.X, initialTransform.OffsetY + translation.Y) 'Raise sibling control's paint events InvokePaintBackground(Control, pevent) InvokePaint(Control, pevent) 'Revert transformation and exclude region pevent.Graphics.Transform = initialTransform siblingClip.Exclude(intersectionClip) Next 'Revert transform and clip to pre-drawing state pevent.Graphics.Transform = initialTransform pevent.Graphics.Clip = initialClip End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload