Ejemplo n.º 1
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var lineString = ((LineString) geometry).Vertices;

            float lineWidth = 1;
            var lineColor = new Color();

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Line.Width;
                lineColor = vectorStyle.Line.Color;
            }

            var line = WorldToScreen(viewport, lineString);
            var path = ToSkia(line);

            using (var paint = new SKPaint())
            {
                paint.IsStroke = true;
                paint.StrokeWidth = lineWidth;
                paint.Color = lineColor.ToSkia();
                paint.StrokeJoin = SKStrokeJoin.Round;

                canvas.DrawPath(path, paint);
            }
        }
Ejemplo n.º 2
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature,
            IDictionary<object, SKBitmapInfo> skBitmapCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                SKBitmapInfo textureInfo;

                if (!skBitmapCache.Keys.Contains(raster))
                {
                    textureInfo = BitmapHelper.LoadTexture(raster.Data);
                    skBitmapCache[raster] = textureInfo;
                }
                else
                {
                    textureInfo = skBitmapCache[raster];
                }

                textureInfo.IterationUsed = currentIteration;
                skBitmapCache[raster] = textureInfo;
                var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                BitmapHelper.RenderRaster(canvas, textureInfo.Bitmap, RoundToPixel(destination).ToSkia());
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }
        }
Ejemplo n.º 3
0
		public static void Draw(CALayer target, IViewport viewport, IStyle style, IFeature feature)
		{
			const string styleKey = "laag";

			if(feature[styleKey] == null) feature[styleKey] = ToiOSBitmap(feature.Geometry);

			var bitmap = (UIImage)feature [styleKey];

			var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
			dest = new BoundingBox(
				dest.MinX,
				dest.MinY,
				dest.MaxX,
				dest.MaxY);

			var destination = RoundToPixel(dest);

			var tile = new CALayer
			{
				Frame = destination,
				Contents = bitmap.CGImage,
			};
			
			target.AddSublayer(tile);
		}
Ejemplo n.º 4
0
 public void PaintValue(Graphics graphic, Rectangle renderRect, Rectangle clipRect, IStyle style, object value)
 {
     brush.Color = ValidateValue(value);
     clipRect.Height--;
     graphic.FillRectangle(brush, clipRect);
     graphic.DrawRectangle(Pens.Black, clipRect);
 }
Ejemplo n.º 5
0
        public static void Draw(IViewport viewport, IStyle style, IFeature feature)
        {
            var lineString = ((LineString)feature.Geometry).Vertices;

            float lineWidth = 1;
            var lineColor = Color.White;

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float)vectorStyle.Line.Width;
                lineColor = vectorStyle.Line.Color;
            }

            float[] points = ToOpenTK(lineString);
            WorldToScreen(viewport, points);

            GL.LineWidth(lineWidth);
            GL.Color4((byte)lineColor.R, (byte)lineColor.G, (byte)lineColor.B, (byte)lineColor.A);
            GL.EnableClientState(All.VertexArray);
            GL.VertexPointer(2, All.Float, 0, points);
            GL.DrawArrays(All.Lines, 0, points.Length / 2);
            GL.DisableClientState(All.VertexArray);
        }
Ejemplo n.º 6
0
 public static void Initialize(         
  IConsole console,
  ISurface surface,
  IStyle style,
  IDrawings drawing,
  IShapes shapes,
  IImages images,
  IControls controls,
  ISounds sounds,         
  IKeyboard keyboard,
  IMouse mouse,
  ITimer timer,
  IFlickr flickr,
  ISpeech speech,
  CancellationToken token)
 {
     TextWindow.Init(console);
      Desktop.Init(surface);
      GraphicsWindow.Init(style, surface, drawing, keyboard, mouse);
      Shapes.Init(shapes);
      ImageList.Init(images);
      Turtle.Init(surface, drawing, shapes);
      Controls.Init(controls);
      Sound.Init(sounds);
      Timer.Init(timer);
      Stack.Init();
      Flickr.Init(flickr);
      Speech.Init(speech);
      Program.Init(token);
 }
Ejemplo n.º 7
0
        public static void Draw(IViewport viewport, IStyle style, IFeature feature, IDictionary<object, TextureInfo> TextureCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                TextureInfo textureInfo;

                if (!TextureCache.Keys.Contains(raster))
                {
                    textureInfo = TextureHelper.LoadTexture(raster.Data);
                    TextureCache[raster] = textureInfo;
                }
                else
                {
                    textureInfo = TextureCache[raster];
                }

                textureInfo.IterationUsed = currentIteration;
                TextureCache[raster] = textureInfo;
                var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                TextureHelper.RenderTexture(textureInfo.TextureId, ToVertexArray(RoundToPixel(destination)));
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 8
0
 public static bool AreStylesEqual(IStyle lhs, IStyle rhs)
 {
     Assert.AreEqual(lhs.MinVisible, rhs.MinVisible, "MinVisible differs");
     Assert.AreEqual(lhs.MaxVisible, rhs.MaxVisible, "MaxVisible differs");
     Assert.AreEqual(lhs.Enabled, rhs.Enabled, "Enabled differs");
     return true;
 }
Ejemplo n.º 9
0
        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            try
            {
                if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry);
                var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style];
                
                var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                dest = new BoundingBox(
                    dest.MinX,
                    dest.MinY,
                    dest.MaxX,
                    dest.MaxY);

                var destination = RoundToPixel(dest);
                using (var paint = new Paint())
                {
                    canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint);
                }

                DrawOutline(canvas, style, destination);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

        }
Ejemplo n.º 10
0
        public static void Render(Graphics graphics, IGeometry feature, IStyle style, IViewport viewport)
        {
            var stream = ((IRaster)feature).Data;
            stream.Position = 0;
            var bitmap = new Bitmap(stream);

            Geometries.Point min = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MinX, feature.GetBoundingBox().MinY));
            Geometries.Point max = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MaxX, feature.GetBoundingBox().MaxY));

            Rectangle destination = RoundToPixel(new RectangleF((float)min.X, (float)max.Y, (float)(max.X - min.X), (float)(min.Y - max.Y)));
            graphics.DrawImage(bitmap,
                destination,
                0, 0, bitmap.Width, bitmap.Height,
                GraphicsUnit.Pixel,
                new ImageAttributes());

            if (DeveloperTools.DeveloperMode)
            {
                var font = new System.Drawing.Font("Arial", 12);
                var message = (GC.GetTotalMemory(true) / 1000).ToString(CultureInfo.InvariantCulture) + " KB";
                graphics.DrawString(message, font, new SolidBrush(Color.Black), 10f, 10f);
            }

            bitmap.Dispose();
        }
Ejemplo n.º 11
0
        public static XamlShapes.Shape RenderPoint(Point point, IStyle style, IViewport viewport,
            BrushCache brushCache = null)
        {
            XamlShapes.Shape symbol;
            var matrix = XamlMedia.Matrix.Identity;

            if (style is SymbolStyle)
            {
                var symbolStyle = style as SymbolStyle;

                if (symbolStyle.BitmapId < 0)
                    symbol = CreateSymbolFromVectorStyle(symbolStyle, symbolStyle.Opacity, symbolStyle.SymbolType);
                else
                    symbol = CreateSymbolFromBitmap(symbolStyle.BitmapId, symbolStyle.Opacity, brushCache);
                matrix = CreatePointSymbolMatrix(viewport.Resolution, symbolStyle);
            }
            else
            {
                symbol = CreateSymbolFromVectorStyle((style as VectorStyle) ?? new VectorStyle());
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }

            MatrixHelper.Append(ref matrix, GeometryRenderer.CreateTransformMatrix(point, viewport));

            symbol.RenderTransform = new XamlMedia.MatrixTransform {Matrix = matrix};
            symbol.IsHitTestVisible = false;

            return symbol;
        }
Ejemplo n.º 12
0
 public static ILayer CreateLineStringLayer(IStyle style = null)
 {
     return new MemoryLayer
     {
         DataSource = new MemoryProvider(
             new[] { new LineString(new[]
                 {
                     new Point(0, 0), 
                     new Point(10000, 10000),
                     new Point(10000, 0),
                     new Point(0, 10000),
                     new Point(100000, 100000),
                     new Point(100000, 0),
                     new Point(0, 100000),
                     new Point(1000000, 1000000),
                     new Point(1000000, 0),
                     new Point(0, 1000000),
                     new Point(10000000, 10000000),
                     new Point(10000000, 0),
                     new Point(0, 10000000)
                 }
             )}
         ),
         Name = "LineStringLayer",
         Style = style
     };
 }
Ejemplo n.º 13
0
        public static XamlShapes.Shape RenderPoint(Point point, IStyle style, IViewport viewport)
        {
            XamlShapes.Shape symbol;
            var matrix = XamlMedia.Matrix.Identity;

            if (style is SymbolStyle)
            {
                var symbolStyle = style as SymbolStyle;

                if (symbolStyle.BitmapId < 0)
                    symbol = CreateSymbolFromVectorStyle(symbolStyle, symbolStyle.Opacity, symbolStyle.SymbolType, symbolStyle.Width, symbolStyle.Height);
                else
                    symbol = CreateSymbolFromBitmap(BitmapRegistry.Instance.Get(symbolStyle.BitmapId), symbolStyle.Opacity);
                matrix = CreatePointSymbolMatrix(viewport.Resolution, symbolStyle);
            }
            else
            {
                symbol = CreateSymbolFromVectorStyle((style as VectorStyle) ?? new VectorStyle());
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }

            MatrixHelper.Append(ref matrix, CreateTransformMatrix(point, viewport));

            symbol.RenderTransform = new XamlMedia.MatrixTransform { Matrix = matrix };
            symbol.IsHitTestVisible = false;

            return symbol;
        }
Ejemplo n.º 14
0
 private static void GetGeneralProperties(ICssStyleDeclaration csd, IStyle style)
 {
     if (csd.GetPropertyValue("zoom-min-visible") != string.Empty)
         style.MinVisible = double.Parse(csd.GetPropertyValue("zoom-min-visible"));
     if (csd.GetPropertyValue("zoom-max-visible") != string.Empty)
         style.MaxVisible = double.Parse(csd.GetPropertyValue("zoom-max-visible"));
 }
Ejemplo n.º 15
0
        public static void PositionMultiPolygon(CALayer shape, MultiPolygon multiPolygon, IStyle style, IViewport viewport)
        {
            var shapeLayer = shape as CAShapeLayer;
            var path = multiPolygon.ToUIKit(viewport);
            //var frame = ConvertBoundingBox (multiPolygon.GetBoundingBox(), viewport);
            shapeLayer.Path = path.CGPath;
            //shape.Frame = frame;
            /*
            if (viewport.Resolution > MinResolution || viewport.Resolution < MaxResolution) {
                //recalculate
                var newImage = RenderMultiPolygonOnLayer (multiPolygon, style, viewport);

                shape.Contents = newImage.Contents;
                shape.Frame = newImage.Frame;

                var resolution = ZoomHelper.ClipResolutionToExtremes (Resolutions, viewport.Resolution);

                MinResolution = ZoomHelper.ZoomOut (Resolutions, resolution);
                MaxResolution = ZoomHelper.ZoomIn (Resolutions, resolution);

            } else {
                //reposition Geometry
                var frame = ConvertBoundingBox (multiPolygon.GetBoundingBox(), viewport);
                var newFrame = new RectangleF (frame.X, (frame.Y), frame.Width, frame.Height);

                shape.Frame = newFrame;
                //shape.Frame = frame;
            }
            */
        }
