diff --git a/EyeBind/BlinkConfig.Designer.cs b/EyeBind/BlinkConfig.Designer.cs index 7fa1af3..21167db 100644 --- a/EyeBind/BlinkConfig.Designer.cs +++ b/EyeBind/BlinkConfig.Designer.cs @@ -30,35 +30,35 @@ private void InitializeComponent() { this.blinktabControl = new System.Windows.Forms.TabControl(); this.leftEyeTabPage = new System.Windows.Forms.TabPage(); + this.leftEyeBinkEnabledCheckBox = new System.Windows.Forms.CheckBox(); this.label7 = new System.Windows.Forms.Label(); this.groupBox11 = new System.Windows.Forms.GroupBox(); this.label5 = new System.Windows.Forms.Label(); this.leftEyeActivationDelayNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.leftEyeClearInputsButton = new System.Windows.Forms.Button(); this.groupBox7 = new System.Windows.Forms.GroupBox(); + this.leftEyeKeyRecorderDataGridView = new EyeBind.KeyRecorderDataGridView(); + this.leftEyeKeyRecorderCheckBox = new EyeBind.KeyRecorderCheckBox(); this.rightEyeTabPage = new System.Windows.Forms.TabPage(); + this.rightEyeBinkEnabledCheckBox = new System.Windows.Forms.CheckBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label2 = new System.Windows.Forms.Label(); this.rightEyeActivationDelayNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.rightEyeClearInputsButton = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.leftEyeKeyRecorderDataGridView = new EyeBind.KeyRecorderDataGridView(); - this.leftEyeKeyRecorderCheckBox = new EyeBind.KeyRecorderCheckBox(); this.rightEyeKeyRecorderDataGridView = new EyeBind.KeyRecorderDataGridView(); this.rightEyeKeyRecorderCheckBox = new EyeBind.KeyRecorderCheckBox(); - this.leftEyeBinkEnabledCheckBox = new System.Windows.Forms.CheckBox(); - this.rightEyeBinkEnabledCheckBox = new System.Windows.Forms.CheckBox(); this.blinktabControl.SuspendLayout(); this.leftEyeTabPage.SuspendLayout(); this.groupBox11.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.leftEyeActivationDelayNumericUpDown)).BeginInit(); this.groupBox7.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.leftEyeKeyRecorderDataGridView)).BeginInit(); this.rightEyeTabPage.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.rightEyeActivationDelayNumericUpDown)).BeginInit(); this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.leftEyeKeyRecorderDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rightEyeKeyRecorderDataGridView)).BeginInit(); this.SuspendLayout(); // @@ -89,6 +89,18 @@ private void InitializeComponent() this.leftEyeTabPage.Text = "Left Eye"; this.leftEyeTabPage.UseVisualStyleBackColor = true; // + // leftEyeBinkEnabledCheckBox + // + this.leftEyeBinkEnabledCheckBox.AutoSize = true; + this.leftEyeBinkEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.LeftEyeBlinkEnabled; + this.leftEyeBinkEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "LeftEyeBlinkEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.leftEyeBinkEnabledCheckBox.Location = new System.Drawing.Point(24, 16); + this.leftEyeBinkEnabledCheckBox.Name = "leftEyeBinkEnabledCheckBox"; + this.leftEyeBinkEnabledCheckBox.Size = new System.Drawing.Size(127, 17); + this.leftEyeBinkEnabledCheckBox.TabIndex = 10; + this.leftEyeBinkEnabledCheckBox.Text = "Enable Left Eye Blink"; + this.leftEyeBinkEnabledCheckBox.UseVisualStyleBackColor = true; + // // label7 // this.label7.AutoSize = true; @@ -166,6 +178,29 @@ private void InitializeComponent() this.groupBox7.TabStop = false; this.groupBox7.Text = "Left Eye Blink Inputs"; // + // leftEyeKeyRecorderDataGridView + // + this.leftEyeKeyRecorderDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.leftEyeKeyRecorderDataGridView.ColumnHeadersVisible = false; + this.leftEyeKeyRecorderDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.leftEyeKeyRecorderDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; + this.leftEyeKeyRecorderDataGridView.Location = new System.Drawing.Point(3, 16); + this.leftEyeKeyRecorderDataGridView.Name = "leftEyeKeyRecorderDataGridView"; + this.leftEyeKeyRecorderDataGridView.RowHeadersVisible = false; + this.leftEyeKeyRecorderDataGridView.Size = new System.Drawing.Size(394, 281); + this.leftEyeKeyRecorderDataGridView.TabIndex = 0; + // + // leftEyeKeyRecorderCheckBox + // + this.leftEyeKeyRecorderCheckBox.Appearance = System.Windows.Forms.Appearance.Button; + this.leftEyeKeyRecorderCheckBox.Location = new System.Drawing.Point(24, 58); + this.leftEyeKeyRecorderCheckBox.Name = "leftEyeKeyRecorderCheckBox"; + this.leftEyeKeyRecorderCheckBox.Size = new System.Drawing.Size(175, 30); + this.leftEyeKeyRecorderCheckBox.TabIndex = 6; + this.leftEyeKeyRecorderCheckBox.Text = "⚫ Start Recording Key"; + this.leftEyeKeyRecorderCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.leftEyeKeyRecorderCheckBox.UseVisualStyleBackColor = true; + // // rightEyeTabPage // this.rightEyeTabPage.Controls.Add(this.rightEyeBinkEnabledCheckBox); @@ -182,6 +217,18 @@ private void InitializeComponent() this.rightEyeTabPage.Text = "Right Eye"; this.rightEyeTabPage.UseVisualStyleBackColor = true; // + // rightEyeBinkEnabledCheckBox + // + this.rightEyeBinkEnabledCheckBox.AutoSize = true; + this.rightEyeBinkEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.RightEyeBlinkEnabled; + this.rightEyeBinkEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "RightEyeBlinkEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.rightEyeBinkEnabledCheckBox.Location = new System.Drawing.Point(24, 16); + this.rightEyeBinkEnabledCheckBox.Name = "rightEyeBinkEnabledCheckBox"; + this.rightEyeBinkEnabledCheckBox.Size = new System.Drawing.Size(134, 17); + this.rightEyeBinkEnabledCheckBox.TabIndex = 10; + this.rightEyeBinkEnabledCheckBox.Text = "Enable Right Eye Blink"; + this.rightEyeBinkEnabledCheckBox.UseVisualStyleBackColor = true; + // // label1 // this.label1.AutoSize = true; @@ -259,29 +306,6 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Right Eye Blink Inputs"; // - // leftEyeKeyRecorderDataGridView - // - this.leftEyeKeyRecorderDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.leftEyeKeyRecorderDataGridView.ColumnHeadersVisible = false; - this.leftEyeKeyRecorderDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; - this.leftEyeKeyRecorderDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; - this.leftEyeKeyRecorderDataGridView.Location = new System.Drawing.Point(3, 16); - this.leftEyeKeyRecorderDataGridView.Name = "leftEyeKeyRecorderDataGridView"; - this.leftEyeKeyRecorderDataGridView.RowHeadersVisible = false; - this.leftEyeKeyRecorderDataGridView.Size = new System.Drawing.Size(394, 281); - this.leftEyeKeyRecorderDataGridView.TabIndex = 0; - // - // leftEyeKeyRecorderCheckBox - // - this.leftEyeKeyRecorderCheckBox.Appearance = System.Windows.Forms.Appearance.Button; - this.leftEyeKeyRecorderCheckBox.Location = new System.Drawing.Point(24, 58); - this.leftEyeKeyRecorderCheckBox.Name = "leftEyeKeyRecorderCheckBox"; - this.leftEyeKeyRecorderCheckBox.Size = new System.Drawing.Size(175, 30); - this.leftEyeKeyRecorderCheckBox.TabIndex = 6; - this.leftEyeKeyRecorderCheckBox.Text = "⚫ Start Recording Key"; - this.leftEyeKeyRecorderCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.leftEyeKeyRecorderCheckBox.UseVisualStyleBackColor = true; - // // rightEyeKeyRecorderDataGridView // this.rightEyeKeyRecorderDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -305,36 +329,14 @@ private void InitializeComponent() this.rightEyeKeyRecorderCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.rightEyeKeyRecorderCheckBox.UseVisualStyleBackColor = true; // - // leftEyeBinkEnabledCheckBox - // - this.leftEyeBinkEnabledCheckBox.AutoSize = true; - this.leftEyeBinkEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.LeftEyeBlinkEnabled; - this.leftEyeBinkEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "LeftEyeBlinkEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.leftEyeBinkEnabledCheckBox.Location = new System.Drawing.Point(24, 16); - this.leftEyeBinkEnabledCheckBox.Name = "leftEyeBinkEnabledCheckBox"; - this.leftEyeBinkEnabledCheckBox.Size = new System.Drawing.Size(127, 17); - this.leftEyeBinkEnabledCheckBox.TabIndex = 10; - this.leftEyeBinkEnabledCheckBox.Text = "Enable Left Eye Blink"; - this.leftEyeBinkEnabledCheckBox.UseVisualStyleBackColor = true; - // - // rightEyeBinkEnabledCheckBox - // - this.rightEyeBinkEnabledCheckBox.AutoSize = true; - this.rightEyeBinkEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.RightEyeBlinkEnabled; - this.rightEyeBinkEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "RightEyeBlinkEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.rightEyeBinkEnabledCheckBox.Location = new System.Drawing.Point(24, 16); - this.rightEyeBinkEnabledCheckBox.Name = "rightEyeBinkEnabledCheckBox"; - this.rightEyeBinkEnabledCheckBox.Size = new System.Drawing.Size(134, 17); - this.rightEyeBinkEnabledCheckBox.TabIndex = 10; - this.rightEyeBinkEnabledCheckBox.Text = "Enable Right Eye Blink"; - this.rightEyeBinkEnabledCheckBox.UseVisualStyleBackColor = true; - // // BlinkConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(452, 542); this.Controls.Add(this.blinktabControl); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "BlinkConfig"; this.Text = "BlinkConfig"; this.blinktabControl.ResumeLayout(false); @@ -344,13 +346,13 @@ private void InitializeComponent() this.groupBox11.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.leftEyeActivationDelayNumericUpDown)).EndInit(); this.groupBox7.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.leftEyeKeyRecorderDataGridView)).EndInit(); this.rightEyeTabPage.ResumeLayout(false); this.rightEyeTabPage.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.rightEyeActivationDelayNumericUpDown)).EndInit(); this.groupBox2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.leftEyeKeyRecorderDataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rightEyeKeyRecorderDataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/EyeBind/EyeBind.csproj b/EyeBind/EyeBind.csproj index aba3b75..6dcfab7 100644 --- a/EyeBind/EyeBind.csproj +++ b/EyeBind/EyeBind.csproj @@ -52,6 +52,12 @@ true + + ..\packages\HtmlRenderer.Core.1.5.0.5\lib\net45\HtmlRenderer.dll + + + ..\packages\HtmlRenderer.WinForms.1.5.0.6\lib\net45\HtmlRenderer.WinForms.dll + @@ -90,12 +96,16 @@ EyeBindMainForm.cs + + Component + UserControl GazePanel.cs + Form @@ -116,6 +126,7 @@ GeneralSettingsDialog.cs + Component @@ -132,12 +143,26 @@ Component + + + Form + + + ProfileCloneDialog.cs + + + Form + + + ProfileCloner.cs + Form ProfileEditor.cs + Component @@ -166,6 +191,12 @@ GeneralSettingsDialog.cs + + ProfileCloneDialog.cs + + + ProfileCloner.cs + ProfileEditor.cs diff --git a/EyeBind/EyeBindMainForm.Designer.cs b/EyeBind/EyeBindMainForm.Designer.cs index 76c0cbe..aba03dd 100644 --- a/EyeBind/EyeBindMainForm.Designer.cs +++ b/EyeBind/EyeBindMainForm.Designer.cs @@ -30,6 +30,8 @@ private void InitializeComponent() { this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.deleteProfileButton = new System.Windows.Forms.Button(); + this.profilesComboBox = new EyeBind.ProfilesComboBox(); + this.gazeRegionsListBox = new EyeBind.GazeRegionsListBox(); this.newProfileButton = new System.Windows.Forms.Button(); this.newGazeRegionButton = new System.Windows.Forms.Button(); this.deleteGazeRegionButton = new System.Windows.Forms.Button(); @@ -42,8 +44,8 @@ private void InitializeComponent() this.blinkButton = new System.Windows.Forms.Button(); this.showGazeRegionsButton = new System.Windows.Forms.Button(); this.mouseMoverButton = new System.Windows.Forms.Button(); - this.profilesComboBox = new EyeBind.ProfilesComboBox(); - this.gazeRegionsListBox = new EyeBind.GazeRegionsListBox(); + this.editProfileButton = new System.Windows.Forms.Button(); + this.cloneProfileButton = new System.Windows.Forms.Button(); this.tableLayoutPanel.SuspendLayout(); this.SuspendLayout(); // @@ -52,44 +54,46 @@ private void InitializeComponent() this.tableLayoutPanel.ColumnCount = 2; this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel.Controls.Add(this.deleteProfileButton, 1, 2); - this.tableLayoutPanel.Controls.Add(this.profilesComboBox, 0, 3); - this.tableLayoutPanel.Controls.Add(this.gazeRegionsListBox, 0, 4); - this.tableLayoutPanel.Controls.Add(this.newProfileButton, 0, 2); - this.tableLayoutPanel.Controls.Add(this.newGazeRegionButton, 0, 5); - this.tableLayoutPanel.Controls.Add(this.deleteGazeRegionButton, 1, 5); - this.tableLayoutPanel.Controls.Add(this.editGazeRegionButton, 0, 6); - this.tableLayoutPanel.Controls.Add(this.cloneGazeRegionButton, 1, 6); - this.tableLayoutPanel.Controls.Add(this.gazeMarkerCheckBox, 1, 0); - this.tableLayoutPanel.Controls.Add(this.pauseSimulationCheckBox, 0, 0); - this.tableLayoutPanel.Controls.Add(this.hideGazeRegionsButton, 0, 7); + this.tableLayoutPanel.Controls.Add(this.deleteProfileButton, 1, 0); + this.tableLayoutPanel.Controls.Add(this.profilesComboBox, 0, 2); + this.tableLayoutPanel.Controls.Add(this.gazeRegionsListBox, 0, 3); + this.tableLayoutPanel.Controls.Add(this.newProfileButton, 0, 0); + this.tableLayoutPanel.Controls.Add(this.newGazeRegionButton, 0, 4); + this.tableLayoutPanel.Controls.Add(this.deleteGazeRegionButton, 1, 4); + this.tableLayoutPanel.Controls.Add(this.editGazeRegionButton, 0, 5); + this.tableLayoutPanel.Controls.Add(this.cloneGazeRegionButton, 1, 5); + this.tableLayoutPanel.Controls.Add(this.gazeMarkerCheckBox, 1, 8); + this.tableLayoutPanel.Controls.Add(this.pauseSimulationCheckBox, 0, 8); + this.tableLayoutPanel.Controls.Add(this.hideGazeRegionsButton, 0, 6); this.tableLayoutPanel.Controls.Add(this.generalSettingsButton, 0, 10); this.tableLayoutPanel.Controls.Add(this.blinkButton, 0, 9); - this.tableLayoutPanel.Controls.Add(this.showGazeRegionsButton, 1, 7); + this.tableLayoutPanel.Controls.Add(this.showGazeRegionsButton, 1, 6); this.tableLayoutPanel.Controls.Add(this.mouseMoverButton, 1, 9); + this.tableLayoutPanel.Controls.Add(this.editProfileButton, 0, 1); + this.tableLayoutPanel.Controls.Add(this.cloneProfileButton, 1, 1); this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel.Name = "tableLayoutPanel"; this.tableLayoutPanel.RowCount = 11; - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 5F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 5F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.Size = new System.Drawing.Size(234, 361); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 36F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(234, 448); this.tableLayoutPanel.TabIndex = 0; // // deleteProfileButton // this.deleteProfileButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.deleteProfileButton.Location = new System.Drawing.Point(117, 37); + this.deleteProfileButton.Location = new System.Drawing.Point(117, 0); this.deleteProfileButton.Margin = new System.Windows.Forms.Padding(0); this.deleteProfileButton.Name = "deleteProfileButton"; this.deleteProfileButton.Size = new System.Drawing.Size(117, 32); @@ -98,10 +102,32 @@ private void InitializeComponent() this.deleteProfileButton.UseVisualStyleBackColor = true; this.deleteProfileButton.Click += new System.EventHandler(this.deleteProfileButton_Click); // + // profilesComboBox + // + this.tableLayoutPanel.SetColumnSpan(this.profilesComboBox, 2); + this.profilesComboBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.profilesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.profilesComboBox.FormattingEnabled = true; + this.profilesComboBox.Location = new System.Drawing.Point(3, 67); + this.profilesComboBox.Name = "profilesComboBox"; + this.profilesComboBox.Size = new System.Drawing.Size(228, 21); + this.profilesComboBox.TabIndex = 0; + // + // gazeRegionsListBox + // + this.tableLayoutPanel.SetColumnSpan(this.gazeRegionsListBox, 2); + this.gazeRegionsListBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.gazeRegionsListBox.FormattingEnabled = true; + this.gazeRegionsListBox.IntegralHeight = false; + this.gazeRegionsListBox.Location = new System.Drawing.Point(3, 94); + this.gazeRegionsListBox.Name = "gazeRegionsListBox"; + this.gazeRegionsListBox.Size = new System.Drawing.Size(228, 141); + this.gazeRegionsListBox.TabIndex = 1; + // // newProfileButton // this.newProfileButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.newProfileButton.Location = new System.Drawing.Point(0, 37); + this.newProfileButton.Location = new System.Drawing.Point(0, 0); this.newProfileButton.Margin = new System.Windows.Forms.Padding(0); this.newProfileButton.Name = "newProfileButton"; this.newProfileButton.Size = new System.Drawing.Size(117, 32); @@ -113,7 +139,7 @@ private void InitializeComponent() // newGazeRegionButton // this.newGazeRegionButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.newGazeRegionButton.Location = new System.Drawing.Point(0, 193); + this.newGazeRegionButton.Location = new System.Drawing.Point(0, 238); this.newGazeRegionButton.Margin = new System.Windows.Forms.Padding(0); this.newGazeRegionButton.Name = "newGazeRegionButton"; this.newGazeRegionButton.Size = new System.Drawing.Size(117, 32); @@ -125,7 +151,7 @@ private void InitializeComponent() // deleteGazeRegionButton // this.deleteGazeRegionButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.deleteGazeRegionButton.Location = new System.Drawing.Point(117, 193); + this.deleteGazeRegionButton.Location = new System.Drawing.Point(117, 238); this.deleteGazeRegionButton.Margin = new System.Windows.Forms.Padding(0); this.deleteGazeRegionButton.Name = "deleteGazeRegionButton"; this.deleteGazeRegionButton.Size = new System.Drawing.Size(117, 32); @@ -137,7 +163,7 @@ private void InitializeComponent() // editGazeRegionButton // this.editGazeRegionButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.editGazeRegionButton.Location = new System.Drawing.Point(0, 225); + this.editGazeRegionButton.Location = new System.Drawing.Point(0, 270); this.editGazeRegionButton.Margin = new System.Windows.Forms.Padding(0); this.editGazeRegionButton.Name = "editGazeRegionButton"; this.editGazeRegionButton.Size = new System.Drawing.Size(117, 32); @@ -149,7 +175,7 @@ private void InitializeComponent() // cloneGazeRegionButton // this.cloneGazeRegionButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.cloneGazeRegionButton.Location = new System.Drawing.Point(117, 225); + this.cloneGazeRegionButton.Location = new System.Drawing.Point(117, 270); this.cloneGazeRegionButton.Margin = new System.Windows.Forms.Padding(0); this.cloneGazeRegionButton.Name = "cloneGazeRegionButton"; this.cloneGazeRegionButton.Size = new System.Drawing.Size(117, 32); @@ -163,7 +189,7 @@ private void InitializeComponent() this.gazeMarkerCheckBox.Appearance = System.Windows.Forms.Appearance.Button; this.gazeMarkerCheckBox.AutoSize = true; this.gazeMarkerCheckBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.gazeMarkerCheckBox.Location = new System.Drawing.Point(117, 0); + this.gazeMarkerCheckBox.Location = new System.Drawing.Point(117, 344); this.gazeMarkerCheckBox.Margin = new System.Windows.Forms.Padding(0); this.gazeMarkerCheckBox.Name = "gazeMarkerCheckBox"; this.gazeMarkerCheckBox.Size = new System.Drawing.Size(117, 32); @@ -180,7 +206,7 @@ private void InitializeComponent() this.pauseSimulationCheckBox.Checked = global::EyeBind.Properties.Settings.Default.InputSimulationPaused; this.pauseSimulationCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "InputSimulationPaused", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.pauseSimulationCheckBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.pauseSimulationCheckBox.Location = new System.Drawing.Point(0, 0); + this.pauseSimulationCheckBox.Location = new System.Drawing.Point(0, 344); this.pauseSimulationCheckBox.Margin = new System.Windows.Forms.Padding(0); this.pauseSimulationCheckBox.Name = "pauseSimulationCheckBox"; this.pauseSimulationCheckBox.Size = new System.Drawing.Size(117, 32); @@ -188,11 +214,12 @@ private void InitializeComponent() this.pauseSimulationCheckBox.Text = "Pause Simulation"; this.pauseSimulationCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.pauseSimulationCheckBox.UseVisualStyleBackColor = true; + this.pauseSimulationCheckBox.CheckedChanged += new System.EventHandler(this.pauseSimulationCheckBox_CheckedChanged); // // hideGazeRegionsButton // this.hideGazeRegionsButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.hideGazeRegionsButton.Location = new System.Drawing.Point(0, 257); + this.hideGazeRegionsButton.Location = new System.Drawing.Point(0, 302); this.hideGazeRegionsButton.Margin = new System.Windows.Forms.Padding(0); this.hideGazeRegionsButton.Name = "hideGazeRegionsButton"; this.hideGazeRegionsButton.Size = new System.Drawing.Size(117, 32); @@ -205,10 +232,10 @@ private void InitializeComponent() // this.tableLayoutPanel.SetColumnSpan(this.generalSettingsButton, 2); this.generalSettingsButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.generalSettingsButton.Location = new System.Drawing.Point(0, 326); + this.generalSettingsButton.Location = new System.Drawing.Point(0, 408); this.generalSettingsButton.Margin = new System.Windows.Forms.Padding(0); this.generalSettingsButton.Name = "generalSettingsButton"; - this.generalSettingsButton.Size = new System.Drawing.Size(234, 35); + this.generalSettingsButton.Size = new System.Drawing.Size(234, 40); this.generalSettingsButton.TabIndex = 11; this.generalSettingsButton.Text = "General Settings"; this.generalSettingsButton.UseVisualStyleBackColor = true; @@ -217,7 +244,7 @@ private void InitializeComponent() // blinkButton // this.blinkButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.blinkButton.Location = new System.Drawing.Point(0, 294); + this.blinkButton.Location = new System.Drawing.Point(0, 376); this.blinkButton.Margin = new System.Windows.Forms.Padding(0); this.blinkButton.Name = "blinkButton"; this.blinkButton.Size = new System.Drawing.Size(117, 32); @@ -229,7 +256,7 @@ private void InitializeComponent() // showGazeRegionsButton // this.showGazeRegionsButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.showGazeRegionsButton.Location = new System.Drawing.Point(117, 257); + this.showGazeRegionsButton.Location = new System.Drawing.Point(117, 302); this.showGazeRegionsButton.Margin = new System.Windows.Forms.Padding(0); this.showGazeRegionsButton.Name = "showGazeRegionsButton"; this.showGazeRegionsButton.Size = new System.Drawing.Size(117, 32); @@ -241,7 +268,7 @@ private void InitializeComponent() // mouseMoverButton // this.mouseMoverButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.mouseMoverButton.Location = new System.Drawing.Point(117, 294); + this.mouseMoverButton.Location = new System.Drawing.Point(117, 376); this.mouseMoverButton.Margin = new System.Windows.Forms.Padding(0); this.mouseMoverButton.Name = "mouseMoverButton"; this.mouseMoverButton.Size = new System.Drawing.Size(117, 32); @@ -250,32 +277,35 @@ private void InitializeComponent() this.mouseMoverButton.UseVisualStyleBackColor = true; this.mouseMoverButton.Click += new System.EventHandler(this.mouseMoverButton_Click); // - // profilesComboBox - // - this.tableLayoutPanel.SetColumnSpan(this.profilesComboBox, 2); - this.profilesComboBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.profilesComboBox.FormattingEnabled = true; - this.profilesComboBox.Location = new System.Drawing.Point(3, 72); - this.profilesComboBox.Name = "profilesComboBox"; - this.profilesComboBox.Size = new System.Drawing.Size(228, 21); - this.profilesComboBox.TabIndex = 0; - // - // gazeRegionsListBox - // - this.tableLayoutPanel.SetColumnSpan(this.gazeRegionsListBox, 2); - this.gazeRegionsListBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.gazeRegionsListBox.FormattingEnabled = true; - this.gazeRegionsListBox.IntegralHeight = false; - this.gazeRegionsListBox.Location = new System.Drawing.Point(3, 99); - this.gazeRegionsListBox.Name = "gazeRegionsListBox"; - this.gazeRegionsListBox.Size = new System.Drawing.Size(228, 91); - this.gazeRegionsListBox.TabIndex = 1; + // editProfileButton + // + this.editProfileButton.Dock = System.Windows.Forms.DockStyle.Fill; + this.editProfileButton.Location = new System.Drawing.Point(0, 32); + this.editProfileButton.Margin = new System.Windows.Forms.Padding(0); + this.editProfileButton.Name = "editProfileButton"; + this.editProfileButton.Size = new System.Drawing.Size(117, 32); + this.editProfileButton.TabIndex = 15; + this.editProfileButton.Text = "Edit Profile"; + this.editProfileButton.UseVisualStyleBackColor = true; + this.editProfileButton.Click += new System.EventHandler(this.editProfileButton_Click); + // + // cloneProfileButton + // + this.cloneProfileButton.Dock = System.Windows.Forms.DockStyle.Fill; + this.cloneProfileButton.Location = new System.Drawing.Point(117, 32); + this.cloneProfileButton.Margin = new System.Windows.Forms.Padding(0); + this.cloneProfileButton.Name = "cloneProfileButton"; + this.cloneProfileButton.Size = new System.Drawing.Size(117, 32); + this.cloneProfileButton.TabIndex = 16; + this.cloneProfileButton.Text = "Clone Profile"; + this.cloneProfileButton.UseVisualStyleBackColor = true; + this.cloneProfileButton.Click += new System.EventHandler(this.cloneProfileButton_Click); // // EyeBindMainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(234, 361); + this.ClientSize = new System.Drawing.Size(234, 448); this.Controls.Add(this.tableLayoutPanel); this.DataBindings.Add(new System.Windows.Forms.Binding("TopMost", global::EyeBind.Properties.Settings.Default, "mainWindowTopMost", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.MaximizeBox = false; @@ -307,6 +337,8 @@ private void InitializeComponent() private System.Windows.Forms.Button blinkButton; private System.Windows.Forms.Button showGazeRegionsButton; private System.Windows.Forms.Button mouseMoverButton; + private System.Windows.Forms.Button editProfileButton; + private System.Windows.Forms.Button cloneProfileButton; } } \ No newline at end of file diff --git a/EyeBind/EyeBindMainForm.cs b/EyeBind/EyeBindMainForm.cs index 4c3fb49..9153a9f 100644 --- a/EyeBind/EyeBindMainForm.cs +++ b/EyeBind/EyeBindMainForm.cs @@ -9,12 +9,12 @@ namespace EyeBind { public partial class EyeBindMainForm : Form { - private KeyboardHookListener keyboardHookManager; - private BindingList profilesList = new BindingList(); + private GazeProfilesBindingList profilesList = new GazeProfilesBindingList(); private BlinkMonitor blinkMonitor; private MouseMover mouseMover = new MouseMover(); private ScreenOverlay gazeMarkerTool; + #region Properties public GazeRegionsListBox GazeRegionsListBox { get @@ -30,62 +30,75 @@ public BindingList ProfilesList return this.profilesList; } } + #endregion public EyeBindMainForm() { InitializeComponent(); - - this.SetPauseSimulationCheckBoxText(); - this.SetGlobalKeyboardHook(); + this.SetPauseSimulationCheckBoxText(); this.mouseMover.Enabled = true; } #region Global Keyboard Hook - private void SetGlobalKeyboardHook() + private void SetHotKeysHandlers() { - this.keyboardHookManager = new KeyboardHookListener(new GlobalHooker()); - this.keyboardHookManager.Enabled = true; - this.keyboardHookManager.KeyUp += keyboardHookManager_KeyUp; + HotkeyManager.OnToggleSimulationHotkeyTriggered += OnToggleSimulationHotkeyTriggered; + HotkeyManager.OnToggleSoundHotkeyTriggered += OnToggleSoundHotkeyTriggered; + HotkeyManager.OnMouseMoveHotkeyTriggered += OnMouseMoveHotkeyTriggered; + HotkeyManager.OnToggleContinuousMouseMoveHotkeyTriggered += OnToggleContinuousMouseMoveHotkeyTriggered; + HotkeyManager.OnToggleGazeMarkerHotkeyTriggered += OnToggleGazeMarkerHotkeyTriggered; + HotkeyManager.OnProfileHotkeyTriggered += OnProfileHotkeyTriggered; } - private void keyboardHookManager_KeyUp(object sender, KeyEventArgs e) + private void OnProfileHotkeyTriggered(object sender, ProfileHotkeyEventArgs e) { - if(e.KeyData == Properties.Settings.Default.ToggleKeyboardSimulationHotKey) + try { - this.SetSimulationState(!GetSimulationState()); + if (this.profilesComboBox.SelectedIndex != e.ProfileIndex) + this.profilesComboBox.SelectedIndex = e.ProfileIndex; } + catch { } + } - if(e.KeyData == Properties.Settings.Default.MouseMoveHotKey) - { - this.mouseMover.MoveMouse(); - } + public void OnToggleSoundHotkeyTriggered(object sender, EventArgs args) + { + Properties.Settings.Default.GlobalSoundEnabled = !Properties.Settings.Default.GlobalSoundEnabled; + } - if(e.KeyData == Properties.Settings.Default.ToggleSoundsHotKey) - { - Properties.Settings.Default.GlobalSoundEnabled = !Properties.Settings.Default.GlobalSoundEnabled; - } + public void OnToggleSimulationHotkeyTriggered(object sender, EventArgs args) + { + this.SetSimulationState(!GetSimulationState()); + } - if (e.KeyData == Properties.Settings.Default.ToggleGazeMarkerHotKey) - { - this.gazeMarkerCheckBox.Checked = !this.gazeMarkerCheckBox.Checked; - } + public void OnMouseMoveHotkeyTriggered(object sender, EventArgs args) + { + this.mouseMover.MoveMouse(); + } - if (e.KeyData == Properties.Settings.Default.ToggleContinuousMouseMoveHotKey) - { - this.mouseMover.ContinuousMouseMoveEnabled = !this.mouseMover.ContinuousMouseMoveEnabled; - } + public void OnToggleContinuousMouseMoveHotkeyTriggered(object sender, EventArgs args) + { + this.mouseMover.ContinuousMouseMoveEnabled = !this.mouseMover.ContinuousMouseMoveEnabled; + } + + public void OnToggleGazeMarkerHotkeyTriggered(object sender, EventArgs args) + { + this.gazeMarkerCheckBox.Checked = !this.gazeMarkerCheckBox.Checked; } #endregion #region overrides + protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.ActiveControl = null; this.LoadProfiles(); this.LoadLastUsedProfile(); + + this.SetHotKeysHandlers(); + HotkeyManager.Enabled = true; } protected override void OnFormClosing(FormClosingEventArgs e) @@ -118,7 +131,7 @@ private void LoadProfiles() string filePath = System.IO.Directory.GetCurrentDirectory(); filePath += "\\profile\\profile.xml"; - if(!System.IO.File.Exists(filePath)) + if (!System.IO.File.Exists(filePath)) { this.LoadXmlFromResource(Properties.Resources.default_profile); return; @@ -158,7 +171,7 @@ private void ProcessProfilesXml(System.Xml.XmlDocument xmlDoc) } this.profilesComboBox.DataSource = this.profilesList; - this.profilesComboBox.DisplayMember = "Name"; + this.profilesComboBox.DisplayMember = "DisplayName"; this.blinkMonitor = new BlinkMonitor(xmlDoc.SelectSingleNode("/EyeBind/BlinkMonitor")); this.blinkMonitor.Enabled = true; @@ -214,10 +227,12 @@ private bool SaveProfiles(string fileName) #endregion - #region Buttons Clicks + #region Buttons/Checkboxes Handlers private void newProfileButton_Click(object sender, EventArgs e) { + HotkeyManager.Enabled = false; this.profilesComboBox.AddProfile(); + HotkeyManager.Enabled = true; } private void deleteProfileButton_Click(object sender, EventArgs e) @@ -225,6 +240,20 @@ private void deleteProfileButton_Click(object sender, EventArgs e) this.profilesComboBox.RemoveSelectedProfile(); } + private void editProfileButton_Click(object sender, EventArgs e) + { + HotkeyManager.Enabled = false; + this.profilesComboBox.EditSelectedProfile(); + HotkeyManager.Enabled = true; + } + + private void cloneProfileButton_Click(object sender, EventArgs e) + { + HotkeyManager.Enabled = false; + this.profilesComboBox.CloneSelectedProfille(); + HotkeyManager.Enabled = true; + } + private void newGazeRegionButton_Click(object sender, EventArgs e) { this.gazeRegionsListBox.AddGazeRegion(); @@ -237,7 +266,9 @@ private void deleteGazeRegionButton_Click(object sender, EventArgs e) private void editGazeRegionButton_Click(object sender, EventArgs e) { + HotkeyManager.Enabled = false; this.gazeRegionsListBox.EditSelectedGazeRegion(); + HotkeyManager.Enabled = true; } private void cloneGazeRegionButton_Click(object sender, EventArgs e) @@ -245,6 +276,21 @@ private void cloneGazeRegionButton_Click(object sender, EventArgs e) this.gazeRegionsListBox.CloneSelectedGazeRegion(); } + private void hideGazeRegionsButton_Click(object sender, EventArgs e) + { + this.profilesComboBox.HideSelectedProfile(); + } + + private void showGazeRegionsButton_Click(object sender, EventArgs e) + { + this.profilesComboBox.ShowSelectedProfile(); + } + + private void pauseSimulationCheckBox_CheckedChanged(object sender, EventArgs e) + { + this.SetPauseSimulationCheckBoxText(); + } + private void gazeMarkerCheckBox_CheckedChanged(object sender, EventArgs e) { if (this.gazeMarkerCheckBox.Checked) @@ -265,23 +311,15 @@ private void gazeMarkerCheckBox_CheckedChanged(object sender, EventArgs e) } } - private void hideGazeRegionsButton_Click(object sender, EventArgs e) - { - this.profilesComboBox.HideSelectedProfile(); - } - - private void showGazeRegionsButton_Click(object sender, EventArgs e) - { - this.profilesComboBox.ShowSelectedProfile(); - } - private void blinkButton_Click(object sender, EventArgs e) { - using(BlinkConfig bc = new BlinkConfig(this.blinkMonitor)) + HotkeyManager.Enabled = false; + using (BlinkConfig bc = new BlinkConfig(this.blinkMonitor)) { bc.ShowDialog(); bc.Dispose(); } + HotkeyManager.Enabled = true; } private void mouseMoverButton_Click(object sender, EventArgs e) @@ -291,15 +329,14 @@ private void mouseMoverButton_Click(object sender, EventArgs e) private void generalSettingsButton_Click(object sender, EventArgs e) { + HotkeyManager.Enabled = false; using (GeneralSettingsDialog gsd = new GeneralSettingsDialog()) { - this.keyboardHookManager.Enabled = false; gsd.ShowDialog(); gsd.Dispose(); - this.keyboardHookManager.Enabled = true; } + HotkeyManager.Enabled = true; } - #endregion public void SetSimulationState(bool paused) { @@ -313,7 +350,7 @@ public bool GetSimulationState() private void SetPauseSimulationCheckBoxText() { - if(this.pauseSimulationCheckBox.Checked) + if (this.pauseSimulationCheckBox.Checked) { this.pauseSimulationCheckBox.Text = "Resume Simulation"; } @@ -322,11 +359,12 @@ private void SetPauseSimulationCheckBoxText() this.pauseSimulationCheckBox.Text = "Pause Simulation"; } } + #endregion #region last used profile private void LoadLastUsedProfile() { - if(Settings.Default.LastUsedProfileIndex > -1) + if (Settings.Default.LastUsedProfileIndex > -1) { try { @@ -344,5 +382,7 @@ private void SaveLastUsedProfile() Settings.Default.LastUsedProfileIndex = this.profilesComboBox.SelectedIndex; } #endregion + + } } diff --git a/EyeBind/GazeHtmlPanel.cs b/EyeBind/GazeHtmlPanel.cs new file mode 100644 index 0000000..7afb21c --- /dev/null +++ b/EyeBind/GazeHtmlPanel.cs @@ -0,0 +1,35 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using TheArtOfDev.HtmlRenderer.WinForms; + +namespace EyeBind +{ + public class GazeHtmlPanel : HtmlPanel + { + public GazeHtmlPanel() + { + this.IsContextMenuEnabled = false; + this.IsSelectionEnabled = false; + this.BackColor = Color.Transparent; + this.Dock = DockStyle.Fill; + this.AutoScroll = false; + } + + protected override void AdjustFormScrollbars(bool displayScrollbars) + { + base.AdjustFormScrollbars(false); + } + + protected override void WndProc(ref Message m) + { + const int WM_NCHITTEST = 0x84; + const int HTTRANSPARENT = -1; + + if (m.Msg == (int)WM_NCHITTEST) + m.Result = (IntPtr)HTTRANSPARENT; + else + base.WndProc(ref m); + } + } +} diff --git a/EyeBind/GazePanel.cs b/EyeBind/GazePanel.cs index 32f4a0f..f89e91e 100644 --- a/EyeBind/GazePanel.cs +++ b/EyeBind/GazePanel.cs @@ -1,11 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace EyeBind @@ -13,7 +7,7 @@ namespace EyeBind public partial class GazePanel : UserControl { Color borderColor = Color.Empty; - int borderWidth = 5; + int borderWidth = 4; public int BorderWidth { diff --git a/EyeBind/GazeProfilesBindingList.cs b/EyeBind/GazeProfilesBindingList.cs new file mode 100644 index 0000000..6e72e10 --- /dev/null +++ b/EyeBind/GazeProfilesBindingList.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace EyeBind +{ + public class GazeProfilesBindingList : BindingList + { + protected override void OnListChanged(ListChangedEventArgs e) + { + base.OnListChanged(e); + + switch(e.ListChangedType) + { + case ListChangedType.Reset: + HotkeyManager.ClearHotkeys(); + break; + + case ListChangedType.ItemAdded: + if(e.NewIndex > -1) + { + Keys k = ((EyeBind.GazeRegionProfile)this[e.NewIndex]).Hotkey; + VerifyHotKeyUniqueness(k, e.NewIndex); + HotkeyManager.RegisterHotkey(k, e.NewIndex); + } + break; + + case ListChangedType.ItemDeleted: + if (e.NewIndex > -1) + { + HotkeyManager.ClearHotkeys(); + RegisterHotKeys(); + } + break; + + case ListChangedType.ItemChanged: + if (e.NewIndex > -1) + { + Keys k = ((EyeBind.GazeRegionProfile)this[e.NewIndex]).Hotkey; + VerifyHotKeyUniqueness(k, e.NewIndex); + HotkeyManager.ClearHotkeys(); + RegisterHotKeys(); + } + break; + } + } + + private void VerifyHotKeyUniqueness(Keys key, int index) + { + for(int i = 0; i < this.Count; i++) + { + if (i == index) + continue; + + Keys k = ((EyeBind.GazeRegionProfile)this[i]).Hotkey; + if (k == key) + ((EyeBind.GazeRegionProfile)this[i]).Hotkey = Keys.None; + } + } + + private void RegisterHotKeys() + { + for (int i = 0; i < this.Count; i++) + { + Keys k = ((EyeBind.GazeRegionProfile)this[i]).Hotkey; + HotkeyManager.RegisterHotkey(k, i); + } + } + } +} diff --git a/EyeBind/GazeRegion.cs b/EyeBind/GazeRegion.cs index 3fa1680..4271ae2 100644 --- a/EyeBind/GazeRegion.cs +++ b/EyeBind/GazeRegion.cs @@ -52,12 +52,12 @@ public class GazeRegion : Form, INotifyPropertyChanged private Color gazeEnterColor = Color.Empty; private Color gazeExitColor = Color.Empty; private readonly Color gazeEnterColorDefault = Color.LightSkyBlue; - private readonly Color gazeExitColorDefault = Color.Transparent; + private readonly Color gazeExitColorDefault = Color.White; private Color gazeActivationColor = Color.Empty; private Color gazeDeactivationColor = Color.Empty; private readonly Color gazeActivationColorDefault = Color.LightBlue; - private readonly Color gazeDeactivationColorDefault = Color.Transparent; + private readonly Color gazeDeactivationColorDefault = Color.White; private int activationDelay; private int deactivationDelay; @@ -73,6 +73,9 @@ public class GazeRegion : Form, INotifyPropertyChanged private KeyboardInputSimulator keyboardInputSimulator = new KeyboardInputSimulator(); private GazePanel gazePanel = new GazePanel(); + private GazeHtmlPanel htmlPanel = new GazeHtmlPanel(); + + private string html; #endregion @@ -93,7 +96,10 @@ public GazeRegion(): base() this.GazeActivationColor = gazeActivationColorDefault; this.GazeDeactivationColor = gazeDeactivationColorDefault; + this.gazePanel.BorderColor = gazeDeactivationColorDefault; + this.Controls.Add(this.gazePanel); + this.gazePanel.Controls.Add(this.htmlPanel); } public GazeRegion(XmlNode xn): this() @@ -125,6 +131,11 @@ public GazeRegion Clone() clone.ActivationDelay = this.ActivationDelay; clone.DeactivationDelay = this.DeactivationDelay; + clone.ActivationCooldown = this.ActivationCooldown; + clone.DeactivationCooldown = this.DeactivationCooldown; + + clone.HTML = this.HTML; + return clone; } @@ -358,6 +369,23 @@ public int DeactivationCooldown } } + public string HTML + { + get + { + return this.html; + } + set + { + if (value != this.html) + { + this.html = value; + NotifyPropertyChanged(); + this.htmlPanel.Text = value; + } + } + } + #endregion #region Gaze data process/logic @@ -673,8 +701,21 @@ private void FromXml(XmlNode xn) catch { this.DeactivationCooldown = 0; + i = 0; } + try + { + n = xn.SelectSingleNode(".//HTML"); + XmlCDataSection cDataNode = (XmlCDataSection)(n.ChildNodes[0]); + this.HTML = cDataNode.Data; + } + catch + { + this.HTML = string.Empty; + } + + n = xn.SelectSingleNode(".//KeyboardInputSimulator"); this.keyboardInputSimulator = new KeyboardInputSimulator(n); } @@ -745,6 +786,11 @@ public XmlDocument ToXml() deactivationCooldown.InnerText = this.DeactivationCooldown.ToString(); root.AppendChild(deactivationCooldown); + XmlElement html = xmlDoc.CreateElement("HTML"); + XmlCDataSection cdata = xmlDoc.CreateCDataSection(this.HTML); + html.AppendChild(cdata); + root.AppendChild(html); + XmlDocument xd = this.keyboardInputSimulator.ToXml(); XmlDocumentFragment xfrag = xmlDoc.CreateDocumentFragment(); xfrag.InnerXml = xd.OuterXml; diff --git a/EyeBind/GazeRegionEditor.Designer.cs b/EyeBind/GazeRegionEditor.Designer.cs index 921bf74..17ca71a 100644 --- a/EyeBind/GazeRegionEditor.Designer.cs +++ b/EyeBind/GazeRegionEditor.Designer.cs @@ -71,7 +71,10 @@ private void InitializeComponent() this.deactivationDelayNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.clearGazeExitKeyboardInputsButton = new System.Windows.Forms.Button(); this.groupBox8 = new System.Windows.Forms.GroupBox(); + this.htmlTabPage = new System.Windows.Forms.TabPage(); + this.htmlTextBox = new System.Windows.Forms.TextBox(); this.colorDialog = new System.Windows.Forms.ColorDialog(); + this.applyHtmlButton = new System.Windows.Forms.Button(); this.gazeEnterInputsDataGridView = new EyeBind.KeyRecorderDataGridView(); this.gazeEnterKeyRecorderCheckBox = new EyeBind.KeyRecorderCheckBox(); this.gazeExitInputsDataGridView = new EyeBind.KeyRecorderDataGridView(); @@ -102,6 +105,7 @@ private void InitializeComponent() this.groupBox12.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.deactivationDelayNumericUpDown)).BeginInit(); this.groupBox8.SuspendLayout(); + this.htmlTabPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gazeEnterInputsDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gazeExitInputsDataGridView)).BeginInit(); this.SuspendLayout(); @@ -112,6 +116,7 @@ private void InitializeComponent() this.tabControl1.Controls.Add(this.AppearanceTabPage); this.tabControl1.Controls.Add(this.gazeEnterInputstabPage); this.tabControl1.Controls.Add(this.gazeExitInputsTabPage); + this.tabControl1.Controls.Add(this.htmlTabPage); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; @@ -478,9 +483,9 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(113, 9); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(236, 13); + this.label7.Size = new System.Drawing.Size(241, 13); this.label7.TabIndex = 4; - this.label7.Text = "All keyboard simulation are paused when editing."; + this.label7.Text = "All keyboard simulations are paused when editing."; // // groupBox11 // @@ -559,9 +564,9 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(113, 9); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(236, 13); + this.label8.Size = new System.Drawing.Size(241, 13); this.label8.TabIndex = 7; - this.label8.Text = "All keyboard simulation are paused when editing."; + this.label8.Text = "All keyboard simulations are paused when editing."; // // groupBox12 // @@ -621,6 +626,35 @@ private void InitializeComponent() this.groupBox8.TabStop = false; this.groupBox8.Text = "Gaze Exit Inputs"; // + // htmlTabPage + // + this.htmlTabPage.BackColor = System.Drawing.SystemColors.Control; + this.htmlTabPage.Controls.Add(this.applyHtmlButton); + this.htmlTabPage.Controls.Add(this.htmlTextBox); + this.htmlTabPage.Location = new System.Drawing.Point(4, 22); + this.htmlTabPage.Name = "htmlTabPage"; + this.htmlTabPage.Size = new System.Drawing.Size(478, 559); + this.htmlTabPage.TabIndex = 4; + this.htmlTabPage.Text = "HTML"; + // + // htmlTextBox + // + this.htmlTextBox.Location = new System.Drawing.Point(8, 13); + this.htmlTextBox.Multiline = true; + this.htmlTextBox.Name = "htmlTextBox"; + this.htmlTextBox.Size = new System.Drawing.Size(462, 494); + this.htmlTextBox.TabIndex = 0; + // + // applyHtmlButton + // + this.applyHtmlButton.Location = new System.Drawing.Point(395, 513); + this.applyHtmlButton.Name = "applyHtmlButton"; + this.applyHtmlButton.Size = new System.Drawing.Size(75, 23); + this.applyHtmlButton.TabIndex = 1; + this.applyHtmlButton.Text = "Apply"; + this.applyHtmlButton.UseVisualStyleBackColor = true; + this.applyHtmlButton.Click += new System.EventHandler(this.applyHtmlButton_Click); + // // gazeEnterInputsDataGridView // this.gazeEnterInputsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -673,6 +707,8 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(486, 585); this.Controls.Add(this.tabControl1); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "GazeRegionEditor"; this.ShowInTaskbar = false; this.Text = "Gaze Region Editor"; @@ -711,6 +747,8 @@ private void InitializeComponent() this.groupBox12.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.deactivationDelayNumericUpDown)).EndInit(); this.groupBox8.ResumeLayout(false); + this.htmlTabPage.ResumeLayout(false); + this.htmlTabPage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.gazeEnterInputsDataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gazeExitInputsDataGridView)).EndInit(); this.ResumeLayout(false); @@ -767,5 +805,8 @@ private void InitializeComponent() private System.Windows.Forms.Panel dockPanel; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.TabPage htmlTabPage; + private System.Windows.Forms.TextBox htmlTextBox; + private System.Windows.Forms.Button applyHtmlButton; } } \ No newline at end of file diff --git a/EyeBind/GazeRegionEditor.cs b/EyeBind/GazeRegionEditor.cs index 288eddb..97cffd7 100644 --- a/EyeBind/GazeRegionEditor.cs +++ b/EyeBind/GazeRegionEditor.cs @@ -57,6 +57,8 @@ private void SetBindings() this.gazeEnterKeyRecorderCheckBox.KeyboardInputBindingList = this.gazeRegion.GazeEnterInputs; this.InitializeDataGridView(this.gazeExitInputsDataGridView, this.gazeRegion.GazeExitInputs); this.gazeExitKeyRecorderCheckBox.KeyboardInputBindingList = this.gazeRegion.GazeExitInputs; + + this.htmlTextBox.Text = this.gazeRegion.HTML; } private void UnsetBindings() @@ -83,6 +85,8 @@ private void UnsetBindings() this.gazeEnterInputsDataGridView.DataSource = null; this.gazeExitInputsDataGridView.DataSource = null; + this.gazeRegion.HTML = this.htmlTextBox.Text; + this.gazeRegion = null; } @@ -175,5 +179,10 @@ private void clearGazeExitKeyboardInputsButton_Click(object sender, EventArgs e) { this.gazeRegion.GazeExitInputs.Clear(); } + + private void applyHtmlButton_Click(object sender, EventArgs e) + { + this.gazeRegion.HTML = this.htmlTextBox.Text; + } } } diff --git a/EyeBind/GazeRegionEditor.resx b/EyeBind/GazeRegionEditor.resx index 167c2e6..605a37d 100644 --- a/EyeBind/GazeRegionEditor.resx +++ b/EyeBind/GazeRegionEditor.resx @@ -121,6 +121,6 @@ 17, 17 - 36 + 34 \ No newline at end of file diff --git a/EyeBind/GazeRegionProfile.cs b/EyeBind/GazeRegionProfile.cs index 455c99c..b8e82be 100644 --- a/EyeBind/GazeRegionProfile.cs +++ b/EyeBind/GazeRegionProfile.cs @@ -1,11 +1,15 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; using System.Windows.Forms; +using System.Xml; namespace EyeBind { - public class GazeRegionProfile + public class GazeRegionProfile: INotifyPropertyChanged { private BindingList grl = new BindingList(); + private const string defaultName = "Gaze Profile"; private string name; private Keys hotkey = Keys.None; @@ -15,7 +19,22 @@ public BindingList Profile { return this.grl; } - + } + + public Keys Hotkey + { + get + { + return this.hotkey; + } + set + { + if (value != this.hotkey) + { + this.hotkey = value; + NotifyPropertyChanged(); + } + } } public string Name @@ -30,6 +49,17 @@ public string Name } } + public string DisplayName + { + get + { + if(this.hotkey == Keys.None) + return this.name; + else + return (this.name + " (" + this.hotkey.ToString() + " )"); + } + } + public GazeRegionProfile() : base() { @@ -37,7 +67,7 @@ public GazeRegionProfile() this.name = string.Empty; } - public GazeRegionProfile(System.Xml.XmlNode xn) + public GazeRegionProfile(XmlNode xn) : this() { this.FromXml(xn); @@ -90,34 +120,70 @@ public void RemoveGazeRegions() } } - private void FromXml(System.Xml.XmlNode xn) + #region XML Read/Write + private void FromXml(XmlNode xn) { - this.Name = xn.Attributes["Name"].Value; + try + { + this.Name = xn.Attributes["Name"].Value; + } + catch + { + this.Name = defaultName; + } + + try + { + Keys k; + if (Enum.TryParse(xn.Attributes["Hotkey"].Value, out k)) + { + this.Hotkey = k; + } + } + catch + { + this.Hotkey = Keys.None; + } - System.Xml.XmlNodeList grn = xn.ChildNodes; - foreach(System.Xml.XmlNode n in grn) + XmlNodeList grn = xn.ChildNodes; + foreach(XmlNode n in grn) { this.grl.Add(new GazeRegion(n)); } } - public System.Xml.XmlDocument ToXml() + public XmlDocument ToXml() { - System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); + XmlDocument xmlDoc = new XmlDocument(); xmlDoc.AppendChild(xmlDoc.CreateElement("GazeRegionProfile")); xmlDoc.DocumentElement.SetAttribute("Name", this.Name); xmlDoc.DocumentElement.SetAttribute("Hotkey", ((int)this.hotkey).ToString()); foreach (GazeRegion gr in this.grl) { - System.Xml.XmlDocument xd = gr.ToXml(); - System.Xml.XmlDocumentFragment xfrag = xmlDoc.CreateDocumentFragment(); + XmlDocument xd = gr.ToXml(); + XmlDocumentFragment xfrag = xmlDoc.CreateDocumentFragment(); xfrag.InnerXml = xd.OuterXml; xmlDoc.DocumentElement.AppendChild(xfrag); } return xmlDoc; } + #endregion + + #region INotifyPropertyChanged + + public event PropertyChangedEventHandler PropertyChanged; + + private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + #endregion } } diff --git a/EyeBind/GazeRegionsListBox.cs b/EyeBind/GazeRegionsListBox.cs index 61b77d1..f2d7ae5 100644 --- a/EyeBind/GazeRegionsListBox.cs +++ b/EyeBind/GazeRegionsListBox.cs @@ -27,8 +27,6 @@ public bool RemoveSelectedGazeRegion() return false; } } - - //System.Media.SystemSounds.Beep.Play(); return false; } diff --git a/EyeBind/GeneralSettingsDialog.Designer.cs b/EyeBind/GeneralSettingsDialog.Designer.cs index 45e0793..ce19f37 100644 --- a/EyeBind/GeneralSettingsDialog.Designer.cs +++ b/EyeBind/GeneralSettingsDialog.Designer.cs @@ -30,7 +30,14 @@ private void InitializeComponent() { this.tabControl = new System.Windows.Forms.TabControl(); this.generalTabPage = new System.Windows.Forms.TabPage(); + this.mainWindowTopMostCheckBox = new System.Windows.Forms.CheckBox(); this.soundsTabPage = new System.Windows.Forms.TabPage(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.globalSoundsEnableCheckBox = new System.Windows.Forms.CheckBox(); + this.activationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); + this.blinkActivationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); + this.deactivationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); this.hotkeysTabPage = new System.Windows.Forms.TabPage(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.toggleGazeMarkerHotKeyResetButton = new System.Windows.Forms.Button(); @@ -47,13 +54,6 @@ private void InitializeComponent() this.groupBox1 = new System.Windows.Forms.GroupBox(); this.moveMouseHotKeyResetButton = new System.Windows.Forms.Button(); this.moveMouseHotKeyTextBox = new EyeBind.HotKeyTextBox(); - this.mainWindowTopMostCheckBox = new System.Windows.Forms.CheckBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.checkBox2 = new System.Windows.Forms.CheckBox(); - this.globalSoundsEnableCheckBox = new System.Windows.Forms.CheckBox(); - this.activationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); - this.blinkActivationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); - this.deactivationSoundEnabledCheckBox = new System.Windows.Forms.CheckBox(); this.tabControl.SuspendLayout(); this.generalTabPage.SuspendLayout(); this.soundsTabPage.SuspendLayout(); @@ -88,6 +88,18 @@ private void InitializeComponent() this.generalTabPage.Text = "General"; this.generalTabPage.UseVisualStyleBackColor = true; // + // mainWindowTopMostCheckBox + // + this.mainWindowTopMostCheckBox.AutoSize = true; + this.mainWindowTopMostCheckBox.Checked = global::EyeBind.Properties.Settings.Default.MainWindowTopMost; + this.mainWindowTopMostCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "mainWindowTopMost", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.mainWindowTopMostCheckBox.Location = new System.Drawing.Point(8, 35); + this.mainWindowTopMostCheckBox.Name = "mainWindowTopMostCheckBox"; + this.mainWindowTopMostCheckBox.Size = new System.Drawing.Size(151, 17); + this.mainWindowTopMostCheckBox.TabIndex = 0; + this.mainWindowTopMostCheckBox.Text = "Keep main window on top."; + this.mainWindowTopMostCheckBox.UseVisualStyleBackColor = true; + // // soundsTabPage // this.soundsTabPage.Controls.Add(this.checkBox1); @@ -104,6 +116,78 @@ private void InitializeComponent() this.soundsTabPage.Text = "Sounds"; this.soundsTabPage.UseVisualStyleBackColor = true; // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Checked = global::EyeBind.Properties.Settings.Default.GazeEnterSoundEnabled; + this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GazeEnterSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.checkBox1.Location = new System.Drawing.Point(23, 56); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(147, 17); + this.checkBox1.TabIndex = 5; + this.checkBox1.Text = "Enable gaze enter sound."; + this.checkBox1.UseVisualStyleBackColor = true; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Checked = global::EyeBind.Properties.Settings.Default.GazeExitSoundEnabled; + this.checkBox2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GazeExitSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.checkBox2.Location = new System.Drawing.Point(23, 79); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(139, 17); + this.checkBox2.TabIndex = 6; + this.checkBox2.Text = "Enable gaze exit sound."; + this.checkBox2.UseVisualStyleBackColor = true; + // + // globalSoundsEnableCheckBox + // + this.globalSoundsEnableCheckBox.AutoSize = true; + this.globalSoundsEnableCheckBox.Checked = global::EyeBind.Properties.Settings.Default.GlobalSoundEnabled; + this.globalSoundsEnableCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GlobalSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.globalSoundsEnableCheckBox.Location = new System.Drawing.Point(8, 35); + this.globalSoundsEnableCheckBox.Name = "globalSoundsEnableCheckBox"; + this.globalSoundsEnableCheckBox.Size = new System.Drawing.Size(96, 17); + this.globalSoundsEnableCheckBox.TabIndex = 4; + this.globalSoundsEnableCheckBox.Text = "Enable sounds"; + this.globalSoundsEnableCheckBox.UseVisualStyleBackColor = true; + // + // activationSoundEnabledCheckBox + // + this.activationSoundEnabledCheckBox.AutoSize = true; + this.activationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.ActivationSoundEnabled; + this.activationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "ActivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.activationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 102); + this.activationSoundEnabledCheckBox.Name = "activationSoundEnabledCheckBox"; + this.activationSoundEnabledCheckBox.Size = new System.Drawing.Size(169, 17); + this.activationSoundEnabledCheckBox.TabIndex = 1; + this.activationSoundEnabledCheckBox.Text = "Enable gaze activation sound."; + this.activationSoundEnabledCheckBox.UseVisualStyleBackColor = true; + // + // blinkActivationSoundEnabledCheckBox + // + this.blinkActivationSoundEnabledCheckBox.AutoSize = true; + this.blinkActivationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.BlinkActivationSoundEnabled; + this.blinkActivationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "BlinkActivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.blinkActivationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 148); + this.blinkActivationSoundEnabledCheckBox.Name = "blinkActivationSoundEnabledCheckBox"; + this.blinkActivationSoundEnabledCheckBox.Size = new System.Drawing.Size(168, 17); + this.blinkActivationSoundEnabledCheckBox.TabIndex = 3; + this.blinkActivationSoundEnabledCheckBox.Text = "Enable blink activation sound."; + this.blinkActivationSoundEnabledCheckBox.UseVisualStyleBackColor = true; + // + // deactivationSoundEnabledCheckBox + // + this.deactivationSoundEnabledCheckBox.AutoSize = true; + this.deactivationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.DeactivationSoundEnabled; + this.deactivationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "DeactivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.deactivationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 125); + this.deactivationSoundEnabledCheckBox.Name = "deactivationSoundEnabledCheckBox"; + this.deactivationSoundEnabledCheckBox.Size = new System.Drawing.Size(181, 17); + this.deactivationSoundEnabledCheckBox.TabIndex = 2; + this.deactivationSoundEnabledCheckBox.Text = "Enable gaze deactivation sound."; + this.deactivationSoundEnabledCheckBox.UseVisualStyleBackColor = true; + // // hotkeysTabPage // this.hotkeysTabPage.Controls.Add(this.groupBox5); @@ -263,96 +347,14 @@ private void InitializeComponent() this.moveMouseHotKeyTextBox.Size = new System.Drawing.Size(147, 20); this.moveMouseHotKeyTextBox.TabIndex = 0; // - // mainWindowTopMostCheckBox - // - this.mainWindowTopMostCheckBox.AutoSize = true; - this.mainWindowTopMostCheckBox.Checked = global::EyeBind.Properties.Settings.Default.MainWindowTopMost; - this.mainWindowTopMostCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "mainWindowTopMost", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.mainWindowTopMostCheckBox.Location = new System.Drawing.Point(8, 35); - this.mainWindowTopMostCheckBox.Name = "mainWindowTopMostCheckBox"; - this.mainWindowTopMostCheckBox.Size = new System.Drawing.Size(151, 17); - this.mainWindowTopMostCheckBox.TabIndex = 0; - this.mainWindowTopMostCheckBox.Text = "Keep main window on top."; - this.mainWindowTopMostCheckBox.UseVisualStyleBackColor = true; - // - // checkBox1 - // - this.checkBox1.AutoSize = true; - this.checkBox1.Checked = global::EyeBind.Properties.Settings.Default.GazeEnterSoundEnabled; - this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GazeEnterSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.checkBox1.Location = new System.Drawing.Point(23, 56); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(147, 17); - this.checkBox1.TabIndex = 5; - this.checkBox1.Text = "Enable gaze enter sound."; - this.checkBox1.UseVisualStyleBackColor = true; - // - // checkBox2 - // - this.checkBox2.AutoSize = true; - this.checkBox2.Checked = global::EyeBind.Properties.Settings.Default.GazeExitSoundEnabled; - this.checkBox2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GazeExitSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.checkBox2.Location = new System.Drawing.Point(23, 79); - this.checkBox2.Name = "checkBox2"; - this.checkBox2.Size = new System.Drawing.Size(139, 17); - this.checkBox2.TabIndex = 6; - this.checkBox2.Text = "Enable gaze exit sound."; - this.checkBox2.UseVisualStyleBackColor = true; - // - // globalSoundsEnableCheckBox - // - this.globalSoundsEnableCheckBox.AutoSize = true; - this.globalSoundsEnableCheckBox.Checked = global::EyeBind.Properties.Settings.Default.GlobalSoundEnabled; - this.globalSoundsEnableCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "GlobalSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.globalSoundsEnableCheckBox.Location = new System.Drawing.Point(8, 35); - this.globalSoundsEnableCheckBox.Name = "globalSoundsEnableCheckBox"; - this.globalSoundsEnableCheckBox.Size = new System.Drawing.Size(96, 17); - this.globalSoundsEnableCheckBox.TabIndex = 4; - this.globalSoundsEnableCheckBox.Text = "Enable sounds"; - this.globalSoundsEnableCheckBox.UseVisualStyleBackColor = true; - // - // activationSoundEnabledCheckBox - // - this.activationSoundEnabledCheckBox.AutoSize = true; - this.activationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.ActivationSoundEnabled; - this.activationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "ActivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.activationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 102); - this.activationSoundEnabledCheckBox.Name = "activationSoundEnabledCheckBox"; - this.activationSoundEnabledCheckBox.Size = new System.Drawing.Size(169, 17); - this.activationSoundEnabledCheckBox.TabIndex = 1; - this.activationSoundEnabledCheckBox.Text = "Enable gaze activation sound."; - this.activationSoundEnabledCheckBox.UseVisualStyleBackColor = true; - // - // blinkActivationSoundEnabledCheckBox - // - this.blinkActivationSoundEnabledCheckBox.AutoSize = true; - this.blinkActivationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.BlinkActivationSoundEnabled; - this.blinkActivationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "BlinkActivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.blinkActivationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 148); - this.blinkActivationSoundEnabledCheckBox.Name = "blinkActivationSoundEnabledCheckBox"; - this.blinkActivationSoundEnabledCheckBox.Size = new System.Drawing.Size(168, 17); - this.blinkActivationSoundEnabledCheckBox.TabIndex = 3; - this.blinkActivationSoundEnabledCheckBox.Text = "Enable blink activation sound."; - this.blinkActivationSoundEnabledCheckBox.UseVisualStyleBackColor = true; - // - // deactivationSoundEnabledCheckBox - // - this.deactivationSoundEnabledCheckBox.AutoSize = true; - this.deactivationSoundEnabledCheckBox.Checked = global::EyeBind.Properties.Settings.Default.DeactivationSoundEnabled; - this.deactivationSoundEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::EyeBind.Properties.Settings.Default, "DeactivationSoundEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.deactivationSoundEnabledCheckBox.Location = new System.Drawing.Point(23, 125); - this.deactivationSoundEnabledCheckBox.Name = "deactivationSoundEnabledCheckBox"; - this.deactivationSoundEnabledCheckBox.Size = new System.Drawing.Size(181, 17); - this.deactivationSoundEnabledCheckBox.TabIndex = 2; - this.deactivationSoundEnabledCheckBox.Text = "Enable gaze deactivation sound."; - this.deactivationSoundEnabledCheckBox.UseVisualStyleBackColor = true; - // // GeneralSettingsDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(289, 385); this.Controls.Add(this.tabControl); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "GeneralSettingsDialog"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; diff --git a/EyeBind/HotkeyManager.cs b/EyeBind/HotkeyManager.cs new file mode 100644 index 0000000..61d9711 --- /dev/null +++ b/EyeBind/HotkeyManager.cs @@ -0,0 +1,153 @@ +using MouseKeyboardActivityMonitor; +using MouseKeyboardActivityMonitor.WinApi; +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace EyeBind +{ + static class HotkeyManager + { + private static Dictionary profilesKeysHotkey = new Dictionary(); + private static KeyboardHookListener keyboardHookManager = new KeyboardHookListener(new GlobalHooker()); + + public static EventHandler OnProfileHotkeyTriggered; + public static EventHandler OnToggleSimulationHotkeyTriggered; + public static EventHandler OnToggleSoundHotkeyTriggered; + public static EventHandler OnToggleGazeMarkerHotkeyTriggered; + public static EventHandler OnToggleContinuousMouseMoveHotkeyTriggered; + public static EventHandler OnMouseMoveHotkeyTriggered; + + static HotkeyManager() + { + keyboardHookManager.KeyUp += keyboardHookManager_KeyUp; + } + + private static void keyboardHookManager_KeyUp(object sender, KeyEventArgs e) + { + if (profilesKeysHotkey.ContainsKey(e.KeyData)) + { + ProfileHotkeyEventArgs args = new ProfileHotkeyEventArgs(e.KeyData, profilesKeysHotkey[e.KeyData]); + RaiseProfileHotkeyTriggered(args); + } + + if (e.KeyData == Properties.Settings.Default.ToggleSoundsHotKey) + { + RaiseToggleSoundHotkeyTriggered(new EventArgs()); + } + + if (e.KeyData == Properties.Settings.Default.ToggleKeyboardSimulationHotKey) + { + RaiseToggleSimulationHotkeyTriggered(new EventArgs()); + } + + if (e.KeyData == Properties.Settings.Default.MouseMoveHotKey) + { + RaiseMouseMoveHotkeyTriggered(new EventArgs()); + } + + if (e.KeyData == Properties.Settings.Default.ToggleContinuousMouseMoveHotKey) + { + RaiseToggleContinuousMouseMoveHotkeyTriggered(new EventArgs()); + } + + if (e.KeyData == Properties.Settings.Default.ToggleGazeMarkerHotKey) + { + RaiseToggleGazeMarkerHotkeyTriggered(new EventArgs()); + } + } + + private static void RaiseProfileHotkeyTriggered(ProfileHotkeyEventArgs e) + { + EventHandler handler = OnProfileHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + private static void RaiseToggleSimulationHotkeyTriggered(EventArgs e) + { + EventHandler handler = OnToggleSimulationHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + private static void RaiseToggleSoundHotkeyTriggered(EventArgs e) + { + EventHandler handler = OnToggleSoundHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + private static void RaiseMouseMoveHotkeyTriggered(EventArgs e) + { + EventHandler handler = OnMouseMoveHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + private static void RaiseToggleContinuousMouseMoveHotkeyTriggered(EventArgs e) + { + EventHandler handler = OnToggleContinuousMouseMoveHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + private static void RaiseToggleGazeMarkerHotkeyTriggered(EventArgs e) + { + EventHandler handler = OnToggleGazeMarkerHotkeyTriggered; + if (handler != null) + { + handler(null, e); + } + } + + public static bool Enabled + { + get + { + return keyboardHookManager.Enabled; + } + set + { + keyboardHookManager.Enabled = value; + } + } + + public static void ClearHotkeys() + { + profilesKeysHotkey.Clear(); + } + + public static bool RegisterHotkey(Keys key, int profileIndex) + { + if (key != Keys.None) + { + if (!profilesKeysHotkey.ContainsKey(key)) + { + profilesKeysHotkey.Add(key, profileIndex); + return true; + } + return false; + } + return false; + } + + public static bool IsProfileHotkeyUsed(Keys key) + { + if (profilesKeysHotkey.ContainsKey(key)) + return true; + else + return false; + } + } +} diff --git a/EyeBind/ProcessChecker.cs b/EyeBind/ProcessChecker.cs new file mode 100644 index 0000000..8c9f31d --- /dev/null +++ b/EyeBind/ProcessChecker.cs @@ -0,0 +1,96 @@ +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; +using System; +using System.Windows.Forms; + +/// +/// Check running processes for an already-running instance. +/// Implements a simple, effective algorithm. +// Find currently running processes with matching titles. +/// +static class ProcessChecker +{ + /// + /// Stores a required string that must be present in the window title for it + /// to be detected. + /// + static string _requiredString; + + /// + /// Contains signatures for C++ DLLs using interop. + /// + internal static class NativeMethods + { + [DllImport("user32.dll")] + public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + + [DllImport("user32.dll")] + public static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll")] + public static extern bool EnumWindows(EnumWindowsProcDel lpEnumFunc, + Int32 lParam); + + [DllImport("user32.dll")] + public static extern int GetWindowThreadProcessId(IntPtr hWnd, + ref Int32 lpdwProcessId); + + [DllImport("user32.dll")] + public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, + Int32 nMaxCount); + + public const int SW_SHOWNORMAL = 1; + } + + public delegate bool EnumWindowsProcDel(IntPtr hWnd, Int32 lParam); + + /// + /// Perform finding and showing of running window. + /// + /// Bool, which is important and must be kept to match up + /// with system call. + static private bool EnumWindowsProc(IntPtr hWnd, Int32 lParam) + { + int processId = 0; + NativeMethods.GetWindowThreadProcessId(hWnd, ref processId); + + StringBuilder caption = new StringBuilder(1024); + NativeMethods.GetWindowText(hWnd, caption, 1024); + + // Use IndexOf to make sure our required string is in the title. + if (processId == lParam && (caption.ToString().IndexOf(_requiredString, + StringComparison.OrdinalIgnoreCase) != -1)) + { + // Restore the window. + NativeMethods.ShowWindowAsync(hWnd, NativeMethods.SW_SHOWNORMAL); + NativeMethods.SetForegroundWindow(hWnd); + } + return true; // Keep this. + } + + /// + /// Find out if we need to continue to load the current process. If we + /// don't focus the old process that is equivalent to this one. + /// + /// This string must be contained in the window + /// to restore. Use a string that contains the most + /// unique sequence possible. If the program has windows with the string + /// "Journal", pass that word. + /// False if no previous process was activated. True if we did + /// focus a previous process and should simply exit the current one. + static public bool IsOnlyProcess(string forceTitle) + { + _requiredString = forceTitle; + foreach (Process proc in Process.GetProcessesByName(Application.ProductName)) + { + if (proc.Id != Process.GetCurrentProcess().Id) + { + NativeMethods.EnumWindows(new EnumWindowsProcDel(EnumWindowsProc), + proc.Id); + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/EyeBind/ProfileCloneDialog.Designer.cs b/EyeBind/ProfileCloneDialog.Designer.cs new file mode 100644 index 0000000..509bfad --- /dev/null +++ b/EyeBind/ProfileCloneDialog.Designer.cs @@ -0,0 +1,49 @@ +namespace EyeBind +{ + partial class ProfileCloneDialog + { + /// + /// 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.SuspendLayout(); + // + // ProfileCloneDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 261); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProfileCloneDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Clone Profile"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/EyeBind/ProfileCloneDialog.cs b/EyeBind/ProfileCloneDialog.cs new file mode 100644 index 0000000..e21c9cb --- /dev/null +++ b/EyeBind/ProfileCloneDialog.cs @@ -0,0 +1,20 @@ +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; + +namespace EyeBind +{ + public partial class ProfileCloneDialog : Form + { + public ProfileCloneDialog() + { + InitializeComponent(); + } + } +} diff --git a/EyeBind/ProfileCloneDialog.resx b/EyeBind/ProfileCloneDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/EyeBind/ProfileCloneDialog.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/EyeBind/ProfileCloner.Designer.cs b/EyeBind/ProfileCloner.Designer.cs new file mode 100644 index 0000000..9819311 --- /dev/null +++ b/EyeBind/ProfileCloner.Designer.cs @@ -0,0 +1,186 @@ +namespace EyeBind +{ + partial class ProfileCloner + { + /// + /// 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.listView1 = new System.Windows.Forms.ListView(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.profileHotkeyResetButton = new System.Windows.Forms.Button(); + this.profileHotKeyTextBox = new EyeBind.HotKeyTextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.profileNameTextBox = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.acceptButton = new System.Windows.Forms.Button(); + this.selectNone = new System.Windows.Forms.Button(); + this.selectAll = new System.Windows.Forms.Button(); + this.groupBox2.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // listView1 + // + this.listView1.CheckBoxes = true; + this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listView1.LabelEdit = true; + this.listView1.Location = new System.Drawing.Point(24, 171); + this.listView1.MultiSelect = false; + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(200, 178); + this.listView1.TabIndex = 0; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.List; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.profileHotkeyResetButton); + this.groupBox2.Controls.Add(this.profileHotKeyTextBox); + this.groupBox2.Location = new System.Drawing.Point(24, 70); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(200, 52); + this.groupBox2.TabIndex = 3; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Profile Hotkey"; + // + // profileHotkeyResetButton + // + this.profileHotkeyResetButton.Location = new System.Drawing.Point(119, 19); + this.profileHotkeyResetButton.Name = "profileHotkeyResetButton"; + this.profileHotkeyResetButton.Size = new System.Drawing.Size(75, 23); + this.profileHotkeyResetButton.TabIndex = 1; + this.profileHotkeyResetButton.Text = "Reset"; + this.profileHotkeyResetButton.UseVisualStyleBackColor = true; + this.profileHotkeyResetButton.Click += new System.EventHandler(this.profileHotkeyResetButton_Click); + // + // profileHotKeyTextBox + // + this.profileHotKeyTextBox.Location = new System.Drawing.Point(6, 19); + this.profileHotKeyTextBox.Name = "profileHotKeyTextBox"; + this.profileHotKeyTextBox.SettingKey = System.Windows.Forms.Keys.None; + this.profileHotKeyTextBox.Size = new System.Drawing.Size(107, 20); + this.profileHotKeyTextBox.TabIndex = 0; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.profileNameTextBox); + this.groupBox1.Location = new System.Drawing.Point(24, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(200, 52); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Profile Name"; + // + // profileNameTextBox + // + this.profileNameTextBox.Location = new System.Drawing.Point(6, 19); + this.profileNameTextBox.Name = "profileNameTextBox"; + this.profileNameTextBox.Size = new System.Drawing.Size(188, 20); + this.profileNameTextBox.TabIndex = 0; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(150, 364); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 5; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // acceptButton + // + this.acceptButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.acceptButton.Location = new System.Drawing.Point(24, 364); + this.acceptButton.Name = "acceptButton"; + this.acceptButton.Size = new System.Drawing.Size(75, 23); + this.acceptButton.TabIndex = 4; + this.acceptButton.Text = "OK"; + this.acceptButton.UseVisualStyleBackColor = true; + this.acceptButton.Click += new System.EventHandler(this.acceptButton_Click); + // + // selectNone + // + this.selectNone.Location = new System.Drawing.Point(150, 136); + this.selectNone.Name = "selectNone"; + this.selectNone.Size = new System.Drawing.Size(75, 23); + this.selectNone.TabIndex = 7; + this.selectNone.Text = "Select None"; + this.selectNone.UseVisualStyleBackColor = true; + this.selectNone.Click += new System.EventHandler(this.selectNone_Click); + // + // selectAll + // + this.selectAll.Location = new System.Drawing.Point(24, 136); + this.selectAll.Name = "selectAll"; + this.selectAll.Size = new System.Drawing.Size(75, 23); + this.selectAll.TabIndex = 6; + this.selectAll.Text = "Select All"; + this.selectAll.UseVisualStyleBackColor = true; + this.selectAll.Click += new System.EventHandler(this.selectAll_Click); + // + // ProfileCloner + // + this.AcceptButton = this.acceptButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(251, 399); + this.Controls.Add(this.selectNone); + this.Controls.Add(this.selectAll); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.acceptButton); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.listView1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProfileCloner"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Clone Profile"; + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button profileHotkeyResetButton; + private HotKeyTextBox profileHotKeyTextBox; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox profileNameTextBox; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button acceptButton; + private System.Windows.Forms.Button selectNone; + private System.Windows.Forms.Button selectAll; + } +} \ No newline at end of file diff --git a/EyeBind/ProfileCloner.cs b/EyeBind/ProfileCloner.cs new file mode 100644 index 0000000..06b1294 --- /dev/null +++ b/EyeBind/ProfileCloner.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace EyeBind +{ + public partial class ProfileCloner : Form + { + public string ProfileName + { + get; + private set; + } + + public Keys Hotkey + { + get; + private set; + } + + public List RegionsToClone + { + get; + private set; + } + + private ProfileCloner() + { + InitializeComponent(); + } + + public ProfileCloner(List regionName, string profileName): this() + { + this.RegionsToClone = new List(); + + this.listView1.Columns.Add("Gaze Region"); + this.listView1.View = View.Details; + this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); + this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); + foreach (string str in regionName) + { + var item = new ListViewItem(new[] { str }); + listView1.Items.Add(item); + } + + this.profileNameTextBox.Text = profileName; + this.profileHotKeyTextBox.SettingKey = Keys.None; + this.profileHotKeyTextBox.Text = Keys.None.ToString(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + } + + private void profileHotkeyResetButton_Click(object sender, EventArgs e) + { + this.profileHotKeyTextBox.SettingKey = Keys.None; + this.profileHotKeyTextBox.Text = Keys.None.ToString(); + } + + private void selectAll_Click(object sender, EventArgs e) + { + foreach(ListViewItem lvi in this.listView1.Items) + { + lvi.Checked = true; + } + } + + private void selectNone_Click(object sender, EventArgs e) + { + foreach (ListViewItem lvi in this.listView1.Items) + { + lvi.Checked = false; + } + } + + private void acceptButton_Click(object sender, EventArgs e) + { + for (int i = 0; i < this.listView1.Items.Count; i++) + { + this.RegionsToClone.Add(this.listView1.Items[i].Checked); + } + + this.ProfileName = this.profileNameTextBox.Text; + this.Hotkey = this.profileHotKeyTextBox.SettingKey; + } + } +} diff --git a/EyeBind/ProfileCloner.resx b/EyeBind/ProfileCloner.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/EyeBind/ProfileCloner.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/EyeBind/ProfileEditor.Designer.cs b/EyeBind/ProfileEditor.Designer.cs index 3634a2d..4507fb5 100644 --- a/EyeBind/ProfileEditor.Designer.cs +++ b/EyeBind/ProfileEditor.Designer.cs @@ -29,16 +29,19 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.profileNameTextBox = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.textBox2 = new System.Windows.Forms.TextBox(); + this.profileHotkeyResetButton = new System.Windows.Forms.Button(); + this.acceptButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.profileHotKeyTextBox = new EyeBind.HotKeyTextBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // - this.groupBox1.Controls.Add(this.textBox1); + this.groupBox1.Controls.Add(this.profileNameTextBox); this.groupBox1.Location = new System.Drawing.Point(23, 19); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(200, 52); @@ -46,16 +49,17 @@ private void InitializeComponent() this.groupBox1.TabStop = false; this.groupBox1.Text = "Profile Name"; // - // textBox1 + // profileNameTextBox // - this.textBox1.Location = new System.Drawing.Point(6, 19); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(188, 20); - this.textBox1.TabIndex = 0; + this.profileNameTextBox.Location = new System.Drawing.Point(6, 19); + this.profileNameTextBox.Name = "profileNameTextBox"; + this.profileNameTextBox.Size = new System.Drawing.Size(188, 20); + this.profileNameTextBox.TabIndex = 0; // // groupBox2 // - this.groupBox2.Controls.Add(this.textBox2); + this.groupBox2.Controls.Add(this.profileHotkeyResetButton); + this.groupBox2.Controls.Add(this.profileHotKeyTextBox); this.groupBox2.Location = new System.Drawing.Point(23, 77); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(200, 52); @@ -63,21 +67,60 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Profile Hotkey"; // - // textBox2 + // profileHotkeyResetButton // - this.textBox2.Location = new System.Drawing.Point(6, 19); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(188, 20); - this.textBox2.TabIndex = 0; + this.profileHotkeyResetButton.Location = new System.Drawing.Point(119, 19); + this.profileHotkeyResetButton.Name = "profileHotkeyResetButton"; + this.profileHotkeyResetButton.Size = new System.Drawing.Size(75, 23); + this.profileHotkeyResetButton.TabIndex = 1; + this.profileHotkeyResetButton.Text = "Reset"; + this.profileHotkeyResetButton.UseVisualStyleBackColor = true; + this.profileHotkeyResetButton.Click += new System.EventHandler(this.profileHotkeyResetButton_Click); + // + // acceptButton + // + this.acceptButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.acceptButton.Location = new System.Drawing.Point(23, 164); + this.acceptButton.Name = "acceptButton"; + this.acceptButton.Size = new System.Drawing.Size(75, 23); + this.acceptButton.TabIndex = 2; + this.acceptButton.Text = "OK"; + this.acceptButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(148, 164); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 3; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // profileHotKeyTextBox + // + this.profileHotKeyTextBox.Location = new System.Drawing.Point(6, 19); + this.profileHotKeyTextBox.Name = "profileHotKeyTextBox"; + this.profileHotKeyTextBox.SettingKey = System.Windows.Forms.Keys.None; + this.profileHotKeyTextBox.Size = new System.Drawing.Size(107, 20); + this.profileHotKeyTextBox.TabIndex = 0; // // ProfileEditor // + this.AcceptButton = this.acceptButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(248, 199); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.acceptButton); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "ProfileEditor"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Profile Editor"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); @@ -90,9 +133,12 @@ private void InitializeComponent() #endregion private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox profileNameTextBox; + private System.Windows.Forms.Button profileHotkeyResetButton; + private HotKeyTextBox profileHotKeyTextBox; + private System.Windows.Forms.Button acceptButton; + private System.Windows.Forms.Button cancelButton; } } \ No newline at end of file diff --git a/EyeBind/ProfileEditor.cs b/EyeBind/ProfileEditor.cs index 1352387..b92a959 100644 --- a/EyeBind/ProfileEditor.cs +++ b/EyeBind/ProfileEditor.cs @@ -1,20 +1,45 @@ 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; namespace EyeBind { public partial class ProfileEditor : Form { + public string ProfileName + { + get; + private set; + } + + public Keys Hotkey + { + get; + private set; + } + + public ProfileEditor(string name, Keys hotkey): this() + { + this.profileNameTextBox.Text = name; + this.profileHotKeyTextBox.Text = hotkey.ToString(); + + } public ProfileEditor() { InitializeComponent(); } + + protected override void OnClosing(CancelEventArgs e) + { + base.OnClosing(e); + this.ProfileName = this.profileNameTextBox.Text; + this.Hotkey = this.profileHotKeyTextBox.SettingKey; + } + + private void profileHotkeyResetButton_Click(object sender, EventArgs e) + { + this.profileHotKeyTextBox.SettingKey = Keys.None; + this.profileHotKeyTextBox.Text = Keys.None.ToString(); + } } } diff --git a/EyeBind/ProfileHotkeyEventArgs.cs b/EyeBind/ProfileHotkeyEventArgs.cs new file mode 100644 index 0000000..d3e139c --- /dev/null +++ b/EyeBind/ProfileHotkeyEventArgs.cs @@ -0,0 +1,27 @@ +using System; +using System.Windows.Forms; + +namespace EyeBind +{ + class ProfileHotkeyEventArgs : EventArgs + { + private Keys key; + private int profileIndex; + + public ProfileHotkeyEventArgs(Keys k, int index) + { + key = k; + profileIndex = index; + } + + public Keys Key + { + get { return key; } + } + + public int ProfileIndex + { + get { return profileIndex; } + } + } +} diff --git a/EyeBind/ProfilesComboBox.cs b/EyeBind/ProfilesComboBox.cs index 4330f61..8db4881 100644 --- a/EyeBind/ProfilesComboBox.cs +++ b/EyeBind/ProfilesComboBox.cs @@ -1,15 +1,17 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using System.ComponentModel; +using System.Collections.Generic; namespace EyeBind { public class ProfilesComboBox : ComboBox { + public ProfilesComboBox() + { + this.DropDownStyle = ComboBoxStyle.DropDownList; + } + public bool ShowSelectedProfile() { if (this.SelectedIndex > -1) @@ -56,7 +58,7 @@ public bool HideSelectedProfile() public bool RemoveSelectedProfile() { - if(this.SelectedIndex > 0) + if (this.SelectedIndex > 0) { try { @@ -67,6 +69,11 @@ public bool RemoveSelectedProfile() grfl[this.SelectedIndex].RemoveGazeRegions(); grfl.RemoveAt(this.SelectedIndex); + + //select first item + if (this.Items.Count >= 0) + this.SelectedIndex = 0; + return true; } catch @@ -74,47 +81,133 @@ public bool RemoveSelectedProfile() return false; } } - - //System.Media.SystemSounds.Beep.Play(); return false; } public bool AddProfile() { - if (!string.IsNullOrEmpty(this.Text)) + try + { + using (ProfileEditor pe = new ProfileEditor("New Profile", Keys.None)) + { + var result = pe.ShowDialog(); + if (result == DialogResult.OK) + { + if (!string.IsNullOrEmpty(pe.ProfileName)) + { + GazeRegionProfile grp = new GazeRegionProfile(); + grp.Name = pe.ProfileName; + grp.Hotkey = pe.Hotkey; + BindingList grfl = this.DataSource as BindingList; + if (grfl == null) + return false; + + grfl.Add(grp); + + //select last item + if (this.Items.Count > 0) + this.SelectedIndex = this.Items.Count - 1; + + return true; + } + } + pe.Dispose(); + } + } + catch + { + return false; + } + + return false; + } + + public bool EditSelectedProfile() + { + if (this.SelectedIndex > -1) + { + BindingList grfl = this.DataSource as BindingList; + if (grfl == null) + return false; + + string name = grfl[this.SelectedIndex].Name; + Keys key = grfl[this.SelectedIndex].Hotkey; + using (ProfileEditor pe = new ProfileEditor(name, key)) + { + var result = pe.ShowDialog(); + if (result == DialogResult.OK) + { + grfl[this.SelectedIndex].Name = pe.ProfileName; + grfl[this.SelectedIndex].Hotkey = pe.Hotkey; + + Form f = FindForm(); + if (f is EyeBindMainForm == false) + return false; + + EyeBindMainForm ebmf = f as EyeBindMainForm; + if (ebmf == null) + return false; + + this.DataSource = null; + this.DataSource = ebmf.ProfilesList; + this.DisplayMember = "DisplayName"; + } + pe.Dispose(); + } + } + return false; + } + + public bool CloneSelectedProfille() + { + if (this.SelectedIndex > -1) { - int index = this.FindStringExact(this.Text); - if (index > -1) + BindingList grfl = this.DataSource as BindingList; + if (grfl == null) + return false; + + GazeRegionProfile grp = grfl[this.SelectedIndex]; + + List regionNames = new List(); + + foreach (GazeRegion gr in grp.Profile) { - this.SelectedIndex = index; + regionNames.Add(gr.RegionName); } - else + + using (ProfileCloner pc = new ProfileCloner(regionNames, grp.Name)) { - try + var result = pc.ShowDialog(); + if (result == DialogResult.OK) { - GazeRegionProfile grp = new GazeRegionProfile(); - grp.Name = this.Text; - BindingList grfl = this.DataSource as BindingList; - if (grfl == null) + GazeRegionProfile ngrp = new GazeRegionProfile(); + + if (grp.Profile.Count == pc.RegionsToClone.Count) + { + for(int i = 0; i < grp.Profile.Count; i++) + { + if (pc.RegionsToClone[i]) + ngrp.Profile.Add(grp.Profile[i].Clone()); + } + } + else + { + pc.Dispose(); return false; + } - grfl.Add(grp); + ngrp.Name = pc.ProfileName; + ngrp.Hotkey = pc.Hotkey; + grfl.Add(ngrp); //select last item if (this.Items.Count > 0) this.SelectedIndex = this.Items.Count - 1; - - return true; - } - catch - { - } + pc.Dispose(); } } - - //System.Media.SystemSounds.Beep.Play(); return false; } @@ -124,7 +217,7 @@ protected override void OnSelectedIndexChanged(EventArgs e) if (this.SelectedIndex != -1) { Form f = FindForm(); - if(f is EyeBindMainForm == false) + if (f is EyeBindMainForm == false) return; EyeBindMainForm ebmf = f as EyeBindMainForm; @@ -147,19 +240,5 @@ protected override void OnSelectedIndexChanged(EventArgs e) } } } - - protected override bool ProcessCmdKey(ref Message msg, Keys k) - { - if (k == Keys.Enter || k == Keys.Return) - { - if(!string.IsNullOrEmpty(this.Text)) - { - this.AddProfile(); - } - return true; - } - - return base.ProcessCmdKey(ref msg, k); - } } } diff --git a/EyeBind/Program.cs b/EyeBind/Program.cs index 1e563ce..e224005 100644 --- a/EyeBind/Program.cs +++ b/EyeBind/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; using EyeXFramework; @@ -9,6 +6,8 @@ namespace EyeBind { static class Program { + private static string eyeBindVersion = "1.2"; + private static string eyeBindName = "EyeBind"; private static EyeXHost _eyeXHost; private static EyeXFramework.GazePointDataStream gazePointDataStream = null; private static EyeXFramework.FixationDataStream fixationDataStream = null; @@ -52,29 +51,32 @@ public static EyeXHost EyeXHost [STAThread] static void Main() { - try + if (ProcessChecker.IsOnlyProcess(eyeBindName)) { - _eyeXHost = new EyeXHost(); - _eyeXHost.Start(); - gazePointDataStream = _eyeXHost.CreateGazePointDataStream(Tobii.EyeX.Framework.GazePointDataMode.LightlyFiltered); - fixationDataStream = _eyeXHost.CreateFixationDataStream(Tobii.EyeX.Framework.FixationDataMode.Slow); - eyePositionDataStream = _eyeXHost.CreateEyePositionDataStream(); - } - catch - { - MessageBox.Show("Fail to start EyeXHost."); - return; - } + try + { + _eyeXHost = new EyeXHost(); + _eyeXHost.Start(); + gazePointDataStream = _eyeXHost.CreateGazePointDataStream(Tobii.EyeX.Framework.GazePointDataMode.LightlyFiltered); + fixationDataStream = _eyeXHost.CreateFixationDataStream(Tobii.EyeX.Framework.FixationDataMode.Slow); + eyePositionDataStream = _eyeXHost.CreateEyePositionDataStream(); + } + catch + { + MessageBox.Show("Fail to start EyeXHost."); + return; + } - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new EyeBindMainForm()); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new EyeBindMainForm()); - gazePointDataStream.Dispose(); - fixationDataStream.Dispose(); - eyePositionDataStream.Dispose(); - _eyeXHost.Dispose(); + gazePointDataStream.Dispose(); + fixationDataStream.Dispose(); + eyePositionDataStream.Dispose(); + _eyeXHost.Dispose(); + } } } } diff --git a/EyeBind/ScreenOverlay.cs b/EyeBind/ScreenOverlay.cs index b983db7..9ded9ad 100644 --- a/EyeBind/ScreenOverlay.cs +++ b/EyeBind/ScreenOverlay.cs @@ -1,15 +1,7 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; using System.Drawing.Drawing2D; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using Tobii.EyeX.Framework; namespace EyeBind { @@ -67,7 +59,11 @@ protected void SetBorderlessFullScreen() this.WindowState = FormWindowState.Normal; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; - //this.TopMost = true; +#if DEBUG + this.TopMost = false; +#else + this.TopMost = true; +#endif } protected void UnSetBorderlessFullScreen() diff --git a/EyeBind/packages.config b/EyeBind/packages.config index e226b8b..0d1badd 100644 --- a/EyeBind/packages.config +++ b/EyeBind/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/README.md b/README.md index 2595fb2..64a3d82 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ A video demonstration of EyeBind will be added in the near future. * Add various animations to better indicate the delay times. * Currently EyeBind is hard-coded to use the EyeX's Fixation Data Stream; however, in a future update, it will allow the user to choose from various data streams provided by the EyeX engine. * Translate physical eyeballs locations into keyboard bindings. -* Add global keyboard hot-keys. +* ~~Add global keyboard hot-keys.~~ * UI improvements. * Allow customizable Gaze Marker. ####Long-term goals: * Gaze gestures (similar to [mouse gestures](http://en.wikipedia.org/wiki/Pointing_device_gesture)). -* Allow greater visual customization of Gaze Regions (perhaps by using a HTML Renderer). +* ~~Allow greater visual customization of Gaze Regions (perhaps by using a HTML Renderer).~~ ####Known Issues/Limitations: @@ -51,13 +51,14 @@ The EyeBind solution should build in Vistual Studio 2013 without any tweaking re ####Contact: -If you find EyeBind to be useful, send me an [e-mail](quoc@hush.ai) so I know my time wasn't wasted. Feedbacks and features requests are also welcomed. -I coded EyeBind primarily for myself, but that isn't entirely true since many of the features in EyeBind would have been hard-coded if it was created purely out of self-interest. The other reason why EyeBind exists is because I find proprietary solutions, especially ones marketed towards disabled users, to be over priced. Hopefully, this will help disabled gamers who can't afford them. +If you find EyeBind to be useful, send me an [e-mail](quoc@hush.ai). Feedbacks and features requests are also welcomed. ## Props to other open source projects used in EyeBind: * [Windows Input Simulator](https://inputsimulator.codeplex.com/) for simulation of keyboard/mouse inputs. * [freesfx](http://www.freesfx.co.uk) for sound effects. * [globalmousekeyhook](https://github.com/gmamaladze/globalmousekeyhook) for global hotkeys detections. +* [HTML-Renderer](https://github.com/ArthurHub/HTML-Renderer) for HTML Rendering. +