Beispiel #1
0
        //
        // Our event handler for reacting to mousedown events
        //
        private void TreeViewMouseDown(object sender, MouseButtonEventArgs e)
        {
            DockPanel clickedDock = (DockPanel)sender;
            clickedDock.Children.RemoveAt(0);
            clickedDock.Children.Insert(0, GetImage(true));
            string clickedText = dockPanelContent[clickedDock];

            FTPFolder clickedFolder = new FTPFolder(clickedText, SafeFolderName(clickedText));
            DrawChildTreeItems(folderNameToTreeItem[clickedText], clickedFolder, true);
            ftpBox.Text = clickedText;
            LoadFilesToList(clickedText);
        }
Beispiel #2
0
        //
        // Given a parent TreeViewItem, FTPFolder, and an expand flag, draws the children folders
        // in your directory structure
        //
        private void DrawChildTreeItems(TreeViewItem parentTree, FTPFolder folder, bool expand)
        {
            List<string> childPaths = GetDirectories(folder.GetPath());
            List<TreeViewItem> treeViewItemList = new List<TreeViewItem>();

            foreach (string t in childPaths) {
                if (folderNameToTreeItem.ContainsKey(t)) {
                    continue;
                }
                else {
                    TreeViewItem tv = new TreeViewItem();
                    FTPFolder newFolder = new FTPFolder(t, SafeFolderName(t));

                    DockPanel dock = new DockPanel();
                    dock.MouseUp += new MouseButtonEventHandler(TreeViewMouseDown);

                    TextBlock textContent = new TextBlock();
                    textContent.Text = newFolder.GetName();

                    dock.Children.Add(GetImage(false));
                    dock.Children.Add(textContent);
                    dockPanelContent.Add(dock, newFolder.GetPath());

                    treeViewItemList.Add(tv);

                    tv.Header = dock;
                    parentTree.Items.Add(tv);

                    folderNameToTreeItem.Add(t, tv);
                    treeItemToFolderName.Add(tv, t);

                    if (expand) {
                        parentTree.IsExpanded = true;
                    }
                    else {
                        parentTree.IsExpanded = false;
                    }
                }
            }
        }
Beispiel #3
0
        //
        // Responsible for initially drawing the tree
        //
        private void SetupTree()
        {
            treeFolderBrowser.Items.Clear();
            TreeViewItem tv = new TreeViewItem();

            DockPanel dock = new DockPanel();
            dock.MouseUp += new MouseButtonEventHandler(TreeViewMouseDown);

            TextBlock textContent = new TextBlock();
            textContent.Text = startingPath;

            dock.Children.Add(GetImage(true));
            dock.Children.Add(textContent);

            dockPanelContent.Add(dock, startingPath);

            tv.Header = dock;

            treeFolderBrowser.Items.Add(tv);

            folderNameToTreeItem.Add(startingPath, tv);
            treeItemToFolderName.Add(tv, startingPath);

            FTPFolder folder = new FTPFolder(startingPath, SafeFolderName(startingPath));
            DrawChildTreeItems(tv, folder, true);
            treeFolderBrowser.Focus();
        }