From 6fcba28093d3197ecc9c3d8d65aeffce2dcc09ec Mon Sep 17 00:00:00 2001 From: jays2kings Date: Mon, 28 Apr 2014 21:14:01 -0400 Subject: [PATCH] Added double tap option (Tap and hold to drag mouse) and a context menu Signed-off-by: jays2kings --- DS4Control/Mouse.cs | 62 ++++++++------ DS4Control/ScpUtil.cs | 15 +++- DS4Tool/Options.Designer.cs | 26 +++++- DS4Tool/Options.cs | 13 +++ DS4Tool/ScpForm.Designer.cs | 154 +++++++++++++++++++++++++++------- DS4Tool/ScpForm.cs | 160 ++++++++++++++++++++++++++++-------- DS4Tool/ScpForm.resx | 3 + 7 files changed, 338 insertions(+), 95 deletions(-) diff --git a/DS4Control/Mouse.cs b/DS4Control/Mouse.cs index bb33962..4f349d6 100644 --- a/DS4Control/Mouse.cs +++ b/DS4Control/Mouse.cs @@ -8,13 +8,14 @@ namespace DS4Control { public class Mouse : ITouchpadBehaviour { - protected DateTime pastTime; + protected DateTime pastTime, firstTap, TimeofEnd; protected Touch firstTouch; private DS4State s = new DS4State(); protected int deviceNum; private DS4Device dev = null; private readonly MouseCursor cursor; private readonly MouseWheel wheel; + private bool tappedOnce = false, secondtouchbegin = false; public Mouse(int deviceID, DS4Device d) { @@ -29,57 +30,63 @@ namespace DS4Control return "Standard Mode"; } - protected virtual void MapClicks() - { - if (pushed != DS4Controls.None) - Mapping.MapTouchpadButton(deviceNum, pushed, clicked); - } - public virtual void touchesMoved(object sender, TouchpadEventArgs arg) { cursor.touchesMoved(arg); wheel.touchesMoved(arg); - //MapClicks(); dev.getCurrentState(s); synthesizeMouseButtons(); //Console.WriteLine(arg.timeStamp.ToString("O") + " " + "moved to " + arg.touches[0].hwX + "," + arg.touches[0].hwY); } - public virtual void touchesBegan(object sender, TouchpadEventArgs arg) { cursor.touchesBegan(arg); wheel.touchesBegan(arg); pastTime = arg.timeStamp; firstTouch = arg.touches[0]; + if (Global.getDoubleTap(deviceNum)) + { + DateTime test = arg.timeStamp; + if (test <= (firstTap + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 1.5)) && !arg.touchButtonPressed) + secondtouchbegin = true; + } dev.getCurrentState(s); - synthesizeMouseButtons(); - //MapClicks(); + synthesizeMouseButtons(); //Console.WriteLine(arg.timeStamp.ToString("O") + " " + "began at " + arg.touches[0].hwX + "," + arg.touches[0].hwY); } - public virtual void touchesEnded(object sender, TouchpadEventArgs arg) { //Console.WriteLine(arg.timeStamp.ToString("O") + " " + "ended at " + arg.touches[0].hwX + "," + arg.touches[0].hwY); if (Global.getTapSensitivity(deviceNum) != 0) { - DateTime test = arg.timeStamp; - if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 2)) && !arg.touchButtonPressed) + + if (secondtouchbegin) { - if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10) - Mapping.MapClick(deviceNum, Mapping.Click.Left); + tappedOnce = false; + secondtouchbegin = false; } + DateTime test = arg.timeStamp; + if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.getTapSensitivity(deviceNum) * 2)) && !arg.touchButtonPressed && !tappedOnce) + if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10) + if (Global.getDoubleTap(deviceNum)) + { + tappedOnce = true; + firstTap = arg.timeStamp; + TimeofEnd = DateTime.Now; //since arg can't be used in synthesizeMouseButtons + } + else + Mapping.MapClick(deviceNum, Mapping.Click.Left); //this way no delay if disabled } dev.getCurrentState(s); //if (buttonLock) synthesizeMouseButtons(); - //MapClicks(); } protected DS4Controls pushed = DS4Controls.None; protected Mapping.Click clicked = Mapping.Click.None; // touch area stuff - public bool leftDown, rightDown, upperDown, multiDown, lowerRDown; + public bool leftDown, rightDown, upperDown, multiDown; private bool isLeft(Touch t) { return t.hwX < 1920 * 2 / 5; @@ -92,16 +99,15 @@ namespace DS4Control public virtual void touchUnchanged(object sender, EventArgs unused) { - //MapClicks(); dev.getCurrentState(s); - if (s.Touch1 || s.Touch2 || s.TouchButton) + //if (s.Touch1 || s.Touch2 || s.TouchButton) synthesizeMouseButtons(); } private DS4State remapped = new DS4State(); private void synthesizeMouseButtons() { - //Mapping.MapCustom(deviceNum, s, remapped); + Mapping.MapCustom(deviceNum, s, remapped); if (leftDown) Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchLeft, Mapping.Click.Left, remapped); if (upperDown) @@ -110,8 +116,18 @@ namespace DS4Control Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchRight, Mapping.Click.Left, remapped); if (multiDown) Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchMulti, Mapping.Click.Right, remapped); - if (lowerRDown) - Mapping.MapClick(deviceNum, Mapping.Click.Right); + if (tappedOnce) + { + DateTime tester = DateTime.Now; + if (tester > (TimeofEnd + TimeSpan.FromMilliseconds((double)(Global.getTapSensitivity(deviceNum)) * 1.5))) + { + Mapping.MapClick(deviceNum, Mapping.Click.Left); + tappedOnce = false; + } + //if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work) + } + if (secondtouchbegin) //if tap and hold (also works as double tap) + Mapping.MapClick(deviceNum, Mapping.Click.Left); s = remapped; //remapped.CopyTo(s); } diff --git a/DS4Control/ScpUtil.cs b/DS4Control/ScpUtil.cs index dc007e7..958299e 100644 --- a/DS4Control/ScpUtil.cs +++ b/DS4Control/ScpUtil.cs @@ -202,6 +202,14 @@ namespace DS4Control { return m_Config.tapSensitivity; } + public static void setDoubleTap(int device, bool on) + { + m_Config.doubleTap = on; + } + public static bool getDoubleTap(int device) + { + return m_Config.doubleTap; + } public static bool getTap(int device) { if (m_Config.tapSensitivity == 0) @@ -389,6 +397,7 @@ namespace DS4Control public Dictionary customMapKeyTypes = null; public Dictionary customMapKeys = null; public Dictionary customMapButtons = null; + public bool doubleTap = false; public BackingStore() { //for (int i = 0; i < 4; i++) @@ -462,11 +471,11 @@ namespace DS4Control XmlNode xmlTouchpadJitterCompensation = m_Xdoc.CreateNode(XmlNodeType.Element, "touchpadJitterCompensation", null); xmlTouchpadJitterCompensation.InnerText = touchpadJitterCompensation.ToString(); Node.AppendChild(xmlTouchpadJitterCompensation); XmlNode xmlLowerRCOn = m_Xdoc.CreateNode(XmlNodeType.Element, "lowerRCOn", null); xmlLowerRCOn.InnerText = lowerRCOn.ToString(); Node.AppendChild(xmlLowerRCOn); XmlNode xmlTapSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "tapSensitivity", null); xmlTapSensitivity.InnerText = tapSensitivity.ToString(); Node.AppendChild(xmlTapSensitivity); + XmlNode xmlDouble = m_Xdoc.CreateNode(XmlNodeType.Element, "doubleTap", null); xmlDouble.InnerText = doubleTap.ToString(); Node.AppendChild(xmlDouble); XmlNode xmlScrollSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "scrollSensitivity", null); xmlScrollSensitivity.InnerText = scrollSensitivity.ToString(); Node.AppendChild(xmlScrollSensitivity); XmlNode xmlLeftTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "LeftTriggerMiddle", null); xmlLeftTriggerMiddle.InnerText = m_LeftTriggerMiddle.ToString(); Node.AppendChild(xmlLeftTriggerMiddle); XmlNode xmlRightTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "RightTriggerMiddle", null); xmlRightTriggerMiddle.InnerText = m_RightTriggerMiddle.ToString(); Node.AppendChild(xmlRightTriggerMiddle); - // m_Xdoc.AppendChild(Node); XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null); XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null); @@ -667,6 +676,8 @@ namespace DS4Control catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/ScpControl/tapSensitivity"); Byte.TryParse(Item.InnerText, out tapSensitivity); } catch { missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/ScpControl/doubleTap"); Boolean.TryParse(Item.InnerText, out doubleTap); } + catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/ScpControl/scrollSensitivity"); Int32.TryParse(Item.InnerText, out scrollSensitivity); } catch { missingSetting = true; } // XXX This sucks, let's do better at removing old values that are no longer valid.... @@ -812,6 +823,8 @@ namespace DS4Control catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/ScpControl/tapSensitivity"); Byte.TryParse(Item.InnerText, out tapSensitivity); } catch { missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/ScpControl/doubleTap"); Boolean.TryParse(Item.InnerText, out doubleTap); } + catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/ScpControl/scrollSensitivity"); Int32.TryParse(Item.InnerText, out scrollSensitivity); } catch { missingSetting = true; } // XXX This sucks, let's do better at removing old values that are no longer valid.... diff --git a/DS4Tool/Options.Designer.cs b/DS4Tool/Options.Designer.cs index 2652901..7058e8f 100644 --- a/DS4Tool/Options.Designer.cs +++ b/DS4Tool/Options.Designer.cs @@ -129,6 +129,7 @@ this.label2 = new System.Windows.Forms.Label(); this.tBProfile = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); + this.cBDoubleTap = new System.Windows.Forms.CheckBox(); this.advColorDialog = new ScpServer.AdvancedColorDialog(); ((System.ComponentModel.ISupportInitialize)(this.blueBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.greenBar)).BeginInit(); @@ -414,12 +415,12 @@ this.cBlowerRCOn.AutoSize = true; this.cBlowerRCOn.Checked = true; this.cBlowerRCOn.CheckState = System.Windows.Forms.CheckState.Checked; - this.cBlowerRCOn.Location = new System.Drawing.Point(240, 120); + this.cBlowerRCOn.Location = new System.Drawing.Point(165, 120); this.cBlowerRCOn.Name = "cBlowerRCOn"; this.cBlowerRCOn.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.cBlowerRCOn.Size = new System.Drawing.Size(109, 17); + this.cBlowerRCOn.Size = new System.Drawing.Size(126, 17); this.cBlowerRCOn.TabIndex = 39; - this.cBlowerRCOn.Text = "Lower Right Click"; + this.cBlowerRCOn.Text = "Lower Right (R-Click)"; this.cBlowerRCOn.UseVisualStyleBackColor = true; // // lowRedValLabel @@ -606,7 +607,7 @@ // this.touchpadJitterCompensation.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.touchpadJitterCompensation.AutoSize = true; - this.touchpadJitterCompensation.Location = new System.Drawing.Point(71, 120); + this.touchpadJitterCompensation.Location = new System.Drawing.Point(3, 120); this.touchpadJitterCompensation.Name = "touchpadJitterCompensation"; this.touchpadJitterCompensation.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.touchpadJitterCompensation.Size = new System.Drawing.Size(118, 17); @@ -1350,6 +1351,7 @@ this.tabTouchPad.Controls.Add(this.numUDTap); this.tabTouchPad.Controls.Add(this.numUDScroll); this.tabTouchPad.Controls.Add(this.numUDTouch); + this.tabTouchPad.Controls.Add(this.cBDoubleTap); this.tabTouchPad.Controls.Add(this.cBlowerRCOn); this.tabTouchPad.Controls.Add(this.touchpadJitterCompensation); this.tabTouchPad.Controls.Add(this.bnTouchUpper); @@ -1703,6 +1705,21 @@ this.label4.TabIndex = 84; this.label4.Text = "Profile Name:"; // + // cBDoubleTap + // + this.cBDoubleTap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cBDoubleTap.AutoSize = true; + this.cBDoubleTap.Checked = true; + this.cBDoubleTap.CheckState = System.Windows.Forms.CheckState.Checked; + this.cBDoubleTap.Location = new System.Drawing.Point(344, 121); + this.cBDoubleTap.Name = "cBDoubleTap"; + this.cBDoubleTap.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.cBDoubleTap.Size = new System.Drawing.Size(82, 17); + this.cBDoubleTap.TabIndex = 39; + this.cBDoubleTap.Text = "Double Tap"; + this.cBDoubleTap.UseVisualStyleBackColor = true; + this.cBDoubleTap.CheckedChanged += new System.EventHandler(this.cBDoubleTap_CheckedChanged); + // // advColorDialog // this.advColorDialog.AnyColor = true; @@ -1866,6 +1883,7 @@ private System.Windows.Forms.CheckBox cBSlide; private System.Windows.Forms.NumericUpDown numUDTap; private System.Windows.Forms.Label label4; + private System.Windows.Forms.CheckBox cBDoubleTap; } }  \ No newline at end of file diff --git a/DS4Tool/Options.cs b/DS4Tool/Options.cs index 3bd537c..6dc5825 100644 --- a/DS4Tool/Options.cs +++ b/DS4Tool/Options.cs @@ -47,6 +47,7 @@ namespace ScpServer numUDScroll.Value = Global.getScrollSensitivity(device); numUDTap.Value = Global.getTapSensitivity(device); cBTap.Checked = Global.getTap(device); + cBDoubleTap.Checked = Global.getDoubleTap(device); leftTriggerMiddlePoint.Text = Global.getLeftTriggerMiddle(device).ToString(); rightTriggerMiddlePoint.Text = Global.getRightTriggerMiddle(device).ToString(); DS4Color lowColor = Global.loadLowColor(device); @@ -87,6 +88,7 @@ namespace ScpServer Global.setTouchpadJitterCompensation(device, touchpadJitterCompensation.Checked); Global.setLowerRCOn(device, cBlowerRCOn.Checked); Global.setTapSensitivity(device, (byte)numUDTap.Value); + Global.setDoubleTap(device, cBDoubleTap.Checked); Global.setScrollSensitivity(device, (byte)numUDScroll.Value); Global.setIdleDisconnectTimeout(device, (int)idleDisconnectTimeout.Value); } @@ -188,6 +190,7 @@ namespace ScpServer Global.LoadProfile(device, buttons.ToArray()); ToolTip tp = new ToolTip(); tp.SetToolTip(cBlowerRCOn, "Best used with right side as mouse"); + tp.SetToolTip(cBDoubleTap, "Tap and hold to drag, slight delay with one tap"); advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; btnLeftStick.Enter += btnSticks_Enter; btnRightStick.Enter += btnSticks_Enter; @@ -334,6 +337,7 @@ namespace ScpServer int disconnectTimeout; if (int.TryParse(idleDisconnectTimeout.Text, out disconnectTimeout)) Global.setIdleDisconnectTimeout(device, disconnectTimeout); + Global.setDoubleTap(device, cBDoubleTap.Checked); if (tBProfile.Text != null && tBProfile.Text != "" && !tBProfile.Text.Contains("\\") && !tBProfile.Text.Contains("/") && !tBProfile.Text.Contains(":") && !tBProfile.Text.Contains("*") && !tBProfile.Text.Contains("?") && !tBProfile.Text.Contains("\"") && !tBProfile.Text.Contains("<") && !tBProfile.Text.Contains(">") && !tBProfile.Text.Contains("|")) { @@ -480,6 +484,10 @@ namespace ScpServer private void numUDTap_ValueChanged(object sender, EventArgs e) { Global.setTapSensitivity(device, (byte)numUDTap.Value); + if (numUDTap.Value == 0) + cBDoubleTap.Enabled = false; + else + cBDoubleTap.Enabled = true; } private void numUDScroll_ValueChanged(object sender, EventArgs e) @@ -697,6 +705,11 @@ namespace ScpServer numUDTap.Enabled = cBTap.Checked; } + private void cBDoubleTap_CheckedChanged(object sender, EventArgs e) + { + Global.setDoubleTap(device, cBDoubleTap.Checked); + } + private void tbProfile_EnterDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) diff --git a/DS4Tool/ScpForm.Designer.cs b/DS4Tool/ScpForm.Designer.cs index 05102fa..a5a5ff2 100644 --- a/DS4Tool/ScpForm.Designer.cs +++ b/DS4Tool/ScpForm.Designer.cs @@ -68,10 +68,20 @@ this.cBController1 = new System.Windows.Forms.ComboBox(); this.lbLastMessage = new System.Windows.Forms.Label(); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); + this.cMTaskbar = new System.Windows.Forms.ContextMenuStrip(this.components); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.editProfileForController1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editProfileForController2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editProfileForController3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editProfileForController4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.pnlButton.SuspendLayout(); this.pnlDebug.SuspendLayout(); this.pnlStatus.SuspendLayout(); this.gpPads.SuspendLayout(); + this.cMTaskbar.SuspendLayout(); this.SuspendLayout(); // // lvDebug @@ -86,7 +96,7 @@ this.lvDebug.FullRowSelect = true; this.lvDebug.Location = new System.Drawing.Point(0, 0); this.lvDebug.Name = "lvDebug"; - this.lvDebug.Size = new System.Drawing.Size(794, 353); + this.lvDebug.Size = new System.Drawing.Size(797, 353); this.lvDebug.TabIndex = 0; this.lvDebug.UseCompatibleStateImageBehavior = false; this.lvDebug.View = System.Windows.Forms.View.Details; @@ -116,9 +126,9 @@ this.pnlButton.Controls.Add(this.hotkeysButton); this.pnlButton.Controls.Add(this.lnkControllers); this.pnlButton.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlButton.Location = new System.Drawing.Point(3, 477); + this.pnlButton.Location = new System.Drawing.Point(0, 477); this.pnlButton.Name = "pnlButton"; - this.pnlButton.Size = new System.Drawing.Size(791, 35); + this.pnlButton.Size = new System.Drawing.Size(794, 35); this.pnlButton.TabIndex = 10; // // AboutButton @@ -134,7 +144,7 @@ // btnStartStop // this.btnStartStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnStartStop.Location = new System.Drawing.Point(663, 5); + this.btnStartStop.Location = new System.Drawing.Point(666, 5); this.btnStartStop.Name = "btnStartStop"; this.btnStartStop.Size = new System.Drawing.Size(119, 23); this.btnStartStop.TabIndex = 1; @@ -146,7 +156,7 @@ // this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Enabled = false; - this.btnClear.Location = new System.Drawing.Point(560, 6); + this.btnClear.Location = new System.Drawing.Point(563, 6); this.btnClear.Name = "btnClear"; this.btnClear.Size = new System.Drawing.Size(97, 23); this.btnClear.TabIndex = 9; @@ -158,7 +168,7 @@ // this.btnStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnStop.Enabled = false; - this.btnStop.Location = new System.Drawing.Point(707, 6); + this.btnStop.Location = new System.Drawing.Point(710, 6); this.btnStop.Name = "btnStop"; this.btnStop.Size = new System.Drawing.Size(75, 23); this.btnStop.TabIndex = 2; @@ -192,7 +202,7 @@ // this.hideDS4CheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.hideDS4CheckBox.AutoSize = true; - this.hideDS4CheckBox.Location = new System.Drawing.Point(672, 109); + this.hideDS4CheckBox.Location = new System.Drawing.Point(675, 109); this.hideDS4CheckBox.Name = "hideDS4CheckBox"; this.hideDS4CheckBox.Size = new System.Drawing.Size(119, 17); this.hideDS4CheckBox.TabIndex = 13; @@ -204,7 +214,7 @@ // this.startMinimizedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.startMinimizedCheckBox.AutoSize = true; - this.startMinimizedCheckBox.Location = new System.Drawing.Point(569, 109); + this.startMinimizedCheckBox.Location = new System.Drawing.Point(572, 109); this.startMinimizedCheckBox.Name = "startMinimizedCheckBox"; this.startMinimizedCheckBox.Size = new System.Drawing.Size(97, 17); this.startMinimizedCheckBox.TabIndex = 40; @@ -216,18 +226,18 @@ // this.pnlDebug.Controls.Add(this.lvDebug); this.pnlDebug.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlDebug.Location = new System.Drawing.Point(3, 124); + this.pnlDebug.Location = new System.Drawing.Point(0, 124); this.pnlDebug.Name = "pnlDebug"; - this.pnlDebug.Size = new System.Drawing.Size(791, 353); + this.pnlDebug.Size = new System.Drawing.Size(794, 353); this.pnlDebug.TabIndex = 11; // // pnlStatus // this.pnlStatus.Controls.Add(this.gpPads); this.pnlStatus.Dock = System.Windows.Forms.DockStyle.Top; - this.pnlStatus.Location = new System.Drawing.Point(3, 0); + this.pnlStatus.Location = new System.Drawing.Point(0, 0); this.pnlStatus.Name = "pnlStatus"; - this.pnlStatus.Size = new System.Drawing.Size(791, 124); + this.pnlStatus.Size = new System.Drawing.Size(794, 124); this.pnlStatus.TabIndex = 9; // // gpPads @@ -259,7 +269,7 @@ this.gpPads.Controls.Add(this.lbLastMessage); this.gpPads.Location = new System.Drawing.Point(-6, -9); this.gpPads.Name = "gpPads"; - this.gpPads.Size = new System.Drawing.Size(800, 129); + this.gpPads.Size = new System.Drawing.Size(803, 129); this.gpPads.TabIndex = 1; this.gpPads.TabStop = false; // @@ -268,7 +278,7 @@ this.lbSelPro4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lbSelPro4.AutoSize = true; this.lbSelPro4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSelPro4.Location = new System.Drawing.Point(467, 86); + this.lbSelPro4.Location = new System.Drawing.Point(470, 86); this.lbSelPro4.Name = "lbSelPro4"; this.lbSelPro4.Size = new System.Drawing.Size(96, 15); this.lbSelPro4.TabIndex = 45; @@ -279,7 +289,7 @@ this.lbSelPro3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lbSelPro3.AutoSize = true; this.lbSelPro3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSelPro3.Location = new System.Drawing.Point(467, 62); + this.lbSelPro3.Location = new System.Drawing.Point(470, 62); this.lbSelPro3.Name = "lbSelPro3"; this.lbSelPro3.Size = new System.Drawing.Size(96, 15); this.lbSelPro3.TabIndex = 45; @@ -290,7 +300,7 @@ this.lbSelPro2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lbSelPro2.AutoSize = true; this.lbSelPro2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSelPro2.Location = new System.Drawing.Point(467, 40); + this.lbSelPro2.Location = new System.Drawing.Point(470, 40); this.lbSelPro2.Name = "lbSelPro2"; this.lbSelPro2.Size = new System.Drawing.Size(96, 15); this.lbSelPro2.TabIndex = 45; @@ -301,7 +311,7 @@ this.lbSelPro1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lbSelPro1.AutoSize = true; this.lbSelPro1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSelPro1.Location = new System.Drawing.Point(467, 17); + this.lbSelPro1.Location = new System.Drawing.Point(470, 17); this.lbSelPro1.Name = "lbSelPro1"; this.lbSelPro1.Size = new System.Drawing.Size(96, 15); this.lbSelPro1.TabIndex = 45; @@ -350,7 +360,7 @@ // bnEditC4 // this.bnEditC4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnEditC4.Location = new System.Drawing.Point(695, 83); + this.bnEditC4.Location = new System.Drawing.Point(698, 83); this.bnEditC4.Name = "bnEditC4"; this.bnEditC4.Size = new System.Drawing.Size(40, 23); this.bnEditC4.TabIndex = 43; @@ -362,7 +372,7 @@ // bnEditC3 // this.bnEditC3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnEditC3.Location = new System.Drawing.Point(695, 60); + this.bnEditC3.Location = new System.Drawing.Point(698, 60); this.bnEditC3.Name = "bnEditC3"; this.bnEditC3.Size = new System.Drawing.Size(40, 23); this.bnEditC3.TabIndex = 43; @@ -374,7 +384,7 @@ // bnEditC2 // this.bnEditC2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnEditC2.Location = new System.Drawing.Point(695, 37); + this.bnEditC2.Location = new System.Drawing.Point(698, 37); this.bnEditC2.Name = "bnEditC2"; this.bnEditC2.Size = new System.Drawing.Size(40, 23); this.bnEditC2.TabIndex = 43; @@ -386,7 +396,7 @@ // bnDeleteC4 // this.bnDeleteC4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnDeleteC4.Location = new System.Drawing.Point(741, 83); + this.bnDeleteC4.Location = new System.Drawing.Point(744, 83); this.bnDeleteC4.Name = "bnDeleteC4"; this.bnDeleteC4.Size = new System.Drawing.Size(47, 23); this.bnDeleteC4.TabIndex = 43; @@ -398,7 +408,7 @@ // bnDeleteC3 // this.bnDeleteC3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnDeleteC3.Location = new System.Drawing.Point(741, 60); + this.bnDeleteC3.Location = new System.Drawing.Point(744, 60); this.bnDeleteC3.Name = "bnDeleteC3"; this.bnDeleteC3.Size = new System.Drawing.Size(47, 23); this.bnDeleteC3.TabIndex = 43; @@ -410,7 +420,7 @@ // bnDeleteC2 // this.bnDeleteC2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnDeleteC2.Location = new System.Drawing.Point(741, 37); + this.bnDeleteC2.Location = new System.Drawing.Point(744, 37); this.bnDeleteC2.Name = "bnDeleteC2"; this.bnDeleteC2.Size = new System.Drawing.Size(47, 23); this.bnDeleteC2.TabIndex = 43; @@ -422,7 +432,7 @@ // bnDeleteC1 // this.bnDeleteC1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnDeleteC1.Location = new System.Drawing.Point(741, 13); + this.bnDeleteC1.Location = new System.Drawing.Point(744, 13); this.bnDeleteC1.Name = "bnDeleteC1"; this.bnDeleteC1.Size = new System.Drawing.Size(47, 23); this.bnDeleteC1.TabIndex = 43; @@ -434,7 +444,7 @@ // bnEditC1 // this.bnEditC1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.bnEditC1.Location = new System.Drawing.Point(695, 13); + this.bnEditC1.Location = new System.Drawing.Point(698, 13); this.bnEditC1.Name = "bnEditC1"; this.bnEditC1.Size = new System.Drawing.Size(40, 23); this.bnEditC1.TabIndex = 43; @@ -448,7 +458,7 @@ this.cBController4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cBController4.Enabled = false; this.cBController4.FormattingEnabled = true; - this.cBController4.Location = new System.Drawing.Point(568, 84); + this.cBController4.Location = new System.Drawing.Point(571, 84); this.cBController4.Name = "cBController4"; this.cBController4.Size = new System.Drawing.Size(121, 21); this.cBController4.TabIndex = 42; @@ -460,7 +470,7 @@ this.cBController3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cBController3.Enabled = false; this.cBController3.FormattingEnabled = true; - this.cBController3.Location = new System.Drawing.Point(568, 61); + this.cBController3.Location = new System.Drawing.Point(571, 61); this.cBController3.Name = "cBController3"; this.cBController3.Size = new System.Drawing.Size(121, 21); this.cBController3.TabIndex = 42; @@ -472,7 +482,7 @@ this.cBController2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cBController2.Enabled = false; this.cBController2.FormattingEnabled = true; - this.cBController2.Location = new System.Drawing.Point(568, 38); + this.cBController2.Location = new System.Drawing.Point(571, 38); this.cBController2.Name = "cBController2"; this.cBController2.Size = new System.Drawing.Size(121, 21); this.cBController2.TabIndex = 42; @@ -484,7 +494,7 @@ this.cBController1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cBController1.Enabled = false; this.cBController1.FormattingEnabled = true; - this.cBController1.Location = new System.Drawing.Point(568, 15); + this.cBController1.Location = new System.Drawing.Point(571, 15); this.cBController1.Name = "cBController1"; this.cBController1.Size = new System.Drawing.Size(121, 21); this.cBController1.TabIndex = 42; @@ -497,7 +507,7 @@ this.lbLastMessage.ForeColor = System.Drawing.SystemColors.GrayText; this.lbLastMessage.Location = new System.Drawing.Point(15, 107); this.lbLastMessage.Name = "lbLastMessage"; - this.lbLastMessage.Size = new System.Drawing.Size(548, 20); + this.lbLastMessage.Size = new System.Drawing.Size(551, 20); this.lbLastMessage.TabIndex = 41; this.lbLastMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.lbLastMessage.Visible = false; @@ -506,9 +516,80 @@ // this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; this.notifyIcon1.BalloonTipTitle = "Scp server"; + this.notifyIcon1.ContextMenuStrip = this.cMTaskbar; this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Text = "DS4 Xinput Tool"; - this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon_Click); + this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon_Click); + // + // cMTaskbar + // + this.cMTaskbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openToolStripMenuItem, + this.toolStripSeparator1, + this.editProfileForController1ToolStripMenuItem, + this.editProfileForController2ToolStripMenuItem, + this.editProfileForController3ToolStripMenuItem, + this.editProfileForController4ToolStripMenuItem, + this.exitToolStripMenuItem}); + this.cMTaskbar.Name = "cMTaskbar"; + this.cMTaskbar.Size = new System.Drawing.Size(215, 142); + this.cMTaskbar.Tag = "25"; + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.openToolStripMenuItem.Text = "Open"; + this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(211, 6); + // + // editProfileForController1ToolStripMenuItem + // + this.editProfileForController1ToolStripMenuItem.Name = "editProfileForController1ToolStripMenuItem"; + this.editProfileForController1ToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.editProfileForController1ToolStripMenuItem.Tag = "0"; + this.editProfileForController1ToolStripMenuItem.Text = "Edit Profile for Controller 1"; + this.editProfileForController1ToolStripMenuItem.Click += new System.EventHandler(this.editMenu_Click); + // + // editProfileForController2ToolStripMenuItem + // + this.editProfileForController2ToolStripMenuItem.Name = "editProfileForController2ToolStripMenuItem"; + this.editProfileForController2ToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.editProfileForController2ToolStripMenuItem.Tag = "1"; + this.editProfileForController2ToolStripMenuItem.Text = "Edit Profile for Controller 2"; + this.editProfileForController2ToolStripMenuItem.Click += new System.EventHandler(this.editMenu_Click); + // + // editProfileForController3ToolStripMenuItem + // + this.editProfileForController3ToolStripMenuItem.Name = "editProfileForController3ToolStripMenuItem"; + this.editProfileForController3ToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.editProfileForController3ToolStripMenuItem.Tag = "2"; + this.editProfileForController3ToolStripMenuItem.Text = "Edit Profile for Controller 3"; + this.editProfileForController3ToolStripMenuItem.Click += new System.EventHandler(this.editMenu_Click); + // + // editProfileForController4ToolStripMenuItem + // + this.editProfileForController4ToolStripMenuItem.Name = "editProfileForController4ToolStripMenuItem"; + this.editProfileForController4ToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.editProfileForController4ToolStripMenuItem.Tag = "4"; + this.editProfileForController4ToolStripMenuItem.Text = "Edit Profile for Controller 4"; + this.editProfileForController4ToolStripMenuItem.Click += new System.EventHandler(this.editMenu_Click); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.exitToolStripMenuItem.Text = "Exit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(211, 6); // // ScpForm // @@ -530,6 +611,7 @@ this.pnlStatus.ResumeLayout(false); this.gpPads.ResumeLayout(false); this.gpPads.PerformLayout(); + this.cMTaskbar.ResumeLayout(false); this.ResumeLayout(false); } @@ -574,6 +656,16 @@ private System.Windows.Forms.Label lbSelPro4; private System.Windows.Forms.Label lbSelPro3; private System.Windows.Forms.Label lbSelPro2; + private System.Windows.Forms.ContextMenuStrip cMTaskbar; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editProfileForController1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editProfileForController2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editProfileForController4ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editProfileForController3ToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + //private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; } } diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index 4859877..b542106 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -73,7 +73,7 @@ namespace ScpServer protected Button[] ebns; protected Button[] dbns; protected Label[] protexts; - + protected ToolStripMenuItem[] shortcuts; public ScpForm() { InitializeComponent(); @@ -85,6 +85,14 @@ namespace ScpServer ebns = new Button[4] { bnEditC1, bnEditC2, bnEditC3, bnEditC4 }; dbns = new Button[4] { bnDeleteC1, bnDeleteC2, bnDeleteC3, bnDeleteC4 }; protexts = new Label[4] { lbSelPro1, lbSelPro2, lbSelPro3, lbSelPro4 }; + + shortcuts = new ToolStripMenuItem[4] { (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[2], + (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[3], + (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[4], + (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[5] }; + foreach (ToolStripMenuItem t in shortcuts) + t.DropDownItemClicked += Profile_Changed_Menu; + } protected void Form_Load(object sender, EventArgs e) @@ -117,7 +125,6 @@ namespace ScpServer for (int i = 0; i < 4; i++) { //Global.LoadProfile(i); - //Global.loadNEW(i, MapSelector.ButtonMode); } Global.ControllerStatusChange += ControllerStatusChange; ControllerStatusChanged(); @@ -130,23 +137,31 @@ namespace ScpServer { string[] profiles = System.IO.Directory.GetFiles(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\"); int cutoff = (Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\").Length; + List profilenames = new List(); + foreach (String s in profiles) + if (s.EndsWith(".xml")) + profilenames.Add(s.Substring(cutoff, s.Length - 4 - cutoff)); for (int i = 0; i < 4; i++) { cbs[i].Items.Clear(); - string defaultprofile = Global.getAProfile(i); - string[] profileA = defaultprofile.Split('\\'); + shortcuts[i].DropDownItems.Clear(); + string[] profileA = Global.getAProfile(i).Split('\\'); string filename = profileA[profileA.Length - 1]; - foreach (String s in profiles) - if (s.EndsWith(".xml")) - cbs[i].Items.Add(s.Substring(cutoff, s.Length - 4 - cutoff)); - for (int j = 0; j < cbs[i].Items.Count; j++) + cbs[i].Items.AddRange(profilenames.ToArray()); + foreach (string s in profilenames) + shortcuts[i].DropDownItems.Add(s); + for (int j = 0; j < cbs[i].Items.Count; j++) if (cbs[i].Items[j] + ".xml" == filename) { cbs[i].SelectedIndex = j; Profile_Changed(cbs[i], null); + ((ToolStripMenuItem)shortcuts[i].DropDownItems[j]).Checked = true; + Global.setAProfile(i, cbs[i].Text); + Global.LoadProfile(i); break; - } + } cbs[i].Items.Add("+New Profile"); + shortcuts[i].DropDownItems.Add("+New Profile"); } } catch (DirectoryNotFoundException) @@ -236,7 +251,8 @@ namespace ScpServer cbs[Index].Enabled = true; ebns[Index].Enabled = true; dbns[Index].Enabled = true; - protexts[Index].Enabled = true; + protexts[Index].Enabled = true; + shortcuts[Index].Enabled = true; Global.LoadProfile(Index); // As above //if (checkFirst && (Pads[Index].Checked && Index != 0)) @@ -252,7 +268,7 @@ namespace ScpServer protexts[Index].Enabled = false; if (OptionsDialog[Index] != null) OptionsDialog[Index].Close(); - + shortcuts[Index].Enabled = false; // As above //if (Index == 0) // checkFirst = false; @@ -276,21 +292,44 @@ namespace ScpServer { Button bn = (Button)sender; int i = Int32.Parse(bn.Tag.ToString()); - ComboBox[] cbs = { cBController1, cBController2, cBController3, cBController4 }; Options opt = OptionsDialog[i] = new Options(rootHub, i, cbs[i].Text, this); opt.Text = "Options for Controller " + (i + 1); opt.Icon = this.Icon; opt.FormClosed += delegate { OptionsDialog[i] = null; - dbns[i].Enabled = true; - cbs[i].Enabled = true; - bn.Enabled = true; + Enable_Controls(i, true); }; opt.Show(); - cbs[i].Enabled = false; - dbns[i].Enabled = false; - bn.Enabled = false; + Enable_Controls(i, false); + + } + private void editMenu_Click(object sender, EventArgs e) + { + ToolStripMenuItem em = (ToolStripMenuItem)sender; + int i = Int32.Parse(em.Tag.ToString()); + foreach (ToolStripDropDownItem t in em.DropDownItems) + if (((ToolStripMenuItem)t).Checked) + { + Options opt = OptionsDialog[i] = new Options(rootHub, i, ((ToolStripMenuItem)t).Text, this); + opt.Text = "Options for Controller " + (i + 1); + opt.Icon = this.Icon; + opt.FormClosed += delegate + { + OptionsDialog[i] = null; + Enable_Controls(i, true); + }; + opt.Show(); + Enable_Controls(i, false); + break; + } + } + private void Enable_Controls(int device, bool on) + { + ebns[device].Enabled = on; + dbns[device].Enabled = on; + cbs[device].Enabled = on; + shortcuts[device].Enabled = on; } private void deleteButtons_Click(object sender, EventArgs e) { @@ -305,11 +344,6 @@ namespace ScpServer } } - private void notifyIcon_Click(object sender, EventArgs e) - { - this.Show(); - WindowState = FormWindowState.Normal; - } private void hotkeysButton_Click(object sender, EventArgs e) { Hotkeys hotkeysForm = new Hotkeys(); @@ -355,30 +389,84 @@ namespace ScpServer private void Profile_Changed(object sender, EventArgs e) { - ComboBox cb = (ComboBox)sender; + ComboBox cb = (ComboBox)sender; int tdevice = Int32.Parse(cb.Tag.ToString()); if (cb.Items[cb.Items.Count - 1].ToString() == "+New Profile") { if (cb.SelectedIndex < cb.Items.Count - 1) { + for (int i = 0; i < shortcuts[tdevice].DropDownItems.Count; i++) + ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[i]).Checked = false; + ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[cb.SelectedIndex]).Checked = true; Global.setAProfile(tdevice, cb.Items[cb.SelectedIndex].ToString()); Global.Save(); Global.LoadProfile(tdevice); } else if (cb.SelectedIndex == cb.Items.Count - 1 && cb.Items.Count > 1) //if +New Profile selected - { - Options opt = OptionsDialog[tdevice] = new Options(rootHub, tdevice, "", this); - opt.Text = "Options for Controller " + (tdevice + 1); - opt.Icon = this.Icon; - int i = tdevice; - opt.FormClosed += delegate { OptionsDialog[i] = null; }; - opt.Show(); - } + { + Options opt = OptionsDialog[tdevice] = new Options(rootHub, tdevice, "", this); + opt.Text = "Options for Controller " + (tdevice + 1); + opt.Icon = this.Icon; + int i = tdevice; + opt.FormClosed += delegate + { + OptionsDialog[i] = null; + Enable_Controls(i, true); + }; + opt.Show(); + Enable_Controls(i, false); + } + if (cb.Text == "") + ebns[tdevice].Text = "New"; + else + ebns[tdevice].Text = "Edit"; } - if (cb.Text == "") - ebns[tdevice].Text = "New"; - else - ebns[tdevice].Text = "Edit"; + } + + private void Profile_Changed_Menu(object sender, ToolStripItemClickedEventArgs e) + { + ToolStripMenuItem tS = (ToolStripMenuItem)sender; + int tdevice = Int32.Parse(tS.Tag.ToString()); + if (e.ClickedItem != tS.DropDownItems[tS.DropDownItems.Count - 1]) + { + for (int i = 0; i < tS.DropDownItems.Count; i++) + ((ToolStripMenuItem)tS.DropDownItems[i]).Checked = false; + ((ToolStripMenuItem)e.ClickedItem).Checked = true; + cbs[tdevice].SelectedIndex = tS.DropDownItems.IndexOf(e.ClickedItem); + Global.setAProfile(tdevice, e.ClickedItem.Text); + Global.Save(); + Global.LoadProfile(tdevice); + } + else if (e.ClickedItem.Text == "+New Profile") //if +New Profile selected + { + Options opt = OptionsDialog[tdevice] = new Options(rootHub, tdevice, "", this); + opt.Text = "Options for Controller " + (tdevice + 1); + opt.Icon = this.Icon; + int i = tdevice; + opt.FormClosed += delegate + { + OptionsDialog[i] = null; + Enable_Controls(i, true); + }; + opt.Show(); + Enable_Controls(i, false); + } + } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void openToolStripMenuItem_Click(object sender, EventArgs e) + { + notifyIcon_Click(sender,e); + } + + private void notifyIcon_Click(object sender, EventArgs e) + { + this.Show(); + WindowState = FormWindowState.Normal; } } diff --git a/DS4Tool/ScpForm.resx b/DS4Tool/ScpForm.resx index c6503ae..ebe74b5 100644 --- a/DS4Tool/ScpForm.resx +++ b/DS4Tool/ScpForm.resx @@ -123,6 +123,9 @@ 226, 17 + + 339, 17 +