Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
AnswerRe: Design Time Events? Pin
Thomas Stockwell22-Mar-06 12:21
professionalThomas Stockwell22-Mar-06 12:21 
QuestionHow to slide a panel without flickering Pin
SJ_Phoenix4-Mar-06 7:48
SJ_Phoenix4-Mar-06 7:48 
AnswerRe: How to slide a panel without flickering Pin
AFSEKI4-Mar-06 9:36
AFSEKI4-Mar-06 9:36 
GeneralRe: How to slide a panel without flickering Pin
SJ_Phoenix4-Mar-06 10:09
SJ_Phoenix4-Mar-06 10:09 
GeneralRe: How to slide a panel without flickering Pin
Thomas Stockwell4-Mar-06 17:25
professionalThomas Stockwell4-Mar-06 17:25 
AnswerRe: How to slide a panel without flickering Pin
AFSEKI5-Mar-06 4:44
AFSEKI5-Mar-06 4:44 
GeneralRe: How to slide a panel without flickering Pin
AFSEKI5-Mar-06 4:47
AFSEKI5-Mar-06 4:47 
GeneralRe: How to slide a panel without flickering Pin
SJ_Phoenix5-Mar-06 10:36
SJ_Phoenix5-Mar-06 10:36 
Thank you for your help.....

it's better now...but with controls on it (like some standard buttons) when the panel grows (I mean when it sliders to the right) it still has some problems...

here is the code:

public partial class LeftSidedSliderPanel : Panel //, IMessageFilter
{
public static List<LeftSidedSliderPanel> allPanels = new List<LeftSidedSliderPanel>();
private int headerWidth = 30;
private bool animating = false;
private Timer slideEffectTimer;

public int HeaderWidth
{
get { return headerWidth; }
set { headerWidth = value; }
}

public LeftSidedSliderPanel()
{
InitializeComponent();
allPanels.Add(this);
this.Disposed += delegate { allPanels.Remove(this); };
this.DoubleBuffered = true;
// Application.AddMessageFilter(this);
}

public void Stop()
{
if (this.slideEffectTimer != null)
{
this.slideEffectTimer.Stop();

}

if (hoverTimer != null)
{
hoverTimer.Stop();
}


//preparing for more speed
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls[i].ResumeLayout();
}

animating = false;
}

private void StartSliding(int targetValue)
{
if (animating)
{
return;
}

this.animating = true;
this.SuspendLayout();

//preparing for more speed
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls[i].SuspendLayout();
}


this.slideEffectTimer = new Timer();
this.slideEffectTimer.Interval = 10;

int difference = 40;// 40;

if (this.Location.X > targetValue + difference) //get smaller
{
difference = 20;
}

int tempDifference = difference;


this.slideEffectTimer.Tick += delegate
{
if (difference <= 0)
{
difference = tempDifference;
}

if (this.Location.X > targetValue + difference) //get smaller
{
User32.MoveWindow(this.Handle, this.Location.X - difference, this.Location.Y, this.Width, this.Height, true);

difference++;
}
else
{
if (this.Location.X < targetValue - difference) //grow
{
User32.MoveWindow(this.Handle, this.Location.X + difference, this.Location.Y, this.Width, this.Height, true);

difference++; //--;
}
else // finnish effect
{
this.Location = new Point(targetValue, this.Location.Y);

this.Stop();
this.ResumeLayout();
this.Invalidate();
this.Refresh();
}
}
};



this.slideEffectTimer.Start();
}

public void Grow(bool withAnimation)
{
this.Stop();

for (int i = 0; i < allPanels.Count; i++)
{
if ((allPanels[i] != null) && (allPanels[i] != this))
{
allPanels[i].Stop();
allPanels[i].Collapse(false);
}
}

if (withAnimation)
{
this.StartSliding(0);
}
else
{
this.Location = new Point(0, this.Location.Y);
}
}

public void Collapse(bool withAnimation)
{
this.Stop();

if (withAnimation)
{
this.StartSliding(this.headerWidth - this.Width);
}
else
{
this.Location = new Point(this.headerWidth - this.Width, this.Location.Y);
}
}

protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);

if (this.Location.X == 0)
{
this.Stop();
return;
}

this.Grow(true);
}

protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);

if (animating)
{
return;
}

hoverTimer = new Timer();
hoverTimer.Interval = 1000;
hoverTimer.Tick += delegate { this.Collapse(true); hoverTimer.Stop(); };
hoverTimer.Start();
}

protected override void OnLayout(LayoutEventArgs levent)
{
base.OnLayout(levent);

if (!this.DesignMode)
{
this.Collapse(false);
}
}

protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
}

private Timer hoverTimer;

int painting = 0; //for animation

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
case 0x000F: // WM_PAINT
if (animating)
{
if (painting % 3 == 0)
{
m.Result = IntPtr.Zero;
}
painting++;
}
break;
}

base.WndProc(ref m);
}

}

QuestionClient-Activated Object Pin
Marcin-Dz4-Mar-06 5:37
Marcin-Dz4-Mar-06 5:37 
Questionhow to turn off system error when i add daplicated ID unique? Pin
superdragon3-Mar-06 23:54
superdragon3-Mar-06 23:54 
AnswerRe: how to turn off system error when i add daplicated ID unique? Pin
Thomas Stockwell4-Mar-06 17:29
professionalThomas Stockwell4-Mar-06 17:29 
QuestionHow to pass the parameters for a dll functiion that is imported in dotnet environment. Pin
varmag3-Mar-06 22:31
varmag3-Mar-06 22:31 
AnswerRe: How to pass the parameters for a dll functiion that is imported in dotnet environment. Pin
AFSEKI5-Mar-06 4:52
AFSEKI5-Mar-06 4:52 
QuestionProcess id=0x748 (1864), Thread id = ... error! Pin
eyej3-Mar-06 14:58
eyej3-Mar-06 14:58 
GeneralRe: Process id=0x748 (1864), Thread id = ... error! Pin
Guffa3-Mar-06 21:39
Guffa3-Mar-06 21:39 
AnswerRe: Process id=0x748 (1864), Thread id = ... error! Pin
mav.northwind3-Mar-06 22:16
mav.northwind3-Mar-06 22:16 
GeneralRe: Process id=0x748 (1864), Thread id = ... error! Pin
eyej4-Mar-06 3:58
eyej4-Mar-06 3:58 
GeneralRe: Process id=0x748 (1864), Thread id = ... error! Pin
mav.northwind4-Mar-06 4:57
mav.northwind4-Mar-06 4:57 
AnswerRe: Process id=0x748 (1864), Thread id = ... error! Pin
leppie4-Mar-06 4:59
leppie4-Mar-06 4:59 
QuestionWhen main thread working the Whole Form Freezes Pin
kourvoisier3-Mar-06 12:20
kourvoisier3-Mar-06 12:20 
AnswerRe: When main thread working the Whole Form Freezes Pin
Sean893-Mar-06 13:16
Sean893-Mar-06 13:16 
AnswerRe: When main thread working the Whole Form Freezes Pin
Office Lineman3-Mar-06 13:36
Office Lineman3-Mar-06 13:36 
GeneralRe: When main thread working the Whole Form Freezes Pin
Sean893-Mar-06 14:09
Sean893-Mar-06 14:09 
AnswerRe: When main thread working the Whole Form Freezes Pin
LighthouseJ3-Mar-06 16:11
LighthouseJ3-Mar-06 16:11 
QuestionRS232 Serial Class with .NET 2.0 Pin
econner3-Mar-06 12:13
econner3-Mar-06 12:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.