/// <summary>
        /// This describes how to launch the form etc.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _context = context;   
          

            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            SQLExpressionDialog dlgExpression = new SQLExpressionDialog();
            string original = (string)value;
            dlgExpression.Expression = (string)value;

            // Try to find the Table
            IFeatureCategory category = context.Instance as IFeatureCategory;
            if (category != null)
            {
                IFeatureScheme scheme = category.GetParentItem() as IFeatureScheme;
                if (scheme != null)
                {
                    IFeatureLayer layer = scheme.GetParentItem() as IFeatureLayer;
                    if (layer != null)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
                else
                {
                    IFeatureLayer layer = category.GetParentItem() as IFeatureLayer;
                    if (layer != null)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
            }

            dlgExpression.ChangesApplied += dlgExpression_ChangesApplied;
            if (dialogProvider.ShowDialog(dlgExpression) != System.Windows.Forms.DialogResult.OK)
            {
                return original;
            }
            else
            {
                return dlgExpression.Expression;
            }
            
        }
Exemplo n.º 2
0
        //User Click the Select Button
        private void BtnSelectClick(object sender, EventArgs e)
        {
            if (_enableUpdate)
            {
                if (((IndexParam) base.Param).Fs == null || ((IndexParam) base.Param).Fs.DataTable == null) return;

                if (((IndexParam) base.Param).Fs.DataTable.Rows.Count < 1) return;
                
                SQLExpressionDialog dlgExpression = new SQLExpressionDialog();
                dlgExpression.Table = ((IndexParam) base.Param).Fs.DataTable;
                dlgExpression.ShowDialog();
                
                if (dlgExpression.DialogResult == DialogResult.OK)
                {
                    _expression = dlgExpression.Expression;
                    textBox1.Text = _expression;
                    base.Status = ToolStatus.Ok;
                    _click = true;
                    LightTipText = MessageStrings.FeaturesSelected;
                }

                
            }
        }