Ejemplo n.º 16
0
        // todo:
        // try to remove the feature argument. LabelStyle should already contain the feature specific text
        // The visible feature iterator should create this LabelStyle
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature, 
            IGeometry geometry, IDictionary<int, SKBitmapInfo> symbolBitmapCache)
        {
            var point = geometry as Point;
            var destination = viewport.WorldToScreen(point);

            if (style is LabelStyle)              // case 1) LabelStyle
            {
                LabelRenderer.Draw(canvas, (LabelStyle) style, feature, (float) destination.X, (float) destination.Y);
            }
            else if (style is SymbolStyle)
            {
                var symbolStyle = (SymbolStyle)style;

                if ( symbolStyle.BitmapId >= 0)   // case 2) Bitmap Style
                {
                    DrawPointWithBitmapStyle(canvas, symbolStyle, destination, symbolBitmapCache);
                }
                else                              // case 3) SymbolStyle without bitmap
                {
                    DrawPointWithSymbolStyle(canvas, symbolStyle, destination, symbolStyle.SymbolType);
                }
            }
            else if (style is VectorStyle)        // case 4) VectorStyle
            {
                DrawPointWithVectorStyle(canvas, (VectorStyle) style, destination);
            }
            else
            {
                throw new Exception($"Style of type '{style.GetType()}' is not supported for points");
            }
        }
Ejemplo n.º 17
0
 public void Load(IStyle[] styles)
 {
     this._attributeValue = null;
     this._dirty = false;
     string attribute = styles[0].GetAttribute(this._omName);
     if (attribute != null)
     {
         attribute = attribute.Trim();
         for (int i = 1; i < styles.Length; i++)
         {
             string str2 = styles[i].GetAttribute(this._omName);
             if (str2 == null)
             {
                 str2 = null;
                 break;
             }
             str2 = str2.Trim();
             if ((this._caseSignificant && !attribute.Equals(str2)) || (string.Compare(attribute, str2, true, CultureInfo.InvariantCulture) != 0))
             {
                 attribute = null;
                 break;
             }
         }
         if (attribute != null)
         {
             this._attributeValue = this._caseSignificant ? attribute : attribute.ToLower(CultureInfo.InvariantCulture);
         }
     }
 }
Ejemplo n.º 18
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var polygon = (Polygon)geometry;

            float lineWidth = 1;
            var lineColor = Color.Black; // default
            var fillColor = Color.Gray; // default

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Outline.Width;
                lineColor = vectorStyle.Outline.Color;
                fillColor = vectorStyle.Fill?.Color;
            }

            using (var path = ToSkia(viewport, polygon))
            {
                using (var paint = new SKPaint())
                {
                    paint.IsAntialias = true;
                    paint.StrokeWidth = lineWidth;

                    paint.Style = SKPaintStyle.Fill;
                    paint.Color = fillColor.ToSkia();
                    canvas.DrawPath(path, paint);
                    paint.Style = SKPaintStyle.Stroke;
                    paint.Color = lineColor.ToSkia();
                    canvas.DrawPath(path, paint);
                }
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates an instance of this class
 /// </summary>
 /// <param name="minValue">The minimum value</param>
 /// <param name="maxValue">The maximum value</param>
 /// <param name="minStyle">The <see cref="IStyle">style</see> to apply for values equal to <paramref name="minValue"/></param>
 /// <param name="maxStyle">The <see cref="IStyle">style</see> to apply for values equal to <paramref name="maxValue"/></param>
 protected GradientThemeBase(double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
 {
     _min = minValue;
     _max = maxValue;
     _maxStyle = maxStyle;
     _minStyle = minStyle;
 }
Ejemplo n.º 20
0
        public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport)
        {
            if (_bgWorker == null)
                _bgWorker = new BackgroundWorker();
            /*
            while (_bgWorker.IsBusy) {
                Thread.Sleep (00001);
            }
            */
            _bgWorker.RunWorkerCompleted += (sender, e) =>
                {
                    var layer = e.Result as CALayer;

                    if (layer != null)
                    {
                        var styleKey = style.GetHashCode().ToString();
                        feature[styleKey] = layer;
                    }
                };

            _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    var layer = RenderImage(multiPolygon, style, viewport);
                    e.Result = layer;
                };

            _bgWorker.RunWorkerAsync();
        }
Ejemplo n.º 21
0
        public static UIElement RenderPoint(Point point, IStyle style, IViewport viewport)
        {
            UIElement symbol;
            var matrix = XamlMedia.Matrix.Identity;

            if (style is SymbolStyle)
            {
                var symbolStyle = style as SymbolStyle;

                if (symbolStyle.Symbol == null || symbolStyle.Symbol.Data == null)
                    symbol = CreateSymbolFromVectorStyle(symbolStyle, symbolStyle.Opacity, symbolStyle.SymbolType);
                else
                    symbol = CreateSymbolFromBitmap(symbolStyle.Symbol.Data, symbolStyle.Opacity);
                matrix = CreatePointSymbolMatrix(viewport.Resolution, symbolStyle);
            }
            else
            {
                symbol = CreateSymbolFromVectorStyle((style as VectorStyle) ?? new VectorStyle());
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }

            MatrixHelper.Append(ref matrix, CreateTransformMatrix(point, viewport));

            symbol.RenderTransform = new XamlMedia.MatrixTransform { Matrix = matrix };

            symbol.IsHitTestVisible = false;

            return symbol;
        }
Ejemplo n.º 22
0
        public static void Draw(IViewport viewport, IStyle style, IFeature feature)
        {
            var lineString = ((Polygon)feature.Geometry).ExteriorRing.Vertices;

            float lineWidth = 1;
            var lineColor = Color.Black; // default
            // todo: var fillColor = Color.Gray; // default

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float)vectorStyle.Outline.Width;
                lineColor = vectorStyle.Outline.Color;
                // todo: fillColor = vectorStyle.Fill.Color;
            }

            float[] points = ToOpenTK(lineString);
            WorldToScreen(viewport, points);

            // Fill
            // Not implemented. It might be hard to draw a concave polygon with holes.

            // Outline
            GL.LineWidth(lineWidth);
            GL.Color4(lineColor.R, lineColor.G, lineColor.B, lineColor.A);
            GL.EnableClientState(All.VertexArray);
            GL.VertexPointer(2, All.Float, 0, points);
            GL.DrawArrays(All.LineLoop, 0, points.Length / 2);
            GL.DisableClientState(All.VertexArray);
        }
Ejemplo n.º 23
0
	    private static void DrawOutline(CGContext currentContext, IStyle style, CGRect destination)
		{
			var vectorStyle = (style as VectorStyle);
			if (vectorStyle == null) return;
			if (vectorStyle.Outline == null) return;
			if (vectorStyle.Outline.Color == null) return;
			DrawRectangle(currentContext, destination, vectorStyle.Outline.Color);
		}
Ejemplo n.º 24
0
 public static void PositionPoint(UIElement renderedGeometry, Point point, IStyle style, IViewport viewport)
 {
     var matrix = XamlMedia.Matrix.Identity;
     if (style is SymbolStyle) matrix = CreatePointSymbolMatrix(viewport.Resolution, style as SymbolStyle);
     else MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
     MatrixHelper.Append(ref matrix, CreateTransformMatrix(point, viewport));
     renderedGeometry.RenderTransform = new XamlMedia.MatrixTransform { Matrix = matrix };
 }
