/// <summary>
        /// Runs the tool.
        /// </summary>
        public override bool Run(ITaskHandle task)
        {
            using (var grid = new GridSource(Input))
            {
                RasterColorScheme rcs = null;

                if (UseBuiltInColorScheme)
                {
                    rcs = grid.RetrieveColorScheme(GridSchemeRetrieval.Auto);
                    if (rcs == null)
                    {
                        Log.Error("No predefined color scheme was found.", null);
                        return(false);
                    }
                }
                else
                {
                    rcs = grid.GenerateColorScheme(GridSchemeGeneration.Gradient, ColorScheme);
                }

                MapConfig.GridProxyFormat = ProxyFormat;

                Output.Result = grid.CreateImageProxy(rcs);
            }

            return(Output.Result != null);
        }
Example #2
0
        public IImageSource GridToImage2(IGridSource grid, RasterColorScheme scheme, GridProxyFormat imageFormat,
                                         bool inRam)
        {
            var img = _utils.GridToImage2(grid.GetInternal(), scheme.GetInternal(), (tkGridProxyFormat)imageFormat, inRam, null);

            return(BitmapSource.Wrap(img));
        }
        public void SetColorSchemeCore(RasterColorScheme value)
        {
            bool showGradient = value != null && value.ColoringType != GridColoringType.Random;

            colorSchemeGrid.DataSource   = null;            // to avoid flicker on setting ShowGradient
            colorSchemeGrid.ShowGradient = showGradient;

            colorSchemeGrid.DataSource = value != null?value.ToList() : null;
        }
        private RasterColorScheme Classify()
        {
            var band = Model.Bands[View.ActiveBandIndex];

            if (band == null)
            {
                return(null);
            }

            RasterColorScheme scheme = null;

            double minValue = View.BandMinValue;
            double maxValue = View.BandMaxValue;

            switch (View.Classification)
            {
            case RasterClassification.EqualIntervals:
                scheme = band.Classify(minValue, maxValue, Classification.EqualIntervals, View.ColorRamp.Count - 1);
                break;

            case RasterClassification.EqualCount:
                scheme = band.Classify(minValue, maxValue, Classification.EqualCount, View.NumBreaks);
                break;

            case RasterClassification.UniqueValues:
                scheme = band.Classify(minValue, maxValue, Classification.UniqueValues, 256);
                if (scheme == null)
                {
                    MessageService.Current.Info("To many values for unique values classification (256 is max).");
                    return(null);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(scheme);
        }
Example #5
0
        /// <summary>
        /// Renders color scheme (rectangle and name for each break).
        /// </summary>
        private void RenderColorScheme(Graphics g, LegendLayer layer, Rectangle bounds, ref Rectangle r, RasterColorScheme scheme, bool gradients, bool horizontal = false)
        {
            var textRect = new Rectangle(
                r.Left + Constants.IconWidth + 3,
                r.Top,
                bounds.Width - Constants.TextRightPadNoIcon - Constants.CsTextLeftIndent,
                Constants.TextHeight);

            if (scheme == null)
            {
                return;
            }

            // var count = 0;
            foreach (var item in scheme)
            {
                Brush brush;
                if (gradients)
                {
                    brush = new LinearGradientBrush(r, item.LowColor, item.HighColor, horizontal ? 0.0f : 90.0f);
                }
                else
                {
                    brush = new SolidBrush(item.LowColor);
                }

                g.FillRectangle(brush, r);
                g.DrawRectangle(Pens.Gray, r);

                layer.Elements.Add(LayerElementType.RasterColorBox, r);

                DrawText(g, item.ToString(), textRect, Font, Color.Black);

                r.Y        += Constants.CsItemHeightAndPad;
                textRect.Y += Constants.CsItemHeightAndPad;
                // count++;
            }
        }
Example #6
0
 public static GridColorScheme GetInternal(this RasterColorScheme colorScheme)
 {
     return(colorScheme.InternalObject as GridColorScheme);
 }
Example #7
0
 public Image GridToImage(IGridSource grid, RasterColorScheme scheme)
 {
     return(_utils.GridToImage(grid.GetInternal(), scheme.GetInternal()));
 }