LinearStripesFill.cs :  » Charting-Reporting-Tools » googlechartsharp » GoogleChartSharp » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Charting Reporting Tools » googlechartsharp 
googlechartsharp » GoogleChartSharp » LinearStripesFill.cs
using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleChartSharp{
    public class LinearStripesFill
    {
        private ChartFillTarget fillTarget;
        /// <summary>
        /// The area that will be filled.
        /// </summary>
        public ChartFillTarget FillTarget
        {
            get { return fillTarget; }
            set { fillTarget = value; }
        }

        private int angle;
        /// <summary>
        /// specifies the angle of the gradient between 0 (vertical) and 90 (horizontal)
        /// </summary>
        public int Angle
        {
            get { return angle; }
            set { angle = value; }
        }

        private List<ColorWidthPair> colorWidthPairs = new List<ColorWidthPair>();

        /// <summary>
        /// Create a linear stripes fill.
        /// </summary>
        /// <param name="fillTarget">The area that will be filled.</param>
        /// <param name="angle">specifies the angle of the gradient between 0 (vertical) and 90 (horizontal)</param>
        public LinearStripesFill(ChartFillTarget fillTarget, int angle)
        {
            this.fillTarget = fillTarget;
            this.angle = angle;
        }

        /// <summary>
        /// A color/width pair describes a linear stripe.
        /// </summary>
        /// <param name="color">RRGGBB format hexadecimal number</param>
        /// <param name="width">must be between 0 and 1 where 1 is the full width of the chart</param>
        public void AddColorWidthPair(string color, double width)
        {
            this.colorWidthPairs.Add(new ColorWidthPair(color, width));
        }

        internal string getTypeUrlChar()
        {
            switch (fillTarget)
            {
                case ChartFillTarget.ChartArea:
                    return "c";
                case ChartFillTarget.Background:
                    return "bg";
            }
            return null;
        }

        internal String GetUrlString()
        {
            string s = string.Empty;
            s += getTypeUrlChar() + ",";
            s += "ls,";
            s += angle.ToString() + ",";

            foreach (ColorWidthPair colorWidthPair in colorWidthPairs)
            {
                s += colorWidthPair.Color + ",";
                s += colorWidthPair.Width + ",";
            }

            return s.TrimEnd(",".ToCharArray());
        }

        private class ColorWidthPair
        {
            /// <summary>
            /// RRGGBB format hexadecimal number
            /// </summary>
            public string Color;

            /// <summary>
            /// must be between 0 and 1 where 1 is the full width of the chart
            /// </summary>
            public double Width;

            /// <summary>
            /// Describes a linear stripe. Stripes are repeated until the chart is filled.
            /// </summary>
            /// <param name="color">RGGBB format hexadecimal number</param>
            /// <param name="width">must be between 0 and 1 where 1 is the full width of the chart</param>
            public ColorWidthPair(string color, double width)
            {
                this.Color = color;
                this.Width = width;
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.