Ejemplo n.º 25
0
 private static void DrawOutline(Canvas canvas, IStyle style, RectF destination)
 {
     var vectorStyle = (style as VectorStyle);
     if (vectorStyle == null) return;
     if (vectorStyle.Outline == null) return;
     if (vectorStyle.Outline.Color == null) return;
     DrawRectangle(canvas, destination, vectorStyle.Outline.Color);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the GradientTheme class
 /// </summary>
 /// <remarks>
 /// <para>The gradient theme interpolates linearly between two styles based on a numerical attribute in the datasource.
 /// This is useful for scaling symbols, line widths, line and fill colors from numerical attributes.</para>
 /// <para>Colors are interpolated between two colors, but if you want to interpolate through more colors (fx. a rainbow),
 /// set the <see cref="TextColorBlend"/>, <see cref="LineColorBlend"/> and <see cref="FillColorBlend"/> properties
 /// to a custom <see cref="ColorBlend"/>.
 /// </para>
 /// <para>The following properties are scaled (properties not mentioned here are not interpolated):
 /// <list type="table">
 ///        <listheader><term>Property</term><description>Remarks</description></listheader>
 ///        <item><term><see cref="Color"/></term><description>Red, Green, Blue and Alpha values are linearly interpolated.</description></item>
 ///        <item><term><see cref="Pen"/></term><description>The color, width, color of pens are interpolated. MiterLimit,StartCap,EndCap,LineJoin,DashStyle,DashPattern,DashOffset,DashCap,CompoundArray, and Alignment are switched in the middle of the min/max values.</description></item>
 ///        <item><term><see cref="Brush"/></term><description>Brush color are interpolated. Other brushes are not supported.</description></item>
 ///        <item><term><see cref="Mapsui.Styles.VectorStyle"/></term><description>MaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values.</description></item>
 ///        <item><term><see cref="Mapsui.Styles.LabelStyle"/></term><description>FontSize, BackColor, ForeColor, MaxVisible, MinVisible, Offset are scaled linearly. All other properties use min-style.</description></item>
 /// </list>
 /// </para>
 /// <example>
 /// Creating a rainbow colorblend showing colors from red, through yellow, green and blue depicting 
 /// the population density of a country.
 /// <code lang="C#">
 /// //Create two vector styles to interpolate between
 /// Mapsui.Styles.VectorStyle min = new Mapsui.Styles.VectorStyle();
 /// Mapsui.Styles.VectorStyle max = new Mapsui.Styles.VectorStyle();
 /// min.Outline.Width = 1f; //Outline width of the minimum value
 /// max.Outline.Width = 3f; //Outline width of the maximum value
 /// //Create a theme interpolating population density between 0 and 400
 /// Mapsui.Rendering.Thematics.GradientTheme popdens = new Mapsui.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max);
 /// //Set the fill-style colors to be a rainbow blend from red to blue.
 /// popdens.FillColorBlend = Mapsui.Rendering.Thematics.ColorBlend.Rainbow5;
 /// myVectorLayer.Styles.Add(popdens);
 /// </code>
 /// </example>
 /// </remarks>
 /// <param name="columnName">Name of column to extract the attribute</param>
 /// <param name="minValue">Minimum value</param>
 /// <param name="maxValue">Maximum value</param>
 /// <param name="minStyle">Color for minimum value</param>
 /// <param name="maxStyle">Color for maximum value</param>
 public GradientTheme(string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
 {
     ColumnName = columnName;
     Min = minValue;
     Max = maxValue;
     MaxStyle = maxStyle;
     MinStyle = minStyle;
 }
Ejemplo n.º 27
0
 private static ILayer CreateRandomPointLayer(BoundingBox envelope, int count = 25, IStyle style = null)
 {
     return new Layer
     {
         DataSource = new MemoryProvider(GenerateRandomPoints(envelope, count)),
         Style = style ?? new VectorStyle { Fill = new Brush(Color.White) }
     };
 }
Ejemplo n.º 28
0
 public CategorialThemeItem(string category, IStyle style, Bitmap symbol, object value)
 {
     label = category;
     this.style = (IStyle)style.Clone();
     Symbol = symbol;
     
     this.value = value;
 }
Ejemplo n.º 29
0
		/// <override></override>
		public override bool NotifyStyleChanged(IStyle style) {
			bool result = base.NotifyStyleChanged(style);
			if (IsStyleAffected(FillStyle, style)) {
				Invalidate();
				result = true;
			}
			return result;
		}
Ejemplo n.º 30
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var multiLineString = (MultiLineString) geometry;

            foreach (var lineString in multiLineString)
            {
                LineStringRenderer.Draw(canvas, viewport, style, lineString);
            }
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Add text to this text block
 /// </summary>
 /// <remarks>
 /// The added text will be internally coverted to UTF32.
 ///
 /// Note that all text indicies returned by and accepted by this object will
 /// be UTF32 "code point indicies".  To convert between UTF16 character indicies
 /// and UTF32 code point indicies use the <see cref="CodePointToCharacterIndex(int)"/>
 /// and <see cref="CharacterToCodePointIndex(int)"/> methods
 /// </remarks>
 /// <param name="text">The text to add</param>
 /// <param name="style">The style of the text</param>
 public void AddText(string text, IStyle style)
 {
     AddText(text.AsSpan(), style);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Creates an instance of this class
 /// </summary>
 /// <param name="minValue">The minimum value</param>
 /// <param name="maxValue">The maximum value</param>
 /// <param name="minStyle">The <see cref="IStyle">style</see> to apply for values equal to <paramref name="minValue"/></param>
 /// <param name="maxStyle">The <see cref="IStyle">style</see> to apply for values equal to <paramref name="maxValue"/></param>
 protected GradientThemeBase(double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
 {
     _min      = minValue;
     _max      = maxValue;
     _maxStyle = maxStyle;
     _minStyle = minStyle;
 }
Ejemplo n.º 33
0
        public GradientTheme(string attributeName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle,
                             ColorBlend fillColorBlend, ColorBlend lineColorBlend, ColorBlend textColorBlend, int numberOfClasses)
        {
            this.numberOfClasses = numberOfClasses;//store for updates later on..
            this.minValue        = minValue;
            this.maxValue        = maxValue;

            this.fillColorBlend = fillColorBlend;
            this.lineColorBlend = lineColorBlend;
            this.textColorBlend = textColorBlend;

            AttributeName = attributeName;

            //create themeitems only for the extremes. Other values are interpolated.
            CreateThemeItems(minStyle, maxStyle, numberOfClasses);

            minColor       = ThemeHelper.ExtractFillColorFromThemeItem(minItem);
            minItem.Symbol = ((VectorStyle)minStyle).LegendSymbol;
            maxColor       = ThemeHelper.ExtractFillColorFromThemeItem(maxItem);
            maxItem.Symbol = ((VectorStyle)maxStyle).LegendSymbol;
        }
Ejemplo n.º 34
0
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];

            //Change to build in name style.
            worksheet.Range["A1"].Value = "Bad";
            worksheet.Range["A1"].Style = workbook.Styles["Bad"];

            //Change to custom name style.
            //Add custom name style.
            IStyle style = workbook.Styles.Add("testStyle");

            //Config custom name style settings begin.
            //Border
            style.Borders[BordersIndex.EdgeLeft].LineStyle   = BorderLineStyle.Thin;
            style.Borders[BordersIndex.EdgeTop].LineStyle    = BorderLineStyle.Thick;
            style.Borders[BordersIndex.EdgeRight].LineStyle  = BorderLineStyle.Double;
            style.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Double;
            style.Borders.Color = Color.FromArgb(0, 255, 0);

            //Font
            style.Font.ThemeColor    = ThemeColor.Accent1;
            style.Font.TintAndShade  = 0.8;
            style.Font.Italic        = true;
            style.Font.Bold          = true;
            style.Font.Name          = "LiSu";
            style.Font.Size          = 28;
            style.Font.Strikethrough = true;
            style.Font.Subscript     = true;
            style.Font.Superscript   = false;
            style.Font.Underline     = UnderlineType.Double;

            //Protection
            style.FormulaHidden = true;
            style.Locked        = false;

            //Number
            style.NumberFormat = "#,##0_);[Red](#,##0)";

            //Alignment
            style.HorizontalAlignment = HorizontalAlignment.Right;
            style.VerticalAlignment   = VerticalAlignment.Bottom;
            style.WrapText            = true;
            style.IndentLevel         = 5;
            style.Orientation         = 45;

            //Fill
            style.Interior.ColorIndex   = 5;
            style.Interior.Pattern      = GrapeCity.Documents.Excel.Pattern.Down;
            style.Interior.PatternColor = Color.FromArgb(0, 0, 255);


            style.IncludeAlignment  = false;
            style.IncludeBorder     = true;
            style.IncludeFont       = false;
            style.IncludeNumber     = true;
            style.IncludePatterns   = false;
            style.IncludeProtection = true;
            //Config custom name style settings end.

            //Set range's style to custom name style.
            worksheet.Range["A2"].Value = "my test style";
            worksheet.Range["A2"].Style = worksheet.Workbook.Styles["testStyle"];

            worksheet.Range["A2"].RowHeightInPixel   = 60;
            worksheet.Range["A2"].ColumnWidthInPixel = 150;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Creates spreadsheet
        /// </summary>
        /// <param name="sender">Contains a reference to the control/object that raised the event</param>
        /// <param name="e">Contains the event data</param>
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            //New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Step 2 : Instantiate the excel application object.
                IApplication application = excelEngine.Excel;

                application.DefaultVersion = ExcelVersion.Xlsx;

                IWorkbook  workbook = application.Workbooks.Create(1);
                IWorksheet sheet1   = workbook.Worksheets[0];
                sheet1.Name = "Budget";
                sheet1.IsGridLinesVisible = false;
                sheet1.EnableSheetCalculations();

                sheet1.Range[1, 1].ColumnWidth   = 19.86;
                sheet1.Range[1, 2].ColumnWidth   = 14.38;
                sheet1.Range[1, 3].ColumnWidth   = 12.98;
                sheet1.Range[1, 4].ColumnWidth   = 12.08;
                sheet1.Range[1, 5].ColumnWidth   = 8.82;
                sheet1.Range["A1:A18"].RowHeight = 20.2;

                //Adding cell style.
                IStyle style1 = workbook.Styles.Add("style1");
                style1.Color = Syncfusion.Drawing.Color.FromArgb(217, 225, 242);
                style1.HorizontalAlignment = ExcelHAlign.HAlignLeft;
                style1.VerticalAlignment   = ExcelVAlign.VAlignCenter;
                style1.Font.Bold           = true;

                IStyle style2 = workbook.Styles.Add("style2");
                style2.Color             = Syncfusion.Drawing.Color.FromArgb(142, 169, 219);
                style2.VerticalAlignment = ExcelVAlign.VAlignCenter;
                style2.NumberFormat      = "[Red]($#,###)";
                style2.Font.Bold         = true;

                sheet1.Range["A10"].CellStyle               = style1;
                sheet1.Range["B10:D10"].CellStyle.Color     = Syncfusion.Drawing.Color.FromArgb(217, 225, 242);
                sheet1.Range["B10:D10"].HorizontalAlignment = ExcelHAlign.HAlignRight;
                sheet1.Range["B10:D10"].VerticalAlignment   = ExcelVAlign.VAlignCenter;
                sheet1.Range["B10:D10"].CellStyle.Font.Bold = true;

                sheet1.Range["A11:A17"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter;
                sheet1.Range["A11:D17"].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
                sheet1.Range["A11:D17"].Borders[ExcelBordersIndex.EdgeBottom].Color     = ExcelKnownColors.Grey_25_percent;

                sheet1.Range["D18"].CellStyle = style2;
                sheet1.Range["D18"].CellStyle.VerticalAlignment     = ExcelVAlign.VAlignCenter;
                sheet1.Range["A18:C18"].CellStyle.Color             = Syncfusion.Drawing.Color.FromArgb(142, 169, 219);
                sheet1.Range["A18:C18"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter;
                sheet1.Range["A18:C18"].CellStyle.Font.Bold         = true;
                sheet1.Range["A18:C18"].NumberFormat = "$#,###";

                sheet1.Range[10, 1].Text = "Category";
                sheet1.Range[10, 2].Text = "Expected cost";
                sheet1.Range[10, 3].Text = "Actual Cost";
                sheet1.Range[10, 4].Text = "Difference";
                sheet1.Range[11, 1].Text = "Venue";
                sheet1.Range[12, 1].Text = "Seating & Decor";
                sheet1.Range[13, 1].Text = "Technical team";
                sheet1.Range[14, 1].Text = "Performers";
                sheet1.Range[15, 1].Text = "Performer\'s transport";
                sheet1.Range[16, 1].Text = "Performer\'s stay";
                sheet1.Range[17, 1].Text = "Marketing";
                sheet1.Range[18, 1].Text = "Total";

                sheet1.Range["B11:D17"].NumberFormat = "$#,###";
                sheet1.Range["D11"].NumberFormat     = "[Red]($#,###)";
                sheet1.Range["D12"].NumberFormat     = "[Red]($#,###)";
                sheet1.Range["D14"].NumberFormat     = "[Red]($#,###)";

                sheet1.Range["B11"].Number  = 16250;
                sheet1.Range["B12"].Number  = 1600;
                sheet1.Range["B13"].Number  = 1000;
                sheet1.Range["B14"].Number  = 12400;
                sheet1.Range["B15"].Number  = 3000;
                sheet1.Range["B16"].Number  = 4500;
                sheet1.Range["B17"].Number  = 3000;
                sheet1.Range["B18"].Formula = "=SUM(B11:B17)";

                sheet1.Range["C11"].Number  = 17500;
                sheet1.Range["C12"].Number  = 1828;
                sheet1.Range["C13"].Number  = 800;
                sheet1.Range["C14"].Number  = 14000;
                sheet1.Range["C15"].Number  = 2600;
                sheet1.Range["C16"].Number  = 4464;
                sheet1.Range["C17"].Number  = 2700;
                sheet1.Range["C18"].Formula = "=SUM(C11:C17)";

                sheet1.Range["D11"].Formula = "=IF(C11>B11,C11-B11,B11-C11)";
                sheet1.Range["D12"].Formula = "=IF(C12>B12,C12-B12,B12-C12)";
                sheet1.Range["D13"].Formula = "=IF(C13>B13,C13-B13,B13-C13)";
                sheet1.Range["D14"].Formula = "=IF(C14>B14,C14-B14,B14-C14)";
                sheet1.Range["D15"].Formula = "=IF(C15>B15,C15-B15,B15-C15)";
                sheet1.Range["D16"].Formula = "=IF(C16>B16,C16-B16,B16-C16)";
                sheet1.Range["D17"].Formula = "=IF(C17>B17,C17-B17,B17-C17)";
                sheet1.Range["D18"].Formula = "=IF(C18>B18,C18-B18,B18-C18)";

                IChartShape chart = sheet1.Charts.Add();
                chart.ChartType           = ExcelChartType.Pie;
                chart.DataRange           = sheet1.Range["A11:B17"];
                chart.IsSeriesInRows      = false;
                chart.ChartTitle          = "Event Expenses";
                chart.ChartTitleArea.Bold = true;
                chart.ChartTitleArea.Size = 16;
                chart.TopRow      = 1;
                chart.BottomRow   = 10;
                chart.LeftColumn  = 1;
                chart.RightColumn = 5;
                chart.ChartArea.Border.LinePattern = ExcelChartLinePattern.None;

                string OutputFilename = "ExpensesReport.xlsx";

                MemoryStream stream = new MemoryStream();
                workbook.SaveAs(stream);
                Save(stream, OutputFilename);
                stream.Dispose();

                //No exception will be thrown if there are unsaved workbooks.
                excelEngine.ThrowNotSavedOnDestroy = false;
            }
        }
Ejemplo n.º 36
0
 // ReSharper disable PublicConstructorInAbstractClass
 ///<summary>
 /// Creates an instance of this class using the given Style
 ///</summary>
 ///<param name="style"></param>
 public Layer(Style style)
 // ReSharper restore PublicConstructorInAbstractClass
 {
     _style = style;
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Creates an instance of this class
 /// </summary>
 protected Layer() //Style style)
 {
     _style = new Style();
 }
Ejemplo n.º 38
0
        void OnExportClicked(object sender, EventArgs e)
        {
            ExcelEngine excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheets
            IWorkbook workbook = application.Workbooks.Create(1);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];

            //Create new DataTable to store the data from DataGrid
            DataTable dataTable = new DataTable();

            //Convert the Grid's data to DataTable
            ConvertGridDataToDataTable(dataTable, dataGrid.ItemsSource);

            //Import the DataTable to worksheet
            sheet.ImportDataTable(dataTable, 5, 1, false);

            #region Define Styles
            IStyle pageHeader = workbook.Styles.Add("PageHeaderStyle");
            IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle");

            pageHeader.Font.RGBColor = COLOR.Color.FromArgb(255, 83, 141, 213);
            pageHeader.Font.FontName = "Calibri";
            pageHeader.Font.Size = 18;
            pageHeader.Font.Bold = true;
            pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
            pageHeader.VerticalAlignment = ExcelVAlign.VAlignCenter;

            tableHeader.Font.Color = ExcelKnownColors.Black;
            tableHeader.Font.Bold = true;
            tableHeader.Font.Size = 11;
            tableHeader.Font.FontName = "Calibri";
            tableHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
            tableHeader.VerticalAlignment = ExcelVAlign.VAlignCenter;
            tableHeader.Color = COLOR.Color.FromArgb(255, 118, 147, 60);
            tableHeader.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
            #endregion

            #region Apply Styles
            // Apply style for header
            sheet["A1:D1"].Merge();
            sheet["A1"].Text = "Yearly Sales Report";
            sheet["A1"].CellStyle = pageHeader;
            sheet["A1"].RowHeight = 20;

            sheet["A2:D2"].Merge();
            sheet["A2"].Text = "Namewise Sales Comparison Report";
            sheet["A2"].CellStyle = pageHeader;
            sheet["A2"].CellStyle.Font.Bold = false;
            sheet["A2"].CellStyle.Font.Size = 16;
            sheet["A2"].RowHeight = 20;

            sheet["A3:A4"].Merge();
            sheet["D3:D4"].Merge();
            sheet["B3:C3"].Merge();
            sheet["B3"].Text = "Sales";
            sheet["A3:D4"].CellStyle = tableHeader;

            sheet["A3"].Text = "Sales Person";
            sheet["B4"].Text = "Jan - Jun";
            sheet["C4"].Text = "Jul - Dec";
            sheet["D3"].Text = "Change (%)";

            sheet.Columns[0].ColumnWidth = 19;
            sheet.Columns[1].ColumnWidth = 10;
            sheet.Columns[2].ColumnWidth = 10;
            sheet.Columns[3].ColumnWidth = 11;
            #endregion
            #endregion

            #region Saving workbook and disposing objects
            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (Device.RuntimePlatform == Device.WinPhone || Device.RuntimePlatform == Device.WinRT || Device.RuntimePlatform == Device.UWP)
                Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("DataTable.xlsx", "application/msexcel", stream);
            else
                Xamarin.Forms.DependencyService.Get<ISave>().Save("DataTable.xlsx", "application/msexcel", stream);
            #endregion
        }
Ejemplo n.º 39
0
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];

            //------------------Set RowHeight & ColumnWidth----------------
            worksheet.StandardHeight = 43.5;
            worksheet.StandardWidth  = 8.43;

            worksheet.Range["1:1"].RowHeight   = 171;
            worksheet.Range["2:2"].RowHeight   = 12.75;
            worksheet.Range["3:3"].RowHeight   = 22.5;
            worksheet.Range["4:7"].RowHeight   = 43.75;
            worksheet.Range["A:A"].ColumnWidth = 2.887;
            worksheet.Range["B:B"].ColumnWidth = 8.441;
            worksheet.Range["C:C"].ColumnWidth = 12.777;
            worksheet.Range["D:D"].ColumnWidth = 25.109;
            worksheet.Range["E:E"].ColumnWidth = 12.109;
            worksheet.Range["F:F"].ColumnWidth = 41.664;
            worksheet.Range["G:G"].ColumnWidth = 18.555;
            worksheet.Range["H:H"].ColumnWidth = 11;
            worksheet.Range["I:I"].ColumnWidth = 13.664;
            worksheet.Range["J:J"].ColumnWidth = 15.109;
            worksheet.Range["K:K"].ColumnWidth = 38.887;
            worksheet.Range["L:L"].ColumnWidth = 2.887;


            //------------------------Set Table Values-------------------
            ITable table = worksheet.Tables.Add(worksheet.Range["B3:K7"], true);

            worksheet.Range["B3:K7"].Value = new object[, ]
            {
                { "NO.", "YEAR", "TITLE", "REVIEW", "STARRING ACTORS", "DIRECTOR", "GENRE", "RATING", "FORMAT", "COMMENTS" },
                { 1, 1994, "Forrest Gump", "5 Stars", "Tom Hanks, Robin Wright, Gary Sinise", "Robert Zemeckis", "Drama", "PG-13", "DVD", "Based on the 1986 novel of the same name by Winston Groom" },
                { 2, 1946, "It’s a Wonderful Life", "2 Stars", "James Stewart, Donna Reed, Lionel Barrymore ", "Frank Capra", "Drama", "G", "VHS", "Colorized version" },
                { 3, 1988, "Big", "4 Stars", "Tom Hanks, Elizabeth Perkins, Robert Loggia ", "Penny Marshall", "Comedy", "PG", "DVD", "" },
                { 4, 1954, "Rear Window", "3 Stars", "James Stewart, Grace Kelly, Wendell Corey ", "Alfred Hitchcock", "Suspense", "PG", "Blu-ray", "" },
            };


            //-----------------------Set Table style--------------------
            ITableStyle tableStyle = workbook.TableStyles.Add("Movie List");

            workbook.DefaultTableStyle = "Movie List";

            tableStyle.TableStyleElements[TableStyleElementType.WholeTable].Interior.Color = Color.White;

            tableStyle.TableStyleElements[TableStyleElementType.FirstRowStripe].Interior.Color = Color.FromArgb(38, 38, 38);

            tableStyle.TableStyleElements[TableStyleElementType.SecondRowStripe].Interior.Color = Color.Black;

            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Font.Color     = Color.Black;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders.Color  = Color.FromArgb(38, 38, 38);
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Interior.Color = Color.FromArgb(68, 217, 255);
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.EdgeTop].LineStyle          = BorderLineStyle.Thick;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.EdgeLeft].LineStyle         = BorderLineStyle.None;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.EdgeRight].LineStyle        = BorderLineStyle.None;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.EdgeBottom].LineStyle       = BorderLineStyle.None;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.InsideHorizontal].LineStyle = BorderLineStyle.None;
            tableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Borders[BordersIndex.InsideVertical].LineStyle   = BorderLineStyle.None;


            //--------------------------------Set Named Styles---------------------
            IStyle movieListBorderStyle = workbook.Styles.Add("Movie list border");

            movieListBorderStyle.IncludeNumber     = true;
            movieListBorderStyle.IncludeAlignment  = true;
            movieListBorderStyle.VerticalAlignment = VerticalAlignment.Center;
            movieListBorderStyle.WrapText          = true;
            movieListBorderStyle.IncludeFont       = true;
            movieListBorderStyle.Font.Name         = "Helvetica";
            movieListBorderStyle.Font.Size         = 11;
            movieListBorderStyle.Font.Color        = Color.White;
            movieListBorderStyle.IncludeBorder     = true;
            movieListBorderStyle.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Thick;
            movieListBorderStyle.Borders[BordersIndex.EdgeBottom].Color     = Color.FromArgb(38, 38, 38);
            movieListBorderStyle.IncludePatterns = true;
            movieListBorderStyle.Interior.Color  = Color.FromArgb(238, 219, 78);

            IStyle nOStyle = workbook.Styles.Add("NO.");

            nOStyle.IncludeNumber       = true;
            nOStyle.IncludeAlignment    = true;
            nOStyle.HorizontalAlignment = HorizontalAlignment.Left;
            nOStyle.VerticalAlignment   = VerticalAlignment.Center;
            nOStyle.IncludeFont         = true;
            nOStyle.Font.Name           = "Helvetica";
            nOStyle.Font.Size           = 11;
            nOStyle.Font.Color          = Color.White;
            nOStyle.IncludeBorder       = true;
            nOStyle.IncludePatterns     = true;
            nOStyle.Interior.Color      = Color.FromArgb(38, 38, 38);

            IStyle reviewStyle = workbook.Styles.Add("Review");

            reviewStyle.IncludeNumber     = true;
            reviewStyle.IncludeAlignment  = true;
            reviewStyle.VerticalAlignment = VerticalAlignment.Center;
            reviewStyle.IncludeFont       = true;
            reviewStyle.Font.Name         = "Helvetica";
            reviewStyle.Font.Size         = 11;
            reviewStyle.Font.Color        = Color.White;
            reviewStyle.IncludeBorder     = true;
            reviewStyle.IncludePatterns   = true;
            reviewStyle.Interior.Color    = Color.FromArgb(38, 38, 38);

            IStyle yearStyle = workbook.Styles.Add("Year");

            yearStyle.IncludeNumber       = true;
            yearStyle.IncludeAlignment    = true;
            yearStyle.HorizontalAlignment = HorizontalAlignment.Left;
            yearStyle.VerticalAlignment   = VerticalAlignment.Center;
            yearStyle.IncludeFont         = true;
            yearStyle.Font.Name           = "Helvetica";
            yearStyle.Font.Size           = 11;
            yearStyle.Font.Color          = Color.White;
            yearStyle.IncludeBorder       = true;
            yearStyle.IncludePatterns     = true;
            yearStyle.Interior.Color      = Color.FromArgb(38, 38, 38);

            IStyle heading1Style = workbook.Styles["Heading 1"];

            heading1Style.IncludeAlignment  = true;
            heading1Style.VerticalAlignment = VerticalAlignment.Bottom;
            heading1Style.IncludeBorder     = true;
            heading1Style.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Thick;
            heading1Style.Borders[BordersIndex.EdgeBottom].Color     = Color.FromArgb(68, 217, 255);
            heading1Style.IncludeFont = true;
            heading1Style.Font.Name   = "Helvetica";
            heading1Style.Font.Bold   = false;
            heading1Style.Font.Size   = 12;
            heading1Style.Font.Color  = Color.Black;

            IStyle normalStyle = workbook.Styles["Normal"];

            normalStyle.IncludeNumber     = true;
            normalStyle.IncludeAlignment  = true;
            normalStyle.VerticalAlignment = VerticalAlignment.Center;
            normalStyle.WrapText          = true;
            normalStyle.IncludeFont       = true;
            normalStyle.Font.Name         = "Helvetica";
            normalStyle.Font.Size         = 11;
            normalStyle.Font.Color        = Color.White;
            normalStyle.IncludePatterns   = true;
            normalStyle.Interior.Color    = Color.FromArgb(38, 38, 38);


            //-----------------------------Use NamedStyle--------------------------
            worksheet.SheetView.DisplayGridlines = false;
            worksheet.TabColor = Color.FromArgb(38, 38, 38);
            table.TableStyle   = tableStyle;

            worksheet.Range["A2:L2"].Style               = movieListBorderStyle;
            worksheet.Range["B3:K3"].Style               = heading1Style;
            worksheet.Range["B4:B7"].Style               = nOStyle;
            worksheet.Range["C4:C7"].Style               = yearStyle;
            worksheet.Range["E4:E7"].Style               = reviewStyle;
            worksheet.Range["F4:F7"].IndentLevel         = 1;
            worksheet.Range["F4:F7"].HorizontalAlignment = HorizontalAlignment.Left;


            //-----------------------------Add Shapes------------------------------
            //Movie picture
            System.IO.Stream stream       = this.GetResourceStream("movie.png");
            IShape           pictureShape = worksheet.Shapes.AddPicture(stream, ImageType.PNG, 0, 1, worksheet.Range["A:L"].Width, worksheet.Range["1:1"].Height - 1.5);

            pictureShape.Placement = Placement.Move;

            //Movie list picture
            System.IO.Stream stream2       = this.GetResourceStream("list.png");
            IShape           pictureShape2 = worksheet.Shapes.AddPicture(stream2, ImageType.PNG, 1, 0.8, 325.572, 85.51);

            pictureShape2.Placement = Placement.Move;

            //Rounded Rectangular Callout 7
            IShape roundedRectangular = worksheet.Shapes.AddShape(AutoShapeType.RoundedRectangularCallout, 437.5, 22.75, 342, 143);

            roundedRectangular.Name      = "Rounded Rectangular Callout 7";
            roundedRectangular.Placement = Placement.Move;
            roundedRectangular.TextFrame.TextRange.Font.Name      = "Helvetica";
            roundedRectangular.TextFrame.TextRange.Font.Color.RGB = Color.FromArgb(38, 38, 38);

            roundedRectangular.Fill.Solid();
            roundedRectangular.Fill.Color.RGB    = Color.FromArgb(68, 217, 255);
            roundedRectangular.Fill.Transparency = 0;
            roundedRectangular.Line.Solid();
            roundedRectangular.Line.Color.RGB    = Color.FromArgb(0, 129, 162);
            roundedRectangular.Line.Weight       = 2;
            roundedRectangular.Line.Transparency = 0;

            ITextRange roundedRectangular_p0 = roundedRectangular.TextFrame.TextRange.Paragraphs[0];

            roundedRectangular_p0.Runs.Font.Bold = true;
            roundedRectangular_p0.Runs.Add("TABLE");
            roundedRectangular_p0.Runs.Add(" TIP");

            roundedRectangular.TextFrame.TextRange.Paragraphs.Add("");

            ITextRange roundedRectangular_p2 = roundedRectangular.TextFrame.TextRange.Paragraphs.Add();

            roundedRectangular_p2.Runs.Add("Use the drop down arrows in the table headings to quickly filter your movie list. " +
                                           "For multiple entry fields, such as Starring Actors,  select the drop down arrow next to the field and enter text in the Search box. " +
                                           "For example, type Tom Hanks or James Stewart, and then select OK.");

            roundedRectangular.TextFrame.TextRange.Paragraphs.Add("");

            ITextRange roundedRectangular_p4 = roundedRectangular.TextFrame.TextRange.Paragraphs.Add();

            roundedRectangular_p4.Runs.Add("To delete this note, click the edge to select it and then press ");
            roundedRectangular_p4.Runs.Add("Delete");
            roundedRectangular_p4.Runs.Add(".");
            roundedRectangular_p4.Runs[2].Font.Bold = true;

            roundedRectangular.TextFrame.TextRange.Paragraphs.Add("");

            //Add Stright Line Shape
            IShape lineShape = worksheet.Shapes.AddConnector(ConnectorType.Straight, 455.228f, 57.35f, 756.228f, 57.35f);

            lineShape.Line.Solid();
            lineShape.Line.Weight    = 3;
            lineShape.Line.Color.RGB = Color.FromArgb(38, 38, 38);
            lineShape.Line.DashStyle = LineDashStyle.SysDot;
        }
