Add option from starting the application minimized to tray. Alsso added proper nuget dependency for ViGEmClient.

This commit is contained in:
Marco Calautti 2019-01-12 12:00:15 +00:00
parent 7fcfa1f383
commit 72fccace33
6 changed files with 114 additions and 58 deletions

3
.gitignore vendored
View file

@ -258,4 +258,5 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/BetterJoyForCemu/FodyWeavers.xml

View file

@ -11,6 +11,8 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -79,9 +81,16 @@
<ApplicationIcon>Icons\betterjoyforcemu_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Crc32.NET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dc0b95cf99bf4e99, processorArchitecture=MSIL">
<HintPath>..\packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll</HintPath>
</Reference>
<Reference Include="Nefarius.ViGEmClient, Version=1.15.16.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nefarius.ViGEmClient.1.15.16\lib\net452\Nefarius.ViGEmClient.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@ -120,6 +129,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
<Content Include="Icons\betterjoyforcemu_icon.ico" />
<Content Include="hidapi.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -131,12 +141,6 @@
<Resource Include="Icons\jc_right.png" />
<Resource Include="Icons\pro.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Downloads\ViGEm-master\ViGEm-master\NET\ViGEmClient\ViGEmClient.csproj">
<Project>{aa18ebcf-7e9d-4bc5-8760-e8c6e9a773e5}</Project>
<Name>ViGEmClient</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
@ -147,4 +151,13 @@
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.2.0\build\net452\Fody.targets" Condition="Exists('..\packages\Fody.2.2.0\build\net452\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.2.2.0\build\net452\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.2.0\build\net452\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
</Target>
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
</Project>

View file

@ -12,7 +12,8 @@ namespace BetterJoyForCemu {
public static void Init() {
variables["ProgressiveScan"] = true;
variables["StartInTray"] = false;
if (File.Exists(PATH)) {
using (StreamReader file = new StreamReader(PATH)) {
string line = String.Empty;
@ -32,7 +33,7 @@ namespace BetterJoyForCemu {
}
public static bool Value(string key) {
if (!variables.ContainsKey("ProgressiveScan")) {
if (!variables.ContainsKey("ProgressiveScan") && !variables.ContainsKey("StartInTray")) {
return false;
}
return variables[key];

View file

@ -34,15 +34,16 @@
this.passiveScanBox = new System.Windows.Forms.CheckBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.conCntrls = new System.Windows.Forms.GroupBox();
this.loc4 = new System.Windows.Forms.Button();
this.loc3 = new System.Windows.Forms.Button();
this.loc2 = new System.Windows.Forms.Button();
this.loc1 = new System.Windows.Forms.Button();
this.con4 = new System.Windows.Forms.Button();
this.con3 = new System.Windows.Forms.Button();
this.con2 = new System.Windows.Forms.Button();
this.con1 = new System.Windows.Forms.Button();
this.loc1 = new System.Windows.Forms.Button();
this.loc2 = new System.Windows.Forms.Button();
this.loc3 = new System.Windows.Forms.Button();
this.loc4 = new System.Windows.Forms.Button();
this.btnTip = new System.Windows.Forms.ToolTip(this.components);
this.startInTrayBox = new System.Windows.Forms.CheckBox();
this.contextMenu.SuspendLayout();
this.conCntrls.SuspendLayout();
this.SuspendLayout();
@ -141,6 +142,42 @@
this.conCntrls.TabStop = false;
this.conCntrls.Text = "Connected Controllers";
//
// loc4
//
this.loc4.Location = new System.Drawing.Point(198, 80);
this.loc4.Name = "loc4";
this.loc4.Size = new System.Drawing.Size(58, 20);
this.loc4.TabIndex = 7;
this.loc4.Text = "Locate";
this.loc4.UseVisualStyleBackColor = true;
//
// loc3
//
this.loc3.Location = new System.Drawing.Point(134, 80);
this.loc3.Name = "loc3";
this.loc3.Size = new System.Drawing.Size(58, 20);
this.loc3.TabIndex = 6;
this.loc3.Text = "Locate";
this.loc3.UseVisualStyleBackColor = true;
//
// loc2
//
this.loc2.Location = new System.Drawing.Point(70, 80);
this.loc2.Name = "loc2";
this.loc2.Size = new System.Drawing.Size(58, 20);
this.loc2.TabIndex = 5;
this.loc2.Text = "Locate";
this.loc2.UseVisualStyleBackColor = true;
//
// loc1
//
this.loc1.Location = new System.Drawing.Point(6, 80);
this.loc1.Name = "loc1";
this.loc1.Size = new System.Drawing.Size(58, 20);
this.loc1.TabIndex = 4;
this.loc1.Text = "Locate";
this.loc1.UseVisualStyleBackColor = true;
//
// con4
//
this.con4.BackgroundImage = global::BetterJoyForCemu.Properties.Resources.cross;
@ -190,47 +227,24 @@
this.btnTip.SetToolTip(this.con1, "Click on Joycons to join/split them");
this.con1.UseVisualStyleBackColor = true;
//
// loc1
// startInTrayBox
//
this.loc1.Location = new System.Drawing.Point(6, 80);
this.loc1.Name = "loc1";
this.loc1.Size = new System.Drawing.Size(58, 20);
this.loc1.TabIndex = 4;
this.loc1.Text = "Locate";
this.loc1.UseVisualStyleBackColor = true;
//
// loc2
//
this.loc2.Location = new System.Drawing.Point(70, 80);
this.loc2.Name = "loc2";
this.loc2.Size = new System.Drawing.Size(58, 20);
this.loc2.TabIndex = 5;
this.loc2.Text = "Locate";
this.loc2.UseVisualStyleBackColor = true;
//
// loc3
//
this.loc3.Location = new System.Drawing.Point(134, 80);
this.loc3.Name = "loc3";
this.loc3.Size = new System.Drawing.Size(58, 20);
this.loc3.TabIndex = 6;
this.loc3.Text = "Locate";
this.loc3.UseVisualStyleBackColor = true;
//
// loc4
//
this.loc4.Location = new System.Drawing.Point(198, 80);
this.loc4.Name = "loc4";
this.loc4.Size = new System.Drawing.Size(58, 20);
this.loc4.TabIndex = 7;
this.loc4.Text = "Locate";
this.loc4.UseVisualStyleBackColor = true;
this.startInTrayBox.AutoSize = true;
this.startInTrayBox.Location = new System.Drawing.Point(107, 238);
this.startInTrayBox.Name = "startInTrayBox";
this.startInTrayBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.startInTrayBox.Size = new System.Drawing.Size(83, 17);
this.startInTrayBox.TabIndex = 6;
this.startInTrayBox.Text = "Start in Tray";
this.startInTrayBox.UseVisualStyleBackColor = true;
this.startInTrayBox.CheckedChanged += new System.EventHandler(this.startInTrayBox_CheckedChanged);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.startInTrayBox);
this.Controls.Add(this.conCntrls);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.passiveScanBox);
@ -272,5 +286,6 @@
private System.Windows.Forms.Button loc2;
private System.Windows.Forms.Button loc1;
private System.Windows.Forms.ToolTip btnTip;
private System.Windows.Forms.CheckBox startInTrayBox;
}
}

View file

@ -21,32 +21,50 @@ namespace BetterJoyForCemu {
con = new List<Button> { con1, con2, con3, con4 };
loc = new List<Button> { loc1, loc2, loc3, loc4 };
}
}
private void HideToTray()
{
this.WindowState = FormWindowState.Minimized;
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(1);
this.ShowInTaskbar = false;
}
private void ShowFromTray()
{
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
notifyIcon.Visible = false;
}
private void MainForm_Resize(object sender, EventArgs e) {
if (this.WindowState == FormWindowState.Minimized) {
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(1);
this.ShowInTaskbar = false;
HideToTray();
}
}
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) {
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
notifyIcon.Visible = false;
ShowFromTray();
}
private void MainForm_Load(object sender, EventArgs e) {
this.ShowInTaskbar = true;
notifyIcon.Visible = false;
this.Show();
Program.Start();
Config.Init();
passiveScanBox.Checked = Config.Value("ProgressiveScan");
}
startInTrayBox.Checked = Config.Value("StartInTray");
if (Config.Value("StartInTray"))
{
HideToTray();
}
else
{
ShowFromTray();
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
try {
@ -173,6 +191,11 @@ namespace BetterJoyForCemu {
}
}
private void startInTrayBox_CheckedChanged(object sender, EventArgs e)
{
Config.Save("StartInTray", startInTrayBox.Checked);
}
void ReenableXinput(Joycon v) {
if (showAsXInput) {
v.xin = new Xbox360Controller(Program.emClient);

View file

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="1.6.2" targetFramework="net461" developmentDependency="true" />
<package id="Crc32.NET" version="1.2.0" targetFramework="net461" />
<package id="Fody" version="2.2.0" targetFramework="net461" developmentDependency="true" />
<package id="Nefarius.ViGEmClient" version="1.15.16" targetFramework="net461" />
</packages>