External/Aga.Controls/Tree/Input/ResizeColumnState.cs
changeset 345 0c551e8818e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/External/Aga.Controls/Tree/Input/ResizeColumnState.cs	Sun May 27 15:16:19 2012 +0000
     1.3 @@ -0,0 +1,57 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.Text;
     1.7 +using System.Windows.Forms;
     1.8 +using System.Security.Permissions;
     1.9 +using System.Drawing;
    1.10 +
    1.11 +namespace Aga.Controls.Tree
    1.12 +{
    1.13 +	internal class ResizeColumnState: ColumnState
    1.14 +	{
    1.15 +		private Point _initLocation;
    1.16 +		private int _initWidth;
    1.17 +
    1.18 +		public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p)
    1.19 +			: base(tree, column)
    1.20 +		{
    1.21 +			_initLocation = p;
    1.22 +			_initWidth = column.Width;
    1.23 +		}
    1.24 +
    1.25 +		public override void KeyDown(KeyEventArgs args)
    1.26 +		{
    1.27 +			args.Handled = true;
    1.28 +			if (args.KeyCode == Keys.Escape)
    1.29 +				FinishResize();
    1.30 +		}
    1.31 +
    1.32 +		public override void MouseDown(TreeNodeAdvMouseEventArgs args)
    1.33 +		{
    1.34 +		}
    1.35 +
    1.36 +		public override void MouseUp(TreeNodeAdvMouseEventArgs args)
    1.37 +		{
    1.38 +			FinishResize();
    1.39 +		}
    1.40 +
    1.41 +		private void FinishResize()
    1.42 +		{
    1.43 +			Tree.ChangeInput();
    1.44 +			Tree.FullUpdate();
    1.45 +			Tree.OnColumnWidthChanged(Column);
    1.46 +		}
    1.47 +
    1.48 +        public override bool MouseMove(MouseEventArgs args)
    1.49 +        {
    1.50 +			Column.Width = _initWidth + args.Location.X - _initLocation.X;
    1.51 +            Tree.UpdateView();
    1.52 +            return true;
    1.53 +        }
    1.54 +
    1.55 +		public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args)
    1.56 +		{
    1.57 +			Tree.AutoSizeColumn(Column);
    1.58 +		}
    1.59 +	}
    1.60 +}