基本教程篇----第九节MasterSampleDemo.cs介绍

2024-04-12 15:18

本文主要是介绍基本教程篇----第九节MasterSampleDemo.cs介绍,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

                                             第九节MasterSampleDemo.cs介绍

           最近一直挺忙的,都没时间写博客了,好在这是基础篇的最后一篇了,我也可以歇歇了,关于其它的深入章节我会在以后的时间补上的。
先来看看这一节的示图和源代码吧。
using System;
using System.Drawing;
using System.Collections;
 
using ZedGraph;
 
namespace ZedGraph.Demo
{
     /// <summary>
     /// Summary description for SimpleDemo.
     /// </summary>
     public class MasterSampleDemo : DemoBase
     {
 
         public MasterSampleDemo() : base( "Code Project MasterPane Sample",
                  "MasterPane Sample", DemoType.Tutorial )
         {
              MasterPane myMaster = base.MasterPane;
 
              // Remove the default GraphPane that comes with ZedGraphControl
              myMaster.PaneList.Clear();
 
              // Set the masterpane title
              myMaster.Title = "ZedGraph MasterPane Example";
              myMaster.IsShowTitle = true;
 
              // Fill the masterpane background with a color gradient
              myMaster.PaneFill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );
 
              // Set the margins to 10 points
              myMaster.MarginAll = 10;
 
              // Enable the masterpane legend
              myMaster.Legend.IsVisible = true;
              myMaster.Legend.Position = LegendPos.TopCenter;
 
              // Add a priority stamp
              TextItem text = new TextItem( "Priority", 0.88F, 0.12F );
              text.Location.CoordinateFrame = CoordType.PaneFraction;
              text.FontSpec.Angle = 15.0F;
              text.FontSpec.FontColor = Color.Red;
              text.FontSpec.IsBold = true;
              text.FontSpec.Size = 15;
              text.FontSpec.Border.IsVisible = false;
              text.FontSpec.Border.Color = Color.Red;
              text.FontSpec.Fill.IsVisible = false;
              text.Location.AlignH = AlignH.Left;
              text.Location.AlignV = AlignV.Bottom;
              myMaster.GraphItemList.Add( text );
 
              // Add a draf watermark è
              text = new TextItem( "DRAFT", 0.5F, 0.5F );
              text.Location.CoordinateFrame = CoordType.PaneFraction;
              text.FontSpec.Angle = 30.0F;
              text.FontSpec.FontColor = Color.FromArgb( 70, 255, 100, 100 );
              text.FontSpec.IsBold = true;
              text.FontSpec.Size = 100;
              text.FontSpec.Border.IsVisible = false;
              text.FontSpec.Fill.IsVisible = false;
              text.Location.AlignH = AlignH.Center;
              text.Location.AlignV = AlignV.Center;
              text.ZOrder = ZOrder.A_InFront;
              myMaster.GraphItemList.Add( text );
 
              // Initialize a color and symbol type rotator
              ColorSymbolRotator rotator = new ColorSymbolRotator();
 
              // Create some new GraphPanes
              for ( int j=0; j<5; j++ )
              {
                  // Create a new graph - rect dimensions do not matter here, since it
                  // will be resized by MasterPane.AutoPaneLayout()
                  GraphPane myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                       "Case #" + (j+1).ToString(),
                       "Time, Days",
                       "Rate, m/s" );
 
                  // Fill the GraphPane background with a color gradient
                  myPane.PaneFill = new Fill( Color.White, Color.LightYellow, 45.0F );
                  myPane.BaseDimension = 6.0F;
 
                  // Make up some data arrays based on the Sine function
                  PointPairList list = new PointPairLis_u40 ?);
                  for ( int i=0; i<36; i++ )
                  {
                       double x = (double) i + 5;
                       double y = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 + (double) j ) );
                       list.Add( x, y );
                  }
 
                  // Add a curve to the Graph, use the next sequential color and symbol
                  LineItem myCurve = myPane.AddCurve( "Type " + j.ToString(),
                       list, ro_u97 ?tor.NextColor, rotator.NextSymbol );
                  // Fill the symbols with white to make them opaque
                  myCurve.Symbol.Fill = new Fill( Color.White );
 
                  // Add the GraphPane to the MasterPane
                  myMaster.Add( myPane );
              }
 
              Graphics g = this.ZedGraphControl.CreateGraphics();
              // Tell ZedGraph to auto layout the new GraphPanes
              myMaster.AutoPaneLayout( g, PaneLayout.ExplicitRow32 );
              myMaster.AxisChange( g );
              g.Dispose();
         }
     }
}
     这一节主要是讲多 pane 的创建方法。里面大部分的方法和属性在以前的章节中已经介绍过了,这里只想讲三个地方: MasterPane 类、 ColorSymbolRotator 类和 ZOrder 这个属性的用法。
     首先就是 MasterPane 类。这个类就是创建多 pane 的类,是一个 GraphPane 类的集合。它里面的大部分属性和方法都继承自 PaneBase Object 。像 .NET 一样,这个类提供了 Item PaneList 属性来设置和获取里面的成员。在程序中我们也看到了,其实 MasterPane 什么也没做,就是把其它的类一项项的 Add 进它的集合中。
           ColorSymbolRotator 类就是一个为 GraphPane.AddCurve 方法循环提供不同颜色和符号的类。这个类的东西不多,我个人认为就相当于一个枚举一样,我们可以看到程序中只用到了 rotator.NextColor rotator.NextSymbol 这两个属性,来获取不同的颜色和符号。
     最后就是 Zorder 这个属性了,在前面的几节中我们也见过这个属性,可是当时我没有讲,现在我说说。 Zorder 就是图形在 Z 轴的位置。如果我们在平面上把左右看成 X 轴,把上下看成 Y 轴,那么内外就是 Z 轴了,也就是 Zorder 就是图形在内外的位置 ( 这个内外是针对其它图形来说的 ) 。我们可以看看示图中的 DRAFT 这个水印的效果,这就是 Zorder 的功能。如果你把程序中的
