Example showing drawing using GINOGRAF
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using GinoGraphics;
namespace grafex3
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(292, 273);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1});
this.Name = "Form1";
this.Text = "Form1";
this.Resize += new System.EventHandler(this.Form1_Resize);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
/* Program grafex3 */
/* ********************************************** */
/* Copyright Bradly Associates Limited */
/* GINOGRAF Version 6.0 */
/* ********************************************** */
/* Assign column height data */
GBARCHART[] bar1 = new GBARCHART[12];
GBARCHART[] bar2 = new GBARCHART[12];
GBARCHART[] bar3 = new GBARCHART[12];
GBARCHART[] bar4 = new GBARCHART[12];
GBARCHART[] bar5 = new GBARCHART[12];
GBARCHART[] bar6 = new GBARCHART[12];
GBARCHART[] bar7 = new GBARCHART[12];
GBARCHART[] bar8 = new GBARCHART[12];
GAREACHART[] land = new GAREACHART[12];
GAREACHART[] sea = new GAREACHART[1];
GAREACHART[] key = new GAREACHART[3];
bar1[0] = new GBARCHART(0.0,20.0); bar1[1] = new GBARCHART(0.0,18.0);
bar1[2] = new GBARCHART(0.0,21.0); bar1[3] = new GBARCHART(0.0,19.0);
bar1[4] = new GBARCHART(0.0,15.0); bar1[5] = new GBARCHART(0.0,37.0);
bar1[6] = new GBARCHART(0.0,39.0); bar1[7] = new GBARCHART(0.0,21.0);
bar1[8] = new GBARCHART(0.0,19.0); bar1[9] = new GBARCHART(0.0,18.5);
bar1[10] = new GBARCHART(0.0,36.0); bar1[11] = new GBARCHART(0.0,22.0);
bar2[0] = new GBARCHART(20.0,28.0); bar2[1] = new GBARCHART(18.0,27.0);
bar2[2] = new GBARCHART(21.0,28.5); bar2[3] = new GBARCHART(19.0,26.0);
bar2[4] = new GBARCHART(15.0,22.5); bar2[5] = new GBARCHART(37.0,47.5);
bar2[6] = new GBARCHART(39.0,47.0); bar2[7] = new GBARCHART(21.0,28.0);
bar2[8] = new GBARCHART(19.0,25.5); bar2[9] = new GBARCHART(18.5,25.0);
bar2[10] = new GBARCHART(36.0,48.0); bar2[11] = new GBARCHART(22.0,32.0);
bar3[0] = new GBARCHART(28.0,47.0); bar3[1] = new GBARCHART(27.0,44.0);
bar3[2] = new GBARCHART(28.5,57.5); bar3[3] = new GBARCHART(26.0,45.4);
bar3[4] = new GBARCHART(22.5,43.0); bar3[5] = new GBARCHART(47.5,61.0);
bar3[6] = new GBARCHART(47.0,56.5); bar3[7] = new GBARCHART(28.0,47.0);
bar3[8] = new GBARCHART(25.5,48.0); bar3[9] = new GBARCHART(25.0,44.0);
bar3[10] = new GBARCHART(48.0,53.0); bar3[11] = new GBARCHART(32.0,44.0);
bar4[0] = new GBARCHART(47.0,54.0); bar4[1] = new GBARCHART(44.0,55.0);
bar4[2] = new GBARCHART(57.5,63.0); bar4[3] = new GBARCHART(45.5,54.0);
bar4[4] = new GBARCHART(43.0,52.5); bar4[5] = new GBARCHART(61.0,69.0);
bar4[6] = new GBARCHART(56.5,64.0); bar4[7] = new GBARCHART(47.0,55.0);
bar4[8] = new GBARCHART(48.0,58.5); bar4[9] = new GBARCHART(44.0,53.0);
bar4[10] = new GBARCHART(53.0,62.5); bar4[11] = new GBARCHART(44.0,53.0);
bar5[0] = new GBARCHART(54.0,56.0); bar5[1] = new GBARCHART(55.0,67.5);
bar5[2] = new GBARCHART(63.0,64.5); bar5[3] = new GBARCHART(54.0,64.0);
bar5[4] = new GBARCHART(52.5,67.0); bar5[5] = new GBARCHART(69.0,73.0);
bar5[6] = new GBARCHART(64.0,67.0); bar5[7] = new GBARCHART(55.0,62.0);
bar5[8] = new GBARCHART(58.5,66.5); bar5[9] = new GBARCHART(53.0,63.5);
bar5[10] = new GBARCHART(62.5,66.5); bar5[11] = new GBARCHART(53.0,56.5);
bar6[0] = new GBARCHART(56.0,73.0); bar6[1] = new GBARCHART(67.5,80.5);
bar6[2] = new GBARCHART(64.5,82.0); bar6[3] = new GBARCHART(64.0,81.0);
bar6[4] = new GBARCHART(67.0,82.0); bar6[5] = new GBARCHART(73.0,87.0);
bar6[6] = new GBARCHART(67.0,81.0); bar6[7] = new GBARCHART(62.0,75.0);
bar6[8] = new GBARCHART(66.5,85.0); bar6[9] = new GBARCHART(63.5,76.0);
bar6[10] = new GBARCHART(66.5,83.0); bar6[11] = new GBARCHART(56.5,72.0);
bar7[0] = new GBARCHART(73.0,83.5); bar7[1] = new GBARCHART(80.5,87.0);
bar7[2] = new GBARCHART(82.0,91.0); bar7[3] = new GBARCHART(81.0,88.0);
bar7[4] = new GBARCHART(82.0,92.0); bar7[5] = new GBARCHART(87.0,94.0);
bar7[6] = new GBARCHART(81.0,92.5); bar7[7] = new GBARCHART(75.0,85.0);
bar7[8] = new GBARCHART(85.0,89.0); bar7[9] = new GBARCHART(76.0,86.5);
bar7[10] = new GBARCHART(83.0,87.5); bar7[11] = new GBARCHART(72.0,77.5);
bar8[0] = new GBARCHART(83.5,100.0); bar8[1] = new GBARCHART(87.0,100.0);
bar8[2] = new GBARCHART(91.0,100.0); bar8[3] = new GBARCHART(88.0,100.0);
bar8[4] = new GBARCHART(92.0,100.0); bar8[5] = new GBARCHART(94.0,100.0);
bar8[6] = new GBARCHART(92.5,100.0); bar8[7] = new GBARCHART(85.0,100.0);
bar8[8] = new GBARCHART(89.0,100.0); bar8[9] = new GBARCHART(86.5,100.0);
bar8[10] = new GBARCHART(87.5,100.0); bar8[11] = new GBARCHART(77.5,100.0);
land[0] = new GAREACHART(0.5,1.5,2.3,3.3);
land[1] = new GAREACHART(0.2,0.4,2.5,2.7);
land[2] = new GAREACHART(1.8,2.2,2.4,2.8);
land[3] = new GAREACHART(1.9,2.2,2.1,2.4);
land[4] = new GAREACHART(1.2,2.2,1.1,2.1);
land[5] = new GAREACHART(0.7,1.5,0.4,1.1);
land[6] = new GAREACHART(0.3,0.7,0.4,0.8);
land[7] = new GAREACHART(2.2,3.2,1.7,2.7);
land[8] = new GAREACHART(2.5,2.8,2.7,3.0);
land[9] = new GAREACHART(2.2,3.2,0.2,1.2);
land[10] = new GAREACHART(3.5,3.9,0.0,0.4);
land[11] = new GAREACHART(2.2,2.3,1.6,1.7);
sea[0] = new GAREACHART(-0.1,4.0,-0.1,3.5);
key[0] = new GAREACHART(1.0,2.0,1.0,2.0);
key[1] = new GAREACHART(1.0,5.0,1.0,5.0);
key[2] = new GAREACHART(1.0,50.0,1.0,50.0);
/* Assign labelling & titling data */
string[] labels = new string[12] {"UK", "I ", "ND", "B ", "F ", "S ", "P ", "G ", "D ", "IT", "GR", "L "};
string country = "U.K. Belgium Denmark France Germany Greece Irish Rep Italy Luxembourg Netherlands Portugal Spain ";
string[] str = new string[3] {"1 million ","10 million","50 million"};
string keys = "Food, beverages, *ntobacco Clothing and footwear Rent, fuel and power Furniture and household *ngoods Medical and health care Transport and *ncommunication Recreation, culture *nand educationMiscellaneous goods *nand services ";
/* Assign hatch & line style data for area fill */
GLIMIT pframe = new GLIMIT(30.0,950.0,50.0,720.0);
GLIMIT frame1 = new GLIMIT(10.0,990.0,50.0,740.0);
GLIMIT frame2 = new GLIMIT(15.0,985.0,55.0,735.0);
int[] il8 = new int[8] {2,3,4,5,7,6,8,9};
int[] fill = new int[12];
int[] line = new int[12];
/* Declare local variables */
GDIM paper;
GPOINT point;
double factor,cw,ch;
int i,ip,ndc,ndt,col;
/* Enter GINO-C & initialise device */
IntPtr hdc = e.Graphics.GetHdc();
Gino.OpenGino();
#if WOGL
Gino.Woglao(0,(int)hdc);
#else
Gino.Mwinao(0,(int)hdc);
#endif
Gino.EnqDrawingLimits(out paper,out ip);
factor = Math.Min(paper.xpap/1000.0,paper.ypap/750.0);
Gino.DefinePictureUnits(factor);
Gino.NewDrawing();
Graf.RestoreAxesSettings();
cw = 7.5;
ch = 7.5;
Gino.SetCharSize(cw,ch);
Gino.EnqColourInfo(out ndc,out ndt);
Gino.EnqLineColour(out col);
/* Draw Area Chart */
Graf.SetAxesPos(AxisPosition.GDATAORIGIN,350.0,420.0,300.0,GraphAxis.GXAXIS);
Graf.SetAxesPos(AxisPosition.GDATAORIGIN,350.0,420.0,300.0,GraphAxis.GYAXIS);
Graf.SetAxesScaling(AxisScaling.GLINEARTYPE1,10,-0.1,4.0,GraphAxis.GXAXIS);
Graf.SetAxesScaling(AxisScaling.GLINEARTYPE1,10,-0.1,3.5,GraphAxis.GYAXIS);
line_style(7,ndc,1,fill,line);
if (ndc > 1) Graf.FillAreaChart(1,sea,GraphAxis.GXAXIS,fill,line);
Graf.AddAreaChartOutline(1,sea,GraphAxis.GXAXIS);
line_style(5,ndc,12,fill,line);
Graf.FillAreaChart(12,land,GraphAxis.GXAXIS,fill,line);
Gino.SetLineColour(Colour.GBLACK);
Graf.AddAreaChartOutline(12,land,GraphAxis.GXAXIS);
for (i=0; i<12; i++) {
Gino.SetLineColour(Colour.GBLACK);
Graf.MoveToGraphPoint(land[i].s+0.05,land[i].h1+0.05);
if(i == 12) {
Graf.MoveToGraphPoint(land[i].s+0.15,land[i].h1-0.05);
Gino.SetLineColour(Colour.GWHITE);
}
Gino.DisplayStr(labels[i]);
}
/* Draw key */
Gino.SetLineColour(col);
Graf.SetAxesPos(AxisPosition.GDATAORIGIN,750.0,420.0,70.0,GraphAxis.GXAXIS);
Graf.SetAxesPos(AxisPosition.GDATAORIGIN,750.0,420.0,70.0,GraphAxis.GYAXIS);
Graf.SetAxesScaling(AxisScaling.GLOG10,5,1.0,50.0,GraphAxis.GXAXIS);
Graf.SetAxesScaling(AxisScaling.GLOG10,5,1.0,50.0,GraphAxis.GYAXIS);
Graf.AddAreaChartOutline(3,key,GraphAxis.GXAXIS);
Gino.SetStrJustify(Justification.GRIGHT);
for (i=0;i<3;i++) {
Graf.MoveToGraphPoint(key[i].s,key[i].h2);
Gino.DisplayStr(str[i]);
}
Gino.SetStrJustify(Justification.GLEFT);
Graf.TransformGraphPoint(key[2].s,key[2].h2,out point);
Gino.MoveTo2D(point.x-75.0,point.y+20.0);
Gino.DisplayStr("Number of people");
/* Draw bar chart */
Graf.SetAxesPos(AxisPosition.GAXISSTART,130.0,110.0,550.0,GraphAxis.GXAXIS);
Graf.SetAxesPos(AxisPosition.GAXISSTART,130.0,110.0,250.0,GraphAxis.GYAXIS);
Graf.SetAxesScaling(AxisScaling.GLINEARTYPE3,10,0.0,100.0,GraphAxis.GXAXIS);
Graf.SetAxesScaling(AxisScaling.GDISCRETE,12,1.0,12.0,GraphAxis.GYAXIS);
line_style(il8[0],ndc,12,fill,line);
Graf.FillBarChart(12,bar1,0.99,fill,line);
line_style(il8[1],ndc,12,fill,line);
Graf.FillBarChart(12,bar2,0.99,fill,line);
line_style(il8[2],ndc,12,fill,line);
Graf.FillBarChart(12,bar3,0.99,fill,line);
line_style(il8[3],ndc,12,fill,line);
Graf.FillBarChart(12,bar4,0.99,fill,line);
line_style(il8[4],ndc,12,fill,line);
Graf.FillBarChart(12,bar5,0.99,fill,line);
line_style(il8[5],ndc,12,fill,line);
Graf.FillBarChart(12,bar6,0.99,fill,line);
line_style(il8[6],ndc,12,fill,line);
Graf.FillBarChart(12,bar7,0.99,fill,line);
line_style(il8[7],ndc,12,fill,line);
Graf.FillBarChart(12,bar8,0.99,fill,line);
Gino.SetLineColour(Colour.GBLACK);
Graf.AddBarChartOutline(12,bar1,0.99);
Graf.AddBarChartOutline(12,bar2,0.99);
Graf.AddBarChartOutline(12,bar3,0.99);
Graf.AddBarChartOutline(12,bar4,0.99);
Graf.AddBarChartOutline(12,bar5,0.99);
Graf.AddBarChartOutline(12,bar6,0.99);
Graf.AddBarChartOutline(12,bar7,0.99);
Graf.AddBarChartOutline(12,bar8,0.99);
Gino.SetLineColour(col);
Graf.SetAxesPos(AxisPosition.GAXISSTART,130.0,99.6,550.0,GraphAxis.GXAXIS);
Graf.DrawAxes(AxisStyle.GCARDINAL,Direction.GCLOCKWISE,ValueDirection.GCLOCKWISE,GraphAxis.GXAXIS);
Graf.DrawAxesTitle("Percent",75.0,GraphAxis.GXAXIS,Alignment.GTOP,Justification.GLEFT);
Graf.DrawAxesLabels(12,country,12,ValueDirection.GANTICLOCKWISE,GraphAxis.GYAXIS);
/* Draw key */
Graf.SetTextChartAttribs(25.0,250.0,Justification.GLEFT,HeaderSwitch.GNOHEAD,-1);
line_style2(il8,ndc,8,fill,line);
Graf.DisplayFillColumn(720.0,350.0,8,fill,line,"*.");
Graf.DisplayStringColumn(750.0,350.0,8,keys,35,"*.");
/* Draw titles */
Graf.SetPlotFrame(pframe);
Gino.SetCharSize(2.0*cw,2.0*ch);
Graf.DrawGraphTitle("*f003EC Population by Country*.",Justification.GLEFT,Alignment.GTOP);
Graf.DrawGraphTitle
("*f003Household Expenditure for EC Countries*.",Justification.GLEFT,Alignment.GMIDDLE);
/* Draw frame */
Gino.SetLineColour(Colour.GCYAN);
Gino.FillRect(FillStyle.GHOLLOW,LineStyle.GCURRENT,frame1);
Gino.FillRect(FillStyle.GHOLLOW,LineStyle.GCURRENT,frame2);
Gino.MoveTo2D(305.0,20.0);
Gino.SetCharSize(15.0,15.0);
Gino.DisplayStr("GINOGRAF Example Program 3");
/* Close down device & leave GINO-C */
e.Graphics.ReleaseHdc(hdc);
Gino.CloseDevice();
Gino.CloseGino();
}
void line_style(int sty,int ndc,int n,int[] fill,int[] line)
{
int i;
for (i=0; i<n; i++) {
if(ndc > 1) {
fill[i]=0;
line[i]=sty;
} else {
fill[i]=sty;
line[i]=1;
}
}
}
void line_style2(int[] sty,int ndc,int n,int[] fill,int[] line)
{
int i;
for (i=0 ;i<n; i++) {
if(ndc > 1) {
fill[i]=0;
line[i]=sty[i];
} else {
fill[i]=sty[i];
line[i]=1;
}
}
}
private void Form1_Resize(object sender, System.EventArgs e)
{
pictureBox1.Refresh();
}
}
}