Implement sequence mode
This commit is contained in:
@@ -35,9 +35,52 @@ namespace DD2Switcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void StartSequenceMode() {
|
||||||
|
if (FirstIndex >= 0 && LastIndex >= 0 && FirstIndex <= LastIndex) {
|
||||||
|
SequenceMode = true;
|
||||||
|
CurrentSequenceIndex = FirstIndex;
|
||||||
|
TabTo(CurrentSequenceIndex + 1); // Tab to first window
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void NextSequenceStep() {
|
||||||
|
if (!SequenceMode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CurrentSequenceIndex++;
|
||||||
|
if (CurrentSequenceIndex > LastIndex) {
|
||||||
|
// End of sequence
|
||||||
|
ExitSequenceMode();
|
||||||
|
} else {
|
||||||
|
TabTo(CurrentSequenceIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExitSequenceMode() {
|
||||||
|
SequenceMode = false;
|
||||||
|
CurrentSequenceIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateSequenceHotkey(Keys newKey) {
|
||||||
|
// Unregister old hotkey
|
||||||
|
if (sequenceHotkeyId != -1) {
|
||||||
|
HotKeyManager.UnregisterHotKey(sequenceHotkeyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register new hotkey
|
||||||
|
sequenceHotkeyId = HotKeyManager.RegisterHotKey(newKey, KeyModifiers.NoRepeat);
|
||||||
|
SequenceKeybind = newKey;
|
||||||
|
}
|
||||||
|
|
||||||
// Static properties for first/last selection persistence
|
// Static properties for first/last selection persistence
|
||||||
public static int FirstIndex { get; set; } = -1;
|
public static int FirstIndex { get; set; } = -1;
|
||||||
public static int LastIndex { get; set; } = -1;
|
public static int LastIndex { get; set; } = -1;
|
||||||
|
|
||||||
|
// Sequence mode state
|
||||||
|
public static bool SequenceMode { get; set; } = false;
|
||||||
|
public static int CurrentSequenceIndex { get; set; } = -1;
|
||||||
|
public static Keys SequenceKeybind { get; set; } = Keys.F1;
|
||||||
|
private static int sequenceHotkeyId = -1;
|
||||||
private static int ActiveIndex = -1;
|
private static int ActiveIndex = -1;
|
||||||
private static bool AltPressed = false;
|
private static bool AltPressed = false;
|
||||||
|
|
||||||
@@ -358,9 +401,25 @@ namespace DD2Switcher {
|
|||||||
for (int i = 0; i < 9; i++) HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt);
|
for (int i = 0; i < 9; i++) HotKeyManager.RegisterHotKey(Keys.NumPad1 + i, KeyModifiers.Alt);
|
||||||
|
|
||||||
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
|
HotKeyManager.RegisterHotKey(Keys.Oemtilde, KeyModifiers.Alt);
|
||||||
|
sequenceHotkeyId = HotKeyManager.RegisterHotKey(SequenceKeybind, KeyModifiers.NoRepeat);
|
||||||
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed;
|
||||||
|
|
||||||
void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
|
void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e) {
|
||||||
|
// Check for sequence mode keybind
|
||||||
|
if (e.Key == SequenceKeybind && e.Modifiers == KeyModifiers.NoRepeat) {
|
||||||
|
if (SequenceMode) {
|
||||||
|
NextSequenceStep();
|
||||||
|
} else {
|
||||||
|
StartSequenceMode();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel sequence mode on any manual window switching
|
||||||
|
if (SequenceMode && e.Modifiers == KeyModifiers.Alt) {
|
||||||
|
ExitSequenceMode();
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt && IsCapsLockOn()) {
|
if (e.Key == Keys.Oemtilde && e.Modifiers == KeyModifiers.Alt && IsCapsLockOn()) {
|
||||||
TrackProcess();
|
TrackProcess();
|
||||||
ToggleCapsLock();
|
ToggleCapsLock();
|
||||||
|
@@ -7,7 +7,13 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace DD2Switcher {
|
namespace DD2Switcher {
|
||||||
public partial class SettingsForm : Form {
|
public partial class SettingsForm : Form {
|
||||||
|
private TabControl tabControl;
|
||||||
|
private TabPage windowsTab;
|
||||||
|
private TabPage sequenceTab;
|
||||||
private FlowLayoutPanel windowsPanel;
|
private FlowLayoutPanel windowsPanel;
|
||||||
|
private Label sequenceKeybindLabel;
|
||||||
|
private TextBox sequenceKeybindTextBox;
|
||||||
|
private Timer statusTimer;
|
||||||
|
|
||||||
public SettingsForm() {
|
public SettingsForm() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -16,32 +22,95 @@ namespace DD2Switcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent() {
|
private void InitializeComponent() {
|
||||||
|
this.tabControl = new System.Windows.Forms.TabControl();
|
||||||
|
this.windowsTab = new System.Windows.Forms.TabPage();
|
||||||
this.windowsPanel = new System.Windows.Forms.FlowLayoutPanel();
|
this.windowsPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
|
this.sequenceTab = new System.Windows.Forms.TabPage();
|
||||||
|
this.sequenceKeybindTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.sequenceKeybindLabel = new System.Windows.Forms.Label();
|
||||||
|
this.tabControl.SuspendLayout();
|
||||||
|
this.windowsTab.SuspendLayout();
|
||||||
|
this.sequenceTab.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
// tabControl
|
||||||
|
//
|
||||||
|
this.tabControl.Controls.Add(this.windowsTab);
|
||||||
|
this.tabControl.Controls.Add(this.sequenceTab);
|
||||||
|
this.tabControl.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.tabControl.Name = "tabControl";
|
||||||
|
this.tabControl.SelectedIndex = 0;
|
||||||
|
this.tabControl.Size = new System.Drawing.Size(576, 396);
|
||||||
|
this.tabControl.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// windowsTab
|
||||||
|
//
|
||||||
|
this.windowsTab.Controls.Add(this.windowsPanel);
|
||||||
|
this.windowsTab.Location = new System.Drawing.Point(4, 22);
|
||||||
|
this.windowsTab.Name = "windowsTab";
|
||||||
|
this.windowsTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
|
this.windowsTab.Size = new System.Drawing.Size(568, 370);
|
||||||
|
this.windowsTab.TabIndex = 0;
|
||||||
|
this.windowsTab.Text = "Windows";
|
||||||
|
this.windowsTab.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// windowsPanel
|
// windowsPanel
|
||||||
//
|
//
|
||||||
this.windowsPanel.AutoScroll = true;
|
this.windowsPanel.AutoScroll = true;
|
||||||
this.windowsPanel.BackColor = System.Drawing.Color.White;
|
this.windowsPanel.BackColor = System.Drawing.Color.White;
|
||||||
this.windowsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.windowsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.windowsPanel.Location = new System.Drawing.Point(12, 12);
|
this.windowsPanel.Location = new System.Drawing.Point(6, 6);
|
||||||
this.windowsPanel.Name = "windowsPanel";
|
this.windowsPanel.Name = "windowsPanel";
|
||||||
this.windowsPanel.Padding = new System.Windows.Forms.Padding(10);
|
this.windowsPanel.Padding = new System.Windows.Forms.Padding(10);
|
||||||
this.windowsPanel.Size = new System.Drawing.Size(576, 396);
|
this.windowsPanel.Size = new System.Drawing.Size(556, 358);
|
||||||
this.windowsPanel.TabIndex = 1;
|
this.windowsPanel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// sequenceTab
|
||||||
|
//
|
||||||
|
this.sequenceTab.Controls.Add(this.sequenceKeybindTextBox);
|
||||||
|
this.sequenceTab.Controls.Add(this.sequenceKeybindLabel);
|
||||||
|
this.sequenceTab.Location = new System.Drawing.Point(4, 22);
|
||||||
|
this.sequenceTab.Name = "sequenceTab";
|
||||||
|
this.sequenceTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
|
this.sequenceTab.Size = new System.Drawing.Size(568, 370);
|
||||||
|
this.sequenceTab.TabIndex = 1;
|
||||||
|
this.sequenceTab.Text = "Sequence";
|
||||||
|
this.sequenceTab.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// sequenceKeybindTextBox
|
||||||
|
//
|
||||||
|
this.sequenceKeybindTextBox.Location = new System.Drawing.Point(126, 17);
|
||||||
|
this.sequenceKeybindTextBox.Name = "sequenceKeybindTextBox";
|
||||||
|
this.sequenceKeybindTextBox.Size = new System.Drawing.Size(111, 20);
|
||||||
|
this.sequenceKeybindTextBox.TabIndex = 1;
|
||||||
|
this.sequenceKeybindTextBox.Text = "F1";
|
||||||
|
this.sequenceKeybindTextBox.Leave += new System.EventHandler(this.sequenceKeybindTextBox_Leave);
|
||||||
|
//
|
||||||
|
// sequenceKeybindLabel
|
||||||
|
//
|
||||||
|
this.sequenceKeybindLabel.AutoSize = true;
|
||||||
|
this.sequenceKeybindLabel.Location = new System.Drawing.Point(20, 20);
|
||||||
|
this.sequenceKeybindLabel.Name = "sequenceKeybindLabel";
|
||||||
|
this.sequenceKeybindLabel.Size = new System.Drawing.Size(100, 13);
|
||||||
|
this.sequenceKeybindLabel.TabIndex = 0;
|
||||||
|
this.sequenceKeybindLabel.Text = "Sequence Keybind:";
|
||||||
//
|
//
|
||||||
// SettingsForm
|
// SettingsForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(600, 420);
|
this.ClientSize = new System.Drawing.Size(600, 420);
|
||||||
this.Controls.Add(this.windowsPanel);
|
this.Controls.Add(this.tabControl);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "SettingsForm";
|
this.Name = "SettingsForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "DD2Switcher Settings";
|
this.Text = "DD2Switcher Settings";
|
||||||
|
this.tabControl.ResumeLayout(false);
|
||||||
|
this.windowsTab.ResumeLayout(false);
|
||||||
|
this.sequenceTab.ResumeLayout(false);
|
||||||
|
this.sequenceTab.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,5 +234,15 @@ namespace DD2Switcher {
|
|||||||
// Use default icon if custom icon not found
|
// Use default icon if custom icon not found
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sequenceKeybindTextBox_Leave(object sender, EventArgs e) {
|
||||||
|
try {
|
||||||
|
KeysConverter converter = new KeysConverter();
|
||||||
|
Keys newKey = (Keys)converter.ConvertFromString(sequenceKeybindTextBox.Text);
|
||||||
|
Program.UpdateSequenceHotkey(newKey);
|
||||||
|
} catch {
|
||||||
|
sequenceKeybindTextBox.Text = Program.SequenceKeybind.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user