ExplorerBrowser
Inheritance: System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector
        private static void OnNavigationPaneChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.NavigationOptions.PaneVisibility.Navigation = (PaneVisibilityState)e.NewValue;
            }
        }
        private static void OnThumbnailSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.ContentOptions.ThumbnailSize = (int)e.NewValue;
            }
        }
        private static void OnNavigateOnceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.NavigationOptions.NavigateOnce = (bool)e.NewValue;
            }
        }
        private static void OnSingleSelectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.ContentOptions.SingleSelection = (bool)e.NewValue;
            }
        }
        private static void OnNoHeaderInAllViewsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.ContentOptions.NoHeaderInAllViews = (bool)e.NewValue;
            }
        }
        private static void OnNavigationLogIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.NavigationLog.NavigateLog((int)e.NewValue);
            }
        }
        private static void navigationTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl.explorerBrowserControl != null)
            {
                instance.ExplorerBrowserControl.Navigate((ShellObject)e.NewValue);
            }
            else
            {
                instance.initialNavigationTarget = (ShellObject)e.NewValue;
            }
        }
        private static void OnViewModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExplorerBrowser instance = d as ExplorerBrowser;

            if (instance.ExplorerBrowserControl != null)
            {
                if (instance.ExplorerBrowserControl.explorerBrowserControl == null)
                {
                    instance.initialViewMode = (ExplorerBrowserViewMode)e.NewValue;
                }
                else
                {
                    instance.ExplorerBrowserControl.ContentOptions.ViewMode = (ExplorerBrowserViewMode)e.NewValue;
                }
            }
        }
Ejemplo n.º 9
0
 private void tryNavigate(ExplorerBrowser browser, TextBox address)
 {
     try
     {
         browser.NavigationTarget = ShellObject.FromParsingName(address.Text);
     }
     catch (Exception _e)
     {
         address.Text = browser.NavigationTarget.ParsingName;
     }
 }
Ejemplo n.º 10
0
        //New tab from ShellObject
        private void NewTab(ShellObject navTarget)
        {
            //Add a delay for creating new tabs
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Interval = 500;
            aTimer.Elapsed += new ElapsedEventHandler(delegate(object source, ElapsedEventArgs e) {
                tabCreateEnabled = true;
            });
            aTimer.Enabled = true;

            if (!tabCreateEnabled)
            {
                tabControl.SelectedIndex = tabControl.Items.Count - 1;
            }
            else {
                tabCreateEnabled = false;

                ExplorerBrowser expBrowser = new ExplorerBrowser();
                expBrowser.HorizontalAlignment = HorizontalAlignment.Left;
                expBrowser.VerticalAlignment = VerticalAlignment.Top;
                expBrowser.Height = (this.Height - 57) > 0 ? (this.Height - 57) : this.Height;
                expBrowser.Width = this.Width;
                expBrowser.NavigationTarget = navTarget;
                expBrowser.AllowDrop = true;
                expBrowser.ViewMode = ExplorerBrowserViewMode.Icon;

                StackPanel expPanel = new StackPanel();
                expPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
                expPanel.VerticalAlignment = VerticalAlignment.Stretch;
                expPanel.Margin = new Thickness(-5, 0, 0, 0);
                expPanel.Background = new SolidColorBrush(Color.FromRgb(245, 246, 247));

                WrapPanel expControls = new WrapPanel();
                expControls.Height = 34;
                expControls.Width = this.Width;

                Button backButton = new Button()
                {
                    Width = 29,
                    Height = 29,
                    Margin = new Thickness(32, 0, 12, 0),
                    VerticalAlignment = VerticalAlignment.Center,
                    Template = (ControlTemplate)FindResource("GlassButton"),
                    Content = new Image()
                    {
                        Width = 29, //back: 20
                        Height = 29, //back: 20
                        VerticalAlignment = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Source = new BitmapImage(new Uri("pack://application:,,,/images/back2.ico"))
                    }
                };

                Button forwardButton = new Button()
                {
                    Width = 29,
                    Height = 29,
                    Margin = new Thickness(12, 0, 12, 0),
                    VerticalAlignment = VerticalAlignment.Center,
                    Template = (ControlTemplate)FindResource("GlassButton"),
                    Content = new Image()
                    {
                        Width = 29, //forward: 20
                        Height = 29, //forward: 20
                        VerticalAlignment = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Source = new BitmapImage(new Uri("pack://application:,,,/images/forward2.ico"))
                    }
                };

                TextBox addressBar = new TextBox() {
                    VerticalAlignment = VerticalAlignment.Center,
                    Width = this.Width - 250,
                    Margin = new Thickness(29, 3, 0, 0),
                    AcceptsReturn = false
                };

                forwardButton.PreviewMouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
                {
                    expBrowser.NavigationLogIndex += 1;
                };

                backButton.PreviewMouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
                {
                    expBrowser.NavigationLogIndex -= 1;
                };

                addressBar.KeyDown += delegate(object sender, KeyEventArgs e)
                {
                    if (e.Key == Key.Enter || e.Key == Key.Return)
                    {
                        tryNavigate(expBrowser, addressBar);
                    }
                };

                addressBar.LostKeyboardFocus += delegate(object sender, KeyboardFocusChangedEventArgs e) {
                    try
                    {
                        expBrowser.NavigationTarget = ShellObject.FromParsingName(addressBar.Text);
                    }
                    catch (Exception _e)
                    {
                        addressBar.Text = expBrowser.NavigationTarget.ParsingName;
                    }
                };

                expControls.Children.Add(backButton);
                expControls.Children.Add(forwardButton);
                expControls.Children.Add(addressBar);

                expPanel.Children.Add(expControls);
                expPanel.Children.Add(expBrowser);

                CloseableTabItem tabItem = new CloseableTabItem()
                {
                    MinWidth = 100,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment = VerticalAlignment.Stretch,
                    Content = expPanel,
                    Header = "Test1",
                };

                tabControl.Items.Add(tabItem);
                tabControl.SelectedIndex = tabControl.Items.Count - 1;

                expBrowser.Loaded += delegate(object sender, RoutedEventArgs e)
                {
                    tabItem.Header = expBrowser.NavigationTarget.Name;
                };

                expBrowser.ExplorerBrowserControl.NavigationComplete +=
                delegate(object sender, Microsoft.WindowsAPICodePack.Controls.NavigationCompleteEventArgs e)
                {
                    tabItem.Header = e.NewLocation.Name;
                    addressBar.Text = e.NewLocation.ParsingName;

                    if (expBrowser.ExplorerBrowserControl.NavigationLog.CanNavigateBackward) {
                        backButton.IsEnabled = true;
                    } else {
                        backButton.IsEnabled = false;
                    }

                    if (expBrowser.ExplorerBrowserControl.NavigationLog.CanNavigateForward) {
                        forwardButton.IsEnabled = true;
                    } else {
                        forwardButton.IsEnabled = false;
                    }
                };

                browsers.Add(tabItem, expBrowser);
            }
        }