Exemplo n.º 1
0
 /// <summary>
 /// Show the color category editor form.
 /// </summary>
 /// <param name="e"></param>
 public void ShowEdit(IColorCategory e)
 {
     using (var frm = new ColorPicker(e))
     {
         ShowDialog(frm);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Show the color category editor form.
 /// </summary>
 /// <param name="e"></param>
 public void ShowEdit(IColorCategory e)
 {
     using (var frm = new ColorPicker(e))
     {
         ShowDialog(frm);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs a new instance and sets it up for a specific color break
 /// </summary>
 public ColorPicker(IColorCategory category)
     : this()
 {
     grdSlider.MinimumColor = category.LowColor;
     grdSlider.MaximumColor = category.HighColor;
     _rasterCategory = category;
     lblPreview.Invalidate();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPicker"/> class.
 /// </summary>
 /// <param name="startColor">The minimum color.</param>
 /// <param name="endColor">The maximum color.</param>
 public ColorPicker(Color startColor, Color endColor)
     : this()
 {
     grdSlider.MinimumColor = startColor;
     grdSlider.MaximumColor = endColor;
     _rasterCategory        = null;
     lblPreview.Invalidate();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPicker"/> class and sets it up for a specific color break.
 /// </summary>
 /// <param name="category">Category used to set the minimum and maximum color.</param>
 public ColorPicker(IColorCategory category)
     : this()
 {
     grdSlider.MinimumColor = category.LowColor;
     grdSlider.MaximumColor = category.HighColor;
     _rasterCategory        = category;
     lblPreview.Invalidate();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Removes the specified category
        /// </summary>
        /// <param name="category"></param>
        public override void RemoveCategory(ICategory category)
        {
            IColorCategory cc = category as IColorCategory;

            if (cc != null)
            {
                _categories.Remove(cc);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds the specified category
        /// </summary>
        /// <param name="category"></param>
        public override void AddCategory(ICategory category)
        {
            IColorCategory cc = category as IColorCategory;

            if (cc != null)
            {
                _categories.Add(cc);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Inserts the item at the specified index
        /// </summary>
        /// <param name="index"></param>
        /// <param name="category"></param>
        public override void InsertCategory(int index, ICategory category)
        {
            IColorCategory cc = category as IColorCategory;

            if (cc != null)
            {
                _categories.Insert(index, cc);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPicker"/> class.
 /// </summary>
 public ColorPicker()
 {
     InitializeComponent();
     _rasterCategory               = null; // this will be reset afterwards, but clear it in case we aren't calling with info.
     dialogButtons1.OkClicked     += BtnOkClick;
     dialogButtons1.CancelClicked += BtnCancelClick;
     dialogButtons1.ApplyClicked  += DialogButtons1ApplyClicked;
     lblPreview.Paint             += LblPreviewPaint;
     grdSlider.GradientChanged    += GrdSliderGradientChanged;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new instance of this form.
 /// </summary>
 public ColorPicker()
 {
     InitializeComponent();
     _rasterCategory = null; // this will be reset afterwards, but clear it in case we aren't calling with info.
     dialogButtons1.OkClicked += BtnOkClick;
     dialogButtons1.CancelClicked += BtnCancelClick;
     dialogButtons1.ApplyClicked += dialogButtons1_ApplyClicked;
     lblPreview.Paint += LblPreviewPaint;
     grdSlider.GradientChanged += GrdSliderGradientChanged;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructs a new instance and sets up the colors, but won;t allow
 /// </summary>
 /// <param name="startColor"></param>
 /// <param name="endColor"></param>
 public ColorPicker(Color startColor, Color endColor)
     : this()
 {
     grdSlider.MinimumColor = startColor;
     grdSlider.MaximumColor = endColor;
     _rasterCategory = null;
     lblPreview.Invalidate();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Controls the drawing of each item.  Overridding this places you directly at the stage where
        /// the backbuffer is being drawn to and e.ClipRectangle is the item bounds.
        /// </summary>
        /// <param name="item">The Icolorbreak to draw</param>
        /// <param name="e">A PaintEventArgs with the Graphics surface and the ClipRectangle</param>
        protected virtual void OnDrawItem(IColorCategory item, PaintEventArgs e)
        {

            Rectangle box;
            string text;
            Brush brush;

            // Draw background
            if (item.IsSelected)
            {
                Rectangle selection = e.ClipRectangle;
                //selection.Y = e.ClipRectangle.Top + _itemSpacing;
                //selection.Height = _itemHeight;
                e.Graphics.FillRectangle(_highlightBrush, e.ClipRectangle);
                brush = _highlightTextBrush;
            }
            else
            {
                if (_contentStyle == ColorPanelStyle.Values && _layerType == LayerTypes.Raster)
                {
                    
                    e.Graphics.FillRectangle(_errorBrush, e.ClipRectangle);
                    
                }
                brush = _foreBrush;
            }


            // Establish bounds
            int left = Padding.Left;
            box = new Rectangle(e.ClipRectangle.Left + left, e.ClipRectangle.Top + _itemSpacing, e.ClipRectangle.Width - left - Padding.Right, ItemHeight - _itemSpacing * 2);


            if (_contentStyle == ColorPanelStyle.Colors)
            {
                brush = new System.Drawing.Drawing2D.LinearGradientBrush(box, item.LowColor, item.HighColor, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                e.Graphics.FillRectangle(brush, box);
                brush.Dispose(); // this was newly created, so dispose it
                e.Graphics.DrawRectangle(Pens.Black, box);
                return;
            }



            else if (_contentStyle == ColorPanelStyle.Captions)
            {

                text = item.LegendText;
            }
            else
            {
                text = item.ToString();
            }


            if (_horizontalAlignment == HorizontalAlignment.Left)
            {

                e.Graphics.DrawString(text, Font, brush, box);
            }
            else if (_horizontalAlignment == HorizontalAlignment.Right)
            {
                // clip the visible region so we don't mess up padding
                e.Graphics.SetClip(box);
                int right = box.Right;
                SizeF measure = e.Graphics.MeasureString(text, Font);
                left = right - Convert.ToInt32(measure.Width);
                Rectangle extendedBox = new Rectangle(left, box.Top, right - left, box.Height);
                e.Graphics.DrawString(text, Font, brush, extendedBox);
                e.Graphics.ResetClip();

            }
            else if (_horizontalAlignment == HorizontalAlignment.Center)
            {
                // clip the visible region so we don't mess up padding
                e.Graphics.SetClip(box);
                int mid = box.Left + box.Width / 2;
                int right = box.Right;
                SizeF measure = e.Graphics.MeasureString(text, Font);
                left = mid - Convert.ToInt32(measure.Width)/2;
                Rectangle extendedBox = new Rectangle(left, box.Top, right - left, box.Height);
                e.Graphics.DrawString(text, Font, brush, extendedBox);
                e.Graphics.ResetClip();

            }







        }
Exemplo n.º 13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDoubleClick(MouseEventArgs e)
 {
     _wasDoubleClick = true;
     Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top);
     foreach (LegendBox lb in _legendBoxes)
     {
         if (!lb.Bounds.Contains(loc)) continue;
         ILineCategory lc = lb.Item as ILineCategory;
         if (lc != null)
         {
             DetailedLineSymbolDialog lsDialog = new DetailedLineSymbolDialog(lc.Symbolizer);
             lsDialog.ShowDialog();
             ILineSymbolizer sel = lc.Symbolizer.Copy();
             sel.SetFillColor(Color.Cyan);
             lc.SelectionSymbolizer = sel;
         }
         IPointCategory pc = lb.Item as IPointCategory;
         if (pc != null)
         {
             DetailedPointSymbolDialog dlg = new DetailedPointSymbolDialog(pc.Symbolizer);
             dlg.ShowDialog();
             IPointSymbolizer ps = pc.Symbolizer.Copy();
             ps.SetFillColor(Color.Cyan);
             pc.SelectionSymbolizer = ps;
         }
         IPolygonCategory polyCat = lb.Item as IPolygonCategory;
         if (polyCat != null)
         {
             DetailedPolygonSymbolDialog dlg = new DetailedPolygonSymbolDialog(polyCat.Symbolizer);
             dlg.ShowDialog();
             IPolygonSymbolizer ps = polyCat.Symbolizer.Copy();
             ps.SetFillColor(Color.Cyan);
             ps.OutlineSymbolizer.SetFillColor(Color.DarkCyan);
             polyCat.SelectionSymbolizer = ps;
         }
         IFeatureLayer fl = lb.Item as IFeatureLayer;
         if (fl != null)
         {
             FeatureLayerDialog layDialog = new FeatureLayerDialog(fl);
             layDialog.ShowDialog();
         }
         IRasterLayer rl = lb.Item as IRasterLayer;
         if(rl != null)
         {
             RasterLayerDialog dlg = new RasterLayerDialog(rl);
             dlg.ShowDialog();
         }
         IColorCategory cb = lb.Item as IColorCategory;
         if(cb != null)
         {
             _tabColorDialog = new TabColorDialog();
             _tabColorDialog.ChangesApplied += new EventHandler(_tabColorDialog_ChangesApplied);
             _tabColorDialog.StartColor = cb.LowColor;
             _tabColorDialog.EndColor = cb.HighColor;
             _editCategory = cb;
             _tabColorDialog.ShowDialog(this);
         }
     }
     base.OnMouseDoubleClick(e);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Updates the raster breaks.
        /// </summary>
        public void UpdateRasterBreaks()
        {
            if (_rasterLayer == null)
            {
                return;
            }
            IColorCategory selectedBrk = null;

            if (_selectedSlider != null)
            {
                selectedBrk = _selectedSlider.Category as IColorCategory;
            }
            Breaks.Clear();
            Statistics stats = _rasterSymbolizer.Scheme.Statistics;
            Rectangle  gb    = _graph.GetGraphBounds();

            _graph.ColorRanges.Clear();
            foreach (IColorCategory category in _rasterSymbolizer.Scheme.Categories)
            {
                ColorRange cr = new ColorRange(category.LowColor, category.Range);
                _graph.ColorRanges.Add(cr);
                BreakSlider bs = new BreakSlider(gb, _graph.Minimum, _graph.Maximum, cr)
                {
                    Color       = _breakColor,
                    SelectColor = _selectedBreakColor
                };
                if (selectedBrk != null && category == selectedBrk)
                {
                    bs.Selected          = true;
                    _selectedSlider      = bs;
                    _graph.SelectedRange = cr;
                }

                bs.Value = category.Maximum != null?double.Parse(category.Maximum.ToString()) : stats.Maximum;

                bs.Category = category;
                Breaks.Add(bs);
            }

            Breaks.Sort();

            // Moving a break generally affects both a maximum and a minimum.
            // Point to the next category to actuate that.
            for (int i = 0; i < Breaks.Count - 1; i++)
            {
                Breaks[i].NextCategory = Breaks[i + 1].Category;

                // We use the maximums to set up breaks. Minimums should simply
                // be set to work with the maximums of the previous category.
                // _breaks[i + 1].Category.Minimum = _breaks[i].Value; REMOVED BY jany_ (2015-07-07) Don't set minimum, because that changes the minimum of the rasters category which causes the colors to change when saving in RasterColorControl without making changes or for example only applying opacity without wanting to use statistics.
            }

            if (Breaks.Count == 0)
            {
                return;
            }
            int         breakIndex = 0;
            BreakSlider nextSlider = Breaks[breakIndex];
            int         count      = 0;

            if (_graph?.Bins == null)
            {
                return;
            }
            foreach (double value in _values)
            {
                if (value < nextSlider.Value)
                {
                    count++;
                    continue;
                }

                nextSlider.Count = count;
                while (value > nextSlider.Value)
                {
                    breakIndex++;
                    if (breakIndex >= Breaks.Count)
                    {
                        break;
                    }

                    nextSlider = Breaks[breakIndex];
                }

                count = 0;
            }
        }
 /// <summary>
 /// Initializes a new instance of the ColorCategoryEventArgs class.
 /// </summary>
 /// <param name="colorCategory">The IColorCategory that is involved in this event.</param>
 public ColorCategoryEventArgs(IColorCategory colorCategory)
 {
     _colorCategory = colorCategory;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Show the color category editor form.
 /// </summary>
 /// <param name="category">The color category.</param>
 public void ShowEdit(IColorCategory category)
 {
     using var frm = new ColorPicker(category);
     ShowDialog(frm);
 }
Exemplo n.º 17
0
        /// <summary>
        /// Attempts to increase the position of the specified category, and returns true
        /// if the index increase was successful.
        /// </summary>
        /// <param name="category">The category to increase the position of</param>
        /// <returns>Boolean, true if the item's position was increased</returns>
        public override bool IncreaseCategoryIndex(ICategory category)
        {
            IColorCategory cc = category as IColorCategory;

            return(cc != null && _categories.IncreaseIndex(cc));
        }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateRasterBreaks()
        {
            if (_rasterLayer == null)
            {
                return;
            }
            IColorCategory selectedBrk = null;

            if (_selectedSlider != null)
            {
                selectedBrk = _selectedSlider.Category as IColorCategory;
            }
            _breaks.Clear();
            Statistics stats = _rasterSymbolizer.Scheme.Statistics;
            Rectangle  gb    = _graph.GetGraphBounds();

            _graph.ColorRanges.Clear();
            foreach (IColorCategory category in _rasterSymbolizer.Scheme.Categories)
            {
                ColorRange cr = new ColorRange(category.LowColor, category.Range);
                _graph.ColorRanges.Add(cr);
                BreakSlider bs = new BreakSlider(gb, _graph.Minimum, _graph.Maximum, cr);
                bs.Color       = _breakColor;
                bs.SelectColor = _selectedBreakColor;
                if (selectedBrk != null && category == selectedBrk)
                {
                    bs.Selected          = true;
                    _selectedSlider      = bs;
                    _graph.SelectedRange = cr;
                }
                if (category.Maximum != null)
                {
                    bs.Value = double.Parse(category.Maximum.ToString());
                }
                else
                {
                    bs.Value = stats.Maximum;
                }
                bs.Category = category;
                _breaks.Add(bs);
            }
            _breaks.Sort();
            // Moving a break generally affects both a maximum and a minimum.
            // Point to the next category to actuate that.
            for (int i = 0; i < _breaks.Count - 1; i++)
            {
                _breaks[i].NextCategory = _breaks[i + 1].Category;
                // We use the maximums to set up breaks.  Minimums should simply
                // be set to work with the maximums of the previous category.
                _breaks[i + 1].Category.Minimum = _breaks[i].Value;
            }

            if (_breaks.Count == 0)
            {
                return;
            }
            int         breakIndex = 0;
            BreakSlider nextSlider = _breaks[breakIndex];
            int         count      = 0;

            if (_graph == null || _graph.Bins == null)
            {
                return;
            }
            foreach (double value in _values)
            {
                if (value < nextSlider.Value)
                {
                    count++;
                    continue;
                }
                nextSlider.Count = count;
                while (value > nextSlider.Value)
                {
                    breakIndex++;
                    if (breakIndex >= _breaks.Count)
                    {
                        break;
                    }
                    nextSlider = _breaks[breakIndex];
                }
                count = 0;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            _wasDoubleClick = true;
            Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top);

            foreach (LegendBox lb in _legendBoxes)
            {
                if (!lb.Bounds.Contains(loc) || lb.CheckBox.Contains(loc))
                {
                    continue;
                }
                ILineCategory lc = lb.Item as ILineCategory;
                if (lc != null)
                {
                    DetailedLineSymbolDialog lsDialog = new DetailedLineSymbolDialog(lc.Symbolizer);
                    lsDialog.ShowDialog();
                    ILineSymbolizer sel = lc.Symbolizer.Copy();
                    sel.SetFillColor(Color.Cyan);
                    lc.SelectionSymbolizer = sel;
                }
                IPointCategory pc = lb.Item as IPointCategory;
                if (pc != null)
                {
                    DetailedPointSymbolDialog dlg = new DetailedPointSymbolDialog(pc.Symbolizer);
                    dlg.ShowDialog();
                    IPointSymbolizer ps = pc.Symbolizer.Copy();
                    ps.SetFillColor(Color.Cyan);
                    pc.SelectionSymbolizer = ps;
                }
                IPolygonCategory polyCat = lb.Item as IPolygonCategory;
                if (polyCat != null)
                {
                    DetailedPolygonSymbolDialog dlg = new DetailedPolygonSymbolDialog(polyCat.Symbolizer);
                    dlg.ShowDialog();
                    IPolygonSymbolizer ps = polyCat.Symbolizer.Copy();
                    ps.SetFillColor(Color.Cyan);
                    ps.OutlineSymbolizer.SetFillColor(Color.DarkCyan);
                    polyCat.SelectionSymbolizer = ps;
                }
                IFeatureLayer fl = lb.Item as IFeatureLayer;
                if (fl != null)
                {
                    LayerDialog layDialog = new LayerDialog(fl, new FeatureCategoryControl());
                    layDialog.ShowDialog();
                }
                IRasterLayer rl = lb.Item as IRasterLayer;
                if (rl != null)
                {
                    LayerDialog dlg = new LayerDialog(rl, new RasterCategoryControl());
                    dlg.ShowDialog();
                }
                IColorCategory cb = lb.Item as IColorCategory;
                if (cb != null)
                {
                    _tabColorDialog = new TabColorDialog();
                    _tabColorDialog.ChangesApplied += TabColorDialogChangesApplied;
                    _tabColorDialog.StartColor      = cb.LowColor;
                    _tabColorDialog.EndColor        = cb.HighColor;
                    _editCategory = cb;
                    _tabColorDialog.ShowDialog(this);
                }
            }
            base.OnMouseDoubleClick(e);
        }
Exemplo n.º 20
0
        private void DgvCategoriesCellValidated(object sender, DataGridViewCellEventArgs e)
        {
            if (_ignoreValidation)
            {
                return;
            }
            if (_newScheme.Categories.Count <= e.RowIndex)
            {
                return;
            }

            if (e.ColumnIndex == 2)
            {
                IColorCategory fctxt = _newScheme.Categories[e.RowIndex];
                fctxt.LegendText = (string)dgvCategories[e.ColumnIndex, e.RowIndex].Value;
                return;
            }

            if (e.ColumnIndex != 1)
            {
                return;
            }

            IColorCategory cb = _newScheme.Categories[e.RowIndex];

            if ((string)dgvCategories[e.ColumnIndex, e.RowIndex].Value == cb.LegendText)
            {
                return;
            }
            _ignoreEnter = true;
            string exp = (string)dgvCategories[e.ColumnIndex, e.RowIndex].Value;

            cb.LegendText = exp;

            cb.Range = new Range(exp);
            if (cb.Range.Maximum != null && cb.Range.Maximum > _raster.Maximum)
            {
                cb.Range.Maximum = _raster.Maximum;
            }

            if (cb.Range.Minimum != null && cb.Range.Minimum > _raster.Maximum)
            {
                cb.Range.Minimum = _raster.Maximum;
            }

            if (cb.Range.Maximum != null && cb.Range.Minimum < _raster.Minimum)
            {
                cb.Range.Minimum = _raster.Minimum;
            }

            if (cb.Range.Minimum != null && cb.Range.Minimum < _raster.Minimum)
            {
                cb.Range.Minimum = _raster.Minimum;
            }

            cb.ApplyMinMax(_newScheme.EditorSettings);
            ColorCategoryCollection breaks = _newScheme.Categories;

            breaks.SuspendEvents();
            if (cb.Range.Minimum == null && cb.Range.Maximum == null)
            {
                breaks.Clear();
                breaks.Add(cb);
            }
            else if (cb.Range.Maximum == null)
            {
                List <IColorCategory> removeList = new();

                int iPrev = e.RowIndex - 1;
                for (int i = 0; i < e.RowIndex; i++)
                {
                    // If the specified max is below the minima of a lower range, remove the lower range.
                    if (breaks[i].Minimum > cb.Minimum)
                    {
                        removeList.Add(breaks[i]);
                        iPrev--;
                    }
                    else if (breaks[i].Maximum > cb.Minimum || i == iPrev)
                    {
                        // otherwise, if the maximum of a lower range is higher than the value, adjust it.
                        breaks[i].Maximum = cb.Minimum;
                        breaks[i].ApplyMinMax(_symbolizer.EditorSettings);
                    }
                }

                for (int i = e.RowIndex + 1; i < breaks.Count; i++)
                {
                    // Since we have just assigned an absolute maximum, any previous categories
                    // that fell above the edited category should be removed.
                    removeList.Add(breaks[i]);
                }

                foreach (IColorCategory brk in removeList)
                {
                    // Do the actual removal.
                    breaks.Remove(brk);
                }
            }
            else if (cb.Range.Minimum == null)
            {
                List <IColorCategory> removeList = new();

                int iNext = e.RowIndex + 1;
                for (int i = e.RowIndex + 1; i < breaks.Count; i++)
                {
                    // If the specified max is below the minima of a lower range, remove the lower range.
                    if (breaks[i].Maximum < cb.Maximum)
                    {
                        removeList.Add(breaks[i]);
                        iNext++;
                    }
                    else if (breaks[i].Minimum < cb.Maximum || i == iNext)
                    {
                        // otherwise, if the maximum of a lower range is higher than the value, adjust it.
                        breaks[i].Minimum = cb.Maximum;
                        breaks[i].ApplyMinMax(_symbolizer.EditorSettings);
                    }
                }

                for (int i = 0; i < e.RowIndex; i++)
                {
                    // Since we have just assigned an absolute minimum, any previous categories
                    // that fell above the edited category should be removed.
                    removeList.Add(breaks[i]);
                }

                foreach (IColorCategory brk in removeList)
                {
                    // Do the actual removal.
                    breaks.Remove(brk);
                }
            }
            else
            {
                // We have two values. Adjust any above or below that conflict.
                List <IColorCategory> removeList = new();
                int iPrev = e.RowIndex - 1;
                for (int i = 0; i < e.RowIndex; i++)
                {
                    // If the specified max is below the minima of a lower range, remove the lower range.
                    if (breaks[i].Minimum > cb.Minimum)
                    {
                        removeList.Add(breaks[i]);
                        iPrev--;
                    }
                    else if (breaks[i].Maximum > cb.Minimum || i == iPrev)
                    {
                        // otherwise, if the maximum of a lower range is higher than the value, adjust it.
                        breaks[i].Maximum = cb.Minimum;
                        breaks[i].ApplyMinMax(_symbolizer.EditorSettings);
                    }
                }

                int iNext = e.RowIndex + 1;
                for (int i = e.RowIndex + 1; i < breaks.Count; i++)
                {
                    // If the specified max is below the minima of a lower range, remove the lower range.
                    if (breaks[i].Maximum < cb.Maximum)
                    {
                        removeList.Add(breaks[i]);
                        iNext++;
                    }
                    else if (breaks[i].Minimum < cb.Maximum || i == iNext)
                    {
                        // otherwise, if the maximum of a lower range is higher than the value, adjust it.
                        breaks[i].Minimum = cb.Maximum;
                        breaks[i].ApplyMinMax(_symbolizer.EditorSettings);
                    }
                }

                foreach (IColorCategory brk in removeList)
                {
                    // Do the actual removal.
                    breaks.Remove(brk);
                }
            }

            breaks.ResumeEvents();
            _ignoreRefresh           = true;
            cmbInterval.SelectedItem = IntervalMethod.Manual;
            _symbolizer.EditorSettings.IntervalMethod = IntervalMethod.Manual;
            _ignoreRefresh = false;
            UpdateStatistics(false);
            _cleanupTimer.Start();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Applies the specified color scheme and uses the specified raster to define the
        /// minimum and maximum to use for the scheme.
        /// </summary>
        /// <param name="schemeType">ColorSchemeType.</param>
        /// <param name="min">THe minimum value to use for the scheme.</param>
        /// <param name="max">THe maximum value to use for the scheme.</param>
        public void ApplyScheme(ColorSchemeType schemeType, double min, double max)
        {
            if (Categories == null)
            {
                Categories = new ColorCategoryCollection(this);
            }
            else
            {
                Categories.Clear();
            }

            IColorCategory eqCat = null, low = null, high = null;

            if (min == max)
            {
                // Create one category
                eqCat = new ColorCategory(min, max)
                {
                    Range = { MaxIsInclusive = true, MinIsInclusive = true }
                };
                eqCat.ApplyMinMax(EditorSettings);
                Categories.Add(eqCat);
            }
            else
            {
                // Create two categories
                low = new ColorCategory(min, (min + max) / 2)
                {
                    Range = { MaxIsInclusive = true }
                };
                high = new ColorCategory((min + max) / 2, max)
                {
                    Range = { MaxIsInclusive = true }
                };
                low.ApplyMinMax(EditorSettings);
                high.ApplyMinMax(EditorSettings);
                Categories.Add(low);
                Categories.Add(high);
            }

            Color lowColor, midColor, highColor;
            int   alpha = Utils.ByteRange(Convert.ToInt32(_opacity * 255F));

            switch (schemeType)
            {
            case ColorSchemeType.SummerMountains:
                lowColor  = Color.FromArgb(alpha, 10, 100, 10);
                midColor  = Color.FromArgb(alpha, 153, 125, 25);
                highColor = Color.FromArgb(alpha, 255, 255, 255);
                break;

            case ColorSchemeType.FallLeaves:
                lowColor  = Color.FromArgb(alpha, 10, 100, 10);
                midColor  = Color.FromArgb(alpha, 199, 130, 61);
                highColor = Color.FromArgb(alpha, 241, 220, 133);
                break;

            case ColorSchemeType.Desert:
                lowColor  = Color.FromArgb(alpha, 211, 206, 97);
                midColor  = Color.FromArgb(alpha, 139, 120, 112);
                highColor = Color.FromArgb(alpha, 255, 255, 255);
                break;

            case ColorSchemeType.Glaciers:
                lowColor  = Color.FromArgb(alpha, 105, 171, 224);
                midColor  = Color.FromArgb(alpha, 162, 234, 240);
                highColor = Color.FromArgb(alpha, 255, 255, 255);
                break;

            case ColorSchemeType.Meadow:
                lowColor  = Color.FromArgb(alpha, 68, 128, 71);
                midColor  = Color.FromArgb(alpha, 43, 91, 30);
                highColor = Color.FromArgb(alpha, 167, 220, 168);
                break;

            case ColorSchemeType.ValleyFires:
                lowColor  = Color.FromArgb(alpha, 164, 0, 0);
                midColor  = Color.FromArgb(alpha, 255, 128, 64);
                highColor = Color.FromArgb(alpha, 255, 255, 191);
                break;

            case ColorSchemeType.DeadSea:
                lowColor  = Color.FromArgb(alpha, 51, 137, 208);
                midColor  = Color.FromArgb(alpha, 226, 227, 166);
                highColor = Color.FromArgb(alpha, 151, 146, 117);
                break;

            case ColorSchemeType.Highway:
                lowColor  = Color.FromArgb(alpha, 51, 137, 208);
                midColor  = Color.FromArgb(alpha, 214, 207, 124);
                highColor = Color.FromArgb(alpha, 54, 152, 69);
                break;

            default:
                lowColor = midColor = highColor = Color.Transparent;
                break;
            }

            if (eqCat != null)
            {
                eqCat.LowColor = eqCat.HighColor = lowColor;
            }
            else
            {
                Debug.Assert(low != null, "low may not be null");
                Debug.Assert(high != null, "high may not be null");

                low.LowColor   = lowColor;
                low.HighColor  = midColor;
                high.LowColor  = midColor;
                high.HighColor = highColor;
            }

            OnItemChanged(this);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the ColorCategoryEventArgs class.
 /// </summary>
 /// <param name="colorCategory">The IColorCategory that is involved in this event.</param>
 public ColorCategoryEventArgs(IColorCategory colorCategory)
 {
     _colorCategory = colorCategory;
 }