コード例 #1
0
        private void Tree_Click(object sender, RoutedEventArgs args)
        {
            Button i = (sender as Button);

            // This bit here is to stop all the parent tree view items from opening new tabs
            foreach (CloseableTab t in Tabs.Items)
            {
                if (t.Title.Equals(i.Content))
                {
                    t.Focus();
                    return;
                }
            }

            CloseableTab tab;

            if (args.RoutedEvent.Name.Equals("ContextMenuOpening") ||
                Tabs.SelectedItem == null)
            {
                tab = new CloseableTab();
                Tabs.Items.Add(tab);
            }
            else
            {
                tab = Tabs.SelectedItem as CloseableTab;
            }

            DirectoryInfo info = null;

            if (i.Tag as DirectoryInfo != null)
            {
                info = i.Tag as DirectoryInfo;
            }
            else if ((i.Tag as DriveInfo).IsReady)
            {
                info = (i.Tag as DriveInfo).RootDirectory;
            }

            if (info != null)
            {
                Populate(tab, info);
                Title            = info.Name;
                LocationBox.Text = info.FullName;
                tab.Focus();
            }
        }
コード例 #2
0
        /*
         * @param tab Closeable tab to populate
         * @param info DirectoryInfo object to get all the file and directory info from.
         */
        private void Populate(CloseableTab tab, DirectoryInfo info)
        {
            // TO DO:
            //          Account for forbidden folders/files
            //          Add caching in some form.
            //

            tab.Title        = info.Name;
            LocationBox.Text = info.FullName;
            tab.Panel.Children.Clear();
            foreach (FileSystemInfo file in info.GetFileSystemInfos())
            {
                FileButton btn = new FileButton(file, config);
                btn.MouseEnter += FileBtn_MouseEnter;
                btn.MouseLeave += FileBtn_MouseLeave;
                btn.Click      += FileBtn_Click;
                tab.Panel.Children.Add(btn);
            }
        }