private void Wizard_PageChanging(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Wizard wizard = sender as Wizard;
            // If underlying command implements ISupportsWizardConfiguration, fire PageChanging method
            // and cancel wizard page change accordingly
            ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;

            if (wizardConfigInterface != null)
            {
                e.Cancel = !wizardConfigInterface.PageChanging();
            }
        }
        private void Wizard_PageChanged(object sender, EventArgs e)
        {
            Wizard wizard = sender as Wizard;
            // If underlying command implements ISupportsWizardConfiguration, update CurrentPage and
            // fire Configure method
            ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;

            if (wizardConfigInterface != null)
            {
                wizardConfigInterface.CurrentPage = wizard.CurrentPage;
                wizardConfigInterface.Configure();
            }
        }
Пример #3
0
 // Removes the wizard pages of the passed-in search providers from the search tool's configuration wizard
 private void removeWizardPages(IEnumerable providers, ObservableCollection <WizardPage> pages)
 {
     foreach (ISearchProvider provider in providers)
     {
         ISupportsWizardConfiguration wizardInfo = provider as ISupportsWizardConfiguration;
         if (wizardInfo != null)
         {
             foreach (WizardPage page in wizardInfo.Pages)
             {
                 if (pages.Contains(page))
                 {
                     pages.Remove(page);
                 }
             }
         }
     }
 }
        private void Wizard_Completed(object sender, EventArgs e)
        {
            // Get tool properties UI
            EditToolbarItemControl toolPropsUI = null;

            if (sender is EditToolbarItemControl)
            {
                toolPropsUI = sender as EditToolbarItemControl;
            }
            else
            {
                Wizard wizard = sender as Wizard;
                foreach (WizardPage page in wizard.Pages)
                {
                    toolPropsUI = page.Content as EditToolbarItemControl;
                    if (toolPropsUI != null)
                    {
                        break;
                    }
                }
            }

            // Update command properties with the configured values
            ToolPanel               = toolPropsUI.SelectedToolPanel;
            DisplayInfo             = DisplayInfo ?? new ButtonDisplayInfo();
            DisplayInfo.Label       = toolPropsUI.Label;
            DisplayInfo.Description = toolPropsUI.Description;
            DisplayInfo.Icon        = toolPropsUI.IconUrl;

            // Set completed flag so window closed handler knows that window was closed as a
            // result of configuration being completed
            completed = true;
            // Hide configuration UI and fire the completed event
            BuilderApplication.Instance.HideWindow(configurationUI);
            ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;

            if (wizardConfigInterface != null)
            {
                wizardConfigInterface.OnCompleted();
            }
            if (Completed != null)
            {
                Completed(this, EventArgs.Empty);
            }
        }
