events in WFA01
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@ -38,6 +38,9 @@
 | 
			
		||||
            this.button3 = new System.Windows.Forms.Button();
 | 
			
		||||
            this.label2 = new System.Windows.Forms.Label();
 | 
			
		||||
            this.label3 = new System.Windows.Forms.Label();
 | 
			
		||||
            this.button4 = new System.Windows.Forms.Button();
 | 
			
		||||
            this.label4 = new System.Windows.Forms.Label();
 | 
			
		||||
            this.label5 = new System.Windows.Forms.Label();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
 | 
			
		||||
@ -142,6 +145,34 @@
 | 
			
		||||
            this.label3.TabIndex = 9;
 | 
			
		||||
            this.label3.Text = "label3";
 | 
			
		||||
            // 
 | 
			
		||||
            // button4
 | 
			
		||||
            // 
 | 
			
		||||
            this.button4.Location = new System.Drawing.Point(356, 57);
 | 
			
		||||
            this.button4.Name = "button4";
 | 
			
		||||
            this.button4.Size = new System.Drawing.Size(75, 23);
 | 
			
		||||
            this.button4.TabIndex = 10;
 | 
			
		||||
            this.button4.Text = "button4";
 | 
			
		||||
            this.button4.UseVisualStyleBackColor = true;
 | 
			
		||||
            this.button4.Click += new System.EventHandler(this.Button4_Click);
 | 
			
		||||
            // 
 | 
			
		||||
            // label4
 | 
			
		||||
            // 
 | 
			
		||||
            this.label4.AutoSize = true;
 | 
			
		||||
            this.label4.Location = new System.Drawing.Point(592, 66);
 | 
			
		||||
            this.label4.Name = "label4";
 | 
			
		||||
            this.label4.Size = new System.Drawing.Size(35, 13);
 | 
			
		||||
            this.label4.TabIndex = 11;
 | 
			
		||||
            this.label4.Text = "label4";
 | 
			
		||||
            // 
 | 
			
		||||
            // label5
 | 
			
		||||
            // 
 | 
			
		||||
            this.label5.AutoSize = true;
 | 
			
		||||
            this.label5.Location = new System.Drawing.Point(700, 88);
 | 
			
		||||
            this.label5.Name = "label5";
 | 
			
		||||
            this.label5.Size = new System.Drawing.Size(35, 13);
 | 
			
		||||
            this.label5.TabIndex = 12;
 | 
			
		||||
            this.label5.Text = "label5";
 | 
			
		||||
            // 
 | 
			
		||||
            // Form1
 | 
			
		||||
            // 
 | 
			
		||||
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
 | 
			
		||||
@ -149,6 +180,9 @@
 | 
			
		||||
            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
 | 
			
		||||
            this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
 | 
			
		||||
            this.ClientSize = new System.Drawing.Size(800, 450);
 | 
			
		||||
            this.Controls.Add(this.label5);
 | 
			
		||||
            this.Controls.Add(this.label4);
 | 
			
		||||
            this.Controls.Add(this.button4);
 | 
			
		||||
            this.Controls.Add(this.label3);
 | 
			
		||||
            this.Controls.Add(this.label2);
 | 
			
		||||
            this.Controls.Add(this.button3);
 | 
			
		||||
@ -184,6 +218,9 @@
 | 
			
		||||
        private System.Windows.Forms.Button button3;
 | 
			
		||||
        private System.Windows.Forms.Label label2;
 | 
			
		||||
        private System.Windows.Forms.Label label3;
 | 
			
		||||
        private System.Windows.Forms.Button button4;
 | 
			
		||||
        private System.Windows.Forms.Label label4;
 | 
			
		||||
        private System.Windows.Forms.Label label5;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -52,6 +52,8 @@ namespace WindowsFormsApp01
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            label1.Text = " ";
 | 
			
		||||
 | 
			
		||||
            calc.CalcFinished += CalcFinished;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Button1_Click(object sender, EventArgs e)
 | 
			
		||||
