|
using System;
using System.Windows.Forms;
using System.Drawing;
namespace Sarafian.Framework.ClientSide.UI.Resources.HorizontalTree.NodeParts
{
public class PartSelect : PartBase
{
static PartSelect()
{
dropedImage = Sarafian.Framework.ClientSide.UI.Resources.HorizontalTree.Properties.Resources.DisplaySelector;
dropImage = (Bitmap)dropedImage.Clone();
dropImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
}
protected static Bitmap dropImage = null;
protected static Bitmap dropedImage = null;
public PartSelect()
{
}
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
RenderImage(pevent.Graphics);
}
protected virtual Image GetImageToDraw()
{
Image image = null;
switch (base.State)
{
case DelegateEnum.ControlPartStates.Hot:
image = dropImage;
break;
case DelegateEnum.ControlPartStates.Normal:
image = dropImage;
break;
case DelegateEnum.ControlPartStates.Pressed:
image = dropedImage;
break;
}
return image;
}
private void RenderImage(Graphics g)
{
Rectangle bounds = Sarafian.Framework.General.Drawing.Rectangle.CenterRectangles(new Rectangle(Point.Empty, dropImage.Size), base.ClientRectangle);
Image imageToDraw = GetImageToDraw();
g.DrawImageUnscaled(imageToDraw, bounds);
}
private DelegateEnum.ControlPartStates stateBeforeDown;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
this.stateBeforeDown = base.State;
State = DelegateEnum.ControlPartStates.Pressed;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
if (this.stateBeforeDown == DelegateEnum.ControlPartStates.Pressed)
{
State = DelegateEnum.ControlPartStates.Hot;
}
else
{
CallPartClicked();
}
}
protected override void otherPart_StateChanged()
{
switch (base.OtherPart.State)
{
case DelegateEnum.ControlPartStates.Normal:
SetState(DelegateEnum.ControlPartStates.Normal);
break;
case DelegateEnum.ControlPartStates.Hot:
SetState(DelegateEnum.ControlPartStates.Hot);
break;
case DelegateEnum.ControlPartStates.Pressed:
SetState(DelegateEnum.ControlPartStates.Pressed);
break;
}
}
}
}
|
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.
I live in Athens Greece and currently I am working with Business scale application with .NET latest technologies
I've been developing applications for personal and friends usage with C++ using majorly Borland's various IDEs since 1994.
In 2002 I began working for an R&D institute where I was introduced to C# which I worships ever since.
I love core application development and I would like to publish more articles here and on my blog, but there is not enough time to do so.
I usualy "waste" my spare time watching sitcoms, preferable SCI-FI.
I would like to play chess but I can't find any real world players to hang out with.