External/Aga.Controls/Tree/Input/ResizeColumnState.cs
author moel.mich
Sun, 27 May 2012 15:16:19 +0000
changeset 345 0c551e8818e0
permissions -rw-r--r--
Added the source code of Aga.Controls (TreeViewAdv for .Net) version 1.7.0.0.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Windows.Forms;
     5 using System.Security.Permissions;
     6 using System.Drawing;
     7 
     8 namespace Aga.Controls.Tree
     9 {
    10 	internal class ResizeColumnState: ColumnState
    11 	{
    12 		private Point _initLocation;
    13 		private int _initWidth;
    14 
    15 		public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p)
    16 			: base(tree, column)
    17 		{
    18 			_initLocation = p;
    19 			_initWidth = column.Width;
    20 		}
    21 
    22 		public override void KeyDown(KeyEventArgs args)
    23 		{
    24 			args.Handled = true;
    25 			if (args.KeyCode == Keys.Escape)
    26 				FinishResize();
    27 		}
    28 
    29 		public override void MouseDown(TreeNodeAdvMouseEventArgs args)
    30 		{
    31 		}
    32 
    33 		public override void MouseUp(TreeNodeAdvMouseEventArgs args)
    34 		{
    35 			FinishResize();
    36 		}
    37 
    38 		private void FinishResize()
    39 		{
    40 			Tree.ChangeInput();
    41 			Tree.FullUpdate();
    42 			Tree.OnColumnWidthChanged(Column);
    43 		}
    44 
    45         public override bool MouseMove(MouseEventArgs args)
    46         {
    47 			Column.Width = _initWidth + args.Location.X - _initLocation.X;
    48             Tree.UpdateView();
    49             return true;
    50         }
    51 
    52 		public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args)
    53 		{
    54 			Tree.AutoSizeColumn(Column);
    55 		}
    56 	}
    57 }