Ejemplo n.º 40
0
 public NoteController(NoteDBContext noteDBContext, IStyle style)
 {
     this._noteDBContext = noteDBContext;
     this.style          = style;
 }
Ejemplo n.º 41
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook  workbook  = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];

            IList <Brands> list = GetVehicleDetails();

            int index = layoutList.IndexOf(selectedLayout);
            ExcelImportDataOptions importDataOptions = new ExcelImportDataOptions();

            importDataOptions.FirstRow = 4;

            if (index == 0)
            {
                importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Default;
            }
            else if (index == 1)
            {
                importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Merge;
            }
            else if (index == 2)
            {
                importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Repeat;
            }

            if (groupSwitch.Selected)
            {
                if (expandButton.IsChecked.Value)
                {
                    importDataOptions.NestedDataGroupOptions = ExcelNestedDataGroupOptions.Expand;
                }
                else if (collapseButton.IsChecked.Value)
                {
                    importDataOptions.NestedDataGroupOptions = ExcelNestedDataGroupOptions.Collapse;
                    if (textField.Text != string.Empty)
                    {
                        importDataOptions.CollapseLevel = int.Parse(textField.Text);
                    }
                }
            }

            worksheet.ImportData(list, importDataOptions);

            #region Define Styles
            IStyle pageHeader  = workbook.Styles.Add("PageHeaderStyle");
            IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle");

            pageHeader.Font.FontName       = "Calibri";
            pageHeader.Font.Size           = 16;
            pageHeader.Font.Bold           = true;
            pageHeader.Color               = Color.FromArgb(0, 146, 208, 80);
            pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
            pageHeader.VerticalAlignment   = ExcelVAlign.VAlignCenter;

            tableHeader.Font.Bold     = true;
            tableHeader.Font.FontName = "Calibri";
            tableHeader.Color         = Color.FromArgb(0, 146, 208, 80);

            #endregion

            #region Apply Styles
            // Apply style for header
            worksheet["A1:C2"].Merge();
            worksheet["A1"].Text      = "Automobile Brands in the US";
            worksheet["A1"].CellStyle = pageHeader;

            worksheet["A4:C4"].CellStyle = tableHeader;

            worksheet["A1:C1"].CellStyle.Font.Bold = true;
            worksheet.UsedRange.AutofitColumns();

            #endregion

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (stream != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save("ImportData.xlsx", "application/msexcel", stream);
            }
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Create a simple Excel document
        /// </summary>
        /// <returns>Return the created excel document as stream</returns>
        public MemoryStream CreateXlsIO(string version)
        {
            //New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Step 2 : Instantiate the excel application object
                IApplication application = excelEngine.Excel;

                //Set the default version
                if (version == "XLSX")
                {
                    application.DefaultVersion = ExcelVersion.Excel2016;
                }
                else
                {
                    application.DefaultVersion = ExcelVersion.Excel97to2003;
                }

                //Creating new workbook
                IWorkbook  workbook = application.Workbooks.Create(3);
                IWorksheet sheet    = workbook.Worksheets[0];

                #region Generate Excel
                sheet.Range["A2"].ColumnWidth = 30;
                sheet.Range["B2"].ColumnWidth = 30;
                sheet.Range["C2"].ColumnWidth = 30;
                sheet.Range["D2"].ColumnWidth = 30;

                sheet.Range["A2:D2"].Merge(true);

                //Inserting sample text into the first cell of the first sheet
                sheet.Range["A2"].Text = "EXPENSE REPORT";
                sheet.Range["A2"].CellStyle.Font.FontName = "Verdana";
                sheet.Range["A2"].CellStyle.Font.Bold     = true;
                sheet.Range["A2"].CellStyle.Font.Size     = 28;
                sheet.Range["A2"].CellStyle.Font.RGBColor = Color.FromArgb(0, 0, 112, 192);
                sheet.Range["A2"].HorizontalAlignment     = ExcelHAlign.HAlignCenter;

                sheet.Range["A4"].Text = "Employee";
                sheet.Range["B4"].Text = "Roger Federer";
                sheet.Range["A4:B7"].CellStyle.Font.FontName = "Verdana";
                sheet.Range["A4:B7"].CellStyle.Font.Bold     = true;
                sheet.Range["A4:B7"].CellStyle.Font.Size     = 11;
                sheet.Range["A4:A7"].CellStyle.Font.RGBColor = Color.FromArgb(0, 128, 128, 128);
                sheet.Range["A4:A7"].HorizontalAlignment     = ExcelHAlign.HAlignLeft;
                sheet.Range["B4:B7"].CellStyle.Font.RGBColor = Color.FromArgb(0, 174, 170, 170);
                sheet.Range["B4:B7"].HorizontalAlignment     = ExcelHAlign.HAlignRight;

                sheet.Range["A9:D20"].CellStyle.Font.FontName = "Verdana";
                sheet.Range["A9:D20"].CellStyle.Font.Size     = 11;

                sheet.Range["A5"].Text = "Department";
                sheet.Range["B5"].Text = "Administration";

                sheet.Range["A6"].Text         = "Week Ending";
                sheet.Range["B6"].NumberFormat = "m/d/yyyy";
                sheet.Range["B6"].DateTime     = DateTime.Parse("10/20/2012", CultureInfo.InvariantCulture);

                sheet.Range["A7"].Text         = "Mileage Rate";
                sheet.Range["B7"].NumberFormat = "$#,##0.00";
                sheet.Range["B7"].Number       = 0.70;

                sheet.Range["A10"].Text = "Miles Driven";
                sheet.Range["A11"].Text = "Miles Reimbursement";
                sheet.Range["A12"].Text = "Parking and Tolls";
                sheet.Range["A13"].Text = "Auto Rental";
                sheet.Range["A14"].Text = "Lodging";
                sheet.Range["A15"].Text = "Breakfast";
                sheet.Range["A16"].Text = "Lunch";
                sheet.Range["A17"].Text = "Dinner";
                sheet.Range["A18"].Text = "Snacks";
                sheet.Range["A19"].Text = "Others";
                sheet.Range["A20"].Text = "Total";
                sheet.Range["A20:D20"].CellStyle.Color      = Color.FromArgb(0, 0, 112, 192);
                sheet.Range["A20:D20"].CellStyle.Font.Color = ExcelKnownColors.White;
                sheet.Range["A20:D20"].CellStyle.Font.Bold  = true;

                IStyle style = sheet["B9:D9"].CellStyle;
                style.VerticalAlignment   = ExcelVAlign.VAlignCenter;
                style.HorizontalAlignment = ExcelHAlign.HAlignRight;
                style.Color      = Color.FromArgb(0, 0, 112, 192);
                style.Font.Bold  = true;
                style.Font.Color = ExcelKnownColors.White;

                sheet.Range["A9"].Text                 = "Expenses";
                sheet.Range["A9"].CellStyle.Color      = Color.FromArgb(0, 0, 112, 192);
                sheet.Range["A9"].CellStyle.Font.Color = ExcelKnownColors.White;
                sheet.Range["A9"].CellStyle.Font.Bold  = true;
                sheet.Range["B9"].Text                 = "Day 1";
                sheet.Range["B10"].Number              = 100;
                sheet.Range["B11"].NumberFormat        = "$#,##0.00";
                sheet.Range["B11"].Formula             = "=(B7*B10)";
                sheet.Range["B12"].NumberFormat        = "$#,##0.00";
                sheet.Range["B12"].Number              = 0;
                sheet.Range["B13"].NumberFormat        = "$#,##0.00";
                sheet.Range["B13"].Number              = 0;
                sheet.Range["B14"].NumberFormat        = "$#,##0.00";
                sheet.Range["B14"].Number              = 0;
                sheet.Range["B15"].NumberFormat        = "$#,##0.00";
                sheet.Range["B15"].Number              = 9;
                sheet.Range["B16"].NumberFormat        = "$#,##0.00";
                sheet.Range["B16"].Number              = 12;
                sheet.Range["B17"].NumberFormat        = "$#,##0.00";
                sheet.Range["B17"].Number              = 13;
                sheet.Range["B18"].NumberFormat        = "$#,##0.00";
                sheet.Range["B18"].Number              = 9.5;
                sheet.Range["B19"].NumberFormat        = "$#,##0.00";
                sheet.Range["B19"].Number              = 0;
                sheet.Range["B20"].NumberFormat        = "$#,##0.00";
                sheet.Range["B20"].Formula             = "=SUM(B11:B19)";

                sheet.Range["C9"].Text          = "Day 2";
                sheet.Range["C10"].Number       = 145;
                sheet.Range["C11"].NumberFormat = "$#,##0.00";
                sheet.Range["C11"].Formula      = "=(B7*C10)";
                sheet.Range["C12"].NumberFormat = "$#,##0.00";
                sheet.Range["C12"].Number       = 15;
                sheet.Range["C13"].NumberFormat = "$#,##0.00";
                sheet.Range["C13"].Number       = 0;
                sheet.Range["C14"].NumberFormat = "$#,##0.00";
                sheet.Range["C14"].Number       = 45;
                sheet.Range["C15"].NumberFormat = "$#,##0.00";
                sheet.Range["C15"].Number       = 9;
                sheet.Range["C16"].NumberFormat = "$#,##0.00";
                sheet.Range["C16"].Number       = 12;
                sheet.Range["C17"].NumberFormat = "$#,##0.00";
                sheet.Range["C17"].Number       = 15;
                sheet.Range["C18"].NumberFormat = "$#,##0.00";
                sheet.Range["C18"].Number       = 7;
                sheet.Range["C19"].NumberFormat = "$#,##0.00";
                sheet.Range["C19"].Number       = 0;
                sheet.Range["C20"].NumberFormat = "$#,##0.00";
                sheet.Range["C20"].Formula      = "=SUM(C11:C19)";

                sheet.Range["D9"].Text          = "Day 3";
                sheet.Range["D10"].Number       = 113;
                sheet.Range["D11"].NumberFormat = "$#,##0.00";
                sheet.Range["D11"].Formula      = "=(B7*D10)";
                sheet.Range["D12"].NumberFormat = "$#,##0.00";
                sheet.Range["D12"].Number       = 17;
                sheet.Range["D13"].NumberFormat = "$#,##0.00";
                sheet.Range["D13"].Number       = 8;
                sheet.Range["D14"].NumberFormat = "$#,##0.00";
                sheet.Range["D14"].Number       = 45;
                sheet.Range["D15"].NumberFormat = "$#,##0.00";
                sheet.Range["D15"].Number       = 7;
                sheet.Range["D16"].NumberFormat = "$#,##0.00";
                sheet.Range["D16"].Number       = 11;
                sheet.Range["D17"].NumberFormat = "$#,##0.00";
                sheet.Range["D17"].Number       = 16;
                sheet.Range["D18"].NumberFormat = "$#,##0.00";
                sheet.Range["D18"].Number       = 7;
                sheet.Range["D19"].NumberFormat = "$#,##0.00";
                sheet.Range["D19"].Number       = 5;
                sheet.Range["D20"].NumberFormat = "$#,##0.00";
                sheet.Range["D20"].Formula      = "=SUM(D11:D19)";
                #endregion

                //Save the document as a stream and retrun the stream
                using (MemoryStream stream = new MemoryStream())
                {
                    //Save the created Excel document to MemoryStream
                    workbook.SaveAs(stream);
                    return(stream);
                }
            }
        }
