Esempio n. 1
0
        private void BuildUI()
        {
            if (ParamContainer == null) return;
            if (ServiceInfo != null && Configuration == null)
            {
                Configuration = new GPConfiguration();
                Configuration.LoadConfiguration(ServiceInfo, ServiceEndpoint);
                return;
            }
            else if (Configuration != null && ServiceEndpoint == null)
            {
                ServiceEndpoint = Configuration.TaskEndPoint;
            }
            paramsScroller.IsEnabled = true;
            if (isLoading)
            {
                ParamContainer.Children.Clear();
                ParamContainer.Children.Add(new TextBlock() { Text = ESRI.ArcGIS.Mapping.GP.Resources.Strings.Loading, FontWeight = System.Windows.FontWeights.Bold });
            }
            else if (Configuration != null)
            {
                double size = ViewUtility.GetViewHeight() - 325;
                paramsScroller.MaxHeight = size < 100 ? 100 : size;
                size = ViewUtility.GetViewWidth() - 200;
                paramsScroller.MaxWidth = size < 100 ? 100 : size;
                if (paramsScroller.MaxWidth > 500)
                    paramsScroller.MaxWidth = 500;
                ParamContainer.Children.Clear();
                ParamContainer.ColumnDefinitions.Clear();
                ParamContainer.RowDefinitions.Clear();
                ParamContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                ParamContainer.ColumnDefinitions.Add(new ColumnDefinition());// { Width = new GridLength(0, GridUnitType.Star) });
                InputParameters.Clear();

                foreach (ParameterSupport.ParameterConfig config in Configuration.InputParameters)
                {
                    ParameterSupport.ParameterBase parameter = ParameterSupport.ParameterFactory.Create(config, Map);
                    if (parameter != null)
                    {
                        parameter.CanExecuteChanged += parameter_CanExecuteChanged;
                        InputParameters.Add(parameter);
                        if (config.ShownAtRunTime)
                        {
                            ParamContainer.RowDefinitions.Add(new RowDefinition());
                            TextBlock label = new TextBlock()
                                                  {
                                                      Text = config.Label,
                                                      VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                                      Padding = new Thickness(2, 0, 2, 0)
                                                  };
                            label.SetValue(Grid.RowProperty, ParamContainer.RowDefinitions.Count - 1);
                            //if (config.Required)
                            //    label.Text += "*";
                            ParamContainer.Children.Add(label);
                            parameter.AddUI(ParamContainer);
                        }
                    }
                }
            }    
        }
        private void GPTaskEndpoint_LoadSucceeded(object sender, EventArgs e)
        {
            if (configuration == null)
            {
                configuration = new GPConfiguration();
            }

            configuration.LoadConfiguration(metadataLoader.ServiceInfo, metadataLoader.ServiceEndpoint);
            configuration.UseProxy = _useProxy;

            // Update pages
            updateInputParamsPage();
            updateOutputParamsPage();
            updateTitleAndLayerOrderPage();
        }
        public void OnCancelled()
        {
            browseDialog.Reset(); //as if it has not yet been configured

            if (_backupConfiguration != null)
            {
                browseDialog.ShowRestrictedServices = _backupConfiguration.UseProxy;

                if (_backupConfiguration.TaskEndPoint != null)
                {
                    // Check whether the proxy URL has changed since the last time tool configuration was saved
                    bool proxyChanged = MapApplication.Current != null && MapApplication.Current.Urls != null &&
                                        _backupConfiguration.ProxyUrl != MapApplication.Current.Urls.ProxyUrl;

                    // Only revert the URL on the service browsing UI if proxy is not being used or the proxy
                    // URL is the same as the last time configuration was saved
                    if (!_backupConfiguration.UseProxy || !proxyChanged)
                    {
                        browseDialog.SelectedResourceUrl = _backupConfiguration.TaskEndPoint.AbsoluteUri;
                    }
                    else
                    {
                        browseDialog.SelectedResourceUrl = null;
                    }
                }

                configuration = _backupConfiguration.Clone();
            }
            else
            {
                browseDialog.SelectedResourceUrl = null;
                configuration = null;
            }

            //refresh the ui with previous settings
            updateInputParamsPage();
            updateOutputParamsPage();
            updateTitleAndLayerOrderPage();
        }
        public void LoadConfiguration(string configData)
        {
            gpConfigSerialized = !string.IsNullOrEmpty(configData);
            configuration      = gpConfigSerialized ? new GPConfiguration(configData) : null;
            if (browseDialog != null)
            {
                browseDialog.ShowRestrictedServices = configuration.UseProxy;
            }

            _backupConfiguration = gpConfigSerialized ? new GPConfiguration(configData) : null;

            if (MapApplication.Current.IsEditMode)
            {
                if (configuration != null && configuration.TaskEndPoint != null)
                {
                    browseDialog.SelectedResourceUrl = configuration.TaskEndPoint.AbsoluteUri;
                }

                // Update pages
                updateInputParamsPage();
                updateOutputParamsPage();
                updateTitleAndLayerOrderPage();
            }
        }
        private void GPTaskEndpoint_LoadSucceeded(object sender, EventArgs e)
        {
            if (configuration == null)
                configuration = new GPConfiguration();

            configuration.LoadConfiguration(metadataLoader.ServiceInfo, metadataLoader.ServiceEndpoint);
            configuration.UseProxy = _useProxy;

            // Update pages
            updateInputParamsPage();
            updateOutputParamsPage();
            updateTitleAndLayerOrderPage();
        }
 public void OnCompleted()
 {
     _backupConfiguration = configuration != null ? configuration.Clone() : null;
 }
        public void OnCancelled()
        {
            browseDialog.Reset(); //as if it has not yet been configured

            if (_backupConfiguration != null)
            {
                browseDialog.ShowRestrictedServices = _backupConfiguration.UseProxy;

                if (_backupConfiguration.TaskEndPoint != null)
                {
                    // Check whether the proxy URL has changed since the last time tool configuration was saved
                    bool proxyChanged = MapApplication.Current != null && MapApplication.Current.Urls != null
                        && _backupConfiguration.ProxyUrl != MapApplication.Current.Urls.ProxyUrl;

                    // Only revert the URL on the service browsing UI if proxy is not being used or the proxy 
                    // URL is the same as the last time configuration was saved
                    if (!_backupConfiguration.UseProxy || !proxyChanged)
                        browseDialog.SelectedResourceUrl = _backupConfiguration.TaskEndPoint.AbsoluteUri;
                    else
                        browseDialog.SelectedResourceUrl = null;
                }

                configuration = _backupConfiguration.Clone();
            }
            else
            {
                browseDialog.SelectedResourceUrl = null;
                configuration = null;
            }

            //refresh the ui with previous settings
            updateInputParamsPage();
            updateOutputParamsPage();
            updateTitleAndLayerOrderPage();
        }
        public void LoadConfiguration(string configData)
        {
            gpConfigSerialized = !string.IsNullOrEmpty(configData);
            configuration = gpConfigSerialized ? new GPConfiguration(configData) : null;
            if (browseDialog != null)
                browseDialog.ShowRestrictedServices = configuration.UseProxy;

            _backupConfiguration = gpConfigSerialized ? new GPConfiguration(configData) : null;

            if (MapApplication.Current.IsEditMode)
            {
                if (configuration != null && configuration.TaskEndPoint != null)
                    browseDialog.SelectedResourceUrl = configuration.TaskEndPoint.AbsoluteUri;

                // Update pages
                updateInputParamsPage();
                updateOutputParamsPage();
                updateTitleAndLayerOrderPage();
            }
        }
