diff --git a/Controls/GimbalControlSettingsForm.Designer.cs b/Controls/GimbalControlSettingsForm.Designer.cs
new file mode 100644
index 0000000000..8a88940627
--- /dev/null
+++ b/Controls/GimbalControlSettingsForm.Designer.cs
@@ -0,0 +1,130 @@
+namespace MissionPlanner.Controls
+{
+ partial class GimbalControlSettingsForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.SettingsPanel = new System.Windows.Forms.Panel();
+ this.SettingsTablePanel = new System.Windows.Forms.TableLayoutPanel();
+ this.ButtonsPanel = new System.Windows.Forms.Panel();
+ this.but_cancel = new MissionPlanner.Controls.MyButton();
+ this.but_save = new MissionPlanner.Controls.MyButton();
+ this.SettingsPanel.SuspendLayout();
+ this.ButtonsPanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // SettingsPanel
+ //
+ this.SettingsPanel.AutoScroll = true;
+ this.SettingsPanel.Controls.Add(this.SettingsTablePanel);
+ this.SettingsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.SettingsPanel.Location = new System.Drawing.Point(0, 0);
+ this.SettingsPanel.Name = "SettingsPanel";
+ this.SettingsPanel.Size = new System.Drawing.Size(533, 474);
+ this.SettingsPanel.TabIndex = 0;
+ //
+ // SettingsTablePanel
+ //
+ this.SettingsTablePanel.AutoSize = true;
+ this.SettingsTablePanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.SettingsTablePanel.ColumnCount = 3;
+ this.SettingsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.SettingsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.SettingsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.SettingsTablePanel.Dock = System.Windows.Forms.DockStyle.Top;
+ this.SettingsTablePanel.Location = new System.Drawing.Point(0, 0);
+ this.SettingsTablePanel.Name = "SettingsTablePanel";
+ this.SettingsTablePanel.RowCount = 6;
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.SettingsTablePanel.Size = new System.Drawing.Size(533, 120);
+ this.SettingsTablePanel.TabIndex = 0;
+ //
+ // ButtonsPanel
+ //
+ this.ButtonsPanel.Controls.Add(this.but_cancel);
+ this.ButtonsPanel.Controls.Add(this.but_save);
+ this.ButtonsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.ButtonsPanel.Location = new System.Drawing.Point(0, 474);
+ this.ButtonsPanel.Name = "ButtonsPanel";
+ this.ButtonsPanel.Size = new System.Drawing.Size(533, 30);
+ this.ButtonsPanel.TabIndex = 1;
+ //
+ // but_cancel
+ //
+ this.but_cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.but_cancel.Location = new System.Drawing.Point(455, 4);
+ this.but_cancel.Name = "but_cancel";
+ this.but_cancel.Size = new System.Drawing.Size(75, 23);
+ this.but_cancel.TabIndex = 1;
+ this.but_cancel.Text = "Cancel";
+ this.but_cancel.TextColorNotEnabled = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(87)))), ((int)(((byte)(4)))));
+ this.but_cancel.UseVisualStyleBackColor = true;
+ this.but_cancel.Click += new System.EventHandler(this.but_cancel_Click);
+ //
+ // but_save
+ //
+ this.but_save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.but_save.Location = new System.Drawing.Point(374, 4);
+ this.but_save.Name = "but_save";
+ this.but_save.Size = new System.Drawing.Size(75, 23);
+ this.but_save.TabIndex = 0;
+ this.but_save.Text = "Save";
+ this.but_save.TextColorNotEnabled = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(87)))), ((int)(((byte)(4)))));
+ this.but_save.UseVisualStyleBackColor = true;
+ this.but_save.Click += new System.EventHandler(this.but_save_Click);
+ //
+ // GimbalControlSettingsForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(533, 504);
+ this.Controls.Add(this.SettingsPanel);
+ this.Controls.Add(this.ButtonsPanel);
+ this.Margin = new System.Windows.Forms.Padding(2);
+ this.Name = "GimbalControlSettingsForm";
+ this.Text = "GimbalVideoControlSettings";
+ this.SettingsPanel.ResumeLayout(false);
+ this.SettingsPanel.PerformLayout();
+ this.ButtonsPanel.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel SettingsPanel;
+ private System.Windows.Forms.Panel ButtonsPanel;
+ private MyButton but_cancel;
+ private MyButton but_save;
+ private System.Windows.Forms.TableLayoutPanel SettingsTablePanel;
+ }
+}
\ No newline at end of file
diff --git a/Controls/GimbalControlSettingsForm.cs b/Controls/GimbalControlSettingsForm.cs
new file mode 100644
index 0000000000..c6375d4906
--- /dev/null
+++ b/Controls/GimbalControlSettingsForm.cs
@@ -0,0 +1,329 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using MissionPlanner.Utilities;
+
+namespace MissionPlanner.Controls
+{
+ public partial class GimbalControlSettingsForm : Form
+ {
+ public GimbalControlSettings preferences;
+
+ public GimbalControlSettingsForm(GimbalControlSettings preferences)
+ {
+ InitializeComponent();
+
+ ThemeManager.ApplyThemeTo(this);
+
+ this.preferences = new GimbalControlSettings(preferences);
+
+ LoadPreferences();
+ }
+
+ private void LoadPreferences()
+ {
+ var properties = preferences.GetType().GetProperties();
+
+ // Delete all rows in the table layout panel
+ SettingsTablePanel.Controls.Clear();
+ SettingsTablePanel.RowStyles.Clear();
+ int row = -1;
+ foreach (var property in properties)
+ {
+ var attributes = property.GetCustomAttributes(typeof(PreferencesAttribute), true);
+ if (attributes.Length == 0)
+ {
+ continue;
+ }
+
+ row++;
+ SettingsTablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
+
+ var attribute = (PreferencesAttribute)attributes[0];
+
+ var label = new Label
+ {
+ Width = 200,
+ Text = attribute.LabelText,
+ TextAlign = ContentAlignment.MiddleLeft,
+ Anchor = AnchorStyles.Left,
+ };
+
+ SettingsTablePanel.Controls.Add(label, 0, row);
+
+ switch (attribute.ControlType)
+ {
+ case ControlType.KeyBindingButton:
+ var keyBindingButton = new KeyBindingButton
+ {
+ KeyBinding = (Keys)property.GetValue(preferences),
+ Anchor = AnchorStyles.Left | AnchorStyles.Right,
+ };
+ keyBindingButton.KeyBindingChanged += (sender, e) =>
+ {
+ property.SetValue(preferences, keyBindingButton.KeyBinding);
+ };
+ SettingsTablePanel.Controls.Add(keyBindingButton, 1, row);
+ var clearKeyButton = new MyButton
+ {
+ Text = "❌",
+ Width = keyBindingButton.Height,
+ Height = keyBindingButton.Height,
+ };
+ clearKeyButton.Click += (sender, e) =>
+ {
+ keyBindingButton.KeyBinding = Keys.None;
+ };
+ SettingsTablePanel.Controls.Add(clearKeyButton, 2, row);
+ break;
+ case ControlType.ClickBindingButton:
+ var clickBindingButton = new ClickBindingButton
+ {
+ ClickBinding = ((Keys, MouseButtons))property.GetValue(preferences),
+ Anchor = AnchorStyles.Left | AnchorStyles.Right,
+ };
+ clickBindingButton.ClickBindingChanged += (sender, e) =>
+ {
+ property.SetValue(preferences, clickBindingButton.ClickBinding);
+ };
+ SettingsTablePanel.Controls.Add(clickBindingButton, 1, row);
+ var clearClickButton = new MyButton
+ {
+ Text = "❌",
+ Width = clickBindingButton.Height,
+ Height = clickBindingButton.Height,
+ };
+ clearClickButton.Click += (sender, e) =>
+ {
+ clickBindingButton.ClickBinding = (Keys.None, MouseButtons.None);
+ };
+ SettingsTablePanel.Controls.Add(clearClickButton, 2, row);
+ break;
+ case ControlType.ModifierBinding:
+ var modifierBinding = new KeyBindingButton
+ {
+ ModifiersOnly = true,
+ Anchor = AnchorStyles.Left | AnchorStyles.Right,
+ };
+ modifierBinding.KeyBinding = (Keys)property.GetValue(preferences);
+ SettingsTablePanel.Controls.Add(modifierBinding, 1, row);
+ modifierBinding.KeyBindingChanged += (sender, e) =>
+ {
+ property.SetValue(preferences, modifierBinding.KeyBinding);
+ };
+ var clearModifierButton = new MyButton
+ {
+ Text = "❌",
+ Width = modifierBinding.Height,
+ Height = modifierBinding.Height,
+ };
+ clearModifierButton.Click += (sender, e) =>
+ {
+ modifierBinding.KeyBinding = Keys.None;
+ };
+ SettingsTablePanel.Controls.Add(clearModifierButton, 2, row);
+ break;
+ case ControlType.DecimalUpDown:
+ var value = (decimal)property.GetValue(preferences);
+ var decimalUpDown = new NumericUpDown
+ {
+ Value = value,
+ Minimum = Math.Min((decimal)attribute.Min, value),
+ Maximum = Math.Max((decimal)attribute.Max, value),
+ Increment = (decimal)attribute.Increment,
+ DecimalPlaces = attribute.DecimalPlaces
+ };
+ decimalUpDown.ValueChanged += (sender, e) =>
+ {
+ property.SetValue(preferences, decimalUpDown.Value);
+ };
+ SettingsTablePanel.Controls.Add(decimalUpDown, 1, row);
+ break;
+ case ControlType.Checkbox:
+ var checkbox = new CheckBox
+ {
+ Checked = (bool)property.GetValue(preferences)
+ };
+ checkbox.CheckedChanged += (sender, e) =>
+ {
+ property.SetValue(preferences, checkbox.Checked);
+ };
+ SettingsTablePanel.Controls.Add(checkbox, 1, row);
+ break;
+ }
+ }
+
+ // Recalculate column widths
+ SettingsTablePanel.Invalidate();
+ }
+
+ private void but_save_Click(object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+ private void but_cancel_Click(object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.Cancel;
+ this.Close();
+ }
+ }
+
+ public enum ControlType
+ {
+ KeyBindingButton,
+ ClickBindingButton,
+ ModifierBinding,
+ DecimalUpDown,
+ Checkbox
+ }
+
+ [AttributeUsage(AttributeTargets.Property)]
+ public class PreferencesAttribute : Attribute
+ {
+ public string LabelText { get; }
+ public ControlType ControlType { get; }
+
+ // Additional properties for DecimalUpDown control
+ public double Min { get; set; } = 0;
+ public double Max { get; set; } = 100;
+ public double Increment { get; set; } = 1;
+ public int DecimalPlaces { get; set; } = 2;
+
+ public PreferencesAttribute(string labelText, ControlType controlType)
+ {
+ LabelText = labelText;
+ ControlType = controlType;
+ }
+ }
+
+ public class GimbalControlSettings
+ {
+ // Keybindings for various actions
+ [Preferences("Slew Left", ControlType.KeyBindingButton)]
+ public Keys SlewLeft { get; set; }
+ [Preferences("Slew Right", ControlType.KeyBindingButton)]
+ public Keys SlewRight { get; set; }
+ [Preferences("Slew Up", ControlType.KeyBindingButton)]
+ public Keys SlewUp { get; set; }
+ [Preferences("Slew Down", ControlType.KeyBindingButton)]
+ public Keys SlewDown { get; set; }
+ [Preferences("Zoom In", ControlType.KeyBindingButton)]
+ public Keys ZoomIn { get; set; }
+ [Preferences("Zoom Out", ControlType.KeyBindingButton)]
+ public Keys ZoomOut { get; set; }
+
+ [Preferences("Slew Fast Modifier", ControlType.ModifierBinding)]
+ public Keys SlewFastModifier { get; set; }
+ [Preferences("Slew Slow Modifier", ControlType.ModifierBinding)]
+ public Keys SlewSlowModifier { get; set; }
+
+ [Preferences("Take Picture", ControlType.KeyBindingButton)]
+ public Keys TakePicture { get; set; }
+ [Preferences("Toggle Recording", ControlType.KeyBindingButton)]
+ public Keys ToggleRecording { get; set; }
+ [Preferences("Start Recording", ControlType.KeyBindingButton)]
+ public Keys StartRecording { get; set; }
+ [Preferences("Stop Recording", ControlType.KeyBindingButton)]
+ public Keys StopRecording { get; set; }
+
+ [Preferences("Toggle Lock/Follow", ControlType.KeyBindingButton)]
+ public Keys ToggleLockFollow { get; set; }
+ [Preferences("Set Lock", ControlType.KeyBindingButton)]
+ public Keys SetLock { get; set; }
+ [Preferences("Set Follow", ControlType.KeyBindingButton)]
+ public Keys SetFollow { get; set; }
+ [Preferences("Retract", ControlType.KeyBindingButton)]
+ public Keys Retract { get; set; }
+ [Preferences("Neutral", ControlType.KeyBindingButton)]
+ public Keys Neutral { get; set; }
+ [Preferences("Point Down", ControlType.KeyBindingButton)]
+ public Keys PointDown { get; set; }
+ [Preferences("Home", ControlType.KeyBindingButton)]
+ public Keys Home { get; set; }
+
+
+ [Preferences("Click Pan/Tilt", ControlType.ClickBindingButton)]
+ public (Keys, MouseButtons) MoveCameraToMouseLocation { get; set; }
+ [Preferences("Click Point-of-Interest", ControlType.ClickBindingButton)]
+ public (Keys, MouseButtons) MoveCameraPOIToMouseLocation { get; set; }
+ [Preferences("Click Track Object", ControlType.ClickBindingButton)]
+ public (Keys, MouseButtons) TrackObjectUnderMouse { get; set; }
+
+
+ // Speed settings
+ [Preferences("Slew Speed Slow (deg/s)", ControlType.DecimalUpDown, Min = 0.1, Max = 360, Increment = 1, DecimalPlaces = 1)]
+ public decimal SlewSpeedSlow { get; set; }
+ [Preferences("Slew Speed Normal (deg/s)", ControlType.DecimalUpDown, Min = 0.1, Max = 360, Increment = 1, DecimalPlaces = 1)]
+ public decimal SlewSpeedNormal { get; set; }
+ [Preferences("Slew Speed Fast (deg/s)", ControlType.DecimalUpDown, Min = 0.1, Max = 360, Increment = 1, DecimalPlaces = 1)]
+ public decimal SlewSpeedFast { get; set; }
+
+ [Preferences("Zoom Speed (unitless)", ControlType.DecimalUpDown, Min = 0.01, Max = 1, Increment = 0.1, DecimalPlaces = 2)]
+ public decimal ZoomSpeed { get; set; }
+ [Preferences("Camera FOV (deg)", ControlType.DecimalUpDown, Min = 0.01, Max = 180, Increment = 1, DecimalPlaces = 2)]
+ public decimal CameraFOV { get; set; }
+
+ // Boolean options
+ [Preferences("Use FOV Reported by Camera", ControlType.Checkbox)]
+ public bool UseFOVReportedByCamera { get; set; }
+ [Preferences("Default Locked Mode", ControlType.Checkbox)]
+ public bool DefaultLockedMode { get; set; }
+
+ public GimbalControlSettings()
+ {
+ SlewLeft = Keys.A;
+ SlewRight = Keys.D;
+ SlewUp = Keys.W;
+ SlewDown = Keys.S;
+ ZoomIn = Keys.E;
+ ZoomOut = Keys.Q;
+
+ SlewSlowModifier = Keys.Control;
+ SlewFastModifier = Keys.Shift;
+
+ TakePicture = Keys.Alt | Keys.F;
+ ToggleRecording = Keys.Alt | Keys.R;
+ StartRecording = Keys.None;
+ StopRecording = Keys.None;
+
+ ToggleLockFollow = Keys.L;
+ SetLock = Keys.None;
+ SetFollow = Keys.None;
+ Retract = Keys.None;
+ Neutral = Keys.N;
+ PointDown = Keys.None;
+ Home = Keys.H;
+
+ MoveCameraToMouseLocation = (Keys.None, MouseButtons.Left);
+ MoveCameraPOIToMouseLocation = (Keys.Control, MouseButtons.Left);
+ TrackObjectUnderMouse = (Keys.Alt, MouseButtons.Left);
+
+ // Default speed settings
+ SlewSpeedSlow = 1m; // deg/sec
+ SlewSpeedNormal = 5m; // deg/sec
+ SlewSpeedFast = 25m; // deg/sec
+ ZoomSpeed = 1.0m; // unitless [0, 1]
+ CameraFOV = 50.0m; // horizontal, degrees
+
+ // Default boolean options
+ DefaultLockedMode = false;
+ UseFOVReportedByCamera = true;
+ }
+
+ public GimbalControlSettings(GimbalControlSettings other)
+ {
+ foreach (var property in other.GetType().GetProperties())
+ {
+ property.SetValue(this, property.GetValue(other));
+ }
+ }
+ }
+}
diff --git a/Controls/GimbalControlSettingsForm.resx b/Controls/GimbalControlSettingsForm.resx
new file mode 100644
index 0000000000..29dcb1b3a3
--- /dev/null
+++ b/Controls/GimbalControlSettingsForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Controls/GimbalVideoControl.Designer.cs b/Controls/GimbalVideoControl.Designer.cs
index dc830d8d99..21c7a3f8c9 100644
--- a/Controls/GimbalVideoControl.Designer.cs
+++ b/Controls/GimbalVideoControl.Designer.cs
@@ -28,11 +28,11 @@ private void InitializeComponent()
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.takePictureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startRecordingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.stopRecordingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ControlInfoTooltip = new System.Windows.Forms.ToolTip(this.components);
this.UITimer = new System.Windows.Forms.Timer(this.components);
- this.stopRecordingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.VideoBox)).BeginInit();
this.VideoBoxContextMenu.SuspendLayout();
this.SuspendLayout();
@@ -77,59 +77,59 @@ private void InitializeComponent()
// videoStreamToolStripMenuItem
//
this.videoStreamToolStripMenuItem.Name = "videoStreamToolStripMenuItem";
- this.videoStreamToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.videoStreamToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.videoStreamToolStripMenuItem.Text = "Video Stream";
this.videoStreamToolStripMenuItem.Click += new System.EventHandler(this.videoStreamToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
- this.toolStripMenuItem1.Size = new System.Drawing.Size(152, 6);
+ this.toolStripMenuItem1.Size = new System.Drawing.Size(177, 6);
//
// retractToolStripMenuItem
//
this.retractToolStripMenuItem.Name = "retractToolStripMenuItem";
- this.retractToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.retractToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.retractToolStripMenuItem.Text = "Retract";
this.retractToolStripMenuItem.Click += new System.EventHandler(this.retractToolStripMenuItem_Click);
//
// neutralToolStripMenuItem
//
this.neutralToolStripMenuItem.Name = "neutralToolStripMenuItem";
- this.neutralToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.neutralToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.neutralToolStripMenuItem.Text = "Neutral";
this.neutralToolStripMenuItem.Click += new System.EventHandler(this.neutralToolStripMenuItem_Click);
//
// pointDownToolStripMenuItem
//
this.pointDownToolStripMenuItem.Name = "pointDownToolStripMenuItem";
- this.pointDownToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.pointDownToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.pointDownToolStripMenuItem.Text = "Point Down";
this.pointDownToolStripMenuItem.Click += new System.EventHandler(this.pointDownToolStripMenuItem_Click);
//
// pointHomeToolStripMenuItem
//
this.pointHomeToolStripMenuItem.Name = "pointHomeToolStripMenuItem";
- this.pointHomeToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.pointHomeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.pointHomeToolStripMenuItem.Text = "Point Home";
this.pointHomeToolStripMenuItem.Click += new System.EventHandler(this.pointHomeToolStripMenuItem_Click);
//
// yawLockToolStripMenuItem
//
this.yawLockToolStripMenuItem.Name = "yawLockToolStripMenuItem";
- this.yawLockToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.yawLockToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.yawLockToolStripMenuItem.Text = "Yaw Lock";
this.yawLockToolStripMenuItem.Click += new System.EventHandler(this.yawLockToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(152, 6);
+ this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
//
// takePictureToolStripMenuItem
//
this.takePictureToolStripMenuItem.Name = "takePictureToolStripMenuItem";
- this.takePictureToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.takePictureToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.takePictureToolStripMenuItem.Text = "Take Picture";
this.takePictureToolStripMenuItem.Click += new System.EventHandler(this.takePictureToolStripMenuItem_Click);
//
@@ -140,16 +140,24 @@ private void InitializeComponent()
this.startRecordingToolStripMenuItem.Text = "Start Recording";
this.startRecordingToolStripMenuItem.Click += new System.EventHandler(this.startRecordingToolStripMenuItem_Click);
//
+ // stopRecordingToolStripMenuItem
+ //
+ this.stopRecordingToolStripMenuItem.Name = "stopRecordingToolStripMenuItem";
+ this.stopRecordingToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.stopRecordingToolStripMenuItem.Text = "Stop Recording";
+ this.stopRecordingToolStripMenuItem.Click += new System.EventHandler(this.stopRecordingToolStripMenuItem_Click);
+ //
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
- this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 6);
+ this.toolStripMenuItem2.Size = new System.Drawing.Size(177, 6);
//
// settingsToolStripMenuItem
//
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
- this.settingsToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
+ this.settingsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.settingsToolStripMenuItem.Text = "Settings";
+ this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click);
//
// UITimer
//
@@ -157,13 +165,6 @@ private void InitializeComponent()
this.UITimer.Interval = 500;
this.UITimer.Tick += new System.EventHandler(this.UITimer_Tick);
//
- // stopRecordingToolStripMenuItem
- //
- this.stopRecordingToolStripMenuItem.Name = "stopRecordingToolStripMenuItem";
- this.stopRecordingToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.stopRecordingToolStripMenuItem.Text = "Stop Recording";
- this.stopRecordingToolStripMenuItem.Click += new System.EventHandler(this.stopRecordingToolStripMenuItem_Click);
- //
// GimbalVideoControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
diff --git a/Controls/GimbalVideoControl.cs b/Controls/GimbalVideoControl.cs
index 37cc099e62..a67805e7eb 100644
--- a/Controls/GimbalVideoControl.cs
+++ b/Controls/GimbalVideoControl.cs
@@ -12,7 +12,6 @@
using System.Windows.Forms;
using MissionPlanner.Utilities;
using SkiaSharp;
-using OpenTK.Input;
using log4net;
using System.Collections.Generic;
using static MAVLink;
@@ -29,7 +28,7 @@ public partial class GimbalVideoControl : UserControl, IMessageFilter
// logger
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
- private GimbalControlPreferences preferences = new GimbalControlPreferences();
+ private GimbalControlSettings preferences = new GimbalControlSettings();
private readonly GStreamer _stream = new GStreamer();
@@ -111,12 +110,13 @@ public GimbalVideoControl()
private void loadPreferences()
{
+ preferences = new GimbalControlSettings();
var json = Settings.Instance["GimbalControlPreferences", ""];
if (json != "")
{
try
{
- preferences = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
+ preferences = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
}
catch (Exception ex)
{
@@ -174,16 +174,6 @@ private void RenderFrame(object sender, MPBitmap image)
PixelFormat.Format32bppPArgb,
image.LockBits(Rectangle.Empty, null, SKColorType.Bgra8888).Scan0);
- // Overlay crosshairs
- if (Control.ModifierKeys == preferences.SlewCameraBasedOnMouseModifier)
- {
- using (var g = Graphics.FromImage(VideoBox.Image))
- {
- g.DrawLine(Pens.Red, image.Width / 2, 0, image.Width / 2, image.Height);
- g.DrawLine(Pens.Red, 0, image.Height / 2, image.Width, image.Height / 2);
- }
- }
-
old?.Dispose();
}
catch (Exception ex)
@@ -493,8 +483,8 @@ private void VideoBox_Click(object sender, EventArgs e)
return;
}
- // Check currently held modifier keys
- if (Control.ModifierKeys == preferences.MoveCameraToMouseLocationModifier)
+ // Check the key/button combination to determine the action
+ if ((Control.ModifierKeys, me.Button) == preferences.MoveCameraToMouseLocation)
{
var attitude = selectedGimbalManager?.GetAttitude(selectedGimbalID);
if (attitude == null)
@@ -513,7 +503,7 @@ private void VideoBox_Click(object sender, EventArgs e)
selectedGimbalManager?.SetAttitudeAsync(q, yaw_lock, selectedGimbalID);
}
- else if (Control.ModifierKeys == preferences.MoveCameraPOIToMouseLocationModifier)
+ else if ((Control.ModifierKeys, me.Button) == preferences.MoveCameraPOIToMouseLocation)
{
var loc = selectedCamera?.CalculateImagePointLocation(point.Value.x, point.Value.y);
if (loc == null)
@@ -607,105 +597,15 @@ private void stopRecordingToolStripMenuItem_Click(object sender, EventArgs e)
{
SetRecording(false);
}
- }
- public class GimbalControlPreferences
- {
- // Keybindings for various actions
- public Keys SlewLeft { get; set; }
- public Keys SlewRight { get; set; }
- public Keys SlewUp { get; set; }
- public Keys SlewDown { get; set; }
- public Keys ZoomIn { get; set; }
- public Keys ZoomOut { get; set; }
-
- public Keys SlewFastModifier { get; set; }
- public Keys SlewSlowModifier { get; set; }
-
- public Keys TakePicture { get; set; }
- public Keys ToggleRecording { get; set; }
- public Keys StartRecording { get; set; }
- public Keys StopRecording { get; set; }
-
- public Keys ToggleLockFollow { get; set; }
- public Keys SetLock { get; set; }
- public Keys SetFollow { get; set; }
- public Keys Retract { get; set; }
- public Keys Neutral { get; set; }
- public Keys PointDown { get; set; }
- public Keys Home { get; set; }
-
-
- public MouseButton MoveCameraToMouseLocation { get; set; }
- public MouseButton MoveCameraPOIToMouseLocation { get; set; }
- public MouseButton SlewCameraBasedOnMouse { get; set; }
- public MouseButton TrackObjectUnderMouse { get; set; }
-
- public Keys MoveCameraToMouseLocationModifier { get; set; }
- public Keys MoveCameraPOIToMouseLocationModifier { get; set; }
- public Keys SlewCameraBasedOnMouseModifier { get; set; }
- public Keys TrackObjectUnderMouseModifier { get; set; }
-
- // Speed settings
- public decimal SlewSpeedSlow { get; set; }
- public decimal SlewSpeedNormal { get; set; }
- public decimal SlewSpeedFast { get; set; }
- public decimal ZoomSpeed { get; set; }
- public decimal CameraFOV { get; set; }
-
- // Boolean options
- public bool UseScrollForZoom { get; set; }
- public bool DefaultLockedMode { get; set; }
- public bool UseFOVReportedByCamera { get; set; }
- public bool ShowCameraControls { get; set; }
-
- public GimbalControlPreferences()
- {
- SlewLeft = Keys.A;
- SlewRight = Keys.D;
- SlewUp = Keys.W;
- SlewDown = Keys.S;
- ZoomIn = Keys.E;
- ZoomOut = Keys.Q;
-
- SlewSlowModifier = Keys.Control;
- SlewFastModifier = Keys.Shift;
-
- TakePicture = Keys.Alt | Keys.F;
- ToggleRecording = Keys.Alt | Keys.R;
- StartRecording = Keys.None;
- StopRecording = Keys.None;
-
- ToggleLockFollow = Keys.L;
- SetLock = Keys.None;
- SetFollow = Keys.None;
- Retract = Keys.None;
- Neutral = Keys.N;
- PointDown = Keys.None;
- Home = Keys.H;
-
- MoveCameraToMouseLocation = MouseButton.Left;
- MoveCameraPOIToMouseLocation = MouseButton.Left;
- SlewCameraBasedOnMouse = MouseButton.Left;
- TrackObjectUnderMouse = MouseButton.Left;
-
- MoveCameraToMouseLocationModifier = Keys.None;
- MoveCameraPOIToMouseLocationModifier = Keys.Control;
- SlewCameraBasedOnMouseModifier = Keys.Alt;
- TrackObjectUnderMouseModifier = Keys.Control | Keys.Alt;
-
- // Default speed settings
- SlewSpeedSlow = 1m; // deg/sec
- SlewSpeedNormal = 5m; // deg/sec
- SlewSpeedFast = 25m; // deg/sec
- ZoomSpeed = 1.0m; // unitless [0, 1]
- CameraFOV = 50.0m; // horizontal, degrees
-
- // Default boolean options
- UseScrollForZoom = true;
- DefaultLockedMode = false;
- UseFOVReportedByCamera = true;
- ShowCameraControls = true;
+ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var form = new GimbalControlSettingsForm(preferences);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ Settings.Instance["GimbalControlPreferences"] = Newtonsoft.Json.JsonConvert.SerializeObject(form.preferences);
+ loadPreferences();
+ }
}
}
}