第一节:InitialSampleDemo.cs介绍
        为了讲解方便,我先附上源代码和效果图。
代码如下:
using System;
using System.Drawing;
using System.Collections;
 
using ZedGraph;
 
namespace ZedGraph.Demo
{
     ///<summary>
     /// Summary description for SimpleDemo.
     ///</summary>
     public class InitialSampleDemo : DemoBase
     {
 
           public InitialSampleDemo() : base(
"Code Project Initial Sample",
                "Initial Sample", DemoType.Tutorial )
           {
                GraphPane myPane = base.GraphPane;
 
                // Set the title and axis labels
                myPane.Title = "My Test Graph/n(For CodeProject Sample)";
                myPane.XAxis.Title = "My X Axis";
                myPane.YAxis.Title = "My Y Axis";
               
                // Make up some data arrays based on the Sine function
                PointPairList list1 = new PointPairList();
                PointPairList list2 = new PointPairList();
                for ( int i=0; i<36; i++
)
                {
                     double x = (double)
i + 5;
                     double y1 = 1.5 + Math.Sin( (double)
i * 0.2 );
                     double y2 = 3.0 * ( 1.5 + Math.Sin( (double)
i * 0.2 ) );
                     list1.Add( x, y1 );
                     list2.Add( x, y2 );
                }
 
                // Generate a red curve with diamond
                // symbols, and "Porsche" in the legend
                LineItem myCurve = myPane.AddCurve( "Porsche",
                     list1, Color.Red, SymbolType.Diamond );
 
                // Generate a blue curve with circle
                // symbols, and "Piper" in the legend
                LineItem myCurve2 = myPane.AddCurve( "Piper",
                     list2, Color.Blue, SymbolType.Circle );
 
                base.ZedGraphControl.AxisChange();
           }
     }
}
 
        我们可以看到,InitialSampleDemo继承自CemoBase类,而DemoBase又继承自ZedGraphDemo这个接口。ZedGraphDemo接口定义了String Description、String Title、ZedGraph. ZedGraphControl ZedGraphControl 和 System.Collection.ICollection Types这四个属性。DemoBase除了实现这四个属性外,还添加了PaneBase Pane和MasterPane
MasterPane这两个属性,此外DemoBase还实现了多载构造函数。关于各个类的具体含义和用法,我会在以后的篇幅中陆续介绍。这里只是给大家一个整体的大致结构。
        下面进行对代码的分析,由于这是第一个例子,所有我会讲得比较细,以后的例子就不会了。
        我们可以看到程序首先
public InitialSampleDemo() : base( "Code Project Initial Sample" , "Initial Sample", DemoType.Tutorial
)
初始化基类的构造函数。基类重载了四个构造函数
public DemoBase( string description, string title, DemoType type )
           {
                ArrayList types = new ArrayList();
                types.Add( type );
 
                Init( description, title, types );
           }
          
           public DemoBase( string description, string title,
DemoType type, DemoType type2 )
           {
                ArrayList types = new ArrayList();
                types.Add( type );
                types.Add( type2 );
 
                Init( description, title, types );
           }
          
           public DemoBase( string description, string title,
ICollection types )
           {
                Init( description, title, types );
           }
          
           private void Init( string description, string title,
ICollection types )
           {
                this.description = description;
                this.title = title;
                this.types = types;
 
                control = new ZedGraphControl();
           }
函数中的变量含义如下:
Description:对此结构的描述。
Title:在树形结构(TreeView)中显示的标题。
Types:要把此类显示在哪个树形结构的区域中。若有多个Types,则把此类分入不同的树形区域中。例如MasterPane Sample在Tutorial Sample和 Special Features两个区域都有。见图中的相应区域标注。
                        myPane.Title = "My Test Graph/n(For CodeProject Sample)";
                myPane.XAxis.Title = "My X Axis";
                myPane.YAxis.Title = "My Y Axis";
     分别指定这个Pane的title、XAxis和YAxis的标题。见上图。
 
                PointPairList list1 = new PointPairList();
                PointPairList list2 = new PointPairList();
                for ( int i=0; i<36; i++
)
                {
                     double x = (double)
i + 5;
                     double y1 = 1.5 + Math.Sin( (double)
i * 0.2 );
                     double y2 = 3.0 * ( 1.5 + Math.Sin( (double)
i * 0.2 ) );
                     list1.Add( x, y1 );
                     list2.Add( x, y2 );
                }
        PointPairList类是一个集合类,继承自
                                                        System.ObjectSystem.Collections.CollectionBaseZedGraph.CollectionPlus
它是PointPair对象的集合,PointPair类是一个包含(X,Y)的坐标类。
其中的for循环在为两个PointPairList复值。
 
LineItem myCurve = myPane.AddCurve( "Porsche", list1, Color.Red, SymbolType.Diamond );
LineItem类是ZedGraph中的线条类.
myPane.AddCurve( "Porsche", list1, Color.Red, SymbolType.Diamond );
的意思是将刚刚赋值的list以”Porsche”这个名字以红色和水晶形状画到Pane中,这个函数的返回值是一个LineItem。你可以通过myCurve这个变量来对它进行进一步的设定。其中SymbolType是个Enum,它枚举了12个可供使用的形状
 
最后一步就是刷新了。base.ZedGraphControl.AxisChange();
这样整个程序就完成了,简单吧,其实这是个简单的应该,以后会介绍更加复杂的用法和类库。

