界面效果:


对外提供的属性设置

        /// <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. Oracle学习第二篇—单行函数

    1字符函数 length  字符长度 lengthb 字节长度 lower 变为小写 upper 变为大写 initcap 首字母大写 select Lower('xun Ying') 小写,Uppe ...

  2. JS常用方法手记

    1.判断arr数组是否含有元素str,没有返回-1 arr.indexOf(str) 2.遍历arr数组,k为键,v为值 arr.map((v, k) => { return;}) 3.arr数 ...

  3. 【LeetCode】Balanced Binary Tree 解题报告

    [题目] Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced bi ...

  4. TP框架---thinkphp修改删除数据

    1.在控制器MainController里面写一个方法,调用Nation表中的数据. public function zhuyemian() { $n = D("Nation"); ...

  5. Bloom Filters

    http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html A Bloom filter is a method for represe ...

  6. HTML5+ 权限设置

    API分模块封装调用了系统各种原生能力,而部分能力需要使用到Android的permissions,以下列出了各模块(或具体API)使用的的权限: -------------------------- ...

  7. 流畅python学习笔记第十八章:使用asyncio包处理并发(二)

    前面介绍了asyncio的用法.下面我们来看下如何用协程的方式来实现之前的旋转指针的方法 @asyncio.coroutine def spin(msg): write,flush=sys.stdou ...

  8. 转换(旋转)transform

    div { transform:rotate(180deg); -ms-transform:rotate(180deg); /* IE 9 */ -moz-transform:rotate(180de ...

  9. keras:Exception: Error when checking model target

    问题: 用keras的functional API搭建多输入多输出模型时,报错某个输出层对应的类标数组大小与模型中不一致. 解决办法:升级keras到最新版(doge脸)keras迭代太快了啊摔,总有 ...

  10. Bootstrap——组件

    1.字体图标 <span class="glyphicon glyphicon-star" aria-hidden="true"></span ...