/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Security.Permissions; using System.Drawing; namespace Aga.Controls.Tree { internal class ResizeColumnState: ColumnState { private Point _initLocation; private int _initWidth; public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p) : base(tree, column) { _initLocation = p; _initWidth = column.Width; } public override void KeyDown(KeyEventArgs args) { args.Handled = true; if (args.KeyCode == Keys.Escape) FinishResize(); } public override void MouseDown(TreeNodeAdvMouseEventArgs args) { } public override void MouseUp(TreeNodeAdvMouseEventArgs args) { FinishResize(); } private void FinishResize() { Tree.ChangeInput(); Tree.FullUpdate(); Tree.OnColumnWidthChanged(Column); } public override bool MouseMove(MouseEventArgs args) { Column.Width = _initWidth + args.Location.X - _initLocation.X; Tree.UpdateView(); return true; } public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) { Tree.AutoSizeColumn(Column); } } }