Esempio n. 1
0
        internal static void ToggleFindToolBar(Decorator findToolBarHost, EventHandler handlerFindClicked, bool enable)
        {
            if (enable)
            {
                // Create FindToolBar and attach it to the host.
                FindToolBar findToolBar = new FindToolBar();
                findToolBarHost.Child      = findToolBar;
                findToolBarHost.Visibility = Visibility.Visible;
                KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.Continue);
                FocusManager.SetIsFocusScope(findToolBarHost, true);

                // Initialize FindToolBar
                findToolBar.SetResourceReference(Control.StyleProperty, FindToolBarStyleKey);
                findToolBar.FindClicked   += handlerFindClicked;
                findToolBar.DocumentLoaded = true;
                findToolBar.GoToTextBox();
            }
            else
            {
                // Reset FindToolBar state to its initial state.
                FindToolBar findToolBar = findToolBarHost.Child as FindToolBar;
                findToolBar.FindClicked   -= handlerFindClicked;
                findToolBar.DocumentLoaded = false;

                // Remov FindToolBar form its host.
                findToolBarHost.Child      = null;
                findToolBarHost.Visibility = Visibility.Collapsed;
                KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.None);
                findToolBarHost.ClearValue(FocusManager.IsFocusScopeProperty);
            }
        }
        internal static void ToggleFindToolBar(Decorator findToolBarHost, EventHandler handlerFindClicked, bool enable)
        {
            if (enable)
            {
                FindToolBar findToolBar = new FindToolBar();
                findToolBarHost.Child      = findToolBar;
                findToolBarHost.Visibility = Visibility.Visible;
                KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.Continue);
                FocusManager.SetIsFocusScope(findToolBarHost, true);
                findToolBar.SetResourceReference(FrameworkElement.StyleProperty, DocumentViewerHelper.FindToolBarStyleKey);
                findToolBar.FindClicked   += handlerFindClicked;
                findToolBar.DocumentLoaded = true;
                findToolBar.GoToTextBox();
                return;
            }
            FindToolBar findToolBar2 = findToolBarHost.Child as FindToolBar;

            findToolBar2.FindClicked   -= handlerFindClicked;
            findToolBar2.DocumentLoaded = false;
            findToolBarHost.Child       = null;
            findToolBarHost.Visibility  = Visibility.Collapsed;
            KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.None);
            findToolBarHost.ClearValue(FocusManager.IsFocusScopeProperty);
        }