Shows popup dialog with UI to rename content item. The item to rename. The created renaming popup.
(ContentItem item)
| 588 | /// <param name="item">The item to rename.</param> |
| 589 | /// <returns>The created renaming popup.</returns> |
| 590 | public void Rename(ContentItem item) |
| 591 | { |
| 592 | if (!item.CanRename) |
| 593 | return; |
| 594 | |
| 595 | // Show element in the view |
| 596 | Select(item, true); |
| 597 | |
| 598 | // Disable scrolling in proper view |
| 599 | _renameInTree = _showAllContentInTree; |
| 600 | if (_renameInTree) |
| 601 | { |
| 602 | if (_contentTreePanel.VScrollBar != null) |
| 603 | _contentTreePanel.VScrollBar.ThumbEnabled = false; |
| 604 | if (_contentTreePanel.HScrollBar != null) |
| 605 | _contentTreePanel.HScrollBar.ThumbEnabled = false; |
| 606 | ScrollingOnTreeView(false); |
| 607 | } |
| 608 | else |
| 609 | { |
| 610 | if (_contentViewPanel.VScrollBar != null) |
| 611 | _contentViewPanel.VScrollBar.ThumbEnabled = false; |
| 612 | if (_contentViewPanel.HScrollBar != null) |
| 613 | _contentViewPanel.HScrollBar.ThumbEnabled = false; |
| 614 | ScrollingOnContentView(false); |
| 615 | } |
| 616 | |
| 617 | // Show rename popup |
| 618 | RenamePopup popup; |
| 619 | if (_renameInTree) |
| 620 | { |
| 621 | TreeNode node = null; |
| 622 | if (item is ContentFolder folder) |
| 623 | node = folder.Node; |
| 624 | else if (item.ParentFolder != null) |
| 625 | node = FindTreeItemNode(item.ParentFolder.Node, item); |
| 626 | if (node == null) |
| 627 | { |
| 628 | // Fallback to content view rename |
| 629 | popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | var area = node.TextRect; |
| 634 | const float minRenameWidth = 220.0f; |
| 635 | if (area.Width < minRenameWidth) |
| 636 | area.Width = minRenameWidth; |
| 637 | area.Y -= 2; |
| 638 | area.Height += 4.0f; |
| 639 | popup = RenamePopup.Show(node, area, item.ShortName, true); |
| 640 | } |
| 641 | } |
| 642 | else |
| 643 | { |
| 644 | popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); |
| 645 | } |
| 646 | popup.Tag = item; |
| 647 | popup.Validate += OnRenameValidate; |
nothing calls this directly
no test coverage detected