Ejemplo n.º 43
0
 /// <summary>
 /// Constructor create a new ListLevelProperties object.
 /// </summary>
 public ListLevelProperties(IStyle style)
 {
     Style = style;
     Node  = new XElement(Ns.Style + "list-level-properties");
 }
        public ActionResult CLRObjects(string Saveoption, string button)
        {
            ViewBag.exportButtonState = "disabled=\"disabled\"";
            //Check FileName
            string fileName = "ExportSales.xlsx";

            ///SaveOption Null
            if (Saveoption == null || button == null)
            {
                _sales = new List <Sales>();
                return(View());
            }

            //Start CLR Object Functions
            if (button == "Input Template")
            {
                //Step 1 : Instantiate the spreadsheet creation engine.
                ExcelEngine excelEngine = new ExcelEngine();
                //Step 2 : Instantiate the excel application object.
                IApplication application = excelEngine.Excel;
                IWorkbook    workbook    = application.Workbooks.Open(ResolveApplicationDataPath(fileName));
                return(excelEngine.SaveAsActionResult(workbook, fileName, HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97));
            }
            else if (button == "Import From Excel")
            {
                //Step 1 : Instantiate the spreadsheet creation engine.
                ExcelEngine excelEngine = new ExcelEngine();
                //Step 2 : Instantiate the excel application object.
                IApplication application = excelEngine.Excel;
                IWorkbook    workbook    = application.Workbooks.Open(ResolveApplicationDataPath(fileName));
                IWorksheet   sheet       = workbook.Worksheets[0];
                //Export Bussiness Objects
                List <Sales> CLRObjects = sheet.ExportData <Sales>(1, 1, 41, 4);
                //Close the workbook.
                workbook.Close();
                excelEngine.Dispose();
                int temp = 1;
                foreach (Sales sale in CLRObjects)
                {
                    sale.ID = temp;
                    temp++;
                }
                //Set the grid value to the Session
                _sales                    = CLRObjects;
                ViewBag.DataSource        = _sales;
                ViewBag.exportButtonState = "";
                button                    = null;
                return(View());
                //return new CustomResult(HttpContext.ApplicationInstance.Response);
            }
            else
            {
                //New instance of XlsIO is created.[Equivalent to launching Microsoft Excel with no workbooks open].
                //The instantiation process consists of two steps.

                //Instantiate the spreadsheet creation engine.
                ExcelEngine  excelEngine = new ExcelEngine();
                IApplication application = excelEngine.Excel;

                if (Saveoption == "Xls")
                {
                    application.DefaultVersion = ExcelVersion.Excel97to2003;
                }
                else
                {
                    application.DefaultVersion = ExcelVersion.Excel2016;
                }

                //Open an existing spreadsheet which will be used as a template for generating the new spreadsheet.
                //After opening, the workbook object represents the complete in-memory object model of the template spreadsheet.
                IWorkbook workbook;
                workbook = excelEngine.Excel.Workbooks.Create(1);
                //The first worksheet object in the worksheets collection is accessed.
                IWorksheet sheet = workbook.Worksheets[0];

                //Import Bussiness Object to worksheet
                sheet.ImportData(_sales, 5, 1, false);
                sheet.Range["E4"].Text = "";
                #region Define Styles
                IStyle pageHeader  = workbook.Styles.Add("PageHeaderStyle");
                IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle");

                pageHeader.Font.RGBColor       = Color.FromArgb(0, 83, 141, 213);
                pageHeader.Font.FontName       = "Calibri";
                pageHeader.Font.Size           = 18;
                pageHeader.Font.Bold           = true;
                pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
                pageHeader.VerticalAlignment   = ExcelVAlign.VAlignCenter;

                tableHeader.Font.Color          = ExcelKnownColors.White;
                tableHeader.Font.Bold           = true;
                tableHeader.Font.Size           = 11;
                tableHeader.Font.FontName       = "Calibri";
                tableHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
                tableHeader.VerticalAlignment   = ExcelVAlign.VAlignCenter;
                tableHeader.Color = Color.FromArgb(0, 118, 147, 60);
                tableHeader.Borders[ExcelBordersIndex.EdgeLeft].LineStyle   = ExcelLineStyle.Thin;
                tableHeader.Borders[ExcelBordersIndex.EdgeRight].LineStyle  = ExcelLineStyle.Thin;
                tableHeader.Borders[ExcelBordersIndex.EdgeTop].LineStyle    = ExcelLineStyle.Thin;
                tableHeader.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
                #endregion

                #region Apply Styles
                // Apply style for header
                sheet["A1:E1"].Merge();
                sheet["A1"].Text      = "Yearly Sales Report";
                sheet["A1"].CellStyle = pageHeader;
                sheet["A2:E2"].Merge();
                sheet["A2"].Text                = "Namewise Sales Comparison Report";
                sheet["A2"].CellStyle           = pageHeader;
                sheet["A2"].CellStyle.Font.Bold = false;
                sheet["A2"].CellStyle.Font.Size = 16;
                sheet["A3:A4"].Merge();
                sheet["B3:B4"].Merge();
                sheet["E3:E4"].Merge();
                sheet["C3:D3"].Merge();
                sheet["C3"].Text         = "Sales";
                sheet["A3:E4"].CellStyle = tableHeader;
                sheet["A3"].Text         = "S.ID";
                sheet["B3"].Text         = "Sales Person";
                sheet["C4"].Text         = "January - June";
                sheet["D4"].Text         = "July - December";
                sheet["E3"].Text         = "Change(%)";
                sheet.UsedRange.AutofitColumns();
                sheet.Columns[0].ColumnWidth = 10;
                sheet.Columns[1].ColumnWidth = 24;
                sheet.Columns[2].ColumnWidth = 21;
                sheet.Columns[3].ColumnWidth = 21;
                sheet.Columns[4].ColumnWidth = 16;
                #endregion

                try
                {
                    //Saving the workbook to disk. This spreadsheet is the result of opening and modifying
                    //an existing spreadsheet and then saving the result to a new workbook.

                    if (Saveoption == "Xlsx")
                    {
                        return(excelEngine.SaveAsActionResult(workbook, "CLRObjects.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016));
                    }
                    else
                    {
                        return(excelEngine.SaveAsActionResult(workbook, "CLRObjects.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97));
                    }
                }
                catch (Exception)
                {
                }

                //Close the workbook.
                workbook.Close();
                excelEngine.Dispose();
            }
            return(View());
        }
Ejemplo n.º 45
0
 public void Render(object dc, IRenderer renderer, IStyle style)
 {
     renderer.DrawPin(dc, style, this);
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Initializes a new instance of the GradientTheme class
 /// </summary>
 /// <remarks>
 /// <para>The gradient theme interpolates linearly between two styles based on a numerical attribute in the datasource.
 /// This is useful for scaling symbols, line widths, line and fill colors from numerical attributes.</para>
 /// <para>Colors are interpolated between two colors, but if you want to interpolate through more colors (fx. a rainbow),
 /// set the <see cref="TextColorBlend"/>, <see cref="LineColorBlend"/> and <see cref="FillColorBlend"/> properties
 /// to a custom <see cref="ColorBlend"/>.
 /// </para>
 /// <para>The following properties are scaled (properties not mentioned here are not interpolated):
 /// <list type="table">
 ///        <listheader><term>Property</term><description>Remarks</description></listheader>
 ///        <item><term><see cref="Color"/></term><description>Red, Green, Blue and Alpha values are linearly interpolated.</description></item>
 ///        <item><term><see cref="Pen"/></term><description>The color, width, color of pens are interpolated. MiterLimit,StartCap,EndCap,LineJoin,DashStyle,DashPattern,DashOffset,DashCap,CompoundArray, and Alignment are switched in the middle of the min/max values.</description></item>
 ///        <item><term><see cref="Brush"/></term><description>Brush color are interpolated. Other brushes are not supported.</description></item>
 ///        <item><term><see cref="Mapsui.Styles.VectorStyle"/></term><description>MaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values.</description></item>
 ///        <item><term><see cref="Mapsui.Styles.LabelStyle"/></term><description>FontSize, BackColor, ForeColor, MaxVisible, MinVisible, Offset are scaled linearly. All other properties use min-style.</description></item>
 /// </list>
 /// </para>
 /// <example>
 /// Creating a rainbow colorblend showing colors from red, through yellow, green and blue depicting
 /// the population density of a country.
 /// <code lang="C#">
 /// //Create two vector styles to interpolate between
 /// Mapsui.Styles.VectorStyle min = new Mapsui.Styles.VectorStyle();
 /// Mapsui.Styles.VectorStyle max = new Mapsui.Styles.VectorStyle();
 /// min.Outline.Width = 1f; //Outline width of the minimum value
 /// max.Outline.Width = 3f; //Outline width of the maximum value
 /// //Create a theme interpolating population density between 0 and 400
 /// Mapsui.Rendering.Thematics.GradientTheme popdens = new Mapsui.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max);
 /// //Set the fill-style colors to be a rainbow blend from red to blue.
 /// popdens.FillColorBlend = Mapsui.Rendering.Thematics.ColorBlend.Rainbow5;
 /// myVectorLayer.Styles.Add(popdens);
 /// </code>
 /// </example>
 /// </remarks>
 /// <param name="columnName">Name of column to extract the attribute</param>
 /// <param name="minValue">Minimum value</param>
 /// <param name="maxValue">Maximum value</param>
 /// <param name="minStyle">Color for minimum value</param>
 /// <param name="maxStyle">Color for maximum value</param>
 public GradientTheme(string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
 {
     ColumnName = columnName;
     Min        = minValue;
     Max        = maxValue;
     MaxStyle   = maxStyle;
     MinStyle   = minStyle;
 }
Ejemplo n.º 47
0
        /// <summary>
        /// Completes the insertion of text by inserting it's style run
        /// and updating the offsets of existing style runs.
        /// </summary>
        /// <param name="utf32">The utf32 slice that was inserted</param>
        /// <param name="style">The style of the inserted text</param>
        void FinishInsert(Slice <int> utf32, IStyle style)
        {
            // Update style runs
            int newRunIndex = 0;

            for (int i = 0; i < _styleRuns.Count; i++)
            {
                // Get the style run
                var sr = _styleRuns[i];

                // Before inserted text?
                if (sr.End < utf32.Start)
                {
                    continue;
                }

                // Special case for inserting at very start of text block
                // with no supplied style.
                if (sr.Start == 0 && utf32.Start == 0 && style == null)
                {
                    sr.Length += utf32.Length;
                    continue;
                }

                // After inserted text?
                if (sr.Start >= utf32.Start)
                {
                    sr.Start += utf32.Length;
                    continue;
                }

                // Inserting exactly at the end of a style run?
                if (sr.End == utf32.Start)
                {
                    if (style == null || style == sr.Style)
                    {
                        // Extend the existing run
                        sr.Length += utf32.Length;

                        // Force style to null to suppress later creation
                        // of a style run for it.
                        style = null;
                    }
                    else
                    {
                        // Remember this is where to insert the new
                        // style run
                        newRunIndex = i + 1;
                    }
                    continue;
                }

                Debug.Assert(sr.End > utf32.Start);
                Debug.Assert(sr.Start < utf32.Start);

                // Inserting inside an existing run
                if (style == null || style == sr.Style)
                {
                    // Extend the existing style run to cover
                    // the newly inserted text with the same style
                    sr.Length += utf32.Length;

                    // Force style to null to suppress later creation
                    // of a style run for it.
                    style = null;
                }
                else
                {
                    // Split this run and insert the new style run between

                    // Create the second part
                    var split = StyleRun.Pool.Value.Get();
                    split.CodePointBuffer = _codePoints;
                    split.Start           = utf32.Start + utf32.Length;
                    split.Length          = sr.End - utf32.Start;
                    split.Style           = sr.Style;
                    _styleRuns.Insert(i + 1, split);

                    // Shorten this part
                    sr.Length = utf32.Start - sr.Start;

                    // Insert the newly styled run after this one
                    newRunIndex = i + 1;

                    // Skip the second part of the split in this for loop
                    // as we've already calculated it
                    i++;
                }
            }

            // Create a new style run
            if (style != null)
            {
                var run = StyleRun.Pool.Value.Get();
                run.CodePointBuffer         = _codePoints;
                run.Start                   = utf32.Start;
                run.Length                  = utf32.Length;
                run.Style                   = style;
                _hasTextDirectionOverrides |= style.TextDirection != TextDirection.Auto;
                _styleRuns.Insert(newRunIndex, run);
            }

            // Coalesc if necessary
            if ((newRunIndex > 0 && _styleRuns[newRunIndex - 1].Style == style) ||
                (newRunIndex + 1 < _styleRuns.Count && _styleRuns[newRunIndex + 1].Style == style))
            {
                CoalescStyleRuns();
            }


            // Need new layout
            OnChanged();
        }
Ejemplo n.º 48
0
 private void RenderFeature(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IStyle style, IFeature feature, float layerOpacity)
 {
     // Check, if we have a special renderer for this style
     if (StyleRenderers.ContainsKey(style.GetType()))
     {
         // Save canvas
         canvas.Save();
         // We have a special renderer, so try, if it could draw this
         var result = ((ISkiaStyleRenderer)StyleRenderers[style.GetType()]).Draw(canvas, viewport, layer, feature, style, _symbolCache);
         // Restore old canvas
         canvas.Restore();
         // Was it drawn?
         if (result)
         {
             // Yes, special style renderer drawn correct
             return;
         }
     }
     // No special style renderer handled this up to now, than try standard renderers
     if (feature.Geometry is Point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiPoint)
     {
         MultiPointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is LineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiLineString)
     {
         MultiLineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is Polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is MultiPolygon)
     {
         MultiPolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is IRaster)
     {
         RasterRenderer.Draw(canvas, viewport, style, feature, layerOpacity * style.Opacity, _tileCache, _currentIteration);
     }
 }
Ejemplo n.º 49
0
 public GradientTheme(string attributeName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle,
                      ColorBlend fillColorBlend, ColorBlend lineColorBlend, ColorBlend textColorBlend) : this(attributeName, minValue, maxValue, minStyle, maxStyle,
                                                                                                              fillColorBlend, lineColorBlend, textColorBlend, 8)
 {
 }
        void ButtonExportClicked(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheets
            IWorkbook workbook = application.Workbooks.Create(1);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];

            Assembly assembly   = Assembly.GetExecutingAssembly();
            Stream   fileStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.XlsIO.Template.CLRObjects.xml");

            //IEnumerable<CLRObject> customers = GetCLRObjectsData(fileStream);
            sheet.ImportData((List <CustomerObject>)sfGrid.ItemsSource, 5, 1, false);

            #region Define Styles
            IStyle pageHeader  = workbook.Styles.Add("PageHeaderStyle");
            IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle");

            pageHeader.Font.RGBColor       = COLOR.Color.FromArgb(255, 83, 141, 213);
            pageHeader.Font.FontName       = "Calibri";
            pageHeader.Font.Size           = 18;
            pageHeader.Font.Bold           = true;
            pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
            pageHeader.VerticalAlignment   = ExcelVAlign.VAlignCenter;

            tableHeader.Font.Color          = ExcelKnownColors.Black;
            tableHeader.Font.Bold           = true;
            tableHeader.Font.Size           = 11;
            tableHeader.Font.FontName       = "Calibri";
            tableHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter;
            tableHeader.VerticalAlignment   = ExcelVAlign.VAlignCenter;
            tableHeader.Color = COLOR.Color.FromArgb(255, 118, 147, 60);
            tableHeader.Borders[ExcelBordersIndex.EdgeLeft].LineStyle   = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeRight].LineStyle  = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeTop].LineStyle    = ExcelLineStyle.Thin;
            tableHeader.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
            #endregion

            #region Apply Styles
            // Apply style for header
            sheet["A1:D1"].Merge();
            sheet["A1"].Text      = "Yearly Sales Report";
            sheet["A1"].CellStyle = pageHeader;
            sheet["A1"].RowHeight = 20;

            sheet["A2:D2"].Merge();
            sheet["A2"].Text                = "Namewise Sales Comparison Report";
            sheet["A2"].CellStyle           = pageHeader;
            sheet["A2"].CellStyle.Font.Bold = false;
            sheet["A2"].CellStyle.Font.Size = 16;
            sheet["A2"].RowHeight           = 20;

            sheet["A3:A4"].Merge();
            sheet["D3:D4"].Merge();
            sheet["B3:C3"].Merge();
            sheet["B3"].Text         = "Sales";
            sheet["A3:D4"].CellStyle = tableHeader;

            sheet["A3"].Text = "Sales Person";
            sheet["B4"].Text = "Jan - Jun";
            sheet["C4"].Text = "Jul - Dec";
            sheet["D3"].Text = "Change (%)";

            sheet.Columns[0].ColumnWidth = 19;
            sheet.Columns[1].ColumnWidth = 10;
            sheet.Columns[2].ColumnWidth = 10;
            sheet.Columns[3].ColumnWidth = 11;
            #endregion
            #endregion

            #region Saving workbook and disposing objects
            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();


            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("CLRObjects.xlsx", "application/msexcel", stream, m_context);
            }
            #endregion
        }
Ejemplo n.º 51
0
        private static void RenderFeature(IReadOnlyViewport viewport, Canvas canvas, IFeature feature, IStyle style, SymbolCache symbolCache, bool rasterizing)
        {
            if (style is LabelStyle)
            {
                var labelStyle = (LabelStyle)style;
                var labelText  = labelStyle.GetLabelText(feature);
                if (string.IsNullOrEmpty(labelText))
                {
                    return;
                }
                canvas.Children.Add(LabelRenderer.RenderLabel(feature.Geometry.BoundingBox.Centroid,
                                                              labelStyle, viewport, labelText));
            }
            else
            {
                Shape renderedGeometry;
                if (feature.RenderedGeometry.TryGetValue(style, out var cachedObject))
                {
                    renderedGeometry = (Shape)cachedObject; // Has to be Shape
                    PositionGeometry(renderedGeometry, viewport, style, feature);
                }
                else
                {
                    renderedGeometry = RenderGeometry(viewport, style, feature, symbolCache);
                    if (!rasterizing)
                    {
                        feature.RenderedGeometry[style] = renderedGeometry;
                    }
                }

                if (!canvas.Children.Contains(renderedGeometry))
                {
                    // Adding twice can happen when a single feature has two identical styles
                    canvas.Children.Add(renderedGeometry);
                }
            }
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Overwrites the styles of existing text in the text block
        /// </summary>
        /// <param name="position">The code point index of the start of the text</param>
        /// <param name="length">The length of the text</param>
        /// <param name="style">The new style to be applied</param>
        public void ApplyStyle(int position, int length, IStyle style)
        {
            // Check args
            if (position < 0 || position + length > this.Length)
            {
                throw new ArgumentException("Invalid range");
            }
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            // Redundant?
            if (length == 0)
            {
                return;
            }

            // Easy case when applying same style to entire text block
            if (position == 0 && length == this.Length)
            {
                // Remove excess runs
                while (_styleRuns.Count > 1)
                {
                    StyleRun.Pool.Value.Return(_styleRuns[1]);
                    _styleRuns.RemoveAt(1);
                }

                // Reconfigure the first
                _styleRuns[0].Start  = 0;
                _styleRuns[0].Length = length;
                _styleRuns[0].Style  = style;

                // Reset text direction overrides flag
                _hasTextDirectionOverrides = style.TextDirection != TextDirection.Auto;

                // Invalidate and done
                OnChanged();
                return;
            }

            // Get all intersecting runs
            int newRunPos = -1;

            foreach (var subRun in _styleRuns.GetIntersectingRunsReverse(position, length))
            {
                if (subRun.Partial)
                {
                    var run = _styleRuns[subRun.Index];


                    if (subRun.Offset == 0)
                    {
                        // Overlaps start of existing run, keep end
                        run.Start  += subRun.Length;
                        run.Length -= subRun.Length;
                        newRunPos   = subRun.Index;
                    }
                    else if (subRun.Offset + subRun.Length == run.Length)
                    {
                        // Overlaps end of existing run, keep start
                        run.Length = subRun.Offset;
                        newRunPos  = subRun.Index + 1;
                    }
                    else
                    {
                        // Internal to existing run, keep start and end

                        // Create new run for end
                        var endRun = StyleRun.Pool.Value.Get();
                        endRun.CodePointBuffer = _codePoints;
                        endRun.Start           = run.Start + subRun.Offset + subRun.Length;
                        endRun.Length          = run.End - endRun.Start;
                        endRun.Style           = run.Style;
                        _styleRuns.Insert(subRun.Index + 1, endRun);

                        // Shorten the existing run to keep start
                        run.Length = subRun.Offset;

                        newRunPos = subRun.Index + 1;
                    }
                }
                else
                {
                    // Remove completely covered style runs
                    StyleRun.Pool.Value.Return(_styleRuns[subRun.Index]);
                    _styleRuns.RemoveAt(subRun.Index);
                    newRunPos = subRun.Index;
                }
            }

            // Create style run for the new style
            var newRun = StyleRun.Pool.Value.Get();

            newRun.CodePointBuffer = _codePoints;
            newRun.Start           = position;
            newRun.Length          = length;
            newRun.Style           = style;

            _hasTextDirectionOverrides |= style.TextDirection != TextDirection.Auto;

            // Insert it
            _styleRuns.Insert(newRunPos, newRun);

            // Coalesc
            CoalescStyleRuns();

            // Need to redo layout
            OnChanged();
        }
 public static void SetStyle(IStyledElement element, IStyle value)
 {
     element.SetValue(StyleProperty, value);
     OnStyleChanged(element, value);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Initializes a new instance of the GradientTheme class
 /// </summary>
 /// <remarks>
 /// <para>The gradient theme interpolates linearly between two styles based on a numerical attribute in the datasource.
 /// This is useful for scaling symbols, line widths, line and fill colors from numerical attributes.</para>
 /// <para>Colors are interpolated between two colors, but if you want to interpolate through more colors (fx. a rainbow),
 /// set the <see cref="GradientThemeBase.TextColorBlend"/>, <see cref="GradientThemeBase.LineColorBlend"/> and <see cref="GradientThemeBase.FillColorBlend"/> properties
 /// to a custom <see cref="ColorBlend"/>.
 /// </para>
 /// <para>The following properties are scaled (properties not mentioned here are not interpolated):
 /// <list type="table">
 ///		<listheader><term>Property</term><description>Remarks</description></listheader>
 ///		<item><term><see cref="System.Drawing.Color"/></term><description>Red, Green, Blue and Alpha values are linearly interpolated.</description></item>
 ///		<item><term><see cref="System.Drawing.Pen"/></term><description>The color, width, color of pens are interpolated. MiterLimit,StartCap,EndCap,LineJoin,DashStyle,DashPattern,DashOffset,DashCap,CompoundArray, and Alignment are switched in the middle of the min/max values.</description></item>
 ///		<item><term><see cref="System.Drawing.SolidBrush"/></term><description>SolidBrush color are interpolated. Other brushes are not supported.</description></item>
 ///		<item><term><see cref="SharpMap.Styles.VectorStyle"/></term><description>MaxVisible, MinVisible, Line, Outline, Fill and SymbolScale are scaled linearly. Symbol, EnableOutline and Enabled switch in the middle of the min/max values.</description></item>
 ///		<item><term><see cref="SharpMap.Styles.LabelStyle"/></term><description>FontSize, BackColor, ForeColor, MaxVisible, MinVisible, Offset are scaled linearly. All other properties use min-style.</description></item>
 /// </list>
 /// </para>
 /// <example>
 /// Creating a rainbow colorblend showing colors from red, through yellow, green and blue depicting
 /// the population density of a country.
 /// <code lang="C#">
 /// //Create two vector styles to interpolate between
 /// SharpMap.Styles.VectorStyle min = new SharpMap.Styles.VectorStyle();
 /// SharpMap.Styles.VectorStyle max = new SharpMap.Styles.VectorStyle();
 /// min.Outline.Width = 1f; //Outline width of the minimum value
 /// max.Outline.Width = 3f; //Outline width of the maximum value
 /// //Create a theme interpolating population density between 0 and 400
 /// SharpMap.Rendering.Thematics.GradientTheme popdens = new SharpMap.Rendering.Thematics.GradientTheme("PopDens", 0, 400, min, max);
 /// //Set the fill-style colors to be a rainbow blend from red to blue.
 /// popdens.FillColorBlend = SharpMap.Rendering.Thematics.ColorBlend.Rainbow5;
 /// myVectorLayer.Theme = popdens;
 /// </code>
 /// </example>
 /// </remarks>
 /// <param name="columnName">Name of column to extract the attribute</param>
 /// <param name="minValue">Minimum value</param>
 /// <param name="maxValue">Maximum value</param>
 /// <param name="minStyle">Color for minimum value</param>
 /// <param name="maxStyle">Color for maximum value</param>
 public GradientTheme(string columnName, double minValue, double maxValue, IStyle minStyle, IStyle maxStyle)
     : base(minValue, maxValue, minStyle, maxStyle)
 {
     _columnName = columnName;
 }
Ejemplo n.º 55
0
        private static bool IsTouchingTakingIntoAccountSymbolStyles(Point point, IFeature feature, IStyle layerStyle,
                                                                    double resolution, ISymbolCache symbolCache, int margin = 0)
        {
            var styles = new List <IStyle>();

            styles.AddRange(ToCollection(layerStyle));
            styles.AddRange(feature.Styles);

            var marginInWorldUnits = margin * resolution;

            if (feature.Geometry is Point)
            {
                foreach (var style in styles)
                {
                    var localStyle = HandleThemeStyle(feature, style);

                    if (localStyle is SymbolStyle symbolStyle)
                    {
                        var scale = symbolStyle.SymbolScale;

                        var size = symbolStyle.BitmapId >= 0
                            ? symbolCache.GetSize(symbolStyle.BitmapId)
                            : new Size(SymbolStyle.DefaultWidth, SymbolStyle.DefaultHeight);

                        // Symbols allways drawn around the center (* 0.5 instead of / 2)
                        var factor  = resolution * scale;
                        var marginX = size.Width * 0.5 * factor;
                        var marginY = size.Height * 0.5 * factor;

                        var box = feature.Geometry.BoundingBox;
                        box = box.Grow(marginX, marginY);
                        if (symbolStyle.SymbolOffset.IsRelative)
                        {
                            box.Offset(
                                size.Width * symbolStyle.SymbolOffset.X * factor,
                                size.Height * symbolStyle.SymbolOffset.Y * factor);
                        }
                        else
                        {
                            box.Offset(symbolStyle.SymbolOffset.X * factor, symbolStyle.SymbolOffset.Y * factor);
                        }
                        if (box.Distance(point) <= marginInWorldUnits)
                        {
                            return(true);
                        }
                    }
                    else if (localStyle is VectorStyle)
                    {
                        var marginX = SymbolStyle.DefaultWidth * 0.5 * resolution;
                        var marginY = SymbolStyle.DefaultHeight * 0.5 * resolution;

                        var box = feature.Geometry.BoundingBox;
                        box = box.Grow(marginX, marginY);
                        if (box.Distance(point) <= marginInWorldUnits)
                        {
                            return(true);
                        }
                    }
                    else if (localStyle == null)
                    {
                        Logger.Log(LogLevel.Warning, $"Feature info with a null style: {String.Join("-", feature.Fields.Select(f => $"[{f}:{feature[f].ToString()}]"))}");
                    }
                    else
                    {
                        if (!(localStyle is LabelStyle)) // I don't intend to support label click, so don't warn
                        {
                            Logger.Log(LogLevel.Warning, $"Feature info not supported for points with {localStyle.GetType()}");
                        }
                    }
                }
            }
            else if (feature.Geometry is LineString || feature.Geometry is MultiLineString)
            {
                foreach (var style in styles)
                {
                    var localStyle = HandleThemeStyle(feature, style);

                    if (localStyle is VectorStyle symbolStyle)
                    {
                        var lineWidthInWorldUnits = symbolStyle.Line.Width * resolution * 0.5;

                        if (feature.Geometry.Distance(point) <= lineWidthInWorldUnits + marginInWorldUnits)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        Logger.Log(LogLevel.Warning, $"Feature info not supported for lines with {localStyle.GetType()}");
                    }
                }
            }
            else
            {
                return(feature.Geometry.Distance(point) <= marginInWorldUnits);
            }
            return(false);
        }