Пример #1
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);
        }
Пример #2
0
 /// <summary>
 /// Occurs when including legend items
 /// </summary>
 /// <param name="item"></param>
 protected override void OnInclude(IFeatureCategory item)
 {
     item.SetParentItem(_scheme.AppearsInLegend ? _scheme : _scheme.GetParentItem());
     base.OnInclude(item);
 }
        /// <summary>
        /// Sets up the Table to work with the specified layer
        /// </summary>
        /// <param name="layer"></param>
        public void Initialize(IFeatureLayer layer)
        {
            _original = layer.Symbology;
            ILegendItem parent = _original.GetParentItem();
            //_original.SetParentItem(null);
            _newScheme = _original.Copy();
            _source = layer.DataSet;
            // _original.SetParentItem(parent); // Disconnect this from actually affecting the layers.
            if(!layer.DataSet.AttributesPopulated)
            {
                if(layer.DataSet.NumRows() < 100000)
                {
                    _source.FillAttributes(); // for small datasets, it is better to just load and cache it.
                }
            }
           
            if(_source.AttributesPopulated)
            {
                _expressionDialog.Table = _source.DataTable;
            }
            else
            {
                _expressionDialog.AttributeSource = _source;
            }
            
            _schemeType = GetSchemeType(layer);

            if (_schemeType != SymbolizerTypes.Polygon)
            {
                chkUseGradients.Visible = false;
                angGradientAngle.Visible = false;
            }
            else
            {
                chkUseGradients.Visible = true;
                angGradientAngle.Visible = true;
            }
            if (_schemeType == SymbolizerTypes.Point)
            {
                IPointScheme ps = _newScheme as IPointScheme;

                if (ps != null)
                {
                    IPointSymbolizer sym;
                    if (ps.Categories.Count == 0 || ps.Categories[0].Symbolizer == null)
                    {
                        sym = new PointSymbolizer();
                    }
                    else
                    {
                        sym = ps.Categories[0].Symbolizer;
                    }
                    _ignoreRefresh = true;
                    featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym,_newScheme.EditorSettings.StartSize , _newScheme.EditorSettings.EndSize);
                    featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange));
                    featureSizeRangeControl1.Scheme = ps;
                    featureSizeRangeControl1.Visible = true;
                    _ignoreRefresh = false;
                }
            }
            else if (_schemeType == SymbolizerTypes.Line)
            {
                ILineScheme ls = _newScheme as ILineScheme;
                if(ls != null)
                {
                    ILineSymbolizer sym;
                    if(ls.Categories.Count == 0 || ls.Categories[0].Symbolizer == null)
                    {
                        sym = new LineSymbolizer();
                    }
                    else
                    {
                        sym = ls.Categories[0].Symbolizer;
                    }
                    _ignoreRefresh = true;
                    featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym, _newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize);
                    featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange));
                    featureSizeRangeControl1.Scheme = ls;
                    featureSizeRangeControl1.Visible = true;
                    _ignoreRefresh = false;
                }
            }
            else
            {
                featureSizeRangeControl1.Visible = false;
            }
            

            UpdateFields();
            if (_newScheme.EditorSettings.ClassificationType != ClassificationTypes.Quantities) return;
            nudCategoryCount.Enabled = true;
            tabScheme.Visible = true;
            dgvCategories.Height = 217;
            UpdateStatistics(false, null);
        }