diff options
| author | JacobPalecki <[email protected]> | 2021-05-19 15:04:45 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-19 15:04:45 -0700 |
| commit | f88751f8653b4bce9d5e3ed3109da2f2427a6f99 (patch) | |
| tree | c67a4e59da866c86cdfffb786a76090525637166 | |
| parent | Merge pull request #86 from a1xd/fix-input (diff) | |
| parent | remove unused variable, improve legend position (diff) | |
| download | rawaccel-f88751f8653b4bce9d5e3ed3109da2f2427a6f99.tar.xz rawaccel-f88751f8653b4bce9d5e3ed3109da2f2427a6f99.zip | |
Merge pull request #87 from matthewstrasiotto/streamer_mode
Improve use of whitespace on charts, make elements bolder, add "streaming mode" toggle for overlaying charts using Chroma key in OBS
| -rw-r--r-- | grapher/Constants/Constants.cs | 21 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 12 | ||||
| -rw-r--r-- | grapher/Form1.cs | 5 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/Charts/AccelCharts.cs | 11 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/ChartState.cs | 7 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartXY.cs | 103 | ||||
| -rw-r--r-- | grapher/Models/Serialized/GUISettings.cs | 9 | ||||
| -rw-r--r-- | grapher/Models/Serialized/SettingsManager.cs | 8 |
9 files changed, 157 insertions, 22 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 446f5fa..ce18389 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -129,6 +129,27 @@ namespace grapher /// <summary> Style used by System.Double.Parse </summary> public const NumberStyles FloatStyle = NumberStyles.Float | NumberStyles.AllowThousands; + /// <summary> Font Size for Chart Titles </summary> + public const float ChartTitleFontSize = 15; + + /// <summary> Font Size for Chart Axis Titles </summary> + public const float ChartAxisFontSize = 12; + + /// <summary> Line Width For Series data on chart </summary> + public const int ChartSeriesLineWidth = 3; + + /// <summary> Foreground Color When Streamer Mode Active </summary> + public static readonly System.Drawing.Color fgStreamer = System.Drawing.Color.White; + + /// <summary> Background Color When Streamer Mode Active </summary> + public static readonly System.Drawing.Color bgStreamer = System.Drawing.Color.Green; + + /// <summary> Foreground Color When Streamer Mode Inactive </summary> + public static readonly System.Drawing.Color fgNoStreamer = System.Drawing.Color.Black; + + /// <summary> Background Color When Streamer Mode Inactive </summary> + public static readonly System.Drawing.Color bgNoStreamer = System.Drawing.Color.White; + #endregion Constants #region ReadOnly diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 20af913..5c9180d 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -188,6 +188,7 @@ namespace grapher this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.streamingModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsPanel.SuspendLayout(); this.DirectionalityPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -1108,7 +1109,8 @@ namespace grapher this.graphsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.scaleByDPIToolStripMenuItem, this.showVelocityGainToolStripMenuItem, - this.showLastMouseMoveToolStripMenuItem}); + this.showLastMouseMoveToolStripMenuItem, + this.streamingModeToolStripMenuItem}); 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); @@ -1495,6 +1497,13 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // + // streamingModeToolStripMenuItem + // + this.streamingModeToolStripMenuItem.CheckOnClick = true; + this.streamingModeToolStripMenuItem.Name = "streamingModeToolStripMenuItem"; + this.streamingModeToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.streamingModeToolStripMenuItem.Text = "Streaming Mode"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1642,6 +1651,7 @@ namespace grapher private System.Windows.Forms.Label RangeActiveValueY; private System.Windows.Forms.CheckBox FakeBox; private System.Windows.Forms.ToolStripMenuItem UseSpecificDeviceMenuItem; + private System.Windows.Forms.ToolStripMenuItem streamingModeToolStripMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 51f1355..d833311 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -64,6 +64,7 @@ namespace grapher toggleButton, showVelocityGainToolStripMenuItem, showLastMouseMoveToolStripMenuItem, + streamingModeToolStripMenuItem, gainCapToolStripMenuItem, legacyCapToolStripMenuItem, gainOffsetToolStripMenuItem, @@ -217,6 +218,6 @@ namespace grapher } - #endregion Method - } + #endregion Method + } } diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 1c42c76..305445a 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -29,6 +29,7 @@ namespace grapher.Models ButtonBase toggleButton, ToolStripMenuItem showVelocityGainToolStripMenuItem, ToolStripMenuItem showLastMouseMoveMenuItem, + ToolStripMenuItem streamingModeToolStripMenuItem, ToolStripMenuItem velocityGainCapToolStripMenuItem, ToolStripMenuItem legacyCapToolStripMenuItem, ToolStripMenuItem gainOffsetToolStripMenuItem, @@ -140,6 +141,7 @@ namespace grapher.Models new ChartXY(gainChart, gainChartY, Constants.GainChartTitle), showVelocityGainToolStripMenuItem, showLastMouseMoveMenuItem, + streamingModeToolStripMenuItem, writeButton, accelCalculator); @@ -402,6 +404,7 @@ namespace grapher.Models autoWriteMenuItem, showLastMouseMoveMenuItem, showVelocityGainToolStripMenuItem, + streamingModeToolStripMenuItem, deviceIdManager); var mouseWatcher = new MouseWatcher(form, mouseLabel, accelCharts, settings); diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 65c636b..7682120 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -18,6 +18,7 @@ namespace grapher ChartXY gainChart, ToolStripMenuItem enableVelocityAndGain, ToolStripMenuItem enableLastMouseMove, + ToolStripMenuItem enableStreamingMode, Button writeButton, AccelCalculator accelCalculator) { @@ -37,6 +38,8 @@ namespace grapher ContainingForm = form; EnableVelocityAndGain = enableVelocityAndGain; EnableLastValue = enableLastMouseMove; + EnableStreamingMode = enableStreamingMode; + WriteButton = writeButton; EnableVelocityAndGain.Click += new System.EventHandler(OnEnableClick); @@ -44,6 +47,8 @@ namespace grapher EnableLastValue.CheckedChanged += new System.EventHandler(OnEnableLastMouseMoveCheckStateChange); + EnableStreamingMode.CheckedChanged += new System.EventHandler(OnEnableStreamingModeCheckStateChange); + ChartState = ChartStateManager.InitialState(); ChartState.Activate(); HideVelocityAndGain(); @@ -57,6 +62,8 @@ namespace grapher public ToolStripMenuItem EnableVelocityAndGain { get; } + public ToolStripMenuItem EnableStreamingMode { get; } + private ToolStripMenuItem EnableLastValue { get; } private Button WriteButton { get; } @@ -174,6 +181,10 @@ namespace grapher HideVelocityAndGain(); } } + private void OnEnableStreamingModeCheckStateChange(object sender, EventArgs e) + { + ChartState.SetStreaming(EnableStreamingMode.Checked); + } private void OnEnableLastMouseMoveCheckStateChange(object sender, EventArgs e) { diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index 5a86713..a50eaf0 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -117,5 +117,12 @@ namespace grapher.Models.Charts.ChartState ChartXY.SetStandard(GainChart.ChartY); } } + + public void SetStreaming(bool streaming) + { + SensitivityChart.SetStreaming(streaming); + GainChart.SetStreaming(streaming); + VelocityChart.SetStreaming(streaming); + } } } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index bd80ea2..5bafb94 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -89,34 +89,91 @@ namespace grapher #region Methods + public static void setChartColors(Chart chart, System.Drawing.Color fgColor, System.Drawing.Color bgColor) + { + chart.ForeColor = fgColor; + chart.BackColor = bgColor; + + chart.Titles[0].ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = fgColor; + chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.LineColor = fgColor; + chart.ChartAreas[0].AxisY.LineColor = fgColor; + chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = fgColor; + chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = fgColor; + + chart.ChartAreas[0].AxisX.MajorGrid.LineColor = fgColor; + chart.ChartAreas[0].AxisY.MajorGrid.LineColor = fgColor; + + chart.ChartAreas[0].AxisX.MinorGrid.LineColor = fgColor; + chart.Legends[0].ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.TitleForeColor = fgColor; + chart.ChartAreas[0].AxisY.TitleForeColor = fgColor; + + chart.ChartAreas[0].BorderColor = fgColor; + + + } + public static void SetupChart(Chart chart) { - chart.ChartAreas[0].AxisX.RoundAxisValues(); + ChartArea area = chart.ChartAreas[0]; + Legend legend = chart.Legends[0]; + Title title = chart.Titles[0]; - chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; - chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + area.AxisX.RoundAxisValues(); - chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; - chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + area.AxisX.ScaleView.Zoomable = true; + area.AxisY.ScaleView.Zoomable = true; - chart.ChartAreas[0].AxisX.LabelStyle.Format = "0.##"; - chart.ChartAreas[0].AxisY.LabelStyle.Format = "0.##"; + area.AxisY.ScaleView.MinSize = 0.01; + area.AxisY.ScaleView.SmallScrollSize = 0.001; + + area.AxisX.LabelStyle.Format = "0.##"; + area.AxisY.LabelStyle.Format = "0.##"; - chart.ChartAreas[0].CursorY.Interval = 0.001; + area.CursorY.Interval = 0.001; - chart.ChartAreas[0].CursorX.AutoScroll = true; - chart.ChartAreas[0].CursorY.AutoScroll = true; + area.CursorX.AutoScroll = true; + area.CursorY.AutoScroll = true; - chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; - chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + area.CursorX.IsUserSelectionEnabled = true; + area.CursorY.IsUserSelectionEnabled = true; - chart.ChartAreas[0].CursorX.IsUserEnabled = true; - chart.ChartAreas[0].CursorY.IsUserEnabled = true; + area.CursorX.IsUserEnabled = true; + area.CursorY.IsUserEnabled = true; chart.Series[1].Points.Clear(); chart.Series[1].Points.AddXY(0, 0); - chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, 9.0f, System.Drawing.FontStyle.Italic); + area.AxisX.TitleFont = new System.Drawing.Font(area.AxisX.TitleFont.Name, Constants.ChartAxisFontSize, System.Drawing.FontStyle.Bold); + area.AxisY.TitleFont = area.AxisX.TitleFont; + + title.Font = new System.Drawing.Font(title.Font.Name, Constants.ChartTitleFontSize, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); + + chart.Series[0].BorderWidth = Constants.ChartSeriesLineWidth; + chart.Series[0].MarkerSize = Constants.ChartSeriesLineWidth * 2; + chart.Series[2].BorderWidth = Constants.ChartSeriesLineWidth; + chart.Series[2].MarkerSize = Constants.ChartSeriesLineWidth * 2; + + area.AxisX.MinorGrid.Enabled = true; + area.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; + + title.Alignment = System.Drawing.ContentAlignment.MiddleCenter; + + legend.DockedToChartArea = area.Name; + legend.LegendStyle = LegendStyle.Row; + + ElementPosition legendPosNew = new ElementPosition(25, 0, 50, 25); + legend.Position = legendPosNew; + + System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; + + area.BackColor = bgTrans; + legend.BackColor = bgTrans; } public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null) @@ -313,6 +370,22 @@ namespace grapher ChartY.Height = height; } + public void SetStreaming(bool streaming) + { + var fgColor = Constants.fgNoStreamer; + var bgColor = Constants.bgNoStreamer; + + if (streaming) + { + fgColor = Constants.fgStreamer; + bgColor = Constants.bgStreamer; + } + + setChartColors(ChartX, fgColor, bgColor); + setChartColors(ChartY, fgColor, bgColor); + Update(); + } + private string SetComponentTitle(string component) { return $"{Title} : {component}"; diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs index bb35055..a4eb627 100644 --- a/grapher/Models/Serialized/GUISettings.cs +++ b/grapher/Models/Serialized/GUISettings.cs @@ -31,6 +31,9 @@ namespace grapher.Models.Serialized [JsonProperty(Order = 5)] public bool AutoWriteToDriverOnStartup { get; set; } + [JsonProperty(Order = 6)] + public bool StreamingMode { get; set; } + #endregion Properties #region Methods @@ -53,7 +56,8 @@ namespace grapher.Models.Serialized PollRate == other.PollRate && ShowLastMouseMove == other.ShowLastMouseMove && ShowVelocityAndGain == other.ShowVelocityAndGain && - AutoWriteToDriverOnStartup == other.AutoWriteToDriverOnStartup; + AutoWriteToDriverOnStartup == other.AutoWriteToDriverOnStartup && + StreamingMode == other.StreamingMode; } public override int GetHashCode() @@ -62,7 +66,8 @@ namespace grapher.Models.Serialized PollRate.GetHashCode() ^ ShowLastMouseMove.GetHashCode() ^ ShowVelocityAndGain.GetHashCode() ^ - AutoWriteToDriverOnStartup.GetHashCode(); + AutoWriteToDriverOnStartup.GetHashCode() ^ + StreamingMode.GetHashCode(); } #endregion Methods diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index 40652dd..c867c0a 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -19,6 +19,7 @@ namespace grapher.Models.Serialized ToolStripMenuItem autoWrite, ToolStripMenuItem showLastMouseMove, ToolStripMenuItem showVelocityAndGain, + ToolStripMenuItem streamingMode, DeviceIDManager deviceIDManager) { ActiveAccel = activeAccel; @@ -27,6 +28,7 @@ namespace grapher.Models.Serialized AutoWriteMenuItem = autoWrite; ShowLastMouseMoveMenuItem = showLastMouseMove; ShowVelocityAndGainMoveMenuItem = showVelocityAndGain; + StreamingModeMenuItem = streamingMode; DeviceIDManager = deviceIDManager; } @@ -49,7 +51,7 @@ namespace grapher.Models.Serialized private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; } private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; } - + private ToolStripMenuItem StreamingModeMenuItem{ get; set; } #endregion Properties #region Methods @@ -73,6 +75,7 @@ namespace grapher.Models.Serialized PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate); ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove; ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain; + StreamingModeMenuItem.Checked = RawAccelSettings.GUISettings.StreamingMode; AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup; } @@ -103,7 +106,8 @@ namespace grapher.Models.Serialized PollRate = (int)PollRateField.Data, ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked, ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked, - AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + StreamingMode = StreamingModeMenuItem.Checked }; } |