基本教程篇--第一节:InitialSampleDemo.cs介绍的更多相关文章

  1. MapServer Tutorial——MapServer7.2.1教程学习——第一节:MapServer的基本配置管理,静态地图应用以及MapFile文件

    MapServer Tutorial——MapServer7.2.1教程学习——第一节:MapServer的基本配置管理,静态地图应用以及MapFile文件 前言 万事开头难,有了<MapSer ...

  2. 2014年度辛星html教程夏季版第一节

    从今天起开始在博客园开启自己的html教程啦,先从第一节开始把,首先推荐一个网站,就是http:/www.w3cschool.cc,这是一个公开的教学网站,但是它有一个问题,那就是虽然很全面,但是不是 ...

  3. 2014年度辛星css教程夏季版第一节

    CSS是Cascading Style Sheets的缩写,即层叠样式表,它用于表现HTML的样式,即HTML只是去写该网页有哪些内容,至于如何去表现它们,由CSS去定制. ************* ...

  4. ZedGraph类库之基本教程篇

      第一部分:基本教程篇                 ZedGraphDemo中一共有9个基本教程的例子.其中大部分都类似,我会讲解其中一些比较典型的例子.把ZedGraph类库的使用逐步展现给大 ...

  5. [Learn Android Studio 汉化教程]第一章 : Android Studio 介绍

    注:为了看上去比较清晰这里只转载了中文 原地址:  [Learn Android Studio 汉化教程]第一章 : Android Studio 介绍 本章将引导您完成安装和设置开发环境,然后你就可 ...

  6. Android精通教程-第一节Android入门简介

    前言 大家好,给大家带来Android精通教程-第一节Android入门简介的概述,希望你们喜欢 每日一句 If life were predictable it would cease to be ...

  7. Matlab高级教程_第一篇:Matlab基础知识提炼_01

    第一篇:Matlab基础知识提炼: 这一篇主要用系统和提炼性的语言对Matlab基础知识进行总结,主要适用于有语言基础的学习者.尽量不讲废话. 第一部分:Matlab是什么? 1 Matlab是Mat ...

  8. Unity3D教程宝典之Web服务器篇:(第一讲)服务器的架设

    转载自风宇冲Unity3D教程学院 引言:本文主要介绍WAMP服务器的架设. 第一部分WAMP介绍;第二部分WAMP安装及使用.                        第一部分WAMP介绍 什 ...

  9. ASP.NET MVC深入浅出(被替换) 第一节: 结合EF的本地缓存属性来介绍【EF增删改操作】的几种形式 第三节: EF调用普通SQL语句的两类封装(ExecuteSqlCommand和SqlQuery ) 第四节: EF调用存储过程的通用写法和DBFirst模式子类调用的特有写法 第六节: EF高级属性(二) 之延迟加载、立即加载、显示加载(含导航属性) 第十节: EF的三种追踪

    ASP.NET MVC深入浅出(被替换)   一. 谈情怀-ASP.NET体系 从事.Net开发以来,最先接触的Web开发框架是Asp.Net WebForm,该框架高度封装,为了隐藏Http的无状态 ...

随机推荐

  1. vmware增加共享文件夹

    增加共享文件夹 VMWare提供共享文件夹功能.前提是在虚拟机中安装VMware tools 1. 安装VMware tools 会自动在虚拟机中的/media/VMware Tools/中有个压缩包 ...

  2. Shell 运算符 if

    Shell 支持多种运算符,包括: 算术运算符 原生bash不支持简单的数学运算,可以使用 expr,let 关系运算符 布尔运算符 字符串运算符 文件运算符 算术运算符 包括加减乘除,取余(%).赋 ...

  3. debug.js中的length的错误

    记得昨天报了一个错,debug.js文件中的length未定义.前台不定位代码,后天也不报错,而debug.js是框架封装的文件,不是自己写的,无从得知是哪里的问题,而项目也已经重新启动过,无法撤销. ...

  4. Job for docker.service failed because the control process exited with error code. See "systemctl status do cker.service" and "journalctl -xe" for details.

    问题出现 :入手操作Docker时,安装启动后报了这个错 Job for docker.service failed because the control process exited with e ...

  5. python django框架(一)

    s4day63内容回顾: 1. 安装 2. 创建用户 + 授权 3. 连接 - 数据库 终端创建数据库(字符编码) - 数据表 终端 ORM pymysql create ...)engine=inn ...

  6. LeetCode OJ:Reverse Linked List (反转链表)

    Reverse a singly linked list. 做II之前应该先来做1的,这个倒是很简单,基本上不用考虑什么,简单的链表反转而已: /** * Definition for singly- ...

  7. 2017.10.26 ECN + product spec+ cypress ble module test+

    1 ECN Ecn  should be issued when modifying drawing,Copy children BOM of subassembly from BIL if one ...

  8. 随机获取图片的api接口

    http://lorempixel.com/1600/900 https://unsplash.it/1600/900?random(国内加载略慢) https://uploadbeta.com/ap ...

  9. python库之_thread

    官方参考文档:https://docs.python.org/3.7/library/_thread.html _thread库方法 (1) _thread.error (2)_thread.Lock ...

  10. 【Xamarin 】MonoTouch - UIImageView响应点击事件

    //圆角头像 UIImageView _avatarView = new UIImageView(new RectangleF(_blockSpace, _blockSpace, 2 * _avata ...