text.ZOrder = ZOrder.A_InFront; 改成 text.ZOrder = ZOrder.G_BehindAll;
那么 DRAFT 就是如下的效果了, DRAFT 就在各个 Pane 的下面了。
Zorder 是一个枚举共有七个枚举值。分别是 G_BehindAll F_BehindAxisFill E_BehindAxis D_BehindCurves C_BehindAxisBorder B_BehindLegend A_InFront 。具体的解释如

Member Name
Description
G_BehindAll
Specifies that the GraphItem will be behind all other objects (including the PaneBase Title).
F_BehindAxisFill
Specifies that the GraphItem will be behind the AxisRect background Fill (see AxisFill).
E_BehindAxis
Specifies that the GraphItem will be behind the Axis objects.
D_BehindCurves
Specifies that the GraphItem will be behind the CurveItem objects.
C_BehindAxisBorder
Specifies that the GraphItem will be behind the Axis border.
B_BehindLegend
Specifies that the GraphItem will be behind the Legend object.
A_InFront
Specifies that the GraphItem will be in front of all other objects, except for the other GraphItem objects that have the same ZOrder and are before this object in the GraphItemList.
Member Name
Description
 
G_BehindAll
Specifies that the GraphItem will be behind all other objects (including the PaneBase Title).
 
F_BehindAxisFill
Specifies that the GraphItem will be behind the AxisRect background Fill (see AxisFill).
 
E_BehindAxis
Specifies that the GraphItem will be behind the Axis objects.
 
D_BehindCurves
Specifies that the GraphItem will be behind the CurveItem objects.
 
C_BehindAxisBorder
Specifies that the GraphItem will be behind the Axis border.
 
B_BehindLegend
Specifies that the GraphItem will be behind the Legend object.
 
A_InFront
Specifies that the GraphItem will be in front of all other objects, except for the other GraphItem objects that have the same ZOrder and are before this object in the GraphItemList.
 
 
 
 
 

 
 

这篇关于基本教程篇----第九节MasterSampleDemo.cs介绍的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/897495

相关文章

Windows环境下解决Matplotlib中文字体显示问题的详细教程

《Windows环境下解决Matplotlib中文字体显示问题的详细教程》本文详细介绍了在Windows下解决Matplotlib中文显示问题的方法,包括安装字体、更新缓存、配置文件设置及编码調整,并... 目录引言问题分析解决方案详解1. 检查系统已安装字体2. 手动添加中文字体(以SimHei为例)步骤

MySql基本查询之表的增删查改+聚合函数案例详解

《MySql基本查询之表的增删查改+聚合函数案例详解》本文详解SQL的CURD操作INSERT用于数据插入(单行/多行及冲突处理),SELECT实现数据检索(列选择、条件过滤、排序分页),UPDATE... 目录一、Create1.1 单行数据 + 全列插入1.2 多行数据 + 指定列插入1.3 插入否则更

Java JDK1.8 安装和环境配置教程详解

《JavaJDK1.8安装和环境配置教程详解》文章简要介绍了JDK1.8的安装流程,包括官网下载对应系统版本、安装时选择非系统盘路径、配置JAVA_HOME、CLASSPATH和Path环境变量,... 目录1.下载JDK2.安装JDK3.配置环境变量4.检验JDK官网下载地址:Java Downloads

C#连接SQL server数据库命令的基本步骤

《C#连接SQLserver数据库命令的基本步骤》文章讲解了连接SQLServer数据库的步骤,包括引入命名空间、构建连接字符串、使用SqlConnection和SqlCommand执行SQL操作,... 目录建议配合使用:如何下载和安装SQL server数据库-CSDN博客1. 引入必要的命名空间2.

zookeeper端口说明及介绍

《zookeeper端口说明及介绍》:本文主要介绍zookeeper端口说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、zookeeper有三个端口(可以修改)aVNMqvZ二、3个端口的作用三、部署时注意总China编程结一、zookeeper有三个端口(可以

Java中的数组与集合基本用法详解

《Java中的数组与集合基本用法详解》本文介绍了Java数组和集合框架的基础知识,数组部分涵盖了一维、二维及多维数组的声明、初始化、访问与遍历方法,以及Arrays类的常用操作,对Java数组与集合相... 目录一、Java数组基础1.1 数组结构概述1.2 一维数组1.2.1 声明与初始化1.2.2 访问

使用Docker构建Python Flask程序的详细教程

《使用Docker构建PythonFlask程序的详细教程》在当今的软件开发领域,容器化技术正变得越来越流行,而Docker无疑是其中的佼佼者,本文我们就来聊聊如何使用Docker构建一个简单的Py... 目录引言一、准备工作二、创建 Flask 应用程序三、创建 dockerfile四、构建 Docker

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

Go语言数据库编程GORM 的基本使用详解

《Go语言数据库编程GORM的基本使用详解》GORM是Go语言流行的ORM框架,封装database/sql,支持自动迁移、关联、事务等,提供CRUD、条件查询、钩子函数、日志等功能,简化数据库操作... 目录一、安装与初始化1. 安装 GORM 及数据库驱动2. 建立数据库连接二、定义模型结构体三、自动迁

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