using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
//--------- Moje Variable --------------
public int pointIndex = 0;
int enableChart = 0;
int PocetBoduGrafu = 10;
Random random = new Random();
//--------------------------------------
private System.Windows.Forms.Label label1;
private Dundas.Charting.WinControl.Chart chart1;
private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
private System.Timers.Timer timer1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.HScrollBar hScrollBar1;
private System.Windows.Forms.HScrollBar hScrollBar2;
private System.Windows.Forms.HScrollBar hScrollBar3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private Sax.Communications.SerialConnection serialConnection1;
private System.ComponentModel.IContainer components;
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.components = new System.ComponentModel.Container();
Dundas.Charting.WinControl.ChartArea chartArea1 = new Dundas.Charting.WinControl.ChartArea();
Dundas.Charting.WinControl.Series series1 = new Dundas.Charting.WinControl.Series();
Dundas.Charting.WinControl.Series series2 = new Dundas.Charting.WinControl.Series();
this.label1 = new System.Windows.Forms.Label();
this.chart1 = new Dundas.Charting.WinControl.Chart();
this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
this.timer1 = new System.Timers.Timer();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
this.hScrollBar2 = new System.Windows.Forms.HScrollBar();
this.hScrollBar3 = new System.Windows.Forms.HScrollBar();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.serialConnection1 = new Sax.Communications.SerialConnection(this.components);
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label1.Size = new System.Drawing.Size(104, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Value1";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// chart1
//
this.chart1.BorderSkin.PageColor = System.Drawing.SystemColors.Control;
this.chart1.BorderSkin.SkinStyle = Dundas.Charting.WinControl.BorderSkinStyle.Emboss;
chartArea1.Area3DStyle.Enable3D = true;
chartArea1.Area3DStyle.Light = Dundas.Charting.WinControl.LightStyle.Realistic;
chartArea1.AxisX.LabelStyle.Format = "G1";
chartArea1.AxisX.LabelStyle.Interval = 0;
chartArea1.AxisX.LabelStyle.IntervalOffset = 0;
chartArea1.AxisX.LabelStyle.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.LabelStyle.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MajorGrid.Interval = 0;
chartArea1.AxisX.MajorGrid.IntervalOffset = 0;
chartArea1.AxisX.MajorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MajorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MajorTickMark.Interval = 0;
chartArea1.AxisX.MajorTickMark.IntervalOffset = 0;
chartArea1.AxisX.MajorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MajorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MajorTickMark.Style = Dundas.Charting.WinControl.TickMarkStyle.Cross;
chartArea1.AxisX.MinorGrid.Interval = 0;
chartArea1.AxisX.MinorGrid.IntervalOffset = 0;
chartArea1.AxisX.MinorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MinorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MinorTickMark.Interval = 0;
chartArea1.AxisX.MinorTickMark.IntervalOffset = 0;
chartArea1.AxisX.MinorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.MinorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX.Title = "Testovac?raf";
chartArea1.AxisX2.LabelStyle.Interval = 0;
chartArea1.AxisX2.LabelStyle.IntervalOffset = 0;
chartArea1.AxisX2.LabelStyle.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.LabelStyle.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MajorGrid.Interval = 0;
chartArea1.AxisX2.MajorGrid.IntervalOffset = 0;
chartArea1.AxisX2.MajorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MajorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MajorTickMark.Interval = 0;
chartArea1.AxisX2.MajorTickMark.IntervalOffset = 0;
chartArea1.AxisX2.MajorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MajorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MinorGrid.Interval = 0;
chartArea1.AxisX2.MinorGrid.IntervalOffset = 0;
chartArea1.AxisX2.MinorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MinorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MinorTickMark.Interval = 0;
chartArea1.AxisX2.MinorTickMark.IntervalOffset = 0;
chartArea1.AxisX2.MinorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisX2.MinorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.LabelStyle.Interval = 0;
chartArea1.AxisY.LabelStyle.IntervalOffset = 0;
chartArea1.AxisY.LabelStyle.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.LabelStyle.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MajorGrid.Interval = 0;
chartArea1.AxisY.MajorGrid.IntervalOffset = 0;
chartArea1.AxisY.MajorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MajorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MajorTickMark.Interval = 0;
chartArea1.AxisY.MajorTickMark.IntervalOffset = 0;
chartArea1.AxisY.MajorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MajorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MinorGrid.Interval = 0;
chartArea1.AxisY.MinorGrid.IntervalOffset = 0;
chartArea1.AxisY.MinorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MinorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MinorTickMark.Interval = 0;
chartArea1.AxisY.MinorTickMark.IntervalOffset = 0;
chartArea1.AxisY.MinorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY.MinorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.LabelStyle.Interval = 0;
chartArea1.AxisY2.LabelStyle.IntervalOffset = 0;
chartArea1.AxisY2.LabelStyle.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.LabelStyle.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MajorGrid.Interval = 0;
chartArea1.AxisY2.MajorGrid.IntervalOffset = 0;
chartArea1.AxisY2.MajorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MajorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MajorTickMark.Interval = 0;
chartArea1.AxisY2.MajorTickMark.IntervalOffset = 0;
chartArea1.AxisY2.MajorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MajorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MinorGrid.Interval = 0;
chartArea1.AxisY2.MinorGrid.IntervalOffset = 0;
chartArea1.AxisY2.MinorGrid.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MinorGrid.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MinorTickMark.Interval = 0;
chartArea1.AxisY2.MinorTickMark.IntervalOffset = 0;
chartArea1.AxisY2.MinorTickMark.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.AxisY2.MinorTickMark.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Auto;
chartArea1.BorderColor = System.Drawing.Color.Empty;
chartArea1.Name = "Default";
this.chart1.ChartAreas.Add(chartArea1);
this.chart1.ChartData = "";
this.chart1.Location = new System.Drawing.Point(136, 8);
this.chart1.Name = "chart1";
this.chart1.Palette = Dundas.Charting.WinControl.ChartColorPalette.Pastel;
series1.BorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
series1.BorderWidth = 2;
series1.ChartType = "Spline";
series1.CustomAttributes = "LabelStyle=Top";
series1.FontAngle = 1;
series1.MarkerBorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
series1.MarkerStyle = Dundas.Charting.WinControl.MarkerStyle.Circle;
series1.Name = "Series1";
series1.ShadowOffset = 1;
series1.ShowLabelAsValue = true;
series2.BorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
series2.BorderWidth = 2;
series2.ChartType = "Spline";
series2.CustomAttributes = "LabelStyle=Top";
series2.FontAngle = 1;
series2.MarkerBorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
series2.MarkerStyle = Dundas.Charting.WinControl.MarkerStyle.Triangle;
series2.Name = "Series2";
series2.ShadowOffset = 1;
series2.ShowLabelAsValue = true;
this.chart1.Series.Add(series1);
this.chart1.Series.Add(series2);
this.chart1.Size = new System.Drawing.Size(440, 248);
this.chart1.TabIndex = 1;
this.chart1.Title = "Pavel Pindora Moje zkou?ka Dundas Grafu";
this.chart1.Click += new System.EventHandler(this.chart1_Click);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 250;
this.timer1.SynchronizingObject = this;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(16, 48);
this.label2.Name = "label2";
this.label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label2.Size = new System.Drawing.Size(104, 16);
this.label2.TabIndex = 0;
this.label2.Text = "Value1";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label3.Location = new System.Drawing.Point(16, 96);
this.label3.Name = "label3";
this.label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label3.Size = new System.Drawing.Size(104, 16);
this.label3.TabIndex = 0;
this.label3.Text = "Value2";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label4.Location = new System.Drawing.Point(16, 112);
this.label4.Name = "label4";
this.label4.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label4.Size = new System.Drawing.Size(104, 16);
this.label4.TabIndex = 0;
this.label4.Text = "Value1";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label5
//
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Location = new System.Drawing.Point(16, 160);
this.label5.Name = "label5";
this.label5.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label5.Size = new System.Drawing.Size(104, 16);
this.label5.TabIndex = 0;
this.label5.Text = "Celkem";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label6
//
this.label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label6.Location = new System.Drawing.Point(16, 176);
this.label6.Name = "label6";
this.label6.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label6.Size = new System.Drawing.Size(104, 16);
this.label6.TabIndex = 0;
this.label6.Text = "Value1";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.ControlDark;
this.button1.Location = new System.Drawing.Point(16, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 20);
this.button1.TabIndex = 2;
this.button1.Text = "Chart starting";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// hScrollBar1
//
this.hScrollBar1.Location = new System.Drawing.Point(28, 284);
this.hScrollBar1.Maximum = 90;
this.hScrollBar1.Minimum = -90;
this.hScrollBar1.Name = "hScrollBar1";
this.hScrollBar1.Size = new System.Drawing.Size(172, 16);
this.hScrollBar1.TabIndex = 3;
this.hScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.hScrollBar1_Scroll);
//
// hScrollBar2
//
this.hScrollBar2.Location = new System.Drawing.Point(208, 284);
this.hScrollBar2.Maximum = 90;
this.hScrollBar2.Minimum = -90;
this.hScrollBar2.Name = "hScrollBar2";
this.hScrollBar2.Size = new System.Drawing.Size(172, 16);
this.hScrollBar2.TabIndex = 3;
this.hScrollBar2.Scroll += new System.Windows.Forms.ScrollEventHandler(this.hScrollBar2_Scroll);
//
// hScrollBar3
//
this.hScrollBar3.Location = new System.Drawing.Point(388, 284);
this.hScrollBar3.Maximum = 90;
this.hScrollBar3.Minimum = -90;
this.hScrollBar3.Name = "hScrollBar3";
this.hScrollBar3.Size = new System.Drawing.Size(172, 16);
this.hScrollBar3.TabIndex = 3;
this.hScrollBar3.Scroll += new System.Windows.Forms.ScrollEventHandler(this.hScrollBar3_Scroll);
//
// label7
//
this.label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label7.Location = new System.Drawing.Point(28, 264);
this.label7.Name = "label7";
this.label7.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label7.Size = new System.Drawing.Size(72, 16);
this.label7.TabIndex = 0;
this.label7.Text = "X Rotation";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label8
//
this.label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label8.Location = new System.Drawing.Point(208, 264);
this.label8.Name = "label8";
this.label8.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label8.Size = new System.Drawing.Size(72, 16);
this.label8.TabIndex = 0;
this.label8.Text = "Y Rotation";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// serialConnection1
//
this.serialConnection1.Options = new Sax.Communications.SerialOptions("COM1", 115200, Sax.Communications.Parity.None, 8, Sax.Communications.CommStopBits.One, false, false, true, false, true, true);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(592, 318);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.hScrollBar1,
this.button1,
this.chart1,
this.label1,
this.label2,
this.label3,
this.label4,
this.label5,
this.label6,
this.hScrollBar2,
this.hScrollBar3,
this.label7,
this.label8});
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void chart1_Click(object sender, System.EventArgs e)
{
}
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if( enableChart>0 )
{
int datoToChart1 = random.Next(0, 100);
int datoToChart2 = random.Next(0, 100);
chart1.Series[0].Points.AddXY(pointIndex + 1,datoToChart1 );
chart1.Series[1].Points.AddXY(pointIndex + 1,datoToChart2 );
++pointIndex;
if(chart1.Series[0].Points.Count > PocetBoduGrafu)
{
if( chart1.Series[0].Points.Count > PocetBoduGrafu )
chart1.Series[0].Points.RemoveAt(0);
chart1.ChartAreas["Default"].AxisX.Minimum = pointIndex - PocetBoduGrafu;
chart1.ChartAreas["Default"].AxisX.Maximum = chart1.ChartAreas["Default"].AxisX.Minimum + PocetBoduGrafu;
}
label2.Text = datoToChart1.ToString();
label4.Text = datoToChart2.ToString();
label6.Text = pointIndex .ToString();
chart1.Invalidate();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
if( enableChart==0 )
{
enableChart = 1;
button1.Text = "Chart starting";
button1.BackColor = Color.LightGreen;
}
else
{
enableChart = 0;
button1.Text = "Press to start";
button1.BackColor = Color.LightGray;
}
}
private void hScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
chart1.ChartAreas["Default"].Area3DStyle.XAngle = hScrollBar1.Value;
}
private void hScrollBar2_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
chart1.ChartAreas["Default"].Area3DStyle.YAngle = hScrollBar2.Value;
}
private void hScrollBar3_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
//chart1.ChartAreas["Default"].Area3DStyle.ZAngle = hScrollBar3.Value;
}
}
}