mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-02-17 08:26:20 +01:00
Minor tweaks
This commit is contained in:
parent
0571f8b663
commit
ece7b25f0c
@ -1,20 +1,12 @@
|
|||||||
using Microsoft.Win32;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
//using Ookii.Dialogs;
|
|
||||||
|
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
{
|
{
|
||||||
@ -43,8 +35,10 @@ namespace DS4Windows
|
|||||||
cbs[i].Items.Add(Properties.Resources.noneProfile);
|
cbs[i].Items.Add(Properties.Resources.noneProfile);
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File.Exists(Global.appdatapath + @"\Auto Profiles.xml"))
|
if (!File.Exists(Global.appdatapath + @"\Auto Profiles.xml"))
|
||||||
Create();
|
Create();
|
||||||
|
|
||||||
LoadP();
|
LoadP();
|
||||||
|
|
||||||
if (Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common"))
|
if (Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common"))
|
||||||
@ -64,7 +58,7 @@ namespace DS4Windows
|
|||||||
|
|
||||||
public bool Create()
|
public bool Create()
|
||||||
{
|
{
|
||||||
Boolean Saved = true;
|
bool Saved = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -101,10 +95,12 @@ namespace DS4Windows
|
|||||||
programpaths.Clear();
|
programpaths.Clear();
|
||||||
if (!File.Exists(Global.appdatapath + "\\Auto Profiles.xml"))
|
if (!File.Exists(Global.appdatapath + "\\Auto Profiles.xml"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
doc.Load(Global.appdatapath + "\\Auto Profiles.xml");
|
doc.Load(Global.appdatapath + "\\Auto Profiles.xml");
|
||||||
XmlNodeList programslist = doc.SelectNodes("Programs/Program");
|
XmlNodeList programslist = doc.SelectNodes("Programs/Program");
|
||||||
foreach (XmlNode x in programslist)
|
foreach (XmlNode x in programslist)
|
||||||
programpaths.Add(x.Attributes["path"].Value);
|
programpaths.Add(x.Attributes["path"].Value);
|
||||||
|
|
||||||
foreach (string st in programpaths)
|
foreach (string st in programpaths)
|
||||||
{
|
{
|
||||||
if (File.Exists(st))
|
if (File.Exists(st))
|
||||||
@ -127,13 +123,6 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void bnLoadSteam_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void GetApps(string path)
|
private void GetApps(string path)
|
||||||
{
|
{
|
||||||
lodsf.Clear();
|
lodsf.Clear();
|
||||||
@ -147,6 +136,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
appsloaded = true;
|
appsloaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +152,10 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
return lods;
|
return lods;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetShortcuts(string path)
|
private void GetShortcuts(string path)
|
||||||
{
|
{
|
||||||
lodsf.Clear();
|
lodsf.Clear();
|
||||||
@ -171,6 +163,7 @@ namespace DS4Windows
|
|||||||
lodsf.AddRange(Directory.GetFiles(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", "*.lnk", SearchOption.AllDirectories));
|
lodsf.AddRange(Directory.GetFiles(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", "*.lnk", SearchOption.AllDirectories));
|
||||||
for (int i = 0; i < lodsf.Count; i++)
|
for (int i = 0; i < lodsf.Count; i++)
|
||||||
lodsf[i] = GetTargetPath(lodsf[i]);
|
lodsf[i] = GetTargetPath(lodsf[i]);
|
||||||
|
|
||||||
appsloaded = true;
|
appsloaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,13 +173,21 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
bnAddPrograms.Text = Properties.Resources.AddingToList;
|
bnAddPrograms.Text = Properties.Resources.AddingToList;
|
||||||
for (int i = lodsf.Count - 1; i >= 0; i--)
|
for (int i = lodsf.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
if (lodsf[i].Contains("etup") || lodsf[i].Contains("dotnet") || lodsf[i].Contains("SETUP")
|
if (lodsf[i].Contains("etup") || lodsf[i].Contains("dotnet") || lodsf[i].Contains("SETUP")
|
||||||
|| lodsf[i].Contains("edist") || lodsf[i].Contains("nstall") || String.IsNullOrEmpty(lodsf[i]))
|
|| lodsf[i].Contains("edist") || lodsf[i].Contains("nstall") || String.IsNullOrEmpty(lodsf[i]))
|
||||||
lodsf.RemoveAt(i);
|
lodsf.RemoveAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = lodsf.Count - 1; i >= 0; i--)
|
for (int i = lodsf.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
for (int j = programpaths.Count - 1; j >= 0; j--)
|
for (int j = programpaths.Count - 1; j >= 0; j--)
|
||||||
|
{
|
||||||
if (lodsf[i].ToLower().Replace('/', '\\') == programpaths[j].ToLower().Replace('/', '\\'))
|
if (lodsf[i].ToLower().Replace('/', '\\') == programpaths[j].ToLower().Replace('/', '\\'))
|
||||||
lodsf.RemoveAt(i);
|
lodsf.RemoveAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (string st in lodsf)
|
foreach (string st in lodsf)
|
||||||
{
|
{
|
||||||
if (File.Exists(st))
|
if (File.Exists(st))
|
||||||
@ -199,6 +200,7 @@ namespace DS4Windows
|
|||||||
lVPrograms.Items.Add(lvi);
|
lVPrograms.Items.Add(lvi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bnAddPrograms.Text = Properties.Resources.AddPrograms;
|
bnAddPrograms.Text = Properties.Resources.AddPrograms;
|
||||||
bnAddPrograms.Enabled = true;
|
bnAddPrograms.Enabled = true;
|
||||||
appsloaded = false;
|
appsloaded = false;
|
||||||
@ -206,7 +208,6 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Save(string name)
|
public void Save(string name)
|
||||||
{
|
{
|
||||||
m_Xdoc.Load(m_Profile);
|
m_Xdoc.Load(m_Profile);
|
||||||
@ -226,16 +227,20 @@ namespace DS4Windows
|
|||||||
el.AppendChild(m_Xdoc.CreateElement("Controller3")).InnerText = cBProfile3.Text;
|
el.AppendChild(m_Xdoc.CreateElement("Controller3")).InnerText = cBProfile3.Text;
|
||||||
el.AppendChild(m_Xdoc.CreateElement("Controller4")).InnerText = cBProfile4.Text;
|
el.AppendChild(m_Xdoc.CreateElement("Controller4")).InnerText = cBProfile4.Text;
|
||||||
el.AppendChild(m_Xdoc.CreateElement("TurnOff")).InnerText = cBTurnOffDS4W.Checked.ToString();
|
el.AppendChild(m_Xdoc.CreateElement("TurnOff")).InnerText = cBTurnOffDS4W.Checked.ToString();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlNode oldxmlprocess = m_Xdoc.SelectSingleNode("/Programs/Program[@path=\"" + lBProgramPath.Text + "\"]");
|
XmlNode oldxmlprocess = m_Xdoc.SelectSingleNode("/Programs/Program[@path=\"" + lBProgramPath.Text + "\"]");
|
||||||
Node.ReplaceChild(el, oldxmlprocess);
|
Node.ReplaceChild(el, oldxmlprocess);
|
||||||
}
|
}
|
||||||
catch { Node.AppendChild(el); }
|
catch { Node.AppendChild(el); }
|
||||||
|
|
||||||
m_Xdoc.AppendChild(Node);
|
m_Xdoc.AppendChild(Node);
|
||||||
m_Xdoc.Save(m_Profile);
|
m_Xdoc.Save(m_Profile);
|
||||||
|
|
||||||
if (lVPrograms.SelectedItems.Count > 0)
|
if (lVPrograms.SelectedItems.Count > 0)
|
||||||
lVPrograms.SelectedItems[0].Checked = true;
|
lVPrograms.SelectedItems[0].Checked = true;
|
||||||
|
|
||||||
form.LoadP();
|
form.LoadP();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +256,9 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/Controller" + (i + 1));
|
Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/Controller" + (i + 1));
|
||||||
if (Item != null)
|
if (Item != null)
|
||||||
|
{
|
||||||
for (int j = 0; j < cbs[i].Items.Count; j++)
|
for (int j = 0; j < cbs[i].Items.Count; j++)
|
||||||
|
{
|
||||||
if (cbs[i].Items[j].ToString() == Item.InnerText)
|
if (cbs[i].Items[j].ToString() == Item.InnerText)
|
||||||
{
|
{
|
||||||
cbs[i].SelectedIndex = j;
|
cbs[i].SelectedIndex = j;
|
||||||
@ -260,9 +267,12 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/TurnOff");
|
Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/TurnOff");
|
||||||
bool turnOff;
|
bool turnOff;
|
||||||
if (Item != null && bool.TryParse(Item.InnerText, out turnOff))
|
if (Item != null && bool.TryParse(Item.InnerText, out turnOff))
|
||||||
@ -276,6 +286,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
|
|
||||||
cBTurnOffDS4W.Checked = false;
|
cBTurnOffDS4W.Checked = false;
|
||||||
bnSave.Enabled = false;
|
bnSave.Enabled = false;
|
||||||
}
|
}
|
||||||
@ -283,22 +294,24 @@ namespace DS4Windows
|
|||||||
|
|
||||||
public void RemoveP(string name, bool uncheck, bool reload = true)
|
public void RemoveP(string name, bool uncheck, bool reload = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(m_Profile);
|
doc.Load(m_Profile);
|
||||||
XmlNode Node = doc.SelectSingleNode("Programs");
|
XmlNode Node = doc.SelectSingleNode("Programs");
|
||||||
XmlNode Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]");
|
XmlNode Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]");
|
||||||
if (Item != null)
|
if (Item != null)
|
||||||
Node.RemoveChild(Item);
|
Node.RemoveChild(Item);
|
||||||
|
|
||||||
doc.AppendChild(Node);
|
doc.AppendChild(Node);
|
||||||
doc.Save(m_Profile);
|
doc.Save(m_Profile);
|
||||||
if (lVPrograms.SelectedItems.Count > 0 && uncheck)
|
if (lVPrograms.SelectedItems.Count > 0 && uncheck)
|
||||||
lVPrograms.SelectedItems[0].Checked = false;
|
lVPrograms.SelectedItems[0].Checked = false;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
|
|
||||||
bnSave.Enabled = false;
|
bnSave.Enabled = false;
|
||||||
if (reload)
|
if (reload)
|
||||||
form.LoadP();
|
form.LoadP();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CBProfile_IndexChanged(object sender, EventArgs e)
|
private void CBProfile_IndexChanged(object sender, EventArgs e)
|
||||||
@ -306,6 +319,7 @@ namespace DS4Windows
|
|||||||
int last = cbs[0].Items.Count - 1;
|
int last = cbs[0].Items.Count - 1;
|
||||||
if (lBProgramPath.Text != string.Empty)
|
if (lBProgramPath.Text != string.Empty)
|
||||||
bnSave.Enabled = true;
|
bnSave.Enabled = true;
|
||||||
|
|
||||||
if (cbs[0].SelectedIndex == last && cbs[1].SelectedIndex == last &&
|
if (cbs[0].SelectedIndex == last && cbs[1].SelectedIndex == last &&
|
||||||
cbs[2].SelectedIndex == last && cbs[3].SelectedIndex == last && !cBTurnOffDS4W.Checked)
|
cbs[2].SelectedIndex == last && cbs[3].SelectedIndex == last && !cBTurnOffDS4W.Checked)
|
||||||
bnSave.Enabled = false;
|
bnSave.Enabled = false;
|
||||||
@ -315,6 +329,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
if (lBProgramPath.Text != "")
|
if (lBProgramPath.Text != "")
|
||||||
Save(lBProgramPath.Text);
|
Save(lBProgramPath.Text);
|
||||||
|
|
||||||
bnSave.Enabled = false;
|
bnSave.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,8 +343,10 @@ namespace DS4Windows
|
|||||||
if (lBProgramPath.Text != "")
|
if (lBProgramPath.Text != "")
|
||||||
LoadP(lBProgramPath.Text);
|
LoadP(lBProgramPath.Text);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bnDelete_Click(object sender, EventArgs e)
|
private void bnDelete_Click(object sender, EventArgs e)
|
||||||
@ -359,7 +376,6 @@ namespace DS4Windows
|
|||||||
form.RefreshAutoProfilesPage();
|
form.RefreshAutoProfilesPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addSteamGamesToolStripMenuItem_Click(object sender, EventArgs e)
|
private void addSteamGamesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -369,6 +385,7 @@ namespace DS4Windows
|
|||||||
AppCollectionThread.Start();
|
AppCollectionThread.Start();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
bnAddPrograms.Text = Properties.Resources.Loading;
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
||||||
bnAddPrograms.Enabled = false;
|
bnAddPrograms.Enabled = false;
|
||||||
cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem);
|
cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem);
|
||||||
@ -389,6 +406,7 @@ namespace DS4Windows
|
|||||||
AppCollectionThread.Start();
|
AppCollectionThread.Start();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
bnAddPrograms.Text = Properties.Resources.Loading;
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
||||||
bnAddPrograms.Enabled = false;
|
bnAddPrograms.Enabled = false;
|
||||||
Timer appstimer = new Timer();
|
Timer appstimer = new Timer();
|
||||||
@ -406,6 +424,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
file = GetTargetPath(file);
|
file = GetTargetPath(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
lBProgramPath.Text = file;
|
lBProgramPath.Text = file;
|
||||||
iLIcons.Images.Add(Icon.ExtractAssociatedIcon(file));
|
iLIcons.Images.Add(Icon.ExtractAssociatedIcon(file));
|
||||||
ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(file), lVPrograms.Items.Count);
|
ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(file), lVPrograms.Items.Count);
|
||||||
@ -423,6 +442,7 @@ namespace DS4Windows
|
|||||||
AppCollectionThread.Start();
|
AppCollectionThread.Start();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
bnAddPrograms.Text = Properties.Resources.Loading;
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
||||||
bnAddPrograms.Enabled = false;
|
bnAddPrograms.Enabled = false;
|
||||||
cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem);
|
cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem);
|
||||||
@ -433,7 +453,6 @@ namespace DS4Windows
|
|||||||
|
|
||||||
private void addProgramsFromStartMenuToolStripMenuItem_Click(object sender, EventArgs e)
|
private void addProgramsFromStartMenuToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var AppCollectionThread = new System.Threading.Thread(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"));
|
var AppCollectionThread = new System.Threading.Thread(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"));
|
||||||
@ -441,6 +460,7 @@ namespace DS4Windows
|
|||||||
AppCollectionThread.Start();
|
AppCollectionThread.Start();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
bnAddPrograms.Text = Properties.Resources.Loading;
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
||||||
bnAddPrograms.Enabled = false;
|
bnAddPrograms.Enabled = false;
|
||||||
cMSPrograms.Items.Remove(addProgramsFromStartMenuToolStripMenuItem);
|
cMSPrograms.Items.Remove(addProgramsFromStartMenuToolStripMenuItem);
|
||||||
@ -545,6 +565,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NativeMethods2
|
class NativeMethods2
|
||||||
{
|
{
|
||||||
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user