protected virtual void OnRowHeightChanged(JetListViewNode node, int oldHeight, int newHeight) { if (RowHeightChanged != null) { RowHeightChanged(this, new RowHeightChangedEventArgs(node, oldHeight, newHeight)); } }
protected internal override Rectangle GetFocusRect(JetListViewNode itemNode, Rectangle rc) { Rectangle rcFocus; int curX = -_scrollOffset + _borderSize; int selWidth = GetTotalColumnWidth(); bool inIndent = false; ColumnWidthEnumerator fixedColEnumerator = new ColumnWidthEnumerator(_columnCollection, itemNode); while (fixedColEnumerator.MoveNext()) { if (IsValueColumn(fixedColEnumerator.Current)) { break; } if (fixedColEnumerator.Current.IsIndentColumn()) { inIndent = true; } curX += fixedColEnumerator.CurrentWidth; if (!inIndent || !fixedColEnumerator.Current.FixedSize) { selWidth -= fixedColEnumerator.CurrentWidth; } } rcFocus = new Rectangle(curX, rc.Top, selWidth, rc.Height); return(rcFocus); }
private void RemoveNode(JetListViewNode parentNode, JetListViewNode childNode) { ClearChildren(childNode); CollapseState oldCollapseState = parentNode.CollapseState; OnNodeRemoving(childNode); if (IsNodeVisible(childNode)) { OnVisibleNodeRemoving(childNode); } parentNode.RemoveChild(childNode); _nodeMap.Remove(childNode.Data, parentNode); OnNodeRemoved(childNode); if (IsNodeVisible(childNode)) { OnVisibleNodeRemoved(childNode); } if (parentNode != _rootNode && IsNodeVisible(parentNode) && oldCollapseState != parentNode.CollapseState) { OnNodeChanged(parentNode); } }
public JetListViewNode GetLastChild(bool needExpanded) { if (ChildCount == 0) { return(null); } JetListViewNode node = null; for (int i = _children.Count - 1; i >= 0; i--) { if (((JetListViewNode)_children [i]).FiltersAccept) { node = (JetListViewNode)_children [i]; break; } } if (node != null && node.ChildCount > 0) { if (needExpanded && node.CollapseState == CollapseState.Collapsed) { return(node); } JetListViewNode nodeChild = node.GetLastChild(needExpanded); if (nodeChild != null) { return(nodeChild); } } return(node); }
public void Remove(object item, JetListViewNode parentNode) { lock (this) { _lastUpdatedNode = null; if (parentNode == null) { parentNode = _rootNode; } JetListViewNode[] childNodes = _nodeMap.NodesFromItem(item); if (childNodes.Length == 0) { throw new ArgumentException("Trying to remove item which was not added", "item"); } int removedNodes = 0; for (int i = 0; i < childNodes.Length; i++) { if (childNodes [i].Parent == parentNode) { RemoveNode(parentNode, childNodes [i]); removedNodes++; } } if (removedNodes == 0) { throw new ArgumentException("Trying to remove item from wrong parent"); } } }
public IVisibleNodeEnumerator GetDirectionalEnumerator(IViewNode startNode, MoveDirection direction) { Guard.NullArgument(startNode, "startNode"); JetListViewNode startLvNode = startNode as JetListViewNode; if (startLvNode != null) { return(new GroupedItemEnumerator(this, _nodeCollection.GetDirectionalEnumerator(startLvNode, direction), direction, (direction == MoveDirection.Down))); } GroupHeaderNode startHeaderNode = startNode as GroupHeaderNode; Debug.Assert(startHeaderNode.TopNode != null); if (startHeaderNode.TopNode == null) { return(new GroupedItemEnumerator(this, new EmptyEnumerator(), direction, false)); } GroupedItemEnumerator enumerator = new GroupedItemEnumerator(this, _nodeCollection.GetDirectionalEnumerator(startHeaderNode.TopNode, direction), direction, false); if (direction == MoveDirection.Up) { // move from first node of current group to last node of previous group enumerator.MoveNext(); } return(enumerator); }
protected internal override Rectangle GetFocusRect(JetListViewNode itemNode, Rectangle rc) { MultiLineColumnScheme scheme = _columnSchemeProvider.GetColumnScheme(itemNode.Data); int indent = GetRowIndent(itemNode, scheme); return(new Rectangle(_borderSize + indent, rc.Top, _visibleWidth - _borderSize - indent, rc.Height)); }
private void ProcessViewNodeRemoving(JetListViewNode node) { if (node.Level == 0) { string nodeGroup = _groupProvider.GetGroupName(node.Data); GroupHeaderNode nodeGroupHeader = (GroupHeaderNode)_groupMap [nodeGroup]; if (nodeGroupHeader != null) { bool haveSameGroup = false; int index = _nodeCollection.Root.IndexOf(node); if (index > 0) { JetListViewNode prevNode = _nodeCollection.Root.Nodes [index - 1]; if (_groupProvider.GetGroupName(prevNode.Data) == nodeGroup) { haveSameGroup = true; } } if (!haveSameGroup && index < _nodeCollection.Root.ChildCount - 1) { JetListViewNode nextNode = _nodeCollection.Root.Nodes [index + 1]; if (_groupProvider.GetGroupName(nextNode.Data) == nodeGroup) { haveSameGroup = true; } } if (!haveSameGroup) { RemoveGroup(nodeGroupHeader); } } } }
public bool MoveNext() { while (true) { if (!MoveNextStep()) { return(false); } if (!_skipFiltered) { return(true); } JetListViewNode curNode = (JetListViewNode)Current; if (_minLevel != -1 && curNode.Level < _minLevel) { return(false); } if (curNode.FiltersAccept) { return(true); } } }
private void DrawNodeRow(Graphics g, Rectangle rectangle, JetListViewNode itemNode, ref int curY) { int itemBaseHeight = _rowRenderer.GetRowHeight(itemNode); int itemHeight = itemBaseHeight; if (_rowDelimiters) { itemHeight++; } if (curY + itemHeight >= rectangle.Top) { Rectangle rcRow = new Rectangle(rectangle.Left, curY, rectangle.Width, itemBaseHeight); if (_rowRenderer != null) { _rowRenderer.DrawRow(g, rcRow, itemNode, GetRowState(itemNode)); } if (_rowDelimiters) { g.DrawLine(SystemPens.Control, rectangle.Left, curY + itemBaseHeight, rectangle.Width, curY + itemBaseHeight); } // Draw an insertion mark if the current row is the insertion drop target (for insertion either above or below) if ((itemNode == _dropTargetRow) && ((_dropTargetRenderMode & DropTargetRenderMode.InsertAny) != 0)) { DrawInsertMark(g, rcRow); } } curY += itemHeight; }
public int Compare(object x, object y) { JetListViewNode node1 = (JetListViewNode)x; JetListViewNode node2 = (JetListViewNode)y; return(_baseComparer.Compare(node1.Data, node2.Data)); }
public bool IncrementalSearchNext(string text, MoveDirection dir) { JetListViewNode curNode = _selection.ActiveNode; IEnumerator enumerator = (dir == MoveDirection.Down) ? _nodeCollection.EnumerateNodesForward(curNode) : _nodeCollection.EnumerateNodesBackward(curNode); enumerator.MoveNext(); if (SearchEnumerator(text, enumerator, null)) { return(true); } JetListViewNode startNode = (dir == MoveDirection.Down) ? _nodeCollection.Nodes [0] : _nodeCollection.LastNode; if (curNode == startNode) { return(false); } enumerator = _nodeCollection.GetDirectionalEnumerator(startNode, dir); return(SearchEnumerator(text, enumerator, curNode)); }
internal void AddChild(JetListViewNode itemNode) { itemNode._parent = this; if (_children == null) { _children = new ArrayList(); } IComparer comparer = _owner.GetNodeComparer(this); lock ( _children ) { if (comparer == null) { _children.Add(itemNode); } else { int index = _children.BinarySearch(itemNode, comparer); if (index < 0) { index = ~index; } _children.Insert(index, itemNode); } } _flags &= 0xfb; if (!itemNode.FiltersAccept) { _unacceptedChildCount++; } }
protected internal void OnExpandChanging(JetListViewNode node) { if (NodeExpandChanging != null) { NodeExpandChanging(this, new JetListViewNodeEventArgs(node)); } }
public MoveDirection GetMoveDirection(IViewNode startNode, IViewNode endNode) { JetListViewNode startLvNode = startNode as JetListViewNode; if (startLvNode == null) { GroupHeaderNode startHeaderNode = (GroupHeaderNode)startNode; startLvNode = startHeaderNode.TopNode; } JetListViewNode endLvNode = endNode as JetListViewNode; if (endLvNode == null) { GroupHeaderNode endHeaderNode = (GroupHeaderNode)endNode; endLvNode = endHeaderNode.TopNode; } int orderDiff = _nodeCollection.CompareVisibleOrder(startLvNode, endLvNode); if (orderDiff == 0 && startNode is GroupHeaderNode && !(endNode is GroupHeaderNode)) { return(MoveDirection.Down); } return((orderDiff < 0) ? MoveDirection.Down : MoveDirection.Up); }
private void OnNodeAdded(JetListViewNode node) { if (NodeAdded != null) { NodeAdded(this, new JetListViewNodeEventArgs(node)); } }
private void OnNodeRemoved(JetListViewNode childNode) { if (NodeRemoved != null) { NodeRemoved(this, new JetListViewNodeEventArgs(childNode)); } }
internal int CompareVisibleOrder(JetListViewNode lhs, JetListViewNode rhs) { JetListViewNode origLhs = lhs; JetListViewNode origRhs = rhs; if (lhs == rhs) { return(0); } while (lhs.Level > rhs.Level) { lhs = lhs.Parent; } while (rhs.Level > lhs.Level) { rhs = rhs.Parent; } while (lhs.Parent != rhs.Parent) { lhs = lhs.Parent; rhs = rhs.Parent; } if (lhs == rhs) { return(origLhs.Level - origRhs.Level); } int lhsIndex = lhs.Parent.IndexOf(lhs); int rhsIndex = rhs.Parent.IndexOf(rhs); return(lhsIndex - rhsIndex); }
public virtual string GetToolTip(JetListViewNode node, Rectangle rc, ref bool needPlace) { string toolTip = null; if (_itemToolTipCallback != null) { toolTip = _itemToolTipCallback(node.Data); } if (OwnerControl != null && OwnerControl.AutoToolTips && GetTextWidth(node.Data, rc.Width) > rc.Width) { if (toolTip == null || toolTip.Length == 0) { toolTip = GetItemText(node.Data, rc.Width); } else { toolTip = GetItemText(node.Data, rc.Width) + " (" + toolTip + ")"; } } else { needPlace = false; } return(toolTip); }
public bool IncrementalSearch(string text) { if (_nodeCollection.Nodes.Count == 0) { return(false); } JetListViewNode startNode = _selection.ActiveNode; if (startNode == null) { startNode = _nodeCollection.Nodes [0]; } lock ( _nodeCollection ) { if (SearchEnumerator(text, _nodeCollection.EnumerateVisibleNodesForward(startNode), null)) { return(true); } if (startNode != _nodeCollection.Nodes [0]) { return(SearchEnumerator(text, _nodeCollection.EnumerateVisibleNodesForward(_nodeCollection.Nodes [0]), startNode)); } } return(false); }
public override void DrawRow(Graphics g, Rectangle rc, JetListViewNode itemNode, RowState state) { MultiLineColumnScheme scheme = _columnSchemeProvider.GetColumnScheme(itemNode.Data); int indent = GetRowIndent(itemNode, scheme); Rectangle rcFocus = GetFocusRect(itemNode, rc); bool focusRow = false, dropTargetRow = false; if (((state & RowState.Focused) != 0 && _searchHighlightText != null && _searchHighlightText.Length > 0)) { state |= RowState.IncSearchMatch; } if (_fullRowSelect) { FillFullRowSelectBar(g, rcFocus, state); } ClearRowSelectState(ref state, ref focusRow, ref dropTargetRow); foreach (MultiLineColumnSetting setting in scheme.ColumnSettings) { if (_fullRowSelect) { if ((state & RowState.IncSearchMatch) != 0 && (state & RowState.ActiveSelected) != 0) { state &= ~RowState.ActiveSelected; state |= RowState.InactiveSelected; } } _lastTextColor = setting.TextColor; _lastItemColorCallback = setting.Column.ForeColorCallback; _lastItemFontCallback = setting.Column.FontCallback; if ((state & (RowState.ActiveSelected | RowState.InactiveSelected)) == 0) { setting.Column.ForeColorCallback = new ItemColorCallback(GetColumnForeColor); } HorizontalAlignment lastAlignment = setting.Column.Alignment; int oldMargin = setting.Column.RightMargin; setting.Column.Alignment = setting.TextAlign; if (setting.TextAlign == HorizontalAlignment.Right) { setting.Column.RightMargin = 5; } Rectangle rcCol = GetRectangleFromSetting(scheme, setting, indent); rcCol.Offset(_borderSize, rc.Top); DrawColumnWithHighlight(g, rcCol, itemNode, setting.Column, state); setting.Column.ForeColorCallback = _lastItemColorCallback; setting.Column.Alignment = lastAlignment; setting.Column.RightMargin = oldMargin; } DrawRowSelectRect(g, rcFocus, dropTargetRow, focusRow); }
private void RecalcColumnWidth(ProcessSizeToContentColumnDelegate callback, JetListViewNode paramNode) { if (_sizeToContentColumnCount > 0) { int fixedWidth = 0; JetListViewColumn indentCol = null; for (int i = 0; i < _columnCollection.Count; i++) { JetListViewColumn col = _columnCollection [i]; if (col.IsIndentColumn()) { indentCol = col; } if (col.FixedSize && indentCol != null) { fixedWidth += col.Width; } if (col.SizeToContent) { callback(col, indentCol, fixedWidth, paramNode); } if (!col.FixedSize && !col.IsIndentColumn()) { indentCol = null; fixedWidth = 0; } } UpdateScrollRange(); } }
private void RecalcOnNodeAdded(JetListViewColumn col, JetListViewColumn indentCol, int fixedWidth, JetListViewNode paramNode) { int desiredWidth = GetDesiredWidthIndented(col, indentCol, paramNode, fixedWidth); col.Width = Math.Max(col.Width, desiredWidth); }
protected internal override int GetWidthDelta(JetListViewNode node) { if (GetItemCheckState(node.Data) == CheckBoxState.Hidden) { return(-Width); } return(base.GetWidthDelta(node)); }
private void SortRecursive(JetListViewNode node) { node.SortChildren(GetNodeComparer(node)); for (int i = 0; i < node.ChildCount; i++) { SortRecursive(node.GetChildNode(i)); } }
public JetListViewDragEventArgs(DragEventArgs e, JetListViewNode dropTargetNode, DropTargetRenderMode dropTargetRenderMode, int localY, int rowHeight) : base(e.Data, e.KeyState, e.X, e.Y, e.AllowedEffect, e.Effect) { _dropTargetNode = dropTargetNode; _dropTargetRenderMode = dropTargetRenderMode; _localY = localY; _rowHeight = rowHeight; }
public int IndexOf(JetListViewNode itemNode) { if (_children == null) { return(-1); } return(_children.IndexOf(itemNode)); }
public override bool HandleDoubleClick(JetListViewNode node) { if (node.HasChildren) { node.Expanded = !node.Expanded; return(true); } return(false); }
public void SetItemComparer(object parentItem, IComparer comparer) { JetListViewNode node = ParentNodeFromItem(parentItem); lock ( _comparerMap ) { _comparerMap [node] = new NodeComparer(comparer); } }
public bool HandleNodeKeyDown(JetListViewNode viewNode, KeyEventArgs e) { if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.Left) { _groupCollection.GetNodeGroupHeader(viewNode).Expanded = false; return(true); } return(false); }