Esempio n. 9
0
        private void BuildUI()
        {
            if (ParamContainer == null)
            {
                return;
            }
            if (ServiceInfo != null && Configuration == null)
            {
                Configuration = new GPConfiguration();
                Configuration.LoadConfiguration(ServiceInfo, ServiceEndpoint);
                return;
            }
            else if (Configuration != null && ServiceEndpoint == null)
            {
                ServiceEndpoint = Configuration.TaskEndPoint;
            }
            paramsScroller.IsEnabled = true;
            if (isLoading)
            {
                ParamContainer.Children.Clear();
                ParamContainer.Children.Add(new TextBlock()
                {
                    Text = ESRI.ArcGIS.Mapping.GP.Resources.Strings.Loading, FontWeight = System.Windows.FontWeights.Bold
                });
            }
            else if (Configuration != null)
            {
                double size = ViewUtility.GetViewHeight() - 325;
                paramsScroller.MaxHeight = size < 100 ? 100 : size;
                size = ViewUtility.GetViewWidth() - 200;
                paramsScroller.MaxWidth = size < 100 ? 100 : size;
                if (paramsScroller.MaxWidth > 500)
                {
                    paramsScroller.MaxWidth = 500;
                }
                ParamContainer.Children.Clear();
                ParamContainer.ColumnDefinitions.Clear();
                ParamContainer.RowDefinitions.Clear();
                ParamContainer.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                ParamContainer.ColumnDefinitions.Add(new ColumnDefinition());// { Width = new GridLength(0, GridUnitType.Star) });
                InputParameters.Clear();

                foreach (ParameterSupport.ParameterConfig config in Configuration.InputParameters)
                {
                    ParameterSupport.ParameterBase parameter = ParameterSupport.ParameterFactory.Create(config, Map);
                    if (parameter != null)
                    {
                        parameter.CanExecuteChanged += parameter_CanExecuteChanged;
                        InputParameters.Add(parameter);
                        if (config.ShownAtRunTime)
                        {
                            ParamContainer.RowDefinitions.Add(new RowDefinition());
                            TextBlock label = new TextBlock()
                            {
                                Text = config.Label,
                                VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                Padding           = new Thickness(2, 0, 2, 0)
                            };
                            label.SetValue(Grid.RowProperty, ParamContainer.RowDefinitions.Count - 1);
                            //if (config.Required)
                            //    label.Text += "*";
                            ParamContainer.Children.Add(label);
                            parameter.AddUI(ParamContainer);
                        }
                    }
                }
            }
        }
 public void OnCompleted()
 {
     _backupConfiguration = configuration != null?configuration.Clone() : null;
 }