External/Aga.Controls/Tree/Input/ResizeColumnState.cs
author StephaneLenclud
Sun, 03 Feb 2013 18:01:50 +0100
branchMiniDisplay
changeset 433 090259cfd699
permissions -rw-r--r--
Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
     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 }