Flexible TreeView Flexible TreeView


Support & Community

Mouse interaction

Previous Table of Contents Next

Every node control allows you to easily interact with the mouse to change the default behavior. To do that, inherit your node control class as stated below and override behavior for a mouse action that you need.

Example:

Here is the custom node control class draws red pixels on the own image when the mouse was clicked and moved over this node control.

class NodeImageActeractive : NodeImage
{
  private bool _clicked;
 
  protected override void MouseDown(MouseActionArgs pArgs, DrawContext pContext)
  {
    _clicked = true;
    //  pContext.Bounds contains the node control bounds rectangle.
    DrawPoint(pArgs.Node, pContext.Bounds, pArgs.Location);
  }
 
  protected override void MouseUp(MouseActionArgs pArgs)
  {
    _clicked = false;
  }
 
  protected override void MouseMove(MouseActionArgs pArgs, DrawContext pContext)
  {
    DrawPoint(pArgs.Node, pContext.Bounds, pArgs.Location);
  }
 
  void DrawPoint(Node pNode, Rectangle pBounds, Point pMouseLocation)
  {
    Bitmap bmp;
    Point pos;
 
    if (!_clicked)
      return;
 
    // calculate the pixel position inside the image.
    pos = pMouseLocation;
    pos.X= pBounds.Location.X;
    pos.Y= pBounds.Location.Y;
 
    bmp = GetValue<Bitmap>(pNode);
    bmp.SetPixel(pos .X, pos.Y, Color.Red);
    // notify and invalidate the treeview after node control changes.
    OnControlChanged(eNodeControlChangeType.Look);
  }
}
 
// use our node control.
NodeImageActeractive nc = new NodeImageActeractive();
nc.AttachTo(tree);
 
NodeWithImage n = new NodeWithImage(ourImage);       // where ourImage is an image to display inside a node.
n.AttachTo(tree);

Previous Top Next


Last news
Bookmark and Share
Use Flexible TreeView in WPF project
Sunday, 18 December 2011

Do you have a WPF project and want to use Flexible TreeView there? No problem!

Flexible TreeView v3.4
Friday, 16 December 2011

Flexible TreeView v3.4 maintenance release has been released.

Flexible TreeView v3.3
Friday, 23 September 2011

Flexible TreeView v3.3 maintenance release has been released. Separate assemblies for .NET 2.0, 4.0 and 4.0 Client Profile, HTML markup extension, etc.

Latest release

Version:
Release date:
3.4
Dec 16, 2011


Copyright © 2006-2012 ARMSoft. All rights reserved.