Пример #5
0
        // Updates the search tool's configuration wizard to incorporate the configuration pages
        // and desired size of the passed-in search providers
        private void addNewWizardInfo(IEnumerable providers, ObservableCollection <WizardPage> pages)
        {
            foreach (ISearchProvider provider in providers)
            {
                ISupportsWizardConfiguration wizardInfo = provider as ISupportsWizardConfiguration;
                if (wizardInfo != null)
                {
                    foreach (WizardPage page in wizardInfo.Pages)
                    {
                        pages.Add(page);
                    }

                    if (wizardInfo.DesiredSize.Width > desiredSize.Width)
                    {
                        desiredSize.Width = wizardInfo.DesiredSize.Width;
                    }

                    if (wizardInfo.DesiredSize.Height > desiredSize.Height)
                    {
                        desiredSize.Height = wizardInfo.DesiredSize.Height;
                    }
                }
            }
        }
        /// <summary>
        /// Creates configuration wizard pages for the current command
        /// </summary>
        /// <returns>The list of wizard pages</returns>
        private List <WizardPage> createWizardPages()
        {
            List <WizardPage> pages = new List <WizardPage>();

            EditToolbarItemControl toolPropsUI = createToolPropertiesUI();

            toolPropsUI.Margin = new Thickness(5, 8, 5, 0);
            // Encapsulate properties dialog in a wizard page
            WizardPage toolPropsPage = new WizardPage()
            {
                Content    = toolPropsUI,
                Heading    = ESRI.ArcGIS.Mapping.Builder.Resources.Strings.SpecifyToolProperties,
                InputValid = toolPropsUI.InputValid
            };

            // Update wizard page validation state on tool properties validation state change
            toolPropsUI.ValidationStateChanged += (o, e) => { toolPropsPage.InputValid = toolPropsUI.InputValid; };

            // initialize wizard pages
            pages.Add(toolPropsPage);
            _locallyInsertedWizardPagesCount++;


            // Get pages from wizard config interface and add to collection
            ISupportsWizardConfiguration wizardConfig = Class as ISupportsWizardConfiguration;

            if (wizardConfig != null)
            {
                foreach (WizardPage page in wizardConfig.Pages)
                {
                    pages.Add(page);
                }
            }

            return(pages);
        }
        private Wizard createWizard()
        {
            Wizard wizard = new Wizard();

            // Include page to select tool
            if (AllowToolSelection)
            {
                AvailableToolbarItemsControl toolList = new AvailableToolbarItemsControl(false)
                {
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    Margin = new Thickness(0, 5, 0, 0)
                };
                WizardPage toolSelectionPage = new WizardPage()
                {
                    Content = toolList,
                    Heading = ESRI.ArcGIS.Mapping.Builder.Resources.Strings.SelectAToolToAdd
                };
                wizard.Pages.Add(toolSelectionPage);
                _locallyInsertedWizardPagesCount++;

                toolList.SelectedItemChanged += (o, e) =>
                {
                    toolSelectionPage.InputValid = toolList.SelectedToolItemType != null;

                    // If a new command is selected, rebuild the wizard pages
                    if (toolSelectionPage.InputValid && toolList.SelectedClass != null && !toolList.SelectedClass.Equals(Class))
                    {
                        // Remove pages collection changed handler from previously selected tool
                        ISupportsWizardConfiguration previousWizardConfigInterface =
                            Class as ISupportsWizardConfiguration;
                        if (previousWizardConfigInterface != null)
                        {
                            previousWizardConfigInterface.Pages.CollectionChanged -= WizardInterfacePages_CollectionChanged;
                        }

                        Class       = toolList.SelectedClass;
                        DisplayInfo = toolList.SelectedItemDisplayInfo;

                        // All but the page showing the available tools will be removed, so reset the number of
                        // pages added to the wizard by the command to one.
                        _locallyInsertedWizardPagesCount = 1;

                        List <WizardPage> configPages = createWizardPages();
                        int pagesToRemove             = wizard.Pages.Count - 1;

                        // Add the new config pages to the wizard, then remove the old ones
                        foreach (WizardPage page in configPages)
                        {
                            wizard.Pages.Add(page);
                        }

                        for (int i = 0; i < pagesToRemove; i++)
                        {
                            wizard.Pages.RemoveAt(1);
                        }

                        updateConfigureButton(wizard);

                        // Initialize CurrentPage if command implements ISupportsWizardConfiguration
                        ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;
                        if (wizardConfigInterface != null)
                        {
                            wizardConfigInterface.Pages.CollectionChanged += WizardInterfacePages_CollectionChanged;
                            wizardConfigInterface.CurrentPage              = toolSelectionPage;
                        }
                    }
                };

                Size maxPageSize = getMaxPageSize(toolList.AvailableItems);
                if (maxPageSize.Height > 0 && maxPageSize.Width > double.MinValue)
                {
                    wizard.ContentHeight = maxPageSize.Height;
                    wizard.ContentWidth  = maxPageSize.Width > 400 ? maxPageSize.Width : 400;
                }
            }
            else
            {
                // Get wizard config interface and use to initialize wizard size
                ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;
                if (wizardConfigInterface != null)
                {
                    wizard.ContentHeight = wizardConfigInterface.DesiredSize.Height;
                    wizard.ContentWidth  = wizardConfigInterface.DesiredSize.Width;
                    wizardConfigInterface.Pages.CollectionChanged += WizardInterfacePages_CollectionChanged;
                }
            }

            // initialize wizard pages
            List <WizardPage> pages = createWizardPages();

            foreach (WizardPage page in pages)
            {
                wizard.Pages.Add(page);
            }

            updateConfigureButton(wizard);

            // Wire events
            wizard.PageChanging += Wizard_PageChanging;
            wizard.PageChanged  += Wizard_PageChanged;
            wizard.Cancelled    += Wizard_Cancelled;
            wizard.Completed    += Wizard_Completed;

            return(wizard);
        }