1. Гость, мы просим Вас ознакомиться с Правилами Форума и Отказом от ответственности!

Результаты поиска

  1. Wrechid
  2. Wrechid
  3. Wrechid
    multi selecting many tasks seems difficult, here is a simple method i added for using SHIFT and CTRL keys to the MainWindow.cs : //(c)Rey35 .... .... .... namespace sTASKedit { public partial class MainWindow : Form { .... .... .... List<TreeNode> selectedNodes; TreeNode previousNode; #endregion public MainWindow(string FileName, int TaskIdSpace, int TaskId) { if (File.Exists(Application.StartupPath + "\\configs\\config.ini")) { selectedNodes = new List<TreeNode>(); .... .... .... } } .... .... .... // add this to BeforeSelect private void treeView_tasks_BeforeSelect(object sender, TreeViewCancelEventArgs e) { e.Cancel = true; } // add this to MouseClick private void treeView_tasks_MouseClick(object sender, MouseEventArgs e) { TreeNode currentNode = treeView_tasks.GetNodeAt(e.Location); bool control = (ModifierKeys == Keys.Control); bool shift = (ModifierKeys == Keys.Shift); if (control) { List<TreeNode> addedNodes = new List<TreeNode>(); List<TreeNode> removedNodes = new List<TreeNode>(); if (!selectedNodes.Contains(currentNode)) { addedNodes.Add(currentNode); previousNode = currentNode; } else { removedNodes.Add(currentNode); } changeSelection(addedNodes, removedNodes); } else if (shift && previousNode != null) { if (currentNode.Parent == previousNode.Parent) { List<TreeNode> addedNodes = new List<TreeNode>(); List<TreeNode> removedNodes = new List<TreeNode>(); bool selection = false; bool selectionEnd = false; TreeNodeCollection nodes = null; if (previousNode.Parent == null) { nodes = treeView_tasks.Nodes; } else { nodes = previousNode.Parent.Nodes; } foreach (TreeNode n in nodes) { if (n == currentNode || n == previousNode) { if (selection) { selectionEnd = true; } if (!selection) { selection = true; } } if (selection && !selectedNodes.Contains(n)) { addedNodes.Add(n); } if (selectionEnd) { break; } } if (addedNodes.Count > 0) { changeSelection(addedNodes, removedNodes); } } } else { if (!currentNode.Checked) { List<TreeNode> addedNodes = new List<TreeNode>(); List<TreeNode> removedNodes = new List<TreeNode>(); removedNodes.AddRange(selectedNodes); if (removedNodes.Contains(currentNode)) { removedNodes.Remove(currentNode); } else { addedNodes.Add(currentNode); } changeSelection(addedNodes, removedNodes); previousNode = currentNode; } } } protected void changeSelection(List<TreeNode> addedNodes, List<TreeNode> removedNodes) { foreach (TreeNode n in addedNodes) { if (!n.Checked) { n.Checked = true; selectedNodes.Add(n); } } foreach (TreeNode n in removedNodes) { n.Checked = false; selectedNodes.Remove(n); } } } } //(c)Rey35 just an idea... :)
    Сообщение от: Wrechid, 13 фев 2019 в разделе: PW Разработки
  4. Wrechid
  5. Wrechid
  6. Wrechid
  7. Wrechid
  8. Wrechid
  9. Wrechid
  10. Wrechid