|
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Threading;
namespace TreeView
{
/// <summary>
/// Summary description for SdeTabPage.
/// </summary>
public class SdeTabPage : System.Windows.Forms.UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private string m_image = null;
private string m_text = null;
private bool m_selected = false;
public bool IsSelected
{
get
{
return m_selected;
}
set
{
m_selected = value;
}
}
private SdeTabPage()
{
}
public SdeTabPage( string image, string text )
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
m_image = image;
m_text = text;
this.MouseEnter += new System.EventHandler(Ctrl_OnMouseEnter);
this.MouseHover += new System.EventHandler(On_MouseHover);
this.MouseLeave += new System.EventHandler(onMouseLeave);
// TODO: Add any initialization after the InitForm call
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
DrawSideStrips();
}
public void DrawSideStrips()
{
Graphics g = this.CreateGraphics();
g.Clear(this.BackColor);
Image sampleImage = (Image) Resources.GetBitmap(m_image);
if (IsSelected)
{
//g.DrawLine(new Pen(SystemBrushes.ControlDark), 0,30,25,30);
//g.FillRectangle(SystemBrushes.ControlLight,2,2,this.Width-4,this.Height-4);
g.DrawString(m_text,new Font("Arial",8.0f),SystemBrushes.ControlDarkDark,5,25,new StringFormat(StringFormatFlags.DirectionVertical));
this.Height = 120;
}
else
{
this.Height = 21;
}
g.DrawImage(sampleImage,5,3);
ControlPaint.DrawBorder3D(g,0,0,this.Width,this.Height,Border3DStyle.Flat);
}
public void Ctrl_OnMouseEnter(object sender,EventArgs args)
{
this.IsSelected = true;
Point locate = new Point(2,2);
foreach ( Control ctrl in this.Parent.Controls )
{
SdeTabPage temp = (SdeTabPage)ctrl;
if ( this != temp )
{
temp.IsSelected = false;
}
ctrl.Location = locate;
temp.DrawSideStrips();
locate.Y += ctrl.Height ;
locate.Y -=1;
// ctrl.Invalidate();
}
}
public void On_MouseHover(object sender, EventArgs args)
{
Form1 myform = (Form1)Form1.ActiveForm;
for(int i= 0; i<=150; i+=10)
{
Thread.Sleep(10);
myform.panel1.AutoScroll = false;
myform.panel1.Width = i;
}
}
private void onMouseLeave(object sender, System.EventArgs e)
{
Form1 myform = (Form1)Form1.ActiveForm;
Thread.Sleep(500);
for(int i= 150; i>= 0; i-=10)
{
Thread.Sleep(10);
myform.panel1.AutoScroll = false;
myform.panel1.Width = i;
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(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()
{
//
// SdeTabPage
//
this.BackColor = System.Drawing.SystemColors.ControlLight;
this.Name = "SdeTabPage";
this.Size = new System.Drawing.Size(25, 120);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.