Transparent Panel control for DSOFramer. This eliminates the problem with DSOFramer not activating it's Tab.

This commit is contained in:
Rich 2008-02-26 16:16:30 +00:00
parent 7692c78ff0
commit f6bb58d4d4
2 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,36 @@
namespace Volian.Controls.Library
{
partial class TransPanel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,61 @@
using System;
using System.Drawing;
//using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
//using System.Data;
namespace Volian.Controls.Library
{
/// <summary>
/// Summary description for TransPanel.
/// </summary>
public partial class TransPanel : Panel
{
private string _Caption = "Inactive";
public string Caption
{
get { return _Caption; }
set { _Caption = value; InvalidateEx(); }
}
private int _Alpha = 128;
public int Alpha
{
get { return _Alpha; }
set { _Alpha = value; InvalidateEx(); }
}
public TransPanel()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}
protected void InvalidateEx()
{
if (Parent == null)
return;
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//do not allow the background to be painted
}
protected override void OnPaint(PaintEventArgs e)
{
SizeF txtSize = e.Graphics.MeasureString(_Caption, this.Font);
//Use a gray rectangle to show that the underlying control is inactive
//using (Brush b2 = new SolidBrush(Color.FromArgb(_Alpha, this.BackColor)))
// e.Graphics.FillRectangle(b2, this.ClientRectangle);
using (Brush b = new SolidBrush(Color.FromArgb(_Alpha, this.ForeColor)))
e.Graphics.DrawString(_Caption, this.Font, b, this.Width - txtSize.Width, 2);
}
}
}