⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmgraph.cs

📁 车载GPS?今天这个就是最好的工具
💻 CS
📖 第 1 页 / 共 5 页
字号:
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Gigasoft.ProEssentials.Enums;
using System.Data;
using System.Data.SqlClient;

namespace GEROSYS
{
    /// <summary>
    /// Summary description for Form2.
    /// </summary>
    public class frmGraph : System.Windows.Forms.Form
    {
//		protected const string SQL_CONNECTION_STRING  =  @"Data Source=diaodushi;DataBase=gero;user id=sa;password=sasa";
		protected const string SQL_CONNECTION_STRING  = @"Server=(local)\PCMS;DataBase=gero;user id=sa;password=pcms;Integrated Security=SSPI";
		private string strConn= new AccessData().ConnectionString ;
        private System.ComponentModel.IContainer components;
        private Gigasoft.ProEssentials.Pego Pego1;
        protected internal System.Windows.Forms.Timer Timer1;
        Int32 m_nChart;
        Random Rand_Num = new Random(unchecked((int)DateTime.Now.Ticks));
        Int32 m_nRealTimeCounter;
		private System.Windows.Forms.Button cmdExit; 
        Int32 m_nSinCounter;

        public frmGraph()
        {
            //
            // 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();
			this.Pego1 = new Gigasoft.ProEssentials.Pego();
			this.Timer1 = new System.Windows.Forms.Timer(this.components);
			this.cmdExit = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// Pego1
			// 
			this.Pego1.Location = new System.Drawing.Point(8, 16);
			this.Pego1.Name = "Pego1";
			this.Pego1.Size = new System.Drawing.Size(616, 312);
			this.Pego1.TabIndex = 0;
			this.Pego1.Text = "Pego1";
			this.Pego1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Pego1_MouseMove);
			this.Pego1.PeCursorMoved += new Gigasoft.ProEssentials.Pego.CursorMovedEventHandler(this.Pego1_PeCursorMoved);
			this.Pego1.PeDataHotSpot += new Gigasoft.ProEssentials.Pego.DataHotSpotEventHandler(this.Pego1_PeDataHotSpot);
			this.Pego1.PeTableAnnotation += new Gigasoft.ProEssentials.Pego.TableAnnotationEventHandler(this.Pego1_PeTableAnnotation);
			// 
			// Timer1
			// 
			this.Timer1.Tick += new System.EventHandler(this.Timer1_Tick);
			// 
			// cmdExit
			// 
			this.cmdExit.Location = new System.Drawing.Point(544, 344);
			this.cmdExit.Name = "cmdExit";
			this.cmdExit.Size = new System.Drawing.Size(80, 40);
			this.cmdExit.TabIndex = 1;
			this.cmdExit.Text = "退出(&E)";
			this.cmdExit.Click += new System.EventHandler(this.cmdExit_Click);
			// 
			// frmGraph
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(648, 389);
			this.Controls.Add(this.cmdExit);
			this.Controls.Add(this.Pego1);
			this.Name = "frmGraph";
			this.Text = "急抢修图形比较分析";
			this.Resize += new System.EventHandler(this.Form2_Resize);
			this.Load += new System.EventHandler(this.Form2_Load);
			this.ResumeLayout(false);

		}
		#endregion

        private void Form2_Resize(object sender, System.EventArgs e)		
        {
			if(Pego1 == null)
				return;

			Pego1.Left = 0;
			Pego1.Top = 0;
			Pego1.Width = this.ClientSize.Width;
			Pego1.Height = this.ClientSize.Height - cmdExit.Height -10;
			cmdExit.Left =544;
			cmdExit.Top = Pego1.Top + Pego1.Height  +5;		


        }

        private void Form2_Load(object sender, System.EventArgs e)
        {			
			this.Left = 0;
			this.Top = 0 ;
			this.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
			this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height ;
        }

