diff --git a/src/MouseGraphView/MouseGraphView.csproj b/src/MouseGraphView/MouseGraphView.csproj index c908256..7c43b56 100644 --- a/src/MouseGraphView/MouseGraphView.csproj +++ b/src/MouseGraphView/MouseGraphView.csproj @@ -38,6 +38,7 @@ + diff --git a/src/MouseGraphView/frmGraph.Designer.cs b/src/MouseGraphView/frmGraph.Designer.cs index 3eec770..d94e39e 100644 --- a/src/MouseGraphView/frmGraph.Designer.cs +++ b/src/MouseGraphView/frmGraph.Designer.cs @@ -28,21 +28,129 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + this.chrtMousePos = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.btnPlay = new System.Windows.Forms.Button(); + this.tbPlot = new System.Windows.Forms.TrackBar(); + this.btnShowBoth = new System.Windows.Forms.Button(); + this.btnShowRecent = new System.Windows.Forms.Button(); + this.btnShowAllButRecent = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.chrtMousePos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbPlot)).BeginInit(); this.SuspendLayout(); // + // chrtMousePos + // + this.chrtMousePos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + chartArea1.AxisX.Minimum = 0D; + chartArea1.AxisX.Title = "X Position"; + chartArea1.AxisY.Minimum = 0D; + chartArea1.AxisY.Title = "Y Position"; + chartArea1.Name = "ChartArea1"; + this.chrtMousePos.ChartAreas.Add(chartArea1); + legend1.Alignment = System.Drawing.StringAlignment.Center; + legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom; + legend1.Name = "Main Legend"; + this.chrtMousePos.Legends.Add(legend1); + this.chrtMousePos.Location = new System.Drawing.Point(12, 12); + this.chrtMousePos.Name = "chrtMousePos"; + series1.ChartArea = "ChartArea1"; + series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series1.Legend = "Main Legend"; + series1.Name = "Position"; + series2.ChartArea = "ChartArea1"; + series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series2.Legend = "Main Legend"; + series2.Name = "Last 5 seconds"; + this.chrtMousePos.Series.Add(series1); + this.chrtMousePos.Series.Add(series2); + this.chrtMousePos.Size = new System.Drawing.Size(595, 427); + this.chrtMousePos.TabIndex = 0; + this.chrtMousePos.Text = "chart1"; + // + // btnPlay + // + this.btnPlay.Location = new System.Drawing.Point(12, 496); + this.btnPlay.Name = "btnPlay"; + this.btnPlay.Size = new System.Drawing.Size(75, 23); + this.btnPlay.TabIndex = 1; + this.btnPlay.Text = "Play"; + this.btnPlay.UseVisualStyleBackColor = true; + // + // tbPlot + // + this.tbPlot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbPlot.Location = new System.Drawing.Point(12, 445); + this.tbPlot.Name = "tbPlot"; + this.tbPlot.Size = new System.Drawing.Size(595, 45); + this.tbPlot.TabIndex = 2; + // + // btnShowBoth + // + this.btnShowBoth.Location = new System.Drawing.Point(276, 496); + this.btnShowBoth.Name = "btnShowBoth"; + this.btnShowBoth.Size = new System.Drawing.Size(75, 23); + this.btnShowBoth.TabIndex = 3; + this.btnShowBoth.Text = "Show Both"; + this.btnShowBoth.UseVisualStyleBackColor = true; + this.btnShowBoth.Click += new System.EventHandler(this.btnShowBoth_Click); + // + // btnShowRecent + // + this.btnShowRecent.Location = new System.Drawing.Point(357, 496); + this.btnShowRecent.Name = "btnShowRecent"; + this.btnShowRecent.Size = new System.Drawing.Size(100, 23); + this.btnShowRecent.TabIndex = 4; + this.btnShowRecent.Text = "Show Recent"; + this.btnShowRecent.UseVisualStyleBackColor = true; + this.btnShowRecent.Click += new System.EventHandler(this.btnShowRecent_Click); + // + // btnShowAllButRecent + // + this.btnShowAllButRecent.Location = new System.Drawing.Point(463, 496); + this.btnShowAllButRecent.Name = "btnShowAllButRecent"; + this.btnShowAllButRecent.Size = new System.Drawing.Size(144, 23); + this.btnShowAllButRecent.TabIndex = 5; + this.btnShowAllButRecent.Text = "Show All Except Recent"; + this.btnShowAllButRecent.UseVisualStyleBackColor = true; + this.btnShowAllButRecent.Click += new System.EventHandler(this.btnShowAllButRecent_Click); + // // frmGraph // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(619, 531); + this.Controls.Add(this.btnShowAllButRecent); + this.Controls.Add(this.btnShowRecent); + this.Controls.Add(this.btnShowBoth); + this.Controls.Add(this.tbPlot); + this.Controls.Add(this.btnPlay); + this.Controls.Add(this.chrtMousePos); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.Name = "frmGraph"; this.Text = "Graph Data"; + this.Load += new System.EventHandler(this.frmGraph_Load); + ((System.ComponentModel.ISupportInitialize)(this.chrtMousePos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbPlot)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion + + private System.Windows.Forms.DataVisualization.Charting.Chart chrtMousePos; + private System.Windows.Forms.Button btnPlay; + private System.Windows.Forms.TrackBar tbPlot; + private System.Windows.Forms.Button btnShowBoth; + private System.Windows.Forms.Button btnShowRecent; + private System.Windows.Forms.Button btnShowAllButRecent; } } \ No newline at end of file diff --git a/src/MouseGraphView/frmGraph.cs b/src/MouseGraphView/frmGraph.cs index dd68080..cd98418 100644 --- a/src/MouseGraphView/frmGraph.cs +++ b/src/MouseGraphView/frmGraph.cs @@ -7,13 +7,65 @@ using System.Text; using System.Windows.Forms; +using MouseMon; + namespace MouseGraphView { public partial class frmGraph : Form { - public frmGraph() + private List PlotData; + + public frmGraph(List _plotData) { InitializeComponent(); + PlotData = _plotData; + } + + private void frmGraph_Load(object sender, EventArgs e) + { + btnShowBoth.Enabled = false; + + DateTime lastTimeRecorded = PlotData[PlotData.Count-1].MouseRecordedTime; + List Last5Seconds = PlotData.Where(s => s.MouseRecordedTime >= lastTimeRecorded.AddSeconds(-5)).ToList(); + List EverythingElse = PlotData.Where(s => s.MouseRecordedTime < lastTimeRecorded.AddSeconds(-5)).ToList(); + + for (int i = 0; i < EverythingElse.Count; i++) + { + chrtMousePos.Series[0].Points.AddXY(EverythingElse[i].MouseX, EverythingElse[i].MouseY); + } + + for (int i = 0; i < Last5Seconds.Count; i++) + { + chrtMousePos.Series[1].Points.AddXY(Last5Seconds[i].MouseX, Last5Seconds[i].MouseY); + } + + } + + private void btnShowBoth_Click(object sender, EventArgs e) + { + btnShowBoth.Enabled = false; + btnShowAllButRecent.Enabled = true; + btnShowRecent.Enabled = true; + chrtMousePos.Series[0].Enabled = true; + chrtMousePos.Series[1].Enabled = true; + } + + private void btnShowRecent_Click(object sender, EventArgs e) + { + btnShowBoth.Enabled = true; + btnShowRecent.Enabled = false; + btnShowAllButRecent.Enabled = true; + chrtMousePos.Series[0].Enabled = false; + chrtMousePos.Series[1].Enabled = true; + } + + private void btnShowAllButRecent_Click(object sender, EventArgs e) + { + btnShowBoth.Enabled = true; + btnShowRecent.Enabled = true; + btnShowAllButRecent.Enabled = false; + chrtMousePos.Series[0].Enabled = true; + chrtMousePos.Series[1].Enabled = false; } } } diff --git a/src/MouseGraphView/frmMain.Designer.cs b/src/MouseGraphView/frmMain.Designer.cs index e254de8..6c58f17 100644 --- a/src/MouseGraphView/frmMain.Designer.cs +++ b/src/MouseGraphView/frmMain.Designer.cs @@ -29,11 +29,11 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.dgvMouseData = new System.Windows.Forms.DataGridView(); - this.btnStart = new System.Windows.Forms.Button(); - this.btnStop = new System.Windows.Forms.Button(); this.dgvColMouseTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dgvColMouseX = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dgvColMouseY = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.btnStart = new System.Windows.Forms.Button(); + this.btnStop = new System.Windows.Forms.Button(); this.txtUpdatesPerSecond = new System.Windows.Forms.TextBox(); this.lblUpdatePerSec = new System.Windows.Forms.Label(); this.txtDataLife = new System.Windows.Forms.TextBox(); @@ -67,27 +67,6 @@ private void InitializeComponent() this.dgvMouseData.Size = new System.Drawing.Size(418, 349); this.dgvMouseData.TabIndex = 0; // - // btnStart - // - this.btnStart.Location = new System.Drawing.Point(12, 12); - this.btnStart.Name = "btnStart"; - this.btnStart.Size = new System.Drawing.Size(75, 23); - this.btnStart.TabIndex = 1; - this.btnStart.Text = "START"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // - // btnStop - // - this.btnStop.Enabled = false; - this.btnStop.Location = new System.Drawing.Point(12, 38); - this.btnStop.Name = "btnStop"; - this.btnStop.Size = new System.Drawing.Size(75, 23); - this.btnStop.TabIndex = 2; - this.btnStop.Text = "STOP"; - this.btnStop.UseVisualStyleBackColor = true; - this.btnStop.Click += new System.EventHandler(this.btnStop_Click); - // // dgvColMouseTime // this.dgvColMouseTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -113,6 +92,27 @@ private void InitializeComponent() this.dgvColMouseY.Resizable = System.Windows.Forms.DataGridViewTriState.False; this.dgvColMouseY.Width = 39; // + // btnStart + // + this.btnStart.Location = new System.Drawing.Point(12, 12); + this.btnStart.Name = "btnStart"; + this.btnStart.Size = new System.Drawing.Size(75, 23); + this.btnStart.TabIndex = 1; + this.btnStart.Text = "START"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // + // btnStop + // + this.btnStop.Enabled = false; + this.btnStop.Location = new System.Drawing.Point(12, 38); + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(75, 23); + this.btnStop.TabIndex = 2; + this.btnStop.Text = "STOP"; + this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); + // // txtUpdatesPerSecond // this.txtUpdatesPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -133,7 +133,8 @@ private void InitializeComponent() // // txtDataLife // - this.txtDataLife.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txtDataLife.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtDataLife.Location = new System.Drawing.Point(226, 40); this.txtDataLife.Name = "txtDataLife"; this.txtDataLife.Size = new System.Drawing.Size(204, 20); @@ -150,6 +151,8 @@ private void InitializeComponent() // // btnGenerateGraph // + this.btnGenerateGraph.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.btnGenerateGraph.Location = new System.Drawing.Point(12, 421); this.btnGenerateGraph.Name = "btnGenerateGraph"; this.btnGenerateGraph.Size = new System.Drawing.Size(418, 23); diff --git a/src/MouseGraphView/frmMain.cs b/src/MouseGraphView/frmMain.cs index 1c8cec6..fb9dd62 100644 --- a/src/MouseGraphView/frmMain.cs +++ b/src/MouseGraphView/frmMain.cs @@ -100,7 +100,7 @@ private void btnStop_Click(object sender, EventArgs e) private void btnGenerateGraph_Click(object sender, EventArgs e) { - frmGraph graphWindow = new frmGraph(); + frmGraph graphWindow = new frmGraph(this.MouseMonitor.GetFullDataset()); graphWindow.Show(); } }