@ -72,18 +74,6 @@ namespace WindowsFormsApp01
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
        private void Panel1_Paint(object sender, PaintEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            Graphics graphics = e.Graphics;
 | 
			
		||||
@ -92,29 +82,27 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
            using (var p = _pen)
 | 
			
		||||
            {
 | 
			
		||||
                //y axis
 | 
			
		||||
                graphics.DrawLine(p, 10, 10, 10, 246);
 | 
			
		||||
 | 
			
		||||
            //y axis
 | 
			
		||||
            graphics.DrawLine(p, 10, 10, 10, 246);
 | 
			
		||||
                //x axis
 | 
			
		||||
                graphics.DrawLine(p, 10, 246, 502, 246);
 | 
			
		||||
 | 
			
		||||
            //x axis
 | 
			
		||||
            graphics.DrawLine(p, 10, 246, 502, 246);
 | 
			
		||||
                //arrow y axis
 | 
			
		||||
                graphics.DrawLine(p, 5, 15, 10, 10);
 | 
			
		||||
                graphics.DrawLine(p, 15, 15, 10, 10);
 | 
			
		||||
 | 
			
		||||
            //arrow y axis
 | 
			
		||||
            graphics.DrawLine(p, 5, 15, 10, 10);
 | 
			
		||||
            graphics.DrawLine(p, 15, 15, 10, 10);
 | 
			
		||||
 | 
			
		||||
            //arrow x axis
 | 
			
		||||
            graphics.DrawLine(p, 498, 241, 502, 246);
 | 
			
		||||
            graphics.DrawLine(p, 498, 251, 502, 246);
 | 
			
		||||
                //arrow x axis
 | 
			
		||||
                graphics.DrawLine(p, 498, 241, 502, 246);
 | 
			
		||||
                graphics.DrawLine(p, 498, 251, 502, 246);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Brush aBrush = (Brush) Brushes.Red;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            for (int i = 10; i < (502 ); i++)
 | 
			
		||||
            for (int i = 10; i < (502); i++)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                int y = (int)( 246 - (((Math.Log(i) * 10) - 23) *_scale  ) );
 | 
			
		||||
                int y = (int) (246 - (((Math.Log(i) * 10) - 23) * _scale));
 | 
			
		||||
 | 
			
		||||
                graphics.FillRectangle(aBrush, i, y, 2, 2);
 | 
			
		||||
            }
 | 
			
		||||
@ -129,7 +117,6 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
        private void TrackBar1_Scroll(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            _scale = (int) trackBar1.Value;
 | 
			
		||||
 | 
			
		||||
            panel1.Refresh();
 | 
			
		||||
@ -137,14 +124,10 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
        private void Panel1_AutoSizeChanged(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Form1_Resize(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            _x = panel1.Width;
 | 
			
		||||
            _y = panel1.Height;
 | 
			
		||||
            panel1.Invalidate();
 | 
			
		||||
@ -158,24 +141,22 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
            string s3 = String.Empty;
 | 
			
		||||
 | 
			
		||||
           Stopwatch sw = new Stopwatch();
 | 
			
		||||
            Stopwatch sw = new Stopwatch();
 | 
			
		||||
 | 
			
		||||
           sw.Start();
 | 
			
		||||
            sw.Start();
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < 50000; i++)
 | 
			
		||||
            {
 | 
			
		||||
                 s3 = s3 + s1 + s2;
 | 
			
		||||
                s3 = s3 + s1 + s2;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            sw.Stop();
 | 
			
		||||
 | 
			
		||||
            label3.Text = sw.ElapsedMilliseconds.ToString();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Button3_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            string s1 = "hello";
 | 
			
		||||
 | 
			
		||||
            string s2 = "Offenburg";
 | 
			
		||||
@ -199,5 +180,48 @@ namespace WindowsFormsApp01
 | 
			
		||||
 | 
			
		||||
            label2.Text = sw.ElapsedMilliseconds.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Button4_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            calc.CalcIt();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CalcFinished(CalcEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            label4.Text = e.Result.ToString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class CalcEventArgs
 | 
			
		||||
    {
 | 
			
		||||
        public CalcEventArgs(int result)
 | 
			
		||||
        {
 | 
			
		||||
            Result = result;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int Result { get; private set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static class calc
 | 
			
		||||
    {
 | 
			
		||||
        public delegate void CalcEventHandler(CalcEventArgs e);
 | 
			
		||||
 | 
			
		||||
        public static event CalcEventHandler CalcFinished;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static void CalcIt()
 | 
			
		||||
        {
 | 
			
		||||
            int res = DateTime.Now.Second;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var e = new CalcEventArgs(res);
 | 
			
		||||
            //trigger handler
 | 
			
		||||
 | 
			
		||||
            if (CalcFinished != null)
 | 
			
		||||
            {
 | 
			
		||||
                CalcFinished(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user