		private void Pego1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if(m_nChart == 7)
			{
				Int32 nA;
				Int32 nX; 
				Int32 nY;
				Double fX = 0;
				Double fY = 0; 				  
				Int32 nLeft;
				Int32 nTop; 
				Int32 nRight; 
				Int32 nBottom; 
				Int32 pX;  
				Int32 pY;
				System.Drawing.Point pt;				
				System.Drawing.Rectangle rect;  

				// get last mouse location within control //'
				pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
				pX = pt.X;
				pY = pt.Y;

				// test to see if this is within grid area //'
				rect = Pego1.PeFunction.GetRectGraph();
				nTop = rect.Top;
				nLeft = rect.Left;
				nRight = rect.Right;
				nBottom = rect.Bottom;

				if( pX > nLeft && pX < nRight && pY > nTop && pY < nBottom)
				{
					nA = 0;      // Initialize axis if using OverlapMultiAxes, else this function will
					// return the axis if MultiAxesSubsets is used without OverlapMultiAxes
					nX = pX;     // Initialize nX and nY with mouse location
					nY = pY;
					Pego1.PeFunction.ConvPixelToGraph(ref nA,ref nX,ref nY,ref fX,ref fY, false, false, false);
					this.Text = fX.ToString() + "   -   " + fY.ToString();
				}
				else	
					this.Text = "Outside Grid";
			}
			else if(m_nChart == 14)
			{				  
				Int32 extra1;  
				Int32 extra2;  
				Int32 pX;  
				Int32 pY;  
				System.Drawing.Point pt;  
				Gigasoft.ProEssentials.Structs.HotSpotData ds;  
				
				// get last mouse location within control //'
				pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
				pX = pt.X;
				pY = pt.Y;

				// Calls to fill hot spot data structure with hot spot data at given x and y
				Pego1.PeFunction.GetHotSpot(pX, pY);

				// Calls PEgethotspot //'
				ds = Pego1.PeFunction.GetHotSpotData();				
				extra1 = ds.Data1;
				extra2 = ds.Data2;

				if(ds.Type == HotSpotType.DataPoint) 
					this.Text = "DataPoint value " + Pego1.PeData.Y[extra1, extra2].ToString();
				else if(ds.Type == HotSpotType.Subset)
					this.Text = "Subset Legend is " + Pego1.PeString.SubsetLabels[extra1];
				else if(ds.Type == HotSpotType.Point) 
					this.Text = "Point Label is " + Pego1.PeString.PointLabels[extra1];
				else
					this.Text = "No Hot Spot";
            
			}
			else if(m_nChart == 28)
			{
				// get last mouse location within control //
				Int32 pX, pY, nA, nX, nY;
				Double fX=0, fY=0;
				System.Drawing.Point pt;				 

				// get last mouse location within control //'
				pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
				pX = pt.X;
				pY = pt.Y;

				nA = 0;      // Initialize axis, non-zero only if using MultiAxesSubsets
				nX = pX;      // Initialize nX and nY with mouse location
				nY = pY;
				Pego1.PeFunction.ConvPixelToGraph(ref nA,ref nX,ref nY,ref fX,ref fY, false, false, false);

				// We now know data coordinates for mouse location //

				// Use fX to interpolate each subset to find approximate Y value //
				float Subset1Y, Subset2Y, Subset3Y, Subset4Y, slope;
				float y0, y1, y2, x1, x2;

				nX = Convert.ToInt32(fX) - 1;   // nX is floor of fX
				x2 = nX + 1;   // x2 is right most point index
				x1 = nX;       // x1 is left most point index or nX

				if(fX < 1 || fX > 12) 
				{
					Pego1.PeAnnotation.Table.Working = 0;
					Pego1.PeAnnotation.Table.Text[0, 2] = "        ";
					Pego1.PeAnnotation.Table.Text[0, 5] = "        ";
					Pego1.PeAnnotation.Table.Working = 1;
					Pego1.PeAnnotation.Table.Text[0, 2] = "        ";
					Pego1.PeAnnotation.Table.Text[0, 5] = "        ";
					Pego1.PeFunction.DrawTable(0);
					Pego1.PeFunction.DrawTable(1);
					return;
				}

				fX = fX - 1.0;

				// 1st subset //
				y2 = Pego1.PeData.Y[0, nX + 1];
				y1 = Pego1.PeData.Y[0, nX];
				slope = (y2 - y1) / (x2 - x1);
				y0 = y1 - (slope * x1);
				Subset1Y = (float)((slope * fX) + y0);

				// 2nd subset //
				y2 = Pego1.PeData.Y[1, nX + 1];
				y1 = Pego1.PeData.Y[1, nX];
				slope = (y2 - y1) / (x2 - x1);
				y0 = y1 - (slope * x1);
				Subset2Y = (float)((slope * fX) + y0);

				// 3rd subset //
				y2 = Pego1.PeData.Y[2, nX + 1];
				y1 = Pego1.PeData.Y[2, nX];
				slope = (y2 - y1) / (x2 - x1);
				y0 = y1 - (slope * x1);
				Subset3Y = (float)((slope * fX) + y0);

				// 4th subset //
				y2 = Pego1.PeData.Y[3, nX + 1];
				y1 = Pego1.PeData.Y[3, nX];
				slope = (y2 - y1) / (x2 - x1);
				y0 = y1 - (slope * x1);
				Subset4Y = (float)((slope * fX) + y0);

				// Place text in table annotation //
				Pego1.PeAnnotation.Table.Working = 0;
				Pego1.PeAnnotation.Table.Text[0, 2] = String.Format("{0:##0.00}",Subset1Y);
				Pego1.PeAnnotation.Table.Text[0, 5] = String.Format("{0:##0.00}",Subset2Y);

				Pego1.PeAnnotation.Table.Working = 1;
				Pego1.PeAnnotation.Table.Text[0, 2] = String.Format("{0:##0.00}",Subset3Y);
				Pego1.PeAnnotation.Table.Text[0, 5] = String.Format("{0:##0.00}",Subset4Y);

				Pego1.PeFunction.DrawTable(0);
				Pego1.PeFunction.DrawTable(1);			
			}
			else if(m_nChart == 30)
			{
				double fX, fY;
				float fHigh, fLow, fOpen, fClose, fVolume;
				Int32 t, nA, nX, nY, pX, pY;
				String szDate, szFmt;
				System.Drawing.Point pt;
				fX = 0.0F;
				fY = 0.0F;

				pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
				pX = pt.X;
				pY = pt.Y;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -