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 void AutoSizeColumn(TreeColumn column)
		{
			if (!Columns.Contains(column))
				throw new ArgumentException("column");

			DrawContext context = new DrawContext();
			context.Graphics = Graphics.FromImage(new Bitmap(1, 1));
			context.Font = this.Font;
			int res = 0;
			for (int row = 0; row < RowCount; row++)
			{
				if (row < RowMap.Count)
				{
					int w = 0;
					TreeNodeAdv node = RowMap[row];
					foreach (NodeControl nc in NodeControls)
					{
						if (nc.ParentColumn == column)
							w += nc.GetActualSize(node, _measureContext).Width;
					}
					res = Math.Max(res, w);
				}
			}

			if (res > 0)
				column.Width = res;
		}
		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;
		}
        internal void SortColumn(TreeColumn column)
        {
            if (column == null)
            {
                return;
            }

            var nodes = ((TreeModel)Model).Nodes.ToList();

            nodes.Sort(delegate(Node node1, Node node2)
            {
                NodeControl nodeControl = NodeControls.FirstOrDefault(control => control.ParentColumn == column);
                if (nodeControl == null)
                {
                    return(0);
                }

                string propName = nodeControl.GetType().GetProperty("DataPropertyName").GetValue(nodeControl, null).ToString();

                object obj1   = node1.GetType().GetProperty(propName).GetValue(node1, null);
                object obj2   = node2.GetType().GetProperty(propName).GetValue(node2, null);
                string value1 = (obj1 == null) ? string.Empty : obj1.ToString();
                string value2 = (obj2 == null) ? string.Empty : obj2.ToString();

                return(column.SortOrder == SortOrder.Ascending ? value1.CompareTo(value2) : value2.CompareTo(value1));
            });

            ((TreeModel)Model).Nodes.Clear();
            foreach (var node in nodes)
            {
                ((TreeModel)Model).Nodes.Add(node);
            }

            Invalidate();
            Update();
            Refresh();
        }
Beispiel #5
0
 public ColumnState(TreeViewAdv tree, TreeColumn column)
     : base(tree)
 {
     _column = column;
 }
 public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p)
     : base(tree, column)
 {
     _initLocation = p;
     _initWidth = column.Width;
 }
Beispiel #7
0
 public ResizeColumnState(TreeViewAdv tree, TreeColumn column, Point p)
     : base(tree, column)
 {
     _initLocation = p;
     _initWidth    = column.Width;
 }
		internal int GetColumnX(TreeColumn column)
		{
			int x = -OffsetX;
			foreach (TreeColumn col in Columns)
			{
				if (col.IsVisible)
				{
					if (column == col)
						return x;
					else
						x += col.Width;
				}
			}
			return x;
		}
 internal void OnColumnReordered(TreeColumn column)
 {
     if (ColumnReordered != null)
         ColumnReordered(this, new TreeColumnEventArgs(column));
 }
 internal void OnColumnWidthChanged(TreeColumn column)
 {
     if (ColumnWidthChanged != null)
         ColumnWidthChanged(this, new TreeColumnEventArgs(column));
 }
        internal void SortColumn(TreeColumn column)
        {
            if (column == null)
                return;

            var nodes = ((TreeModel)Model).Nodes.ToList();
            nodes.Sort(delegate(Node node1, Node node2)
            {
                NodeControl nodeControl = NodeControls.FirstOrDefault(control => control.ParentColumn == column);
                if (nodeControl == null)
                    return 0;

                string propName = nodeControl.GetType().GetProperty("DataPropertyName").GetValue(nodeControl, null).ToString();

                object obj1 = node1.GetType().GetProperty(propName).GetValue(node1, null);
                object obj2 = node2.GetType().GetProperty(propName).GetValue(node2, null);
                string value1 = (obj1 == null) ? string.Empty : obj1.ToString();
                string value2 = (obj2 == null) ? string.Empty : obj2.ToString();

                return column.SortOrder == SortOrder.Ascending ? value1.CompareTo(value2) : value2.CompareTo(value1);
            });

            ((TreeModel)Model).Nodes.Clear();
            foreach (var node in nodes)
                ((TreeModel)Model).Nodes.Add(node);

            Invalidate();
            Update();
            Refresh();
        }
 internal void ChangeColumnWidth(TreeColumn column)
 {
     if (!(_input is ResizeColumnState))
     {
         FullUpdate();
         OnColumnWidthChanged(column);
     }
 }
		public ClickColumnState(TreeViewAdv tree, TreeColumn column, Point location)
			: base(tree, column)
		{
			_location = location;
		}
		private void UpdateToolTip(MouseEventArgs e)
		{
			TreeColumn col = GetColumnAt(e.Location);
			if (col != null)
			{
				if (col != _tooltipColumn)
					SetTooltip(col.TooltipText);
			}
			else
				DisplayNodesTooltip(e);
			_tooltipColumn = col;
		}
		public ColumnState(TreeViewAdv tree, TreeColumn column)
			: base(tree)
		{
			_column = column;
		}
 public TreeColumnEventArgs(TreeColumn column)
 {
     _column = column;
 }
        internal void OnColumnClicked(TreeColumn column)
        {
            if (AllowColumnSort)
            {
                if (column == null)
                    return;

                if (column.SortOrder == SortOrder.None)
                    column.SortOrder = SortOrder.Ascending;

                else if (column.SortOrder == SortOrder.Descending)
                    column.SortOrder = SortOrder.Ascending;

                else if (column.SortOrder == SortOrder.Ascending)
                    column.SortOrder = SortOrder.Descending;

                SortColumn(column);
            }

            if (ColumnClicked != null)
                ColumnClicked(this, new TreeColumnEventArgs(column));
        }
 public ClickColumnState(TreeViewAdv tree, TreeColumn column, Point location)
     : base(tree, column)
 {
     _location = location;
 }
 public TreeColumnEventArgs(TreeColumn column)
 {
     _column = column;
 }