Пример #1
0
        private void DlgExpressionChangesApplied(object sender, EventArgs e)
        {
            SQLExpressionDialog dlg = sender as SQLExpressionDialog;

            if (dlg != null)
            {
                string exp = dlg.Expression;
                _context.PropertyDescriptor.SetValue(_context.Instance, exp);
            }
        }
Пример #2
0
        /// <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(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 += DlgExpressionChangesApplied;
            var result = dialogProvider.ShowDialog(dlgExpression);

            dlgExpression.ChangesApplied -= DlgExpressionChangesApplied;
            return(result != DialogResult.OK ? original : dlgExpression.Expression);
        }