using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Diagnostics;

namespace ElapsedTime
{
    public partial class frm100ElapsedTime : Form
    {
        public frm100ElapsedTime()
        {
            InitializeComponent();
        }

        private DateTime StartTime, StopTime;
        Stopwatch Watch;
        Stopwatch TotalWatch = new Stopwatch();

        private void frm100ElapsedTime_Load(object sender, EventArgs e)
        {
            frequencyTextBox.Text = Stopwatch.Frequency.ToString();
            nsPerTickTextBox.Text = (1000000000 / Stopwatch.Frequency).ToString();
            isHighResTextBox.Text = Stopwatch.IsHighResolution.ToString();
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            startButton.Enabled = false;
            stopButton.Enabled = true;
            elapsed1TextBox.Clear();
            elapsed2TextBox.Clear();
            tlapsed3TextBox.Clear();

            Watch.Restart();
            TotalWatch.Start();
            StartTime = DateTime.Now;
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            StopTime = DateTime.Now;
            Watch.Stop();
            TotalWatch.Stop();

            TimeSpan elapsed = StopTime.Subtract(StartTime);
            elapsed1TextBox.Text = elapsed.TotalSeconds.ToString("0.000000");

            elapsed2TextBox.Text = Watch.Elapsed.TotalSeconds.ToString("0.000000");

            tlapsed3TextBox.Text = TotalWatch.Elapsed.TotalSeconds.ToString("0.000000");

            startButton.Enabled = true;
            stopButton.Enabled = false;
        }


        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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.label6 = new System.Windows.Forms.Label();
            this.nsPerTickTextBox = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.isHighResTextBox = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.frequencyTextBox = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.tlapsed3TextBox = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.elapsed2TextBox = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.elapsed1TextBox = new System.Windows.Forms.TextBox();
            this.stopButton = new System.Windows.Forms.Button();
            this.startButton = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(12, 176);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(47, 13);
            this.label6.TabIndex = 30;
            this.label6.Text = "ns/Tick:";
            // 
            // nsPerTickTextBox
            // 
            this.nsPerTickTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.nsPerTickTextBox.Location = new System.Drawing.Point(83, 173);
            this.nsPerTickTextBox.Name = "nsPerTickTextBox";
            this.nsPerTickTextBox.ReadOnly = true;
            this.nsPerTickTextBox.Size = new System.Drawing.Size(149, 20);
            this.nsPerTickTextBox.TabIndex = 6;
            this.nsPerTickTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(12, 202);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(65, 13);
            this.label4.TabIndex = 28;
            this.label4.Text = "Is High Res:";
            // 
            // isHighResTextBox
            // 
            this.isHighResTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.isHighResTextBox.Location = new System.Drawing.Point(83, 199);
            this.isHighResTextBox.Name = "isHighResTextBox";
            this.isHighResTextBox.ReadOnly = true;
            this.isHighResTextBox.Size = new System.Drawing.Size(149, 20);
            this.isHighResTextBox.TabIndex = 7;
            this.isHighResTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(12, 150);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(60, 13);
            this.label5.TabIndex = 26;
            this.label5.Text = "Ticks/Sec:";
            // 
            // frequencyTextBox
            // 
            this.frequencyTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.frequencyTextBox.Location = new System.Drawing.Point(83, 147);
            this.frequencyTextBox.Name = "frequencyTextBox";
            this.frequencyTextBox.ReadOnly = true;
            this.frequencyTextBox.Size = new System.Drawing.Size(149, 20);
            this.frequencyTextBox.TabIndex = 5;
            this.frequencyTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(12, 106);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(34, 13);
            this.label3.TabIndex = 24;
            this.label3.Text = "Total:";
            // 
            // tlapsed3TextBox
            // 
            this.tlapsed3TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tlapsed3TextBox.Location = new System.Drawing.Point(83, 103);
            this.tlapsed3TextBox.Name = "tlapsed3TextBox";
            this.tlapsed3TextBox.ReadOnly = true;
            this.tlapsed3TextBox.Size = new System.Drawing.Size(149, 20);
            this.tlapsed3TextBox.TabIndex = 4;
            this.tlapsed3TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(12, 80);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(61, 13);
            this.label2.TabIndex = 22;
            this.label2.Text = "Stopwatch:";
            // 
            // elapsed2TextBox
            // 
            this.elapsed2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.elapsed2TextBox.Location = new System.Drawing.Point(83, 77);
            this.elapsed2TextBox.Name = "elapsed2TextBox";
            this.elapsed2TextBox.ReadOnly = true;
            this.elapsed2TextBox.Size = new System.Drawing.Size(149, 20);
            this.elapsed2TextBox.TabIndex = 3;
            this.elapsed2TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 54);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(56, 13);
            this.label1.TabIndex = 20;
            this.label1.Text = "DateTime:";
            // 
            // elapsed1TextBox
            // 
            this.elapsed1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.elapsed1TextBox.Location = new System.Drawing.Point(83, 51);
            this.elapsed1TextBox.Name = "elapsed1TextBox";
            this.elapsed1TextBox.ReadOnly = true;
            this.elapsed1TextBox.Size = new System.Drawing.Size(149, 20);
            this.elapsed1TextBox.TabIndex = 2;
            this.elapsed1TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // stopButton
            // 
            this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.stopButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.stopButton.Enabled = false;
            this.stopButton.Location = new System.Drawing.Point(157, 12);
            this.stopButton.Name = "stopButton";
            this.stopButton.Size = new System.Drawing.Size(75, 23);
            this.stopButton.TabIndex = 1;
            this.stopButton.Text = "Stop";
            this.stopButton.UseVisualStyleBackColor = true;
            this.stopButton.Click += new System.EventHandler(this.btnStop_Click);
            // 
            // startButton
            // 
            this.startButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.startButton.Location = new System.Drawing.Point(12, 12);
            this.startButton.Name = "startButton";
            this.startButton.Size = new System.Drawing.Size(75, 23);
            this.startButton.TabIndex = 0;
            this.startButton.Text = "Start";
            this.startButton.UseVisualStyleBackColor = true;
            this.startButton.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // frm100ElapsedTime
            // 
            this.AcceptButton = this.startButton;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.CancelButton = this.stopButton;
            this.ClientSize = new System.Drawing.Size(244, 236);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.nsPerTickTextBox);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.isHighResTextBox);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.frequencyTextBox);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.tlapsed3TextBox);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.elapsed2TextBox);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.elapsed1TextBox);
            this.Controls.Add(this.stopButton);
            this.Controls.Add(this.startButton);
            this.Name = "frm100ElapsedTime";
            this.Text = "ElapsedTime";
            this.Load += new System.EventHandler(this.frm100ElapsedTime_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox nsPerTickTextBox;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox isHighResTextBox;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox frequencyTextBox;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox tlapsed3TextBox;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox elapsed2TextBox;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox elapsed1TextBox;
        private System.Windows.Forms.Button stopButton;
        private System.Windows.Forms.Button startButton;
    }
}