界面效果:


对外提供的属性设置

        /// <summary>
        /// 背景色
        /// </summary>
        public Color BackColor;

        /// <summary>
        /// 边框颜色
        /// </summary>
        , , );

        /// <summary>
        /// 线条颜色
        /// </summary>
        , , );

        /// <summary>
        /// 折线颜色
        /// </summary>
        , , );

        /// <summary>
        /// 是否显示控件边框
        /// </summary>
        public bool rect_isvisable = false;
       /// <summary>
        /// 边框线宽
        /// </summary>
        ;

        /// <summary>
        /// 垂直线条间距
        /// </summary>
        ;
        /// <summary>
        /// 水平线条间距
        /// </summary>
        ;

        /// <summary>
        /// 点密度,越小越稀疏
        /// </summary>
        private float point_density = 0.7f;

        #region
        public float Point_density
        {
            get
            {
                return point_density;
            }

            set
            {
                point_density = value;

                 || value > )
                {
                    point_density = 0.7f;
                }
            }
        }

        public float Linewidth
        {
            get
            {
                return linewidth;
            }

            set
            {
                linewidth = value;
                )
                {
                    linewidth = ;
                }
            }
        }

        public int Vertical_spacing
        {
            get
            {
                return vertical_spacing;
            }

            set
            {
                )
                {
                    value = ;
                }
                vertical_spacing = value;
            }
        }

        public int Horizontal_spacing
        {
            get
            {
                return horizontal_spacing;
            }

            set
            {
                )
                {
                    value = ;
                }
                horizontal_spacing = value;
            }
        }

        #endregion

这些要保证是大于0,我使用属性了,这样比频繁的类型转换要好


绘制

        protected override void OnPaint(PaintEventArgs pe)
        {
            this.drawtable();
            this.drawpolygonal();
            base.OnPaint(pe);
        }

        private void drawtable()//表格绘制
        {

            if (this.rect_isvisable)
            {
                this.rectanglelinecolor = Color.Black;
            }
            else
            {
                this.rectanglelinecolor = this.BackColor;
            }
            Graphics g = this.CreateGraphics();
            g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);

            )+this.vertical_spacing;i<this.Height;i+=this.vertical_spacing)
            {
                g.DrawLine(), this.ClientRectangle.X, i, this.Width, i);
            }

            )+this.Horizontal_spacing;i<this.Width;i+=this.Horizontal_spacing)
            {
                g.DrawLine(), i,this.ClientRectangle.Y,i,  this.Height);
            }
            g.DrawRectangle(, , this.Width - this.linewidth, this.Height - this.linewidth);
            g.Dispose();
        }

        /// <summary>
        /// 折线绘制
        /// </summary>
        private void drawpolygonal()
        {
            Point ps=new Point();
            Point pe;

            Graphics g = this.CreateGraphics();
            ,j=; i>=;i--,j++)
            {
                float f = this.polygonalpoint[i];
                int w = this.Width - this.Horizontal_spacing_per_pp*j;
                int h = this.Height - (int)(f * this.Height);
                pe = ps;
                ps = new Point(w, h);
                )
                {
                    g.DrawLine(p,pe, ps);
                }

            }
        }

链接:http://pan.baidu.com/s/1gdjod8J

添加到自己的项目里拖进去就可以了;和普通的控件一样使用

M$自己也有更好的linechart,不过插件肯定比较大的了

