void ProcessFileNode(TreeNode node) { SEItem shellEx = (SEItem)node.Tag; //reconstruct full (File not treeView) path string newPath = (node.Index * spaceBetweenItems).ToString("D2") + "." + shellEx.GetLogicalFileName(); TreeNode child = node; TreeNode parent; while ((parent = child.Parent) != null) { newPath = Path.Combine((parent.Index * spaceBetweenItems).ToString("D2") + "." + (parent.Tag as SEItem).GetLogicalFileName(), newPath); child = parent; } newPath = Path.Combine(baseDirectory, newPath); //Trace.WriteLine(newPath); if (newPath != shellEx.location) { if (!Directory.Exists(Path.GetDirectoryName(newPath))) { Directory.CreateDirectory(Path.GetDirectoryName(newPath)); } File.Move(shellEx.location, newPath); } }
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e) { SEItem item = (SEItem)e.Node.Tag; Brush b = Brushes.Black; if (item.isConsole) { b = Brushes.Blue; } if (!item.Enabled) { b = Brushes.Gray; } else { TreeNode parent = e.Node.Parent; while (parent != null) { if (!parent.Checked) { b = Brushes.Gray; break; } parent = parent.Parent; } } Rectangle frame = e.Bounds; if ((e.State & TreeNodeStates.Selected) != 0) { frame.Width = (int)e.Graphics.MeasureString(item.ToString(), treeView1.Font).Width; e.Graphics.FillRectangle(TreeViewBackBrush, frame); frame.Inflate(-1, -1); e.Graphics.DrawRectangle(Pens.Red, frame); } if (item.isSeparator) { e.Graphics.DrawLine(Pens.Black, frame.Left + 4, frame.Top + frame.Height / 2, frame.Right - 4, frame.Top + frame.Height / 2); } else { e.Graphics.DrawString(item.ToString(), treeView1.Font, b, e.Bounds.Left, e.Bounds.Top + 2); } }
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e) { if (!ignoreChecking) { SEItem item = (SEItem)e.Node.Tag; if (readOnlyMode) { ignoreChecking = true; e.Node.Checked = !e.Node.Checked; ignoreChecking = false; } else { if (item.isDir) //directories cannot be disabled { ignoreChecking = true; e.Node.Checked = !e.Node.Checked; ignoreChecking = false; MessageBox.Show("Disabling 'parent' menus is not supported.\nIf you want to control such menu items you need to press 'Browse' button and adjust the corresponding directories."); } else { item.Enabled = !item.Enabled; //if (item.Enabled) // e.Node.Expand(); //else // e.Node.Collapse(); treeView1.Invalidate(); } } if (additionalOnCheckHandler != null) { additionalOnCheckHandler(sender, e); } } }
public void ReadShellExtensions(string path) { int iterator = 0; ArrayList dirList = new ArrayList(); ArrayList itemsList = new ArrayList(); dirList.Add(path); while (iterator < dirList.Count) { foreach (string dir in Directory.GetDirectories(dirList[iterator].ToString())) { dirList.Add(dir); itemsList.Add(dir); } foreach (string file in Directory.GetFiles(dirList[iterator].ToString(), "*.cmd*")) itemsList.Add(file); foreach (string file in Directory.GetFiles(dirList[iterator].ToString(), "*.separator")) itemsList.Add(file); iterator++; } //sort according the ShellExtension sorting algorithm itemsList.Sort(Sorter.instance); //foreach (string item in itemsList) // Trace.WriteLine(item); TreeNode dirNode = null; foreach (string item in itemsList) { SEItem shellEx = new SEItem(item); TreeNode node = new TreeNode(shellEx.ToString()); node.Checked = shellEx.Enabled; node.Tag = shellEx; if (dirNode == null) { treeView1.Nodes.Add(node); } else { TreeNode parentNode = dirNode; SEItem parentShellEx = null; do { parentShellEx = (parentNode.Tag as SEItem); if (parentShellEx == null) { treeView1.Nodes.Add(node); } else if (parentShellEx.level == shellEx.level - 1) { parentNode.Nodes.Add(node); break; } parentNode = parentNode.Parent; } while (parentNode != null); if (parentNode == null) treeView1.Nodes.Add(node); } if (shellEx.isDir) dirNode = node; } treeView1.ExpandAll(); }
public void ReadShellExtensions(string path) { int iterator = 0; ArrayList dirList = new ArrayList(); ArrayList itemsList = new ArrayList(); dirList.Add(path); while (iterator < dirList.Count) { foreach (string dir in Directory.GetDirectories(dirList[iterator].ToString())) { dirList.Add(dir); itemsList.Add(dir); } foreach (string file in Directory.GetFiles(dirList[iterator].ToString(), "*.cmd*")) { itemsList.Add(file); } foreach (string file in Directory.GetFiles(dirList[iterator].ToString(), "*.separator")) { itemsList.Add(file); } iterator++; } //sort according the ShellExtension sorting algorithm itemsList.Sort(Sorter.instance); //foreach (string item in itemsList) // Trace.WriteLine(item); TreeNode dirNode = null; foreach (string item in itemsList) { SEItem shellEx = new SEItem(item); TreeNode node = new TreeNode(shellEx.ToString()); node.Checked = shellEx.Enabled; node.Tag = shellEx; if (dirNode == null) { treeView1.Nodes.Add(node); } else { TreeNode parentNode = dirNode; SEItem parentShellEx = null; do { parentShellEx = (parentNode.Tag as SEItem); if (parentShellEx == null) { treeView1.Nodes.Add(node); } else if (parentShellEx.level == shellEx.level - 1) { parentNode.Nodes.Add(node); break; } parentNode = parentNode.Parent; } while (parentNode != null); if (parentNode == null) { treeView1.Nodes.Add(node); } } if (shellEx.isDir) { dirNode = node; } } treeView1.ExpandAll(); }