From 53c9025337166a408febc15078af3e9b136b3bab Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 19 Aug 2020 15:26:25 -0700 Subject: Add natural gain accel; add scale by DPI, poll rate in GUI --- grapher/Form1.Designer.cs | 315 +++++++++++++++---------- grapher/Form1.cs | 9 +- grapher/Layouts/NaturalGainLayout.cs | 20 ++ grapher/Layouts/OffLayout.cs | 2 +- grapher/Models/AccelGUI.cs | 17 +- grapher/Models/Calculations/AccelCalculator.cs | 64 +++-- grapher/Models/Options/AccelOptions.cs | 1 + grapher/grapher.csproj | 1 + 8 files changed, 282 insertions(+), 147 deletions(-) create mode 100644 grapher/Layouts/NaturalGainLayout.cs (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index f30de99..788f3c7 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -30,30 +30,30 @@ namespace grapher /// 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(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea13 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend13 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series25 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series26 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea14 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend14 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series27 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series28 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea15 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend15 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series29 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series30 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea16 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend16 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series31 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series32 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea17 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend17 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series33 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series34 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea18 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend18 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series35 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series36 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.accelTypeDrop = new System.Windows.Forms.ComboBox(); this.sensitivityBoxX = new System.Windows.Forms.TextBox(); @@ -85,6 +85,12 @@ namespace grapher this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.graphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scaleByDPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.DPITextBox = new System.Windows.Forms.ToolStripTextBox(); + this.pollRateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.PollRateTextBox = new System.Windows.Forms.ToolStripTextBox(); + this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -104,25 +110,25 @@ namespace grapher // // AccelerationChart // - chartArea1.AxisX.Title = "Speed (counts/ms)"; - chartArea1.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea1.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea1); - legend1.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend1); + chartArea13.AxisX.Title = "Speed (counts/ms)"; + chartArea13.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea13.Name = "ChartArea1"; + this.AccelerationChart.ChartAreas.Add(chartArea13); + legend13.Name = "Legend1"; + this.AccelerationChart.Legends.Add(legend13); this.AccelerationChart.Location = new System.Drawing.Point(240, 0); this.AccelerationChart.Name = "AccelerationChart"; - series1.ChartArea = "ChartArea1"; - series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series1.Legend = "Legend1"; - series1.Name = "Accelerated Sensitivity"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series2.Legend = "Legend1"; - series2.Name = "LastAccelVal"; - this.AccelerationChart.Series.Add(series1); - this.AccelerationChart.Series.Add(series2); + series25.ChartArea = "ChartArea1"; + series25.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series25.Legend = "Legend1"; + series25.Name = "Accelerated Sensitivity"; + series26.ChartArea = "ChartArea1"; + series26.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series26.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series26.Legend = "Legend1"; + series26.Name = "LastAccelVal"; + this.AccelerationChart.Series.Add(series25); + this.AccelerationChart.Series.Add(series26); this.AccelerationChart.Size = new System.Drawing.Size(723, 328); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; @@ -345,50 +351,50 @@ namespace grapher // // VelocityChart // - chartArea2.AxisX.Title = "Speed (count/ms)"; - chartArea2.AxisY.Title = "Output Speed (counts/ms)"; - chartArea2.Name = "ChartArea1"; - this.VelocityChart.ChartAreas.Add(chartArea2); - legend2.Name = "Legend1"; - this.VelocityChart.Legends.Add(legend2); + chartArea14.AxisX.Title = "Speed (count/ms)"; + chartArea14.AxisY.Title = "Output Speed (counts/ms)"; + chartArea14.Name = "ChartArea1"; + this.VelocityChart.ChartAreas.Add(chartArea14); + legend14.Name = "Legend1"; + this.VelocityChart.Legends.Add(legend14); this.VelocityChart.Location = new System.Drawing.Point(240, 334); this.VelocityChart.Name = "VelocityChart"; - series3.ChartArea = "ChartArea1"; - series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series3.Legend = "Legend1"; - series3.Name = "Mouse Velocity"; - series4.ChartArea = "ChartArea1"; - series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series4.Legend = "Legend1"; - series4.Name = "LastVelocityVal"; - this.VelocityChart.Series.Add(series3); - this.VelocityChart.Series.Add(series4); + series27.ChartArea = "ChartArea1"; + series27.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series27.Legend = "Legend1"; + series27.Name = "Mouse Velocity"; + series28.ChartArea = "ChartArea1"; + series28.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series28.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series28.Legend = "Legend1"; + series28.Name = "LastVelocityVal"; + this.VelocityChart.Series.Add(series27); + this.VelocityChart.Series.Add(series28); this.VelocityChart.Size = new System.Drawing.Size(723, 307); this.VelocityChart.TabIndex = 28; this.VelocityChart.Text = "chart1"; // // GainChart // - chartArea3.AxisX.Title = "Speed (counts/ms)"; - chartArea3.AxisY.Title = "Slope of Velocity Chart"; - chartArea3.Name = "ChartArea1"; - this.GainChart.ChartAreas.Add(chartArea3); - legend3.Name = "Legend1"; - this.GainChart.Legends.Add(legend3); + chartArea15.AxisX.Title = "Speed (counts/ms)"; + chartArea15.AxisY.Title = "Slope of Velocity Chart"; + chartArea15.Name = "ChartArea1"; + this.GainChart.ChartAreas.Add(chartArea15); + legend15.Name = "Legend1"; + this.GainChart.Legends.Add(legend15); this.GainChart.Location = new System.Drawing.Point(240, 647); this.GainChart.Name = "GainChart"; - series5.ChartArea = "ChartArea1"; - series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series5.Legend = "Legend1"; - series5.Name = "Velocity Gain"; - series6.ChartArea = "ChartArea1"; - series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series6.Legend = "Legend1"; - series6.Name = "LastGainVal"; - this.GainChart.Series.Add(series5); - this.GainChart.Series.Add(series6); + series29.ChartArea = "ChartArea1"; + series29.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series29.Legend = "Legend1"; + series29.Name = "Velocity Gain"; + series30.ChartArea = "ChartArea1"; + series30.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series30.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series30.Legend = "Legend1"; + series30.Name = "LastGainVal"; + this.GainChart.Series.Add(series29); + this.GainChart.Series.Add(series30); this.GainChart.Size = new System.Drawing.Size(723, 309); this.GainChart.TabIndex = 29; this.GainChart.Text = "chart1"; @@ -409,7 +415,8 @@ namespace grapher // this.graphsToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.graphsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.showVelocityGainToolStripMenuItem}); + this.showVelocityGainToolStripMenuItem, + this.scaleByDPIToolStripMenuItem}); this.graphsToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.graphsToolStripMenuItem.Name = "graphsToolStripMenuItem"; this.graphsToolStripMenuItem.Size = new System.Drawing.Size(53, 20); @@ -418,9 +425,53 @@ namespace grapher // showVelocityGainToolStripMenuItem // this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem"; - this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(198, 22); this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain"; // + // scaleByDPIToolStripMenuItem + // + this.scaleByDPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.dPIToolStripMenuItem, + this.pollRateToolStripMenuItem, + this.ScaleMenuItem}); + this.scaleByDPIToolStripMenuItem.Name = "scaleByDPIToolStripMenuItem"; + this.scaleByDPIToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.scaleByDPIToolStripMenuItem.Text = "Scale by Mouse Settngs"; + // + // dPIToolStripMenuItem + // + this.dPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.DPITextBox}); + this.dPIToolStripMenuItem.Name = "dPIToolStripMenuItem"; + this.dPIToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.dPIToolStripMenuItem.Text = "DPI"; + // + // DPITextBox + // + this.DPITextBox.Font = new System.Drawing.Font("Segoe UI", 9F); + this.DPITextBox.Name = "DPITextBox"; + this.DPITextBox.Size = new System.Drawing.Size(100, 23); + // + // pollRateToolStripMenuItem + // + this.pollRateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.PollRateTextBox}); + this.pollRateToolStripMenuItem.Name = "pollRateToolStripMenuItem"; + this.pollRateToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pollRateToolStripMenuItem.Text = "Poll Rate"; + // + // PollRateTextBox + // + this.PollRateTextBox.Font = new System.Drawing.Font("Segoe UI", 9F); + this.PollRateTextBox.Name = "PollRateTextBox"; + this.PollRateTextBox.Size = new System.Drawing.Size(100, 23); + // + // ScaleMenuItem + // + this.ScaleMenuItem.Name = "ScaleMenuItem"; + this.ScaleMenuItem.Size = new System.Drawing.Size(180, 22); + this.ScaleMenuItem.Text = "Re-scale by above"; + // // advancedToolStripMenuItem // this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -435,7 +486,7 @@ namespace grapher this.sensitivityToolStripMenuItem, this.velocityGainToolStripMenuItem}); this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem"; - this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.capStyleToolStripMenuItem.Text = "Cap Style"; // // sensitivityToolStripMenuItem @@ -454,75 +505,75 @@ namespace grapher // // AccelerationChartY // - chartArea4.AxisX.Title = "Speed (counts/ms)"; - chartArea4.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea4.Name = "ChartArea1"; - this.AccelerationChartY.ChartAreas.Add(chartArea4); - legend4.Name = "Legend1"; - this.AccelerationChartY.Legends.Add(legend4); + chartArea16.AxisX.Title = "Speed (counts/ms)"; + chartArea16.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea16.Name = "ChartArea1"; + this.AccelerationChartY.ChartAreas.Add(chartArea16); + legend16.Name = "Legend1"; + this.AccelerationChartY.Legends.Add(legend16); this.AccelerationChartY.Location = new System.Drawing.Point(969, 0); this.AccelerationChartY.Name = "AccelerationChartY"; - series7.ChartArea = "ChartArea1"; - series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series7.Legend = "Legend1"; - series7.Name = "Accelerated Sensitivity"; - series8.ChartArea = "ChartArea1"; - series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series8.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series8.Legend = "Legend1"; - series8.Name = "LastAccelVal"; - this.AccelerationChartY.Series.Add(series7); - this.AccelerationChartY.Series.Add(series8); + series31.ChartArea = "ChartArea1"; + series31.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series31.Legend = "Legend1"; + series31.Name = "Accelerated Sensitivity"; + series32.ChartArea = "ChartArea1"; + series32.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series32.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series32.Legend = "Legend1"; + series32.Name = "LastAccelVal"; + this.AccelerationChartY.Series.Add(series31); + this.AccelerationChartY.Series.Add(series32); this.AccelerationChartY.Size = new System.Drawing.Size(723, 328); this.AccelerationChartY.TabIndex = 31; this.AccelerationChartY.Text = "chart1"; // // VelocityChartY // - chartArea5.AxisX.Title = "Speed (count/ms)"; - chartArea5.AxisY.Title = "Output Speed (counts/ms)"; - chartArea5.Name = "ChartArea1"; - this.VelocityChartY.ChartAreas.Add(chartArea5); - legend5.Name = "Legend1"; - this.VelocityChartY.Legends.Add(legend5); + chartArea17.AxisX.Title = "Speed (count/ms)"; + chartArea17.AxisY.Title = "Output Speed (counts/ms)"; + chartArea17.Name = "ChartArea1"; + this.VelocityChartY.ChartAreas.Add(chartArea17); + legend17.Name = "Legend1"; + this.VelocityChartY.Legends.Add(legend17); this.VelocityChartY.Location = new System.Drawing.Point(970, 334); this.VelocityChartY.Name = "VelocityChartY"; - series9.ChartArea = "ChartArea1"; - series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series9.Legend = "Legend1"; - series9.Name = "Mouse Velocity"; - series10.ChartArea = "ChartArea1"; - series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series10.Legend = "Legend1"; - series10.Name = "LastVelocityVal"; - this.VelocityChartY.Series.Add(series9); - this.VelocityChartY.Series.Add(series10); + series33.ChartArea = "ChartArea1"; + series33.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series33.Legend = "Legend1"; + series33.Name = "Mouse Velocity"; + series34.ChartArea = "ChartArea1"; + series34.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series34.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series34.Legend = "Legend1"; + series34.Name = "LastVelocityVal"; + this.VelocityChartY.Series.Add(series33); + this.VelocityChartY.Series.Add(series34); this.VelocityChartY.Size = new System.Drawing.Size(723, 307); this.VelocityChartY.TabIndex = 32; this.VelocityChartY.Text = "chart1"; // // GainChartY // - chartArea6.AxisX.Title = "Speed (counts/ms)"; - chartArea6.AxisY.Title = "Slope of Velocity Chart"; - chartArea6.Name = "ChartArea1"; - this.GainChartY.ChartAreas.Add(chartArea6); - legend6.Name = "Legend1"; - this.GainChartY.Legends.Add(legend6); + chartArea18.AxisX.Title = "Speed (counts/ms)"; + chartArea18.AxisY.Title = "Slope of Velocity Chart"; + chartArea18.Name = "ChartArea1"; + this.GainChartY.ChartAreas.Add(chartArea18); + legend18.Name = "Legend1"; + this.GainChartY.Legends.Add(legend18); this.GainChartY.Location = new System.Drawing.Point(970, 647); this.GainChartY.Name = "GainChartY"; - series11.ChartArea = "ChartArea1"; - series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series11.Legend = "Legend1"; - series11.Name = "Velocity Gain"; - series12.ChartArea = "ChartArea1"; - series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series12.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series12.Legend = "Legend1"; - series12.Name = "LastGainVal"; - this.GainChartY.Series.Add(series11); - this.GainChartY.Series.Add(series12); + series35.ChartArea = "ChartArea1"; + series35.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series35.Legend = "Legend1"; + series35.Name = "Velocity Gain"; + series36.ChartArea = "ChartArea1"; + series36.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series36.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series36.Legend = "Legend1"; + series36.Name = "LastGainVal"; + this.GainChartY.Series.Add(series35); + this.GainChartY.Series.Add(series36); this.GainChartY.Size = new System.Drawing.Size(723, 309); this.GainChartY.TabIndex = 33; this.GainChartY.Text = "chart1"; @@ -632,6 +683,12 @@ namespace grapher private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY; private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY; private System.Windows.Forms.Label MouseLabel; + private System.Windows.Forms.ToolStripMenuItem scaleByDPIToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem dPIToolStripMenuItem; + private System.Windows.Forms.ToolStripTextBox DPITextBox; + private System.Windows.Forms.ToolStripMenuItem pollRateToolStripMenuItem; + private System.Windows.Forms.ToolStripTextBox PollRateTextBox; + private System.Windows.Forms.ToolStripMenuItem ScaleMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index d8db6fc..6e08683 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; +using grapher.Models.Calculations; namespace grapher { @@ -131,8 +132,13 @@ namespace grapher cap, weight); + AccelCalculator accelCalculator = new AccelCalculator( + new Field(DPITextBox.TextBox, this, AccelCalculator.DefaultDPI), + new Field(PollRateTextBox.TextBox, this, AccelCalculator.DefaultPollRate)); + AccelGUI = new AccelGUI( this, + accelCalculator, accelCharts, managedAcceleration, accelerationOptions, @@ -145,7 +151,8 @@ namespace grapher limitOrExponent, midpoint, writeButton, - MouseLabel); + MouseLabel, + ScaleMenuItem); } #endregion Constructor diff --git a/grapher/Layouts/NaturalGainLayout.cs b/grapher/Layouts/NaturalGainLayout.cs new file mode 100644 index 0000000..e062850 --- /dev/null +++ b/grapher/Layouts/NaturalGainLayout.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Layouts +{ + public class NaturalGainLayout : LayoutBase + { + public NaturalGainLayout() + : base() + { + Name = "NaturalGain"; + Index = 7; + ShowOptions = new bool[] { true, true, true, false }; + OptionNames = new string[] { Offset, Acceleration, Limit, string.Empty }; + } + } +} diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs index cecba05..55f44b7 100644 --- a/grapher/Layouts/OffLayout.cs +++ b/grapher/Layouts/OffLayout.cs @@ -12,7 +12,7 @@ namespace grapher.Layouts : base() { Name = "Off"; - Index = 7; + Index = 8; ShowOptions = new bool[] { false, false, false, false }; OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty }; ShowOptionsXY = new bool[] { false, false }; diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 8eb2226..2c27bf7 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -18,6 +18,7 @@ namespace grapher public AccelGUI( RawAcceleration accelForm, + AccelCalculator accelCalculator, AccelCharts accelCharts, ManagedAccel managedAccel, AccelOptions accelOptions, @@ -30,9 +31,11 @@ namespace grapher Option limtOrExp, Option midpoint, Button writeButton, - Label mouseMoveLabel) + Label mouseMoveLabel, + ToolStripMenuItem scaleMenuItem) { AccelForm = accelForm; + AccelCalculator = accelCalculator; AccelCharts = accelCharts; ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; @@ -45,11 +48,14 @@ namespace grapher LimitOrExponent = limtOrExp; Midpoint = midpoint; WriteButton = writeButton; + ScaleMenuItem = scaleMenuItem; ManagedAcceleration.ReadFromDriver(); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); + + ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick); } #endregion constructors @@ -58,6 +64,8 @@ namespace grapher public RawAcceleration AccelForm { get; } + public AccelCalculator AccelCalculator { get; } + public AccelCharts AccelCharts { get; } public ManagedAccel ManagedAcceleration { get; } @@ -84,17 +92,22 @@ namespace grapher public MouseWatcher MouseWatcher { get; } + public ToolStripMenuItem ScaleMenuItem { get; } + #endregion properties #region methods - public void UpdateGraph() { AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); } + private void OnScaleMenuItemClick(object sender, EventArgs e) + { + UpdateGraph(); + } #endregion methods } diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index bba3c32..0346fb8 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -4,13 +4,17 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace grapher.Models.Calculations { - public static class AccelCalculator + public class AccelCalculator { - public const int MaxCombined = 100; - public const int MaxXY = 150; + public const int DefaultDPI = 1200; + public const int DefaultPollRate = 1000; + public const int Resolution = 100; + public const double MaxMultiplier = 85; + public const double XYToCombinedRatio = 1.3; public struct MagnitudeData { @@ -19,12 +23,33 @@ namespace grapher.Models.Calculations public int y; } - public static ReadOnlyCollection MagnitudesCombined = GetMagnitudes(); - public static ReadOnlyCollection MagnitudesX = GetMagnitudesX(); - public static ReadOnlyCollection MagnitudesY = GetMagnitudesY(); - public static void Calculate(AccelData data, ManagedAccel accel) + public AccelCalculator(Field dpi, Field pollRate) { + DPI = dpi; + PollRate = pollRate; + } + + public ReadOnlyCollection MagnitudesCombined { get; private set; } + + public ReadOnlyCollection MagnitudesX { get; private set; } + + public ReadOnlyCollection MagnitudesY { get; private set; } + + public Field DPI { get; private set; } + + public Field PollRate { get; private set; } + + private double CombinedMaxVelocity { get; set; } + + private double XYMaxVelocity { get; set; } + + private int Increment { get; set; } + + public void Calculate(AccelData data, ManagedAccel accel) + { + ScaleByMouseSettings(); + data.Clear(); Calculate(data.Combined, accel, accel.GetSensitivityX(), MagnitudesCombined); @@ -70,12 +95,12 @@ namespace grapher.Models.Calculations data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList()); } - public static ReadOnlyCollection GetMagnitudes() + public ReadOnlyCollection GetMagnitudes() { var magnitudes = new List(); - for (int i = 0; i < MaxCombined; i++) + for (int i = 0; i < CombinedMaxVelocity; i+=Increment) { - for (int j = 0; j <= i; j++) + for (int j = 0; j <= i; j+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = Magnitude(i, j); @@ -90,11 +115,11 @@ namespace grapher.Models.Calculations return magnitudes.AsReadOnly(); } - public static ReadOnlyCollection GetMagnitudesX() + public ReadOnlyCollection GetMagnitudesX() { var magnitudes = new List(); - for (int i = 0; i < MaxXY; i++) + for (int i = 0; i < XYMaxVelocity; i+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = i; @@ -106,11 +131,11 @@ namespace grapher.Models.Calculations return magnitudes.AsReadOnly(); } - public static ReadOnlyCollection GetMagnitudesY() + public ReadOnlyCollection GetMagnitudesY() { var magnitudes = new List(); - for (int i = 0; i < MaxXY; i++) + for (int i = 0; i < XYMaxVelocity; i+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = i; @@ -141,5 +166,16 @@ namespace grapher.Models.Calculations { return Magnitude(x, y) / time; } + + public void ScaleByMouseSettings() + { + var dpiPollFactor = DPI.Data / PollRate.Data; + CombinedMaxVelocity = dpiPollFactor * MaxMultiplier; + Increment = (int) Math.Floor(CombinedMaxVelocity / Resolution); + XYMaxVelocity = CombinedMaxVelocity * 1.5; + MagnitudesCombined = GetMagnitudes(); + MagnitudesX = GetMagnitudesX(); + MagnitudesY = GetMagnitudesY(); + } } } diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index b233552..03d6ff6 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -22,6 +22,7 @@ namespace grapher new LogLayout(), new SigmoidLayout(), new PowerLayout(), + new NaturalGainLayout(), new OffLayout() }.ToDictionary(k => k.Name); diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index cbda661..cc7a8b4 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -47,6 +47,7 @@ + -- cgit v1.2.3 From 3dd0bb9163380de64d0df4f0b5c16dd86979714e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 00:32:11 -0700 Subject: Sigmoid gain --- grapher/Layouts/OffLayout.cs | 2 +- grapher/Layouts/SigmoidGainLayout.cs | 20 ++++++++++++++++++++ grapher/Models/Options/AccelOptions.cs | 1 + grapher/grapher.csproj | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 grapher/Layouts/SigmoidGainLayout.cs (limited to 'grapher') diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs index 55f44b7..087885f 100644 --- a/grapher/Layouts/OffLayout.cs +++ b/grapher/Layouts/OffLayout.cs @@ -12,7 +12,7 @@ namespace grapher.Layouts : base() { Name = "Off"; - Index = 8; + Index = 9; ShowOptions = new bool[] { false, false, false, false }; OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty }; ShowOptionsXY = new bool[] { false, false }; diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/SigmoidGainLayout.cs new file mode 100644 index 0000000..c620925 --- /dev/null +++ b/grapher/Layouts/SigmoidGainLayout.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Layouts +{ + public class SigmoidGainLayout : LayoutBase + { + public SigmoidGainLayout() + : base() + { + Name = "SigmoidGain"; + Index = 8; + ShowOptions = new bool[] { true, true, true, true }; + OptionNames = new string[] { Offset, Acceleration, Limit, Midpoint }; + } + } +} diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 03d6ff6..8da873f 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -23,6 +23,7 @@ namespace grapher new SigmoidLayout(), new PowerLayout(), new NaturalGainLayout(), + new SigmoidGainLayout(), new OffLayout() }.ToDictionary(k => k.Name); diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index cc7a8b4..2d9f4ab 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -48,6 +48,7 @@ + -- cgit v1.2.3 From 85353dfa6594f2eb37515a426eef2944370cd309 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 01:20:18 -0700 Subject: Add empty active labels for all options --- grapher/Form1.Designer.cs | 432 +++++++++++++++++++++++++++++++--------------- 1 file changed, 294 insertions(+), 138 deletions(-) (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 788f3c7..ab9aa99 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -30,30 +30,30 @@ namespace grapher /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea13 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend13 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series25 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series26 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea14 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend14 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series27 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series28 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea15 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend15 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series29 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series30 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea16 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend16 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series31 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series32 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea17 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend17 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series33 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series34 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea18 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend18 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series35 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series36 = new System.Windows.Forms.DataVisualization.Charting.Series(); + 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(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.accelTypeDrop = new System.Windows.Forms.ComboBox(); this.sensitivityBoxX = new System.Windows.Forms.TextBox(); @@ -99,6 +99,19 @@ namespace grapher this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.MouseLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SensitivityActiveXLabel = new System.Windows.Forms.Label(); + this.SensitivityActiveYLabel = new System.Windows.Forms.Label(); + this.RotationActiveLabel = new System.Windows.Forms.Label(); + this.AccelTypeActiveLabel = new System.Windows.Forms.Label(); + this.AccelerationActiveLabel = new System.Windows.Forms.Label(); + this.CapActiveXLabel = new System.Windows.Forms.Label(); + this.WeightActiveXLabel = new System.Windows.Forms.Label(); + this.WeightActiveYLabel = new System.Windows.Forms.Label(); + this.CapActiveYLabel = new System.Windows.Forms.Label(); + this.OffsetActiveLabel = new System.Windows.Forms.Label(); + this.LimitExpActiveLabel = new System.Windows.Forms.Label(); + this.MidpointActiveLabel = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); @@ -110,25 +123,25 @@ namespace grapher // // AccelerationChart // - chartArea13.AxisX.Title = "Speed (counts/ms)"; - chartArea13.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea13.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea13); - legend13.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend13); - this.AccelerationChart.Location = new System.Drawing.Point(240, 0); + chartArea1.AxisX.Title = "Speed (counts/ms)"; + chartArea1.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea1.Name = "ChartArea1"; + this.AccelerationChart.ChartAreas.Add(chartArea1); + legend1.Name = "Legend1"; + this.AccelerationChart.Legends.Add(legend1); + this.AccelerationChart.Location = new System.Drawing.Point(322, 0); this.AccelerationChart.Name = "AccelerationChart"; - series25.ChartArea = "ChartArea1"; - series25.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series25.Legend = "Legend1"; - series25.Name = "Accelerated Sensitivity"; - series26.ChartArea = "ChartArea1"; - series26.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series26.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series26.Legend = "Legend1"; - series26.Name = "LastAccelVal"; - this.AccelerationChart.Series.Add(series25); - this.AccelerationChart.Series.Add(series26); + series1.ChartArea = "ChartArea1"; + series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series1.Legend = "Legend1"; + series1.Name = "Accelerated Sensitivity"; + series2.ChartArea = "ChartArea1"; + series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series2.Legend = "Legend1"; + series2.Name = "LastAccelVal"; + this.AccelerationChart.Series.Add(series1); + this.AccelerationChart.Series.Add(series2); this.AccelerationChart.Size = new System.Drawing.Size(723, 328); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; @@ -351,50 +364,50 @@ namespace grapher // // VelocityChart // - chartArea14.AxisX.Title = "Speed (count/ms)"; - chartArea14.AxisY.Title = "Output Speed (counts/ms)"; - chartArea14.Name = "ChartArea1"; - this.VelocityChart.ChartAreas.Add(chartArea14); - legend14.Name = "Legend1"; - this.VelocityChart.Legends.Add(legend14); - this.VelocityChart.Location = new System.Drawing.Point(240, 334); + chartArea2.AxisX.Title = "Speed (count/ms)"; + chartArea2.AxisY.Title = "Output Speed (counts/ms)"; + chartArea2.Name = "ChartArea1"; + this.VelocityChart.ChartAreas.Add(chartArea2); + legend2.Name = "Legend1"; + this.VelocityChart.Legends.Add(legend2); + this.VelocityChart.Location = new System.Drawing.Point(322, 334); this.VelocityChart.Name = "VelocityChart"; - series27.ChartArea = "ChartArea1"; - series27.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series27.Legend = "Legend1"; - series27.Name = "Mouse Velocity"; - series28.ChartArea = "ChartArea1"; - series28.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series28.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series28.Legend = "Legend1"; - series28.Name = "LastVelocityVal"; - this.VelocityChart.Series.Add(series27); - this.VelocityChart.Series.Add(series28); + series3.ChartArea = "ChartArea1"; + series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series3.Legend = "Legend1"; + series3.Name = "Mouse Velocity"; + series4.ChartArea = "ChartArea1"; + series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series4.Legend = "Legend1"; + series4.Name = "LastVelocityVal"; + this.VelocityChart.Series.Add(series3); + this.VelocityChart.Series.Add(series4); this.VelocityChart.Size = new System.Drawing.Size(723, 307); this.VelocityChart.TabIndex = 28; this.VelocityChart.Text = "chart1"; // // GainChart // - chartArea15.AxisX.Title = "Speed (counts/ms)"; - chartArea15.AxisY.Title = "Slope of Velocity Chart"; - chartArea15.Name = "ChartArea1"; - this.GainChart.ChartAreas.Add(chartArea15); - legend15.Name = "Legend1"; - this.GainChart.Legends.Add(legend15); - this.GainChart.Location = new System.Drawing.Point(240, 647); + chartArea3.AxisX.Title = "Speed (counts/ms)"; + chartArea3.AxisY.Title = "Slope of Velocity Chart"; + chartArea3.Name = "ChartArea1"; + this.GainChart.ChartAreas.Add(chartArea3); + legend3.Name = "Legend1"; + this.GainChart.Legends.Add(legend3); + this.GainChart.Location = new System.Drawing.Point(322, 647); this.GainChart.Name = "GainChart"; - series29.ChartArea = "ChartArea1"; - series29.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series29.Legend = "Legend1"; - series29.Name = "Velocity Gain"; - series30.ChartArea = "ChartArea1"; - series30.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series30.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series30.Legend = "Legend1"; - series30.Name = "LastGainVal"; - this.GainChart.Series.Add(series29); - this.GainChart.Series.Add(series30); + series5.ChartArea = "ChartArea1"; + series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series5.Legend = "Legend1"; + series5.Name = "Velocity Gain"; + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series6.Legend = "Legend1"; + series6.Name = "LastGainVal"; + this.GainChart.Series.Add(series5); + this.GainChart.Series.Add(series6); this.GainChart.Size = new System.Drawing.Size(723, 309); this.GainChart.TabIndex = 29; this.GainChart.Text = "chart1"; @@ -407,7 +420,7 @@ namespace grapher this.advancedToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1693, 24); + this.menuStrip1.Size = new System.Drawing.Size(1773, 24); this.menuStrip1.TabIndex = 30; this.menuStrip1.Text = "menuStrip1"; // @@ -443,7 +456,7 @@ namespace grapher this.dPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.DPITextBox}); this.dPIToolStripMenuItem.Name = "dPIToolStripMenuItem"; - this.dPIToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.dPIToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.dPIToolStripMenuItem.Text = "DPI"; // // DPITextBox @@ -457,7 +470,7 @@ namespace grapher this.pollRateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.PollRateTextBox}); this.pollRateToolStripMenuItem.Name = "pollRateToolStripMenuItem"; - this.pollRateToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pollRateToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.pollRateToolStripMenuItem.Text = "Poll Rate"; // // PollRateTextBox @@ -469,7 +482,7 @@ namespace grapher // ScaleMenuItem // this.ScaleMenuItem.Name = "ScaleMenuItem"; - this.ScaleMenuItem.Size = new System.Drawing.Size(180, 22); + this.ScaleMenuItem.Size = new System.Drawing.Size(169, 22); this.ScaleMenuItem.Text = "Re-scale by above"; // // advancedToolStripMenuItem @@ -486,7 +499,7 @@ namespace grapher this.sensitivityToolStripMenuItem, this.velocityGainToolStripMenuItem}); this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem"; - this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.capStyleToolStripMenuItem.Text = "Cap Style"; // // sensitivityToolStripMenuItem @@ -505,75 +518,75 @@ namespace grapher // // AccelerationChartY // - chartArea16.AxisX.Title = "Speed (counts/ms)"; - chartArea16.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea16.Name = "ChartArea1"; - this.AccelerationChartY.ChartAreas.Add(chartArea16); - legend16.Name = "Legend1"; - this.AccelerationChartY.Legends.Add(legend16); - this.AccelerationChartY.Location = new System.Drawing.Point(969, 0); + chartArea4.AxisX.Title = "Speed (counts/ms)"; + chartArea4.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea4.Name = "ChartArea1"; + this.AccelerationChartY.ChartAreas.Add(chartArea4); + legend4.Name = "Legend1"; + this.AccelerationChartY.Legends.Add(legend4); + this.AccelerationChartY.Location = new System.Drawing.Point(1051, 0); this.AccelerationChartY.Name = "AccelerationChartY"; - series31.ChartArea = "ChartArea1"; - series31.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series31.Legend = "Legend1"; - series31.Name = "Accelerated Sensitivity"; - series32.ChartArea = "ChartArea1"; - series32.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series32.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series32.Legend = "Legend1"; - series32.Name = "LastAccelVal"; - this.AccelerationChartY.Series.Add(series31); - this.AccelerationChartY.Series.Add(series32); + series7.ChartArea = "ChartArea1"; + series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series7.Legend = "Legend1"; + series7.Name = "Accelerated Sensitivity"; + series8.ChartArea = "ChartArea1"; + series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series8.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series8.Legend = "Legend1"; + series8.Name = "LastAccelVal"; + this.AccelerationChartY.Series.Add(series7); + this.AccelerationChartY.Series.Add(series8); this.AccelerationChartY.Size = new System.Drawing.Size(723, 328); this.AccelerationChartY.TabIndex = 31; this.AccelerationChartY.Text = "chart1"; // // VelocityChartY // - chartArea17.AxisX.Title = "Speed (count/ms)"; - chartArea17.AxisY.Title = "Output Speed (counts/ms)"; - chartArea17.Name = "ChartArea1"; - this.VelocityChartY.ChartAreas.Add(chartArea17); - legend17.Name = "Legend1"; - this.VelocityChartY.Legends.Add(legend17); - this.VelocityChartY.Location = new System.Drawing.Point(970, 334); + chartArea5.AxisX.Title = "Speed (count/ms)"; + chartArea5.AxisY.Title = "Output Speed (counts/ms)"; + chartArea5.Name = "ChartArea1"; + this.VelocityChartY.ChartAreas.Add(chartArea5); + legend5.Name = "Legend1"; + this.VelocityChartY.Legends.Add(legend5); + this.VelocityChartY.Location = new System.Drawing.Point(1051, 334); this.VelocityChartY.Name = "VelocityChartY"; - series33.ChartArea = "ChartArea1"; - series33.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series33.Legend = "Legend1"; - series33.Name = "Mouse Velocity"; - series34.ChartArea = "ChartArea1"; - series34.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series34.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series34.Legend = "Legend1"; - series34.Name = "LastVelocityVal"; - this.VelocityChartY.Series.Add(series33); - this.VelocityChartY.Series.Add(series34); + series9.ChartArea = "ChartArea1"; + series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series9.Legend = "Legend1"; + series9.Name = "Mouse Velocity"; + series10.ChartArea = "ChartArea1"; + series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series10.Legend = "Legend1"; + series10.Name = "LastVelocityVal"; + this.VelocityChartY.Series.Add(series9); + this.VelocityChartY.Series.Add(series10); this.VelocityChartY.Size = new System.Drawing.Size(723, 307); this.VelocityChartY.TabIndex = 32; this.VelocityChartY.Text = "chart1"; // // GainChartY // - chartArea18.AxisX.Title = "Speed (counts/ms)"; - chartArea18.AxisY.Title = "Slope of Velocity Chart"; - chartArea18.Name = "ChartArea1"; - this.GainChartY.ChartAreas.Add(chartArea18); - legend18.Name = "Legend1"; - this.GainChartY.Legends.Add(legend18); - this.GainChartY.Location = new System.Drawing.Point(970, 647); + chartArea6.AxisX.Title = "Speed (counts/ms)"; + chartArea6.AxisY.Title = "Slope of Velocity Chart"; + chartArea6.Name = "ChartArea1"; + this.GainChartY.ChartAreas.Add(chartArea6); + legend6.Name = "Legend1"; + this.GainChartY.Legends.Add(legend6); + this.GainChartY.Location = new System.Drawing.Point(1051, 647); this.GainChartY.Name = "GainChartY"; - series35.ChartArea = "ChartArea1"; - series35.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series35.Legend = "Legend1"; - series35.Name = "Velocity Gain"; - series36.ChartArea = "ChartArea1"; - series36.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series36.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - series36.Legend = "Legend1"; - series36.Name = "LastGainVal"; - this.GainChartY.Series.Add(series35); - this.GainChartY.Series.Add(series36); + series11.ChartArea = "ChartArea1"; + series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series11.Legend = "Legend1"; + series11.Name = "Velocity Gain"; + series12.ChartArea = "ChartArea1"; + series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series12.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + series12.Legend = "Legend1"; + series12.Name = "LastGainVal"; + this.GainChartY.Series.Add(series11); + this.GainChartY.Series.Add(series12); this.GainChartY.Size = new System.Drawing.Size(723, 309); this.GainChartY.TabIndex = 33; this.GainChartY.Text = "chart1"; @@ -587,11 +600,141 @@ namespace grapher this.MouseLabel.TabIndex = 34; this.MouseLabel.Text = "Last (x, y): (x, y)"; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(249, 30); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(67, 13); + this.label1.TabIndex = 35; + this.label1.Text = "Active Value"; + // + // SensitivityActiveXLabel + // + this.SensitivityActiveXLabel.AutoSize = true; + this.SensitivityActiveXLabel.Location = new System.Drawing.Point(259, 49); + this.SensitivityActiveXLabel.Name = "SensitivityActiveXLabel"; + this.SensitivityActiveXLabel.Size = new System.Drawing.Size(14, 13); + this.SensitivityActiveXLabel.TabIndex = 36; + this.SensitivityActiveXLabel.Text = "X"; + // + // SensitivityActiveYLabel + // + this.SensitivityActiveYLabel.AutoSize = true; + this.SensitivityActiveYLabel.Location = new System.Drawing.Point(279, 49); + this.SensitivityActiveYLabel.Name = "SensitivityActiveYLabel"; + this.SensitivityActiveYLabel.Size = new System.Drawing.Size(14, 13); + this.SensitivityActiveYLabel.TabIndex = 37; + this.SensitivityActiveYLabel.Text = "Y"; + // + // RotationActiveLabel + // + this.RotationActiveLabel.AutoSize = true; + this.RotationActiveLabel.Location = new System.Drawing.Point(269, 75); + this.RotationActiveLabel.Name = "RotationActiveLabel"; + this.RotationActiveLabel.Size = new System.Drawing.Size(13, 13); + this.RotationActiveLabel.TabIndex = 38; + this.RotationActiveLabel.Text = "0"; + // + // AccelTypeActiveLabel + // + this.AccelTypeActiveLabel.AutoSize = true; + this.AccelTypeActiveLabel.Location = new System.Drawing.Point(252, 98); + this.AccelTypeActiveLabel.Name = "AccelTypeActiveLabel"; + this.AccelTypeActiveLabel.Size = new System.Drawing.Size(41, 13); + this.AccelTypeActiveLabel.TabIndex = 39; + this.AccelTypeActiveLabel.Text = "Default"; + // + // AccelerationActiveLabel + // + this.AccelerationActiveLabel.AutoSize = true; + this.AccelerationActiveLabel.Location = new System.Drawing.Point(269, 128); + this.AccelerationActiveLabel.Name = "AccelerationActiveLabel"; + this.AccelerationActiveLabel.Size = new System.Drawing.Size(13, 13); + this.AccelerationActiveLabel.TabIndex = 40; + this.AccelerationActiveLabel.Text = "0"; + // + // CapActiveXLabel + // + this.CapActiveXLabel.AutoSize = true; + this.CapActiveXLabel.Location = new System.Drawing.Point(260, 151); + this.CapActiveXLabel.Name = "CapActiveXLabel"; + this.CapActiveXLabel.Size = new System.Drawing.Size(13, 13); + this.CapActiveXLabel.TabIndex = 41; + this.CapActiveXLabel.Text = "0"; + // + // WeightActiveXLabel + // + this.WeightActiveXLabel.AutoSize = true; + this.WeightActiveXLabel.Location = new System.Drawing.Point(259, 180); + this.WeightActiveXLabel.Name = "WeightActiveXLabel"; + this.WeightActiveXLabel.Size = new System.Drawing.Size(13, 13); + this.WeightActiveXLabel.TabIndex = 42; + this.WeightActiveXLabel.Text = "0"; + // + // WeightActiveYLabel + // + this.WeightActiveYLabel.AutoSize = true; + this.WeightActiveYLabel.Location = new System.Drawing.Point(278, 180); + this.WeightActiveYLabel.Name = "WeightActiveYLabel"; + this.WeightActiveYLabel.Size = new System.Drawing.Size(13, 13); + this.WeightActiveYLabel.TabIndex = 43; + this.WeightActiveYLabel.Text = "0"; + // + // CapActiveYLabel + // + this.CapActiveYLabel.AutoSize = true; + this.CapActiveYLabel.Location = new System.Drawing.Point(278, 151); + this.CapActiveYLabel.Name = "CapActiveYLabel"; + this.CapActiveYLabel.Size = new System.Drawing.Size(13, 13); + this.CapActiveYLabel.TabIndex = 44; + this.CapActiveYLabel.Text = "0"; + // + // OffsetActiveLabel + // + this.OffsetActiveLabel.AutoSize = true; + this.OffsetActiveLabel.Location = new System.Drawing.Point(269, 206); + this.OffsetActiveLabel.Name = "OffsetActiveLabel"; + this.OffsetActiveLabel.Size = new System.Drawing.Size(13, 13); + this.OffsetActiveLabel.TabIndex = 45; + this.OffsetActiveLabel.Text = "0"; + // + // LimitExpActiveLabel + // + this.LimitExpActiveLabel.AutoSize = true; + this.LimitExpActiveLabel.Location = new System.Drawing.Point(269, 232); + this.LimitExpActiveLabel.Name = "LimitExpActiveLabel"; + this.LimitExpActiveLabel.Size = new System.Drawing.Size(13, 13); + this.LimitExpActiveLabel.TabIndex = 46; + this.LimitExpActiveLabel.Text = "0"; + // + // MidpointActiveLabel + // + this.MidpointActiveLabel.AutoSize = true; + this.MidpointActiveLabel.Location = new System.Drawing.Point(269, 255); + this.MidpointActiveLabel.Name = "MidpointActiveLabel"; + this.MidpointActiveLabel.Size = new System.Drawing.Size(13, 13); + this.MidpointActiveLabel.TabIndex = 47; + this.MidpointActiveLabel.Text = "0"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1693, 958); + this.ClientSize = new System.Drawing.Size(1773, 958); + this.Controls.Add(this.MidpointActiveLabel); + this.Controls.Add(this.LimitExpActiveLabel); + this.Controls.Add(this.OffsetActiveLabel); + this.Controls.Add(this.CapActiveYLabel); + this.Controls.Add(this.WeightActiveYLabel); + this.Controls.Add(this.WeightActiveXLabel); + this.Controls.Add(this.CapActiveXLabel); + this.Controls.Add(this.AccelerationActiveLabel); + this.Controls.Add(this.AccelTypeActiveLabel); + this.Controls.Add(this.RotationActiveLabel); + this.Controls.Add(this.SensitivityActiveYLabel); + this.Controls.Add(this.SensitivityActiveXLabel); + this.Controls.Add(this.label1); this.Controls.Add(this.MouseLabel); this.Controls.Add(this.GainChartY); this.Controls.Add(this.VelocityChartY); @@ -689,6 +832,19 @@ namespace grapher private System.Windows.Forms.ToolStripMenuItem pollRateToolStripMenuItem; private System.Windows.Forms.ToolStripTextBox PollRateTextBox; private System.Windows.Forms.ToolStripMenuItem ScaleMenuItem; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label SensitivityActiveXLabel; + private System.Windows.Forms.Label SensitivityActiveYLabel; + private System.Windows.Forms.Label RotationActiveLabel; + private System.Windows.Forms.Label AccelTypeActiveLabel; + private System.Windows.Forms.Label AccelerationActiveLabel; + private System.Windows.Forms.Label CapActiveXLabel; + private System.Windows.Forms.Label WeightActiveXLabel; + private System.Windows.Forms.Label WeightActiveYLabel; + private System.Windows.Forms.Label CapActiveYLabel; + private System.Windows.Forms.Label OffsetActiveLabel; + private System.Windows.Forms.Label LimitExpActiveLabel; + private System.Windows.Forms.Label MidpointActiveLabel; } } -- cgit v1.2.3 From fe17d04e571d180e663c7014e803ce790693f4b1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 12:51:33 -0700 Subject: Display active values --- grapher/Form1.Designer.cs | 20 +++---- grapher/Form1.cs | 79 +++++++++++++++++++++++--- grapher/Models/AccelGUI.cs | 13 +++++ grapher/Models/Calculations/AccelCalculator.cs | 6 +- grapher/Models/Options/ActiveValueLabel.cs | 46 +++++++++++++++ grapher/Models/Options/ActiveValueLabelXY.cs | 64 +++++++++++++++++++++ grapher/Models/Options/CapOptions.cs | 20 +++++-- grapher/Models/Options/Option.cs | 50 ++++++++++++++-- grapher/Models/Options/OptionXY.cs | 22 +++++-- grapher/grapher.csproj | 2 + 10 files changed, 285 insertions(+), 37 deletions(-) create mode 100644 grapher/Models/Options/ActiveValueLabel.cs create mode 100644 grapher/Models/Options/ActiveValueLabelXY.cs (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index ab9aa99..bb6b9ee 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -99,7 +99,7 @@ namespace grapher this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.MouseLabel = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.ActiveValueTitle = new System.Windows.Forms.Label(); this.SensitivityActiveXLabel = new System.Windows.Forms.Label(); this.SensitivityActiveYLabel = new System.Windows.Forms.Label(); this.RotationActiveLabel = new System.Windows.Forms.Label(); @@ -600,14 +600,14 @@ namespace grapher this.MouseLabel.TabIndex = 34; this.MouseLabel.Text = "Last (x, y): (x, y)"; // - // label1 + // ActiveValueTitle // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(249, 30); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(67, 13); - this.label1.TabIndex = 35; - this.label1.Text = "Active Value"; + this.ActiveValueTitle.AutoSize = true; + this.ActiveValueTitle.Location = new System.Drawing.Point(249, 30); + this.ActiveValueTitle.Name = "ActiveValueTitle"; + this.ActiveValueTitle.Size = new System.Drawing.Size(67, 13); + this.ActiveValueTitle.TabIndex = 35; + this.ActiveValueTitle.Text = "Active Value"; // // SensitivityActiveXLabel // @@ -734,7 +734,7 @@ namespace grapher this.Controls.Add(this.RotationActiveLabel); this.Controls.Add(this.SensitivityActiveYLabel); this.Controls.Add(this.SensitivityActiveXLabel); - this.Controls.Add(this.label1); + this.Controls.Add(this.ActiveValueTitle); this.Controls.Add(this.MouseLabel); this.Controls.Add(this.GainChartY); this.Controls.Add(this.VelocityChartY); @@ -832,7 +832,7 @@ namespace grapher private System.Windows.Forms.ToolStripMenuItem pollRateToolStripMenuItem; private System.Windows.Forms.ToolStripTextBox PollRateTextBox; private System.Windows.Forms.ToolStripMenuItem ScaleMenuItem; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label ActiveValueTitle; private System.Windows.Forms.Label SensitivityActiveXLabel; private System.Windows.Forms.Label SensitivityActiveYLabel; private System.Windows.Forms.Label RotationActiveLabel; diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 6e08683..01e7b20 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -10,12 +10,13 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; using grapher.Models.Calculations; +using grapher.Models.Options; namespace grapher { public enum accel_mode { - linear=1, classic, natural, logarithmic, sigmoid, power, noaccel + linear=1, classic, natural, logarithmic, sigmoid, power, naturalgain, sigmoidgain, noaccel } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] @@ -99,16 +100,76 @@ namespace grapher new CheckBox[] { sensXYLock, weightXYLock, capXYLock }); - var sensitivity = new OptionXY(sensitivityBoxX, sensitivityBoxY, sensXYLock, this, 1, sensitivityLabel, "Sensitivity", accelCharts); - var rotation = new Option(rotationBox, this, 0, rotationLabel, "Rotation"); - var weight = new OptionXY(weightBoxFirst, weightBoxSecond, weightXYLock, this, 1, weightLabel, "Weight", accelCharts); - var cap = new OptionXY(capBoxX, capBoxY, capXYLock, this, 0, capLabel, "Cap", accelCharts); - var offset = new Option(offsetBox, this, 0, offsetLabel, "Offset"); + var sensitivity = new OptionXY( + sensitivityBoxX, + sensitivityBoxY, + sensXYLock, + this, + 1, + sensitivityLabel, + new ActiveValueLabelXY( + new ActiveValueLabel(SensitivityActiveXLabel, ActiveValueTitle), + new ActiveValueLabel(SensitivityActiveYLabel, ActiveValueTitle)), + "Sensitivity", + accelCharts); + + var rotation = new Option( + rotationBox, + this, + 0, + rotationLabel, + new ActiveValueLabel(RotationActiveLabel, ActiveValueTitle), + "Rotation"); + + var weight = new OptionXY( + weightBoxFirst, + weightBoxSecond, + weightXYLock, + this, + 1, + weightLabel, + new ActiveValueLabelXY( + new ActiveValueLabel(WeightActiveXLabel, ActiveValueTitle), + new ActiveValueLabel(WeightActiveYLabel, ActiveValueTitle)), + "Weight", + accelCharts); + + var cap = new OptionXY( + capBoxX, + capBoxY, + capXYLock, + this, + 0, + capLabel, + new ActiveValueLabelXY( + new ActiveValueLabel(CapActiveXLabel, ActiveValueTitle), + new ActiveValueLabel(CapActiveYLabel, ActiveValueTitle)), + "Cap", + accelCharts); + + var offset = new Option( + offsetBox, + this, + 0, + offsetLabel, + new ActiveValueLabel(OffsetActiveLabel, ActiveValueTitle), + "Offset"); // The name and layout of these options is handled by AccelerationOptions object. - var acceleration = new Option(new Field(accelerationBox, this, 0), constantOneLabel); - var limitOrExponent = new Option(new Field(limitBox, this, 2), constantTwoLabel); - var midpoint = new Option(new Field(midpointBox, this, 0), constantThreeLabel); + var acceleration = new Option( + new Field(accelerationBox, this, 0), + constantOneLabel, + new ActiveValueLabel(AccelerationActiveLabel, ActiveValueTitle)); + + var limitOrExponent = new Option( + new Field(limitBox, this, 2), + constantTwoLabel, + new ActiveValueLabel(LimitExpActiveLabel, ActiveValueTitle)); + + var midpoint = new Option( + new Field(midpointBox, this, 0), + constantThreeLabel, + new ActiveValueLabel(MidpointActiveLabel, ActiveValueTitle)); var accelerationOptions = new AccelOptions( accelTypeDrop, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 2c27bf7..afc3def 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -102,6 +102,19 @@ namespace grapher { AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); + UpdateActiveValueLabels(); + } + + public void UpdateActiveValueLabels() + { + Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); + Rotation.SetActiveValue(ManagedAcceleration.Rotation); + Offset.SetActiveValue(ManagedAcceleration.Offset); + Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); + Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); + Weight.SetActiveValues(ManagedAcceleration.WeightX, ManagedAcceleration.WeightY); + LimitOrExponent.SetActiveValue(ManagedAcceleration.LimitExp); + Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); } private void OnScaleMenuItemClick(object sender, EventArgs e) diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 0346fb8..63ed281 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -52,9 +52,9 @@ namespace grapher.Models.Calculations data.Clear(); - Calculate(data.Combined, accel, accel.GetSensitivityX(), MagnitudesCombined); - Calculate(data.X, accel, accel.GetSensitivityX(), MagnitudesX); - Calculate(data.Y, accel, accel.GetSensitivityY(), MagnitudesY); + Calculate(data.Combined, accel, accel.SensitivityX, MagnitudesCombined); + Calculate(data.X, accel, accel.SensitivityX, MagnitudesX); + Calculate(data.Y, accel, accel.SensitivityY, MagnitudesY); } public static void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection magnitudeData) diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs new file mode 100644 index 0000000..ecafaba --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options +{ + public class ActiveValueLabel + { + public const string DefaultFormatString = "0.######"; + + public ActiveValueLabel(Label valueLabel, Label centeringLabel) + { + ValueLabel = valueLabel; + ValueLabel.ForeColor = Color.DarkGray; + ValueLabel.Left = centeringLabel.Left; + ValueLabel.Width = centeringLabel.Width; + ValueLabel.AutoSize = false; + ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + } + + public Label ValueLabel { get; } + + private int Left { get; } + + private int Width { get; } + + public void Hide() + { + ValueLabel.Hide(); + } + + public void Show() + { + ValueLabel.Show(); + } + + public void SetValue(double value) + { + ValueLabel.Text = value.ToString(DefaultFormatString); + } + } +} diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs new file mode 100644 index 0000000..b3b580f --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Options +{ + public class ActiveValueLabelXY + { + public const int ActiveLabelXYSeparation = 4; + + public ActiveValueLabelXY( + ActiveValueLabel x, + ActiveValueLabel y) + { + X = x; + Y = y; + Combined = false; + SetCombined(); + } + + public ActiveValueLabel X { get; } + + public ActiveValueLabel Y { get; } + + public bool Combined { get; private set; } + + public void SetValues(double x, double y) + { + X.SetValue(x); + Y.SetValue(y); + + if (x == y) + { + SetCombined(); + } + else + { + SetSeparate(); + } + } + + public void SetCombined() + { + if (!Combined) + { + Y.Hide(); + } + + Combined = true; + } + + public void SetSeparate() + { + if (Combined) + { + Y.Show(); + } + + Combined = false; + } + } +} diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 2ee7f6b..fedda08 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -30,13 +30,13 @@ namespace grapher EnableSensitivityCap(); } - ToolStripMenuItem SensitivityCapCheck { get; } + public ToolStripMenuItem SensitivityCapCheck { get; } - ToolStripMenuItem VelocityGainCapCheck { get; } + public ToolStripMenuItem VelocityGainCapCheck { get; } - OptionXY CapOption { get; } + public OptionXY CapOption { get; } - OptionXY WeightOption { get; } + public OptionXY WeightOption { get; } public double SensitivityCapX { get @@ -82,6 +82,18 @@ namespace grapher public bool IsSensitivityGain { get; private set; } + public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled) + { + if (capGainEnabled) + { + CapOption.SetActiveValues(gainCap, gainCap); + } + else + { + CapOption.SetActiveValues(sensCapX, sensCapY); + } + } + void OnSensitivityCapCheckClick(object sender, EventArgs e) { if (!SensitivityCapCheck.Checked) diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index eb5105e..bacd760 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,19 +10,42 @@ namespace grapher { public class Option { - public Option(Field field, Label label) + public Option( + Field field, + Label label, + ActiveValueLabel activeValueLabel) { Field = field; Label = label; + ActiveValueLabel = activeValueLabel; } - public Option(TextBox box, Form containingForm, double defaultData, Label label) - : this(new Field(box, containingForm, defaultData), label) + public Option( + TextBox box, + Form containingForm, + double defaultData, + Label label, + ActiveValueLabel activeValueLabel) + : this( + new Field(box, containingForm, defaultData), + label, + activeValueLabel) { } - public Option(TextBox box, Form containingForm, double defaultData, Label label, string startingName) - : this(box, containingForm, defaultData, label) + public Option( + TextBox box, + Form containingForm, + double defaultData, + Label label, + ActiveValueLabel activeValueLabel, + string startingName) + : this( + box, + containingForm, + defaultData, + label, + activeValueLabel) { SetName(startingName); } @@ -30,22 +54,36 @@ namespace grapher public Label Label { get; } + public ActiveValueLabel ActiveValueLabel { get; } + public void SetName(string name) { Label.Text = name; Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); } + public void SetActiveValue(double value) + { + ActiveValueLabel.SetValue(value); + } + public void Hide() { Field.Box.Hide(); Label.Hide(); + ActiveValueLabel.Hide(); } public void Show() { Field.Box.Show(); Label.Show(); + ActiveValueLabel.Show(); + } + + public void UpdateActiveValue(double value) + { + ActiveValueLabel.SetValue(value); } public void Show(string name) diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index 90a46d7..b22bb78 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,10 +10,11 @@ namespace grapher { public class OptionXY { - public OptionXY(FieldXY fields, Label label) + public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels) { Fields = fields; Label = label; + ActiveValueLabels = activeValueLabels; } public OptionXY( @@ -22,8 +24,9 @@ namespace grapher Form containingForm, double defaultData, Label label, - AccelCharts accelCharts) - : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label) + AccelCharts accelCharts, + ActiveValueLabelXY activeValueLabels) + : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label, activeValueLabels) { } @@ -34,6 +37,7 @@ namespace grapher Form containingForm, double defaultData, Label label, + ActiveValueLabelXY activeValueLabels, string startingName, AccelCharts accelCharts): this( @@ -43,7 +47,8 @@ namespace grapher containingForm, defaultData, label, - accelCharts) + accelCharts, + activeValueLabels) { SetName(startingName); } @@ -52,12 +57,19 @@ namespace grapher public Label Label { get; } + public ActiveValueLabelXY ActiveValueLabels { get; } + public void SetName(string name) { Label.Text = name; Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0)); } + public void SetActiveValues(double x, double y) + { + ActiveValueLabels.SetValues(x, y); + } + public void Hide() { Fields.Hide(); diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 2d9f4ab..64f5e3c 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -58,6 +58,8 @@ + + -- cgit v1.2.3 From 7dbeae9d4cf108e78072b356d832123f12e42a90 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 14:22:14 -0700 Subject: Add accel type to active values and tweak color --- grapher/Form1.Designer.cs | 40 +++++++-------- grapher/Form1.cs | 7 ++- grapher/Models/AccelGUI.cs | 1 + grapher/Models/Options/AccelOptions.cs | 13 ++++- grapher/Models/Options/ActiveValueLabel.cs | 73 +++++++++++++++++++++++++--- grapher/Models/Options/ActiveValueLabelXY.cs | 22 ++++++++- grapher/Models/Options/CapOptions.cs | 10 +++- 7 files changed, 136 insertions(+), 30 deletions(-) (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index bb6b9ee..d9cec5c 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -129,7 +129,7 @@ namespace grapher this.AccelerationChart.ChartAreas.Add(chartArea1); legend1.Name = "Legend1"; this.AccelerationChart.Legends.Add(legend1); - this.AccelerationChart.Location = new System.Drawing.Point(322, 0); + this.AccelerationChart.Location = new System.Drawing.Point(333, 0); this.AccelerationChart.Name = "AccelerationChart"; series1.ChartArea = "ChartArea1"; series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -370,7 +370,7 @@ namespace grapher this.VelocityChart.ChartAreas.Add(chartArea2); legend2.Name = "Legend1"; this.VelocityChart.Legends.Add(legend2); - this.VelocityChart.Location = new System.Drawing.Point(322, 334); + this.VelocityChart.Location = new System.Drawing.Point(333, 334); this.VelocityChart.Name = "VelocityChart"; series3.ChartArea = "ChartArea1"; series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -395,7 +395,7 @@ namespace grapher this.GainChart.ChartAreas.Add(chartArea3); legend3.Name = "Legend1"; this.GainChart.Legends.Add(legend3); - this.GainChart.Location = new System.Drawing.Point(322, 647); + this.GainChart.Location = new System.Drawing.Point(333, 647); this.GainChart.Name = "GainChart"; series5.ChartArea = "ChartArea1"; series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -420,7 +420,7 @@ namespace grapher this.advancedToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1773, 24); + this.menuStrip1.Size = new System.Drawing.Size(1786, 24); this.menuStrip1.TabIndex = 30; this.menuStrip1.Text = "menuStrip1"; // @@ -524,7 +524,7 @@ namespace grapher this.AccelerationChartY.ChartAreas.Add(chartArea4); legend4.Name = "Legend1"; this.AccelerationChartY.Legends.Add(legend4); - this.AccelerationChartY.Location = new System.Drawing.Point(1051, 0); + this.AccelerationChartY.Location = new System.Drawing.Point(1062, 0); this.AccelerationChartY.Name = "AccelerationChartY"; series7.ChartArea = "ChartArea1"; series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -549,7 +549,7 @@ namespace grapher this.VelocityChartY.ChartAreas.Add(chartArea5); legend5.Name = "Legend1"; this.VelocityChartY.Legends.Add(legend5); - this.VelocityChartY.Location = new System.Drawing.Point(1051, 334); + this.VelocityChartY.Location = new System.Drawing.Point(1062, 334); this.VelocityChartY.Name = "VelocityChartY"; series9.ChartArea = "ChartArea1"; series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -574,7 +574,7 @@ namespace grapher this.GainChartY.ChartAreas.Add(chartArea6); legend6.Name = "Legend1"; this.GainChartY.Legends.Add(legend6); - this.GainChartY.Location = new System.Drawing.Point(1051, 647); + this.GainChartY.Location = new System.Drawing.Point(1062, 647); this.GainChartY.Name = "GainChartY"; series11.ChartArea = "ChartArea1"; series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; @@ -603,7 +603,7 @@ namespace grapher // ActiveValueTitle // this.ActiveValueTitle.AutoSize = true; - this.ActiveValueTitle.Location = new System.Drawing.Point(249, 30); + this.ActiveValueTitle.Location = new System.Drawing.Point(248, 30); this.ActiveValueTitle.Name = "ActiveValueTitle"; this.ActiveValueTitle.Size = new System.Drawing.Size(67, 13); this.ActiveValueTitle.TabIndex = 35; @@ -612,7 +612,7 @@ namespace grapher // SensitivityActiveXLabel // this.SensitivityActiveXLabel.AutoSize = true; - this.SensitivityActiveXLabel.Location = new System.Drawing.Point(259, 49); + this.SensitivityActiveXLabel.Location = new System.Drawing.Point(258, 49); this.SensitivityActiveXLabel.Name = "SensitivityActiveXLabel"; this.SensitivityActiveXLabel.Size = new System.Drawing.Size(14, 13); this.SensitivityActiveXLabel.TabIndex = 36; @@ -621,7 +621,7 @@ namespace grapher // SensitivityActiveYLabel // this.SensitivityActiveYLabel.AutoSize = true; - this.SensitivityActiveYLabel.Location = new System.Drawing.Point(279, 49); + this.SensitivityActiveYLabel.Location = new System.Drawing.Point(286, 50); this.SensitivityActiveYLabel.Name = "SensitivityActiveYLabel"; this.SensitivityActiveYLabel.Size = new System.Drawing.Size(14, 13); this.SensitivityActiveYLabel.TabIndex = 37; @@ -630,7 +630,7 @@ namespace grapher // RotationActiveLabel // this.RotationActiveLabel.AutoSize = true; - this.RotationActiveLabel.Location = new System.Drawing.Point(269, 75); + this.RotationActiveLabel.Location = new System.Drawing.Point(268, 75); this.RotationActiveLabel.Name = "RotationActiveLabel"; this.RotationActiveLabel.Size = new System.Drawing.Size(13, 13); this.RotationActiveLabel.TabIndex = 38; @@ -639,7 +639,7 @@ namespace grapher // AccelTypeActiveLabel // this.AccelTypeActiveLabel.AutoSize = true; - this.AccelTypeActiveLabel.Location = new System.Drawing.Point(252, 98); + this.AccelTypeActiveLabel.Location = new System.Drawing.Point(258, 98); this.AccelTypeActiveLabel.Name = "AccelTypeActiveLabel"; this.AccelTypeActiveLabel.Size = new System.Drawing.Size(41, 13); this.AccelTypeActiveLabel.TabIndex = 39; @@ -648,7 +648,7 @@ namespace grapher // AccelerationActiveLabel // this.AccelerationActiveLabel.AutoSize = true; - this.AccelerationActiveLabel.Location = new System.Drawing.Point(269, 128); + this.AccelerationActiveLabel.Location = new System.Drawing.Point(268, 128); this.AccelerationActiveLabel.Name = "AccelerationActiveLabel"; this.AccelerationActiveLabel.Size = new System.Drawing.Size(13, 13); this.AccelerationActiveLabel.TabIndex = 40; @@ -657,7 +657,7 @@ namespace grapher // CapActiveXLabel // this.CapActiveXLabel.AutoSize = true; - this.CapActiveXLabel.Location = new System.Drawing.Point(260, 151); + this.CapActiveXLabel.Location = new System.Drawing.Point(259, 151); this.CapActiveXLabel.Name = "CapActiveXLabel"; this.CapActiveXLabel.Size = new System.Drawing.Size(13, 13); this.CapActiveXLabel.TabIndex = 41; @@ -675,7 +675,7 @@ namespace grapher // WeightActiveYLabel // this.WeightActiveYLabel.AutoSize = true; - this.WeightActiveYLabel.Location = new System.Drawing.Point(278, 180); + this.WeightActiveYLabel.Location = new System.Drawing.Point(286, 180); this.WeightActiveYLabel.Name = "WeightActiveYLabel"; this.WeightActiveYLabel.Size = new System.Drawing.Size(13, 13); this.WeightActiveYLabel.TabIndex = 43; @@ -684,7 +684,7 @@ namespace grapher // CapActiveYLabel // this.CapActiveYLabel.AutoSize = true; - this.CapActiveYLabel.Location = new System.Drawing.Point(278, 151); + this.CapActiveYLabel.Location = new System.Drawing.Point(286, 151); this.CapActiveYLabel.Name = "CapActiveYLabel"; this.CapActiveYLabel.Size = new System.Drawing.Size(13, 13); this.CapActiveYLabel.TabIndex = 44; @@ -693,7 +693,7 @@ namespace grapher // OffsetActiveLabel // this.OffsetActiveLabel.AutoSize = true; - this.OffsetActiveLabel.Location = new System.Drawing.Point(269, 206); + this.OffsetActiveLabel.Location = new System.Drawing.Point(268, 206); this.OffsetActiveLabel.Name = "OffsetActiveLabel"; this.OffsetActiveLabel.Size = new System.Drawing.Size(13, 13); this.OffsetActiveLabel.TabIndex = 45; @@ -702,7 +702,7 @@ namespace grapher // LimitExpActiveLabel // this.LimitExpActiveLabel.AutoSize = true; - this.LimitExpActiveLabel.Location = new System.Drawing.Point(269, 232); + this.LimitExpActiveLabel.Location = new System.Drawing.Point(268, 232); this.LimitExpActiveLabel.Name = "LimitExpActiveLabel"; this.LimitExpActiveLabel.Size = new System.Drawing.Size(13, 13); this.LimitExpActiveLabel.TabIndex = 46; @@ -711,7 +711,7 @@ namespace grapher // MidpointActiveLabel // this.MidpointActiveLabel.AutoSize = true; - this.MidpointActiveLabel.Location = new System.Drawing.Point(269, 255); + this.MidpointActiveLabel.Location = new System.Drawing.Point(268, 255); this.MidpointActiveLabel.Name = "MidpointActiveLabel"; this.MidpointActiveLabel.Size = new System.Drawing.Size(13, 13); this.MidpointActiveLabel.TabIndex = 47; @@ -721,7 +721,7 @@ namespace grapher // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1773, 958); + this.ClientSize = new System.Drawing.Size(1786, 958); this.Controls.Add(this.MidpointActiveLabel); this.Controls.Add(this.LimitExpActiveLabel); this.Controls.Add(this.OffsetActiveLabel); diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 01e7b20..1e38809 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -99,6 +99,10 @@ namespace grapher showVelocityGainToolStripMenuItem, new CheckBox[] { sensXYLock, weightXYLock, capXYLock }); + ActiveValueTitle.AutoSize = false; + ActiveValueTitle.Left = LockXYLabel.Left + LockXYLabel.Width; + ActiveValueTitle.Width = AccelerationChart.Left - ActiveValueTitle.Left; + ActiveValueTitle.TextAlign = ContentAlignment.MiddleCenter; var sensitivity = new OptionXY( sensitivityBoxX, @@ -185,7 +189,8 @@ namespace grapher weight, cap, }, - writeButton); + writeButton, + new ActiveValueLabel(AccelTypeActiveLabel, ActiveValueTitle)); var capOptions = new CapOptions( sensitivityToolStripMenuItem, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index afc3def..e345743 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -109,6 +109,7 @@ namespace grapher { Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); Rotation.SetActiveValue(ManagedAcceleration.Rotation); + AccelerationOptions.SetActiveValue(ManagedAcceleration.Type); Offset.SetActiveValue(ManagedAcceleration.Offset); Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 8da873f..cd7c4e5 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -1,4 +1,5 @@ using grapher.Layouts; +using grapher.Models.Options; using System; using System.Collections.Generic; using System.Linq; @@ -31,7 +32,8 @@ namespace grapher ComboBox accelDropdown, Option[] options, OptionXY[] optionsXY, - Button writeButton) + Button writeButton, + ActiveValueLabel activeValueLabel) { AccelDropdown = accelDropdown; AccelDropdown.Items.Clear(); @@ -51,6 +53,7 @@ namespace grapher Options = options; OptionsXY = optionsXY; WriteButton = writeButton; + ActiveValueLabel = activeValueLabel; Layout("Default"); } @@ -61,10 +64,18 @@ namespace grapher public int AccelerationIndex { get; private set; } + public ActiveValueLabel ActiveValueLabel { get; } + public Option[] Options { get; } public OptionXY[] OptionsXY { get; } + public void SetActiveValue(int index) + { + var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; + ActiveValueLabel.SetValue(name); + } + private void OnIndexChanged(object sender, EventArgs e) { var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index ecafaba..138775a 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -11,22 +11,73 @@ namespace grapher.Models.Options public class ActiveValueLabel { public const string DefaultFormatString = "0.######"; + public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); + + private string _prefix; + private string _value; public ActiveValueLabel(Label valueLabel, Label centeringLabel) { ValueLabel = valueLabel; - ValueLabel.ForeColor = Color.DarkGray; - ValueLabel.Left = centeringLabel.Left; - ValueLabel.Width = centeringLabel.Width; + ValueLabel.ForeColor = ActiveValueFontColor; + Left = centeringLabel.Left; + Width = centeringLabel.Width; ValueLabel.AutoSize = false; ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + + FormatString = DefaultFormatString; + Prefix = string.Empty; } public Label ValueLabel { get; } - private int Left { get; } + public string FormatString { get; set; } + + public string Prefix + { + get { return _prefix; } + set + { + _prefix = value; + RefreshText(); + } + } + + private string Value + { + get { return _value; } + set + { + _value = value; + RefreshText(); + } + } - private int Width { get; } + public int Left + { + get + { + return ValueLabel.Left; + } + + set + { + ValueLabel.Left = value; + } + } + + public int Width + { + get + { + return ValueLabel.Width; + } + + set + { + ValueLabel.Width = value; + } + } public void Hide() { @@ -40,7 +91,17 @@ namespace grapher.Models.Options public void SetValue(double value) { - ValueLabel.Text = value.ToString(DefaultFormatString); + SetValue(value.ToString(FormatString)); + } + + public void SetValue(string value) + { + Value = value; + } + + public void RefreshText() + { + ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}"; } } } diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index b3b580f..12506e9 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -8,7 +8,8 @@ namespace grapher.Models.Options { public class ActiveValueLabelXY { - public const int ActiveLabelXYSeparation = 4; + public const int ActiveLabelXYSeparation = 2; + public const string ShortenedFormatString = "0.###"; public ActiveValueLabelXY( ActiveValueLabel x, @@ -16,6 +17,14 @@ namespace grapher.Models.Options { X = x; Y = y; + + FullWidth = x.Width; + ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2; + + Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation; + Y.Width = ShortenedWidth; + Y.FormatString = ShortenedFormatString; + Combined = false; SetCombined(); } @@ -26,6 +35,10 @@ namespace grapher.Models.Options public bool Combined { get; private set; } + private int FullWidth { get; } + + private int ShortenedWidth { get; } + public void SetValues(double x, double y) { X.SetValue(x); @@ -45,6 +58,9 @@ namespace grapher.Models.Options { if (!Combined) { + X.FormatString = ActiveValueLabel.DefaultFormatString; + X.Width = FullWidth; + X.Prefix = string.Empty; Y.Hide(); } @@ -55,6 +71,10 @@ namespace grapher.Models.Options { if (Combined) { + X.FormatString = ShortenedFormatString; + X.Width = ShortenedWidth; + X.Prefix = "X"; + Y.Prefix = "Y"; Y.Show(); } diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index fedda08..493561a 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,6 +10,9 @@ namespace grapher { public class CapOptions { + + public const string GainCapFormatString = "0.##"; + public CapOptions( ToolStripMenuItem sensitivityCapCheck, ToolStripMenuItem velocityGainCapCheck, @@ -86,10 +90,14 @@ namespace grapher { if (capGainEnabled) { + CapOption.ActiveValueLabels.X.FormatString = GainCapFormatString; + CapOption.ActiveValueLabels.X.Prefix = "Gain"; CapOption.SetActiveValues(gainCap, gainCap); } else { + CapOption.ActiveValueLabels.X.FormatString = ActiveValueLabel.DefaultFormatString; + CapOption.ActiveValueLabels.X.Prefix = string.Empty; CapOption.SetActiveValues(sensCapX, sensCapY); } } -- cgit v1.2.3 From 55b739c50db217e6a61678c1eb1412e8884e3462 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 15:46:04 -0700 Subject: Serialization mostly working --- grapher/Form1.Designer.cs | 22 +++++++- grapher/Form1.cs | 3 +- grapher/Models/AccelGUI.cs | 27 ++++++++- grapher/Models/Serialized/GUISettings.cs | 51 +++++++++++++++++ grapher/Models/Serialized/RawAccelSettings.cs | 81 +++++++++++++++++++++++++++ grapher/grapher.csproj | 6 ++ grapher/packages.config | 4 ++ 7 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 grapher/Models/Serialized/GUISettings.cs create mode 100644 grapher/Models/Serialized/RawAccelSettings.cs create mode 100644 grapher/packages.config (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index d9cec5c..7a5eb43 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -112,6 +112,8 @@ namespace grapher this.OffsetActiveLabel = new System.Windows.Forms.Label(); this.LimitExpActiveLabel = new System.Windows.Forms.Label(); this.MidpointActiveLabel = new System.Windows.Forms.Label(); + this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); @@ -417,7 +419,8 @@ namespace grapher this.menuStrip1.BackColor = System.Drawing.SystemColors.ControlLight; this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.graphsToolStripMenuItem, - this.advancedToolStripMenuItem}); + this.advancedToolStripMenuItem, + this.startupToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1786, 24); @@ -717,6 +720,21 @@ namespace grapher this.MidpointActiveLabel.TabIndex = 47; this.MidpointActiveLabel.Text = "0"; // + // startupToolStripMenuItem + // + this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AutoWriteMenuItem}); + this.startupToolStripMenuItem.Name = "startupToolStripMenuItem"; + this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20); + this.startupToolStripMenuItem.Text = "Startup"; + // + // AutoWriteMenuItem + // + this.AutoWriteMenuItem.CheckOnClick = true; + this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; + this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22); + this.AutoWriteMenuItem.Text = "Apply Settings File on Startup"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -845,6 +863,8 @@ namespace grapher private System.Windows.Forms.Label OffsetActiveLabel; private System.Windows.Forms.Label LimitExpActiveLabel; private System.Windows.Forms.Label MidpointActiveLabel; + private System.Windows.Forms.ToolStripMenuItem startupToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 1e38809..ef06527 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -218,7 +218,8 @@ namespace grapher midpoint, writeButton, MouseLabel, - ScaleMenuItem); + ScaleMenuItem, + AutoWriteMenuItem); } #endregion Constructor diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e345743..a0a76c8 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -1,5 +1,6 @@ using grapher.Models.Calculations; using grapher.Models.Mouse; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -32,7 +33,8 @@ namespace grapher Option midpoint, Button writeButton, Label mouseMoveLabel, - ToolStripMenuItem scaleMenuItem) + ToolStripMenuItem scaleMenuItem, + ToolStripMenuItem autoWriteMenuItem) { AccelForm = accelForm; AccelCalculator = accelCalculator; @@ -51,6 +53,7 @@ namespace grapher ScaleMenuItem = scaleMenuItem; ManagedAcceleration.ReadFromDriver(); + SavedSettings = StartupLoad(AccelCalculator.DPI, AccelCalculator.PollRate, autoWriteMenuItem); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); @@ -64,6 +67,8 @@ namespace grapher public RawAcceleration AccelForm { get; } + public RawAccelSettings SavedSettings { get; } + public AccelCalculator AccelCalculator { get; } public AccelCharts AccelCharts { get; } @@ -103,6 +108,7 @@ namespace grapher AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); UpdateActiveValueLabels(); + SavedSettings.Save(); } public void UpdateActiveValueLabels() @@ -118,6 +124,25 @@ namespace grapher Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); } + private RawAccelSettings StartupLoad(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) + { + if (RawAccelSettings.Exists()) + { + var settings = RawAccelSettings.Load(); + settings.GUISettings.BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + return settings; + } + else + { + return new RawAccelSettings( + ManagedAcceleration, + new GUISettings( + AccelCalculator.DPI, + AccelCalculator.PollRate, + autoWriteMenuItem)); + } + } + private void OnScaleMenuItemClick(object sender, EventArgs e) { UpdateGraph(); diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs new file mode 100644 index 0000000..8c182ae --- /dev/null +++ b/grapher/Models/Serialized/GUISettings.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + [Serializable] + public class GUISettings + { + public GUISettings( + Field dpiField, + Field pollRateField, + ToolStripMenuItem autoWriteMenuItem) + { + BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + } + + public bool AutoWriteToDriverOnStartup { get; set; } + + public int DPI { get; set; } + + public int PollRate { get; set; } + + [field: NonSerialized] + private Field DpiField { get; set; } + + [field: NonSerialized] + private Field PollRateField { get; set; } + + [field: NonSerialized] + private ToolStripMenuItem AutoWriteMenuItem { get; set; } + + public void UpdateSettings() + { + DPI = (int)DpiField.Data; + PollRate = (int)PollRateField.Data; + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked; + } + + public void BindToGUI(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) + { + DpiField = dpiField; + PollRateField = pollRateField; + AutoWriteMenuItem = autoWriteMenuItem; + } + } +} diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs new file mode 100644 index 0000000..d8896b6 --- /dev/null +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -0,0 +1,81 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + [Serializable] + public class RawAccelSettings + { + public const string DefaultSettingsFile = @".\settings.json"; + + public RawAccelSettings( + ManagedAccel managedAccel, + GUISettings guiSettings) + { + ManagedAccel = managedAccel; + GUISettings = guiSettings; + } + + public ManagedAccel ManagedAccel { get; set; } + + public GUISettings GUISettings { get; set; } + + public static RawAccelSettings Load() + { + return Load(DefaultSettingsFile); + } + + public static RawAccelSettings Load(string file) + { + if (!Exists(file)) + { + throw new Exception($"Settings file does not exist at {file}"); + } + + object deserializedObject; + try + { + deserializedObject = JsonConvert.DeserializeObject(File.ReadAllText(file)); + } + catch + { + throw new Exception($"Settings file at {file} does not contain valid JSON."); + } + + RawAccelSettings deserializedSettings = (RawAccelSettings)deserializedObject; + + if (deserializedSettings == null) + { + throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings."); + } + + return deserializedSettings; + } + + public static bool Exists() + { + return Exists(DefaultSettingsFile); + } + + public static bool Exists(string file) + { + return File.Exists(file); + } + + public void Save() + { + Save(DefaultSettingsFile); + } + + public void Save(string file) + { + File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented)); + } + } +} diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 64f5e3c..54b73c8 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -33,6 +33,9 @@ 4 + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + @@ -81,6 +84,8 @@ + + @@ -95,6 +100,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/grapher/packages.config b/grapher/packages.config new file mode 100644 index 0000000..a9de8b5 --- /dev/null +++ b/grapher/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.2.3 From b874058d82a60a39163e91a26f370ff308b8af32 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sat, 22 Aug 2020 02:46:45 -0700 Subject: Saving and loading fully works --- grapher/Form1.Designer.cs | 36 ++++---- grapher/Form1.cs | 28 +++--- grapher/Models/AccelGUI.cs | 71 +++++++-------- grapher/Models/Serialized/GUISettings.cs | 40 +++------ grapher/Models/Serialized/ModifierArgs.cs | 75 ++++++++++++++++ grapher/Models/Serialized/RawAccelSettings.cs | 31 ++++--- grapher/Models/Serialized/SettingsManager.cs | 123 ++++++++++++++++++++++++++ grapher/grapher.csproj | 2 + 8 files changed, 291 insertions(+), 115 deletions(-) create mode 100644 grapher/Models/Serialized/ModifierArgs.cs create mode 100644 grapher/Models/Serialized/SettingsManager.cs (limited to 'grapher') diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 7a5eb43..ac438a1 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -95,6 +95,8 @@ namespace grapher this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.velocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); @@ -112,8 +114,6 @@ namespace grapher this.OffsetActiveLabel = new System.Windows.Forms.Label(); this.LimitExpActiveLabel = new System.Windows.Forms.Label(); this.MidpointActiveLabel = new System.Windows.Forms.Label(); - this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); @@ -519,6 +519,23 @@ namespace grapher this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(142, 22); this.velocityGainToolStripMenuItem.Text = "Velocity Gain"; // + // startupToolStripMenuItem + // + this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AutoWriteMenuItem}); + this.startupToolStripMenuItem.Name = "startupToolStripMenuItem"; + this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20); + this.startupToolStripMenuItem.Text = "Startup"; + // + // AutoWriteMenuItem + // + this.AutoWriteMenuItem.Checked = true; + this.AutoWriteMenuItem.CheckOnClick = true; + this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; + this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22); + this.AutoWriteMenuItem.Text = "Apply Settings File on Startup"; + // // AccelerationChartY // chartArea4.AxisX.Title = "Speed (counts/ms)"; @@ -720,21 +737,6 @@ namespace grapher this.MidpointActiveLabel.TabIndex = 47; this.MidpointActiveLabel.Text = "0"; // - // startupToolStripMenuItem - // - this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.AutoWriteMenuItem}); - this.startupToolStripMenuItem.Name = "startupToolStripMenuItem"; - this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20); - this.startupToolStripMenuItem.Text = "Startup"; - // - // AutoWriteMenuItem - // - this.AutoWriteMenuItem.CheckOnClick = true; - this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; - this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22); - this.AutoWriteMenuItem.Text = "Apply Settings File on Startup"; - // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/grapher/Form1.cs b/grapher/Form1.cs index ef06527..d6f7990 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -11,6 +11,7 @@ using System.Windows.Forms; using System.Runtime.InteropServices; using grapher.Models.Calculations; using grapher.Models.Options; +using grapher.Models.Serialized; namespace grapher { @@ -91,6 +92,7 @@ namespace grapher Marshal.FreeHGlobal(args_ptr); + var accelCharts = new AccelCharts( this, new ChartXY(AccelerationChart, AccelerationChartY), @@ -198,15 +200,21 @@ namespace grapher cap, weight); - AccelCalculator accelCalculator = new AccelCalculator( + var accelCalculator = new AccelCalculator( new Field(DPITextBox.TextBox, this, AccelCalculator.DefaultDPI), new Field(PollRateTextBox.TextBox, this, AccelCalculator.DefaultPollRate)); + var settings = new SettingsManager( + managedAcceleration, + accelCalculator.DPI, + accelCalculator.PollRate, + AutoWriteMenuItem); + AccelGUI = new AccelGUI( this, accelCalculator, accelCharts, - managedAcceleration, + settings, accelerationOptions, sensitivity, rotation, @@ -249,21 +257,7 @@ namespace grapher private void writeButton_Click(object sender, EventArgs e) { - AccelGUI.ManagedAcceleration.UpdateAccel( - AccelGUI.AccelerationOptions.AccelerationIndex, - AccelGUI.Rotation.Field.Data, - AccelGUI.Sensitivity.Fields.X, - AccelGUI.Sensitivity.Fields.Y, - AccelGUI.Weight.Fields.X, - AccelGUI.Weight.Fields.Y, - AccelGUI.Cap.SensitivityCapX, - AccelGUI.Cap.SensitivityCapY, - AccelGUI.Offset.Field.Data, - AccelGUI.Acceleration.Field.Data, - AccelGUI.LimitOrExponent.Field.Data, - AccelGUI.Midpoint.Field.Data, - AccelGUI.Cap.VelocityGainCap); - AccelGUI.UpdateGraph(); + AccelGUI.UpdateActiveSettingsFromFields(); } #endregion Methods diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index a0a76c8..e0dcc03 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -21,7 +21,7 @@ namespace grapher RawAcceleration accelForm, AccelCalculator accelCalculator, AccelCharts accelCharts, - ManagedAccel managedAccel, + SettingsManager settings, AccelOptions accelOptions, OptionXY sensitivity, Option rotation, @@ -39,7 +39,6 @@ namespace grapher AccelForm = accelForm; AccelCalculator = accelCalculator; AccelCharts = accelCharts; - ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; Sensitivity = sensitivity; Rotation = rotation; @@ -51,9 +50,8 @@ namespace grapher Midpoint = midpoint; WriteButton = writeButton; ScaleMenuItem = scaleMenuItem; - - ManagedAcceleration.ReadFromDriver(); - SavedSettings = StartupLoad(AccelCalculator.DPI, AccelCalculator.PollRate, autoWriteMenuItem); + Settings = settings; + Settings.Startup(); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); @@ -67,13 +65,11 @@ namespace grapher public RawAcceleration AccelForm { get; } - public RawAccelSettings SavedSettings { get; } - public AccelCalculator AccelCalculator { get; } public AccelCharts AccelCharts { get; } - public ManagedAccel ManagedAcceleration { get; } + public SettingsManager Settings { get; } public AccelOptions AccelerationOptions { get; } @@ -103,44 +99,43 @@ namespace grapher #region methods + public void UpdateActiveSettingsFromFields() + { + Settings.UpdateActiveSettings( + AccelerationOptions.AccelerationIndex, + Rotation.Field.Data, + Sensitivity.Fields.X, + Sensitivity.Fields.Y, + Weight.Fields.X, + Weight.Fields.Y, + Cap.SensitivityCapX, + Cap.SensitivityCapY, + Offset.Field.Data, + Acceleration.Field.Data, + LimitOrExponent.Field.Data, + Midpoint.Field.Data, + Cap.VelocityGainCap); + UpdateGraph(); + } + public void UpdateGraph() { - AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); + AccelCalculator.Calculate(AccelCharts.AccelData, Settings.ActiveAccel); AccelCharts.Bind(); UpdateActiveValueLabels(); - SavedSettings.Save(); } public void UpdateActiveValueLabels() { - Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); - Rotation.SetActiveValue(ManagedAcceleration.Rotation); - AccelerationOptions.SetActiveValue(ManagedAcceleration.Type); - Offset.SetActiveValue(ManagedAcceleration.Offset); - Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); - Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); - Weight.SetActiveValues(ManagedAcceleration.WeightX, ManagedAcceleration.WeightY); - LimitOrExponent.SetActiveValue(ManagedAcceleration.LimitExp); - Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); - } - - private RawAccelSettings StartupLoad(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) - { - if (RawAccelSettings.Exists()) - { - var settings = RawAccelSettings.Load(); - settings.GUISettings.BindToGUI(dpiField, pollRateField, autoWriteMenuItem); - return settings; - } - else - { - return new RawAccelSettings( - ManagedAcceleration, - new GUISettings( - AccelCalculator.DPI, - AccelCalculator.PollRate, - autoWriteMenuItem)); - } + Sensitivity.SetActiveValues(Settings.ActiveAccel.SensitivityX, Settings.ActiveAccel.SensitivityY); + Rotation.SetActiveValue(Settings.ActiveAccel.Rotation); + AccelerationOptions.SetActiveValue(Settings.ActiveAccel.Type); + Offset.SetActiveValue(Settings.ActiveAccel.Offset); + Acceleration.SetActiveValue(Settings.ActiveAccel.Acceleration); + Cap.SetActiveValues(Settings.ActiveAccel.GainCap, Settings.ActiveAccel.CapX, Settings.ActiveAccel.CapY, Settings.ActiveAccel.GainCapEnabled); + Weight.SetActiveValues(Settings.ActiveAccel.WeightX, Settings.ActiveAccel.WeightY); + LimitOrExponent.SetActiveValue(Settings.ActiveAccel.LimitExp); + Midpoint.SetActiveValue(Settings.ActiveAccel.Midpoint); } private void OnScaleMenuItemClick(object sender, EventArgs e) diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs index 8c182ae..7c8e9a4 100644 --- a/grapher/Models/Serialized/GUISettings.cs +++ b/grapher/Models/Serialized/GUISettings.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -11,41 +12,22 @@ namespace grapher.Models.Serialized [Serializable] public class GUISettings { - public GUISettings( - Field dpiField, - Field pollRateField, - ToolStripMenuItem autoWriteMenuItem) + public GUISettings() {} + + public GUISettings(bool autoWrite, int dpi, int pollRate) { - BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + AutoWriteToDriverOnStartup = autoWrite; + DPI = dpi; + PollRate = pollRate; } + [JsonProperty(Order = 1)] public bool AutoWriteToDriverOnStartup { get; set; } + [JsonProperty(Order = 2)] public int DPI { get; set; } + [JsonProperty(Order = 3)] public int PollRate { get; set; } - - [field: NonSerialized] - private Field DpiField { get; set; } - - [field: NonSerialized] - private Field PollRateField { get; set; } - - [field: NonSerialized] - private ToolStripMenuItem AutoWriteMenuItem { get; set; } - - public void UpdateSettings() - { - DPI = (int)DpiField.Data; - PollRate = (int)PollRateField.Data; - AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked; - } - - public void BindToGUI(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) - { - DpiField = dpiField; - PollRateField = pollRateField; - AutoWriteMenuItem = autoWriteMenuItem; - } } } diff --git a/grapher/Models/Serialized/ModifierArgs.cs b/grapher/Models/Serialized/ModifierArgs.cs new file mode 100644 index 0000000..206a3c9 --- /dev/null +++ b/grapher/Models/Serialized/ModifierArgs.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Serialized +{ + public enum accel_mode + { + linear=1, classic, natural, logarithmic, sigmoid, power, naturalgain, sigmoidgain, noaccel + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct vec2d + { + public double x; + public double y; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct accel_args + { + public double offset; + public double accel; + public double limit; + public double exponent; + public double midpoint; + public double power_scale; + public double gain_cap; + public vec2d weight; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct accel_fn_args + { + public accel_args acc_args; + public int accel_mode; + public double time_min; + public vec2d cap; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct modifier_args + { + public double degrees; + public vec2d sens; + public accel_fn_args acc_fn_args; + + public modifier_args(ManagedAccel managedAccel) + { + degrees = managedAccel.Rotation; + sens.x = managedAccel.SensitivityX; + sens.y = managedAccel.SensitivityY; + acc_fn_args.accel_mode = managedAccel.Type; + acc_fn_args.time_min = managedAccel.MinimumTime; + acc_fn_args.cap.x = managedAccel.CapX; + acc_fn_args.cap.y = managedAccel.CapY; + acc_fn_args.acc_args.accel = managedAccel.Acceleration; + acc_fn_args.acc_args.exponent = managedAccel.LimitExp; + acc_fn_args.acc_args.gain_cap = managedAccel.GainCap; + acc_fn_args.acc_args.limit = managedAccel.LimitExp; + acc_fn_args.acc_args.midpoint = managedAccel.Midpoint; + acc_fn_args.acc_args.offset = managedAccel.Offset; + acc_fn_args.acc_args.power_scale = managedAccel.PowerScale; + acc_fn_args.acc_args.weight.x = managedAccel.WeightX; + acc_fn_args.acc_args.weight.y = managedAccel.WeightY; + } + } +} diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index d8896b6..21a7f0c 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,20 +13,29 @@ namespace grapher.Models.Serialized [Serializable] public class RawAccelSettings { - public const string DefaultSettingsFile = @".\settings.json"; + public const string DefaultSettingsFileName = @"settings.json"; + public static readonly string ExecutingDirectory = AppDomain.CurrentDomain.BaseDirectory; + public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, DefaultSettingsFileName); + public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings + { + MissingMemberHandling = MissingMemberHandling.Error, + }; + + public RawAccelSettings() { } public RawAccelSettings( ManagedAccel managedAccel, GUISettings guiSettings) { - ManagedAccel = managedAccel; + AccelerationSettings = new modifier_args(managedAccel); GUISettings = guiSettings; } - public ManagedAccel ManagedAccel { get; set; } public GUISettings GUISettings { get; set; } + public modifier_args AccelerationSettings { get; set; } + public static RawAccelSettings Load() { return Load(DefaultSettingsFile); @@ -38,21 +48,14 @@ namespace grapher.Models.Serialized throw new Exception($"Settings file does not exist at {file}"); } - object deserializedObject; + RawAccelSettings deserializedSettings; try { - deserializedObject = JsonConvert.DeserializeObject(File.ReadAllText(file)); + deserializedSettings = JsonConvert.DeserializeObject(File.ReadAllText(file), SerializerSettings); } - catch - { - throw new Exception($"Settings file at {file} does not contain valid JSON."); - } - - RawAccelSettings deserializedSettings = (RawAccelSettings)deserializedObject; - - if (deserializedSettings == null) + catch(Exception e) { - throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings."); + throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings.", e); } return deserializedSettings; diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs new file mode 100644 index 0000000..848606d --- /dev/null +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + public class SettingsManager + { + public SettingsManager( + ManagedAccel activeAccel, + Field dpiField, + Field pollRateField, + ToolStripMenuItem autoWrite) + { + ActiveAccel = activeAccel; + DpiField = dpiField; + PollRateField = pollRateField; + AutoWriteMenuItem = autoWrite; + } + + public ManagedAccel ActiveAccel { get; } + + public RawAccelSettings RawAccelSettings { get; private set; } + + private Field DpiField { get; set; } + + private Field PollRateField { get; set; } + + private ToolStripMenuItem AutoWriteMenuItem { get; set; } + + public void UpdateActiveSettings( + int mode, + double degrees, + double sensitivityX, + double sensitivityY, + double weightX, + double weightY, + double capX, + double capY, + double offset, + double accel, + double limitOrExp, + double midpoint, + double gainCap) + { + ActiveAccel.UpdateAccel( + mode, + degrees, + sensitivityX, + sensitivityY, + weightX, + weightY, + capX, + capY, + offset, + accel, + limitOrExp, + midpoint, + gainCap); + + RawAccelSettings.AccelerationSettings = new modifier_args(ActiveAccel); + RawAccelSettings.GUISettings = new GUISettings + { + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + DPI = (int)DpiField.Data, + PollRate = (int)PollRateField.Data + }; + + RawAccelSettings.Save(); + } + + public void UpdateActiveAccelFromFileSettings() + { + ActiveAccel.UpdateAccel( + RawAccelSettings.AccelerationSettings.acc_fn_args.accel_mode, + RawAccelSettings.AccelerationSettings.degrees, + RawAccelSettings.AccelerationSettings.sens.x, + RawAccelSettings.AccelerationSettings.sens.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.weight.x, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.weight.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.cap.x, + RawAccelSettings.AccelerationSettings.acc_fn_args.cap.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.offset, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.accel, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.exponent, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.midpoint, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.gain_cap); + DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI); + PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate); + AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup; + } + + public void Startup() + { + ActiveAccel.ReadFromDriver(); + + if(RawAccelSettings.Exists()) + { + RawAccelSettings = RawAccelSettings.Load(); + if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup) + { + UpdateActiveAccelFromFileSettings(); + } + } + else + { + RawAccelSettings = new RawAccelSettings( + ActiveAccel, + new GUISettings + { + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + DPI = (int)DpiField.Data, + PollRate = (int)PollRateField.Data + }); + RawAccelSettings.Save(); + } + } + } +} diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 54b73c8..6e03ae0 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -85,7 +85,9 @@ + + -- cgit v1.2.3