C#自定义控件 类似于Linechart的更多相关文章

  1. MPAndroidChart Wiki(译文)~Part 2

    7. 填充数据 这一章节将讲解给各式各样的图表设置数据的方法. 7.1 LineChart(线形图) 想给图表添加数据,使用如下方法: public void setData(ChartData da ...

  2. 自定义控件--CircleImageView(类似于QQ、微信圆形头像自定义控件)

    现在基本上所有的需要用户注册的APP都有一个需要用户上传头像的需求,上传的头像基本都是类似于QQ.微信等社交应用圆形头像.最近,正在做的一个社交应用多处需要用到这种圆形头像的处理,总不能每次都对图片做 ...

  3. android自定义控件一站式入门

    自定义控件 Android系统提供了一系列UI相关的类来帮助我们构造app的界面,以及完成交互的处理. 一般的,所有可以在窗口中被展示的UI对象类型,最终都是继承自View的类,这包括展示最终内容的非 ...

  4. ASP.NET MVC学习之母版页和自定义控件的使用

    一.母板页_Layout.cshtml类似于传统WebForm中的.master文件,起到页面整体框架重用的目地1.母板页代码预览 <!DOCTYPE html> <html> ...

  5. android第一行代码-6.自定义控件的实现

    0.假设一个应用中标题栏控件都是共用的,如果每个activity都需要设置button,绑定方法,那代码就会很臃肿.那我们可以自定义控件,然后继承这个控件就行了. 自定义控件为TitleLayout, ...

  6. android自定义控件(3)-自定义当前按钮属性

    那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...

  7. android自定义控件(1)-点击实现开关按钮切换

    自定义控件的步骤.用到的主要方法:   1.首先需要定义一个类,继承自View:对于继承View的类,会需要实现至少一个构造方法:实际上这里一共有三个构造方法: public View (Contex ...

  8. android 自定义控件 使用declare-styleable进行配置属性(源码角度)

          android自定义styleableattrs源码 最近在模仿今日头条,发现它的很多属性都是通过自定义控件并设定相关的配置属性进行配置,于是便查询了解了下declare-styleabl ...

  9. c#自定义控件属性面板及选择资源设置

    博客转移到 http://jacean.github.io/ 继续分享编程经验 因为要做流体布局,但两个控件没办法组合,就做自定义控件.这个控件需要一个text设置文本,一个pic设置图片显示,图片通 ...

随机推荐

  1. C#使用for循环移除HTML标记

    public static string StripTagsCharArray(string source) { char[] array = new char[source.Length]; int ...

  2. EasyNVR如何实现跨域鉴权

    EasyNVR提供简单的登录鉴权,客户端通过用户名密码登录成功后,服务端返回认证token的cookie, 后续的接口访问, 服务端从cookie读取token进行校验. 但是, 在与客户系统集成时, ...

  3. ios Symbol(s) not found for architecture arm64总结 含隐藏错误cocoapods

    一.通用 报错:Desktop/project/ASDF/WEIXIN/libWeChatSDK.a (3 slices) Undefinedsymbols for architecture arm6 ...

  4. 洛谷 3275 [SCOI2011]糖果

    题目戳这里 N句话题意 有N个人,k个限制,有五种限制 如果X=1, 表示第A个小朋友的糖果必须和第B个小朋友的糖果一样多: 如果X=2, 表示第A个小朋友的糖果必须少于第B个小朋友的糖果: 如果X= ...

  5. Android开发之ListView添加多种布局效果演示

    在这个案例中展示的新闻列表,使用到ListView控件,然后在适配器中添加多种布局效果,这里通过重写BaseAdapter类中的 getViewType()和getItemViewType()来做判断 ...

  6. 测试drawable animation

    public class DAActivity extends Activity implements OnClickListener { private ImageView iv_da_mm; pr ...

  7. PAT 乙级 1084. 外观数列 (20) 【字符串】

    题目链接 https://www.patest.cn/contests/pat-b-practise/1084 思路 用字符串模拟 然后要注意一点 它是连续的 才并在一起 就比如说 d, d1, d1 ...

  8. 《CSS权威指南(第三版)》---第六章 文本属性

    本章主要的内容是: 1.文本缩进: text-indent.行内元素无法缩进,一般用左内边距或外边距来创造这种效果. 2.文本对齐:text-align .只应用于块状元素. 3.行高:一般line- ...

  9. 批量导入oracle 的sql脚本

    以下为脚本样例:execute.sql,在PL/sql的command窗口或sqlplus中执行:@目录/execute.sql (以下“目录”需要替换为实际sql所在目录) --执行前需要在目录下新 ...

  10. HDU4825 Xor Sum —— Trie树

    题目链接:https://vjudge.net/problem/HDU-4825 Xor Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Li ...