ReorderColumnState.cs :  » GUI » TreeViewAdv » Aga » Controls » Tree » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » TreeViewAdv 
TreeViewAdv » Aga » Controls » Tree » ReorderColumnState.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace Aga.Controls.Tree{
  internal class ReorderColumnState : ColumnState
  {
    #region Properties

    private Point _location;
    public Point Location
    {
      get { return _location; }
    }

    private Bitmap _ghostImage;
    public Bitmap GhostImage
    {
      get { return _ghostImage; }
    }

    private TreeColumn _dropColumn;
    public TreeColumn DropColumn
    {
      get { return _dropColumn; }
    }

    private int _dragOffset;
    public int DragOffset
    {
      get { return _dragOffset; }
    }

    #endregion

    public ReorderColumnState(TreeViewAdv tree, TreeColumn column, Point initialMouseLocation)
      : base(tree, column)
    {
      _location = new Point(initialMouseLocation.X + Tree.OffsetX, 0);
      _dragOffset = tree.GetColumnX(column) - initialMouseLocation.X;
      _ghostImage = column.CreateGhostImage(new Rectangle(0, 0, column.Width, tree.ColumnHeaderHeight), tree.Font);
    }

    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();
    }

    public override bool MouseMove(MouseEventArgs args)
    {
      _dropColumn = null;
      _location = new Point(args.X + Tree.OffsetX, 0);
      int x = 0;
      foreach (TreeColumn c in Tree.Columns)
      {
        if (c.IsVisible)
        {
          if (_location.X < x + c.Width / 2)
          {
            _dropColumn = c;
            break;
          }
          x += c.Width;
        }
      }
      Tree.UpdateHeaders();
      return true;
    }

    private void FinishResize()
    {
      Tree.ChangeInput();
      if (Column == DropColumn)
        Tree.UpdateView();
      else
      {
        Tree.Columns.Remove(Column);
        if (DropColumn == null)
          Tree.Columns.Add(Column);
        else
          Tree.Columns.Insert(Tree.Columns.IndexOf(DropColumn), Column);

        Tree.OnColumnReordered(Column);
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.