Exemplo n.º 1
0
        private void MainWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!WorkbenchMainWindow.IsVisible)
            {
                return;
            }

            WorkbenchMainWindow.IsVisibleChanged -= this.MainWindow_IsVisibleChanged;

            WizardPad.ShowInWorkbench();
        }
        /// <summary>
        ///     Invokes the command.
        /// </summary>
        public override void Run()
        {
            if (ShowParametersPopup())
            {
                return;
            }

            var wizardPad = WizardPad.ShowInWorkbench();

            if (wizardPad != null)
            {
                wizardPad.InnerControl.ActivateParameters();
            }
        }
Exemplo n.º 3
0
        private void MainWindow_Activated(object sender, EventArgs eventArgs)
        {
            WorkbenchMainWindow.Activated -= this.MainWindow_Activated;

            WizardPad.ShowInWorkbench();
        }
        private static bool DoShowParametersPopup(TextArea textArea, Point popupPoint)
        {
            #region Argument Check

            if (textArea == null)
            {
                throw new ArgumentNullException("textArea");
            }

            #endregion

            var text = textArea.Selection.GetText(textArea.Document);
            if (text.IsNullOrEmpty())
            {
                return(false);
            }

            var wizardPad = WizardPad.FindPad();
            if (wizardPad == null)
            {
                return(false);
            }

            //// TODO [vmaklai] Think up a good idea of popup sizing

            var parametersPage = new ParametersPageControl
            {
                Width     = 600,
                Height    = 400,
                ViewModel =
                {
                    ParametersPage = { IsReplaceMode = true, AutoFocusedValue = text }
                }
            };

            // Must be set after the control is created and initialized
            parametersPage.ViewModel.ImportPage.RepositoryPath =
                wizardPad.InnerControl.ViewModel.ImportPage.RepositoryPath;
            parametersPage.ViewModel.ParametersPage.SetSelectedIdocItem(
                wizardPad.InnerControl.ViewModel.ParametersPage.GetSelectedIdocItem());

            var popupContent = new Grid
            {
                Background = SystemColors.ControlBrush,
                Children   =
                {
                    new Border
                    {
                        BorderThickness = new Thickness(2d),
                        BorderBrush     = SystemColors.ActiveBorderBrush,
                        Child           = parametersPage
                    }
                }
            };

            var popup = new KeyboardFriendlyPopup
            {
                IsOpen             = false,
                StaysOpen          = false,
                AllowsTransparency = true,
                Placement          = PlacementMode.Relative,
                PlacementTarget    = textArea,
                HorizontalOffset   = popupPoint.X,
                VerticalOffset     = popupPoint.Y,
                PopupAnimation     = PopupAnimation.None,
                Focusable          = false,
                Opacity            = 0d,
                Child = popupContent
            };

            popup.PreviewMouseLeftButtonDown +=
                (sender, e) =>
            {
                if (e.ClickCount == 2)
                {
                    parametersPage.PerformAction();
                }
            };

            FocusManager.SetFocusedElement(popup, parametersPage.ParameterTreeViewReference);

            popup.Closed += (sender, e) => textArea.Focus();

            popup.PreviewKeyDown +=
                (sender, e) =>
            {
                switch (e.Key)
                {
                case Key.Escape:
                    popup.IsOpen = false;
                    break;

                case Key.Enter:
                    parametersPage.PerformAction();
                    break;
                }
            };

            parametersPage.ActionExecuted += (sender, e) => popup.IsOpen = false;

            popup.IsOpen = true;
            return(true);
        }