public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                grid.RowDefinitions.Add(new RowDefinition());
                #region
                StackPanel g = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, Margin=new Thickness(5,0,0,0) };

                TextBlock lblUrl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lblUrl.Text = Resources.Strings.LabelUrl;
                g.Children.Add(lblUrl);

                TextBox tbFormat = new TextBox() { Margin = new Thickness(4,2,0,2), Width = 50, MaxWidth= 60 };
                TextBox tb = new TextBox() { 
                    Margin = new Thickness(2), 
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
                if (value != null)
                    tb.Text = value.Url.ToString();

                tb.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Url = tb.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tb);

                TextBlock lbl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lbl.Text = Resources.Strings.LabelFormat;
                g.Children.Add(lbl);

                if (Config is RasterDataParameterConfig)
                    tbFormat.SetValue(ToolTipService.ToolTipProperty, (Config as RasterDataParameterConfig).FormatToolTip);
                if (value != null)
                    tbFormat.Text = value.Format.ToString();
                tbFormat.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Format = tbFormat.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tbFormat);

                g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                g.SetValue(Grid.ColumnProperty, 0);
                g.SetValue(Grid.ColumnSpanProperty, 2);
                grid.Children.Add(g);
                RaiseCanExecuteChanged();
                #endregion
            }
        }
Esempio n. 2
0
        public static string ParameterToDisplayString(GPParameterType type, GPParameter param)
        {
            if (param == null)
            {
                return(string.Empty);
            }
            switch (type)
            {
            case GPParameterType.Date:
                GPDate date = param as GPDate;
                if (date != null && date.Value != null)
                {
                    return(date.Value.ToString());
                }
                return(null);

            case GPParameterType.LinearUnit:
                GPLinearUnit lu = param as GPLinearUnit;
                if (lu != null)
                {
                    return(string.Format("{0} {1}", lu.Distance, lu.Unit.ToString().Replace("esri", "")));
                }
                return(null);

            case GPParameterType.Boolean:
            case GPParameterType.Double:
            case GPParameterType.Long:
            case GPParameterType.String:
            case GPParameterType.FeatureLayer:
            case GPParameterType.RecordSet:
            case GPParameterType.DataFile:
                return(ParameterToString(type, param, CultureHelper.GetCurrentCulture()));

            case GPParameterType.RasterData:
            case GPParameterType.RasterDataLayer:
                GPRasterData ras = param as GPRasterData;
                if (ras != null)
                {
                    return(ras.Url);
                }
                return(null);
            }
            return(string.Empty);
        }
        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                grid.RowDefinitions.Add(new RowDefinition());
                #region
                StackPanel g = new StackPanel()
                {
                    Orientation = System.Windows.Controls.Orientation.Horizontal, Margin = new Thickness(5, 0, 0, 0)
                };

                TextBlock lblUrl = new TextBlock()
                {
                    VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2)
                };
                lblUrl.Text = Resources.Strings.LabelUrl;
                g.Children.Add(lblUrl);

                TextBox tbFormat = new TextBox()
                {
                    Margin = new Thickness(4, 2, 0, 2), Width = 50, MaxWidth = 60
                };
                TextBox tb = new TextBox()
                {
                    Margin = new Thickness(2),
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
                if (value != null)
                {
                    tb.Text = value.Url.ToString();
                }

                tb.TextChanged += (s, e) =>
                {
                    if (value == null)
                    {
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text)
                        {
                            Format = tbFormat.Text
                        }
                    }
                    ;                                                                                            //Workaround for slapi bug
                    else
                    {
                        value.Url = tb.Text;
                    }
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tb);

                TextBlock lbl = new TextBlock()
                {
                    VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2)
                };
                lbl.Text = Resources.Strings.LabelFormat;
                g.Children.Add(lbl);

                if (Config is RasterDataParameterConfig)
                {
                    tbFormat.SetValue(ToolTipService.ToolTipProperty, (Config as RasterDataParameterConfig).FormatToolTip);
                }
                if (value != null)
                {
                    tbFormat.Text = value.Format.ToString();
                }
                tbFormat.TextChanged += (s, e) =>
                {
                    if (value == null)
                    {
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text)
                        {
                            Format = tbFormat.Text
                        }
                    }
                    ;                                                                                            //Workaround for slapi bug
                    else
                    {
                        value.Format = tbFormat.Text;
                    }
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tbFormat);

                g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                g.SetValue(Grid.ColumnProperty, 0);
                g.SetValue(Grid.ColumnSpanProperty, 2);
                grid.Children.Add(g);
                RaiseCanExecuteChanged();
                #endregion
            }
        }