Skip to content

Commit

Permalink
Cemu .wua file support, new ShortCute animation, fixed doble click bu…
Browse files Browse the repository at this point in the history
…g on File Explorer
  • Loading branch information
Haruki1707 committed May 12, 2022
1 parent 0c1247a commit fa9a370
Show file tree
Hide file tree
Showing 13 changed files with 342 additions and 102 deletions.
12 changes: 6 additions & 6 deletions ShortCutes/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Management;
using System.Net;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Management;
using System.Windows.Forms;
using System.Security.Principal;
using System.Security.Cryptography;

namespace ShortCutes
{
Expand Down Expand Up @@ -54,8 +54,8 @@ static bool IsUserAdministrator()
ManagementObjectCollection MOClist = new ManagementObjectSearcher("SELECT UUID FROM Win32_ComputerSystemProduct").Get();
foreach (ManagementBaseObject mo in MOClist)
UUID = mo["UUID"] as string;
using(SHA256 shaHash = SHA256.Create())
using (SHA256 shaHash = SHA256.Create())
{
byte[] data = shaHash.ComputeHash(Encoding.UTF8.GetBytes(UUID));
StringBuilder sbuild = new StringBuilder();
Expand All @@ -67,7 +67,7 @@ static bool IsUserAdministrator()
using (WebClient wc = new WebClient())
{
wc.Headers.Add("User-Agent", "ShortCutes");
wc.OpenRead("http://freetests20.000webhostapp.com/ShortCutes/version.php?User=" + UUID + @"\\" + Environment.UserName + "&Version=v" + EZ_Updater.Updater.ProgramFileVersion);
wc.OpenRead("http://freetests20.000webhostapp.com/ShortCutes/version.php?User=" + UUID + @"\\" + Environment.UserName + "&Version=v" + Application.ProductVersion);
}
}
catch { }
Expand Down
4 changes: 2 additions & 2 deletions ShortCutes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
// utilizando el carácter "*", como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2")]
[assembly: AssemblyFileVersion("1.4.2")]
[assembly: AssemblyVersion("1.4.3")]
[assembly: AssemblyFileVersion("1.4.3")]
[assembly: NeutralResourcesLanguage("en")]
6 changes: 6 additions & 0 deletions ShortCutes/ShortCutesForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 71 additions & 28 deletions ShortCutes/ShortCutesForm.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using EZ_Updater;
using System;
using System.IO;
using System.Net;
using System.Drawing;
using System.Threading;
using Microsoft.CSharp;
using System.Diagnostics;
using System.Windows.Forms;
using System.Threading.Tasks;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShortCutes
{
Expand Down Expand Up @@ -78,15 +78,19 @@ public ShortCutes()
OpenFolder.Hide();
}

private async void ShortCutes_Shown(object sender, EventArgs e)
private void ShortCutes_Shown(object sender, EventArgs e)
{
if (await Updater.CheckUpdateAsync("Haruki1707", "ShortCutes"))
Updater.GUI_Context = SynchronizationContext.Current;
Thread t = new Thread(async () =>
{
if (Updater.CannotWriteOnDir)
MessageForm.Error(Updater.Message);
else
new MessageForm("", 4).ShowDialog();
}
if (await Updater.CheckUpdateAsync("Haruki1707", "ShortCutes"))
{
if (Updater.CannotWriteOnDir)
MessageForm.Error(Updater.Message);
else
new MessageForm("", 4).ShowDialog();
}
});
}

public static void Form1_UIThreadException(object sender, ThreadExceptionEventArgs t)
Expand Down Expand Up @@ -275,6 +279,11 @@ private string Roslyn_FormCode(string gamedir)
code = code.Replace("%GAMEFILE%", gamedir);
code = code.Replace("%ARGUMENTS%", SelectedEmu.Arguments(gamedir));

Color color = ControlPaint.Dark(GetAverageColor(ICOpic.Image));
code = code.Replace("%avgR%", color.R.ToString());
code = code.Replace("%avgG%", color.G.ToString());
code = code.Replace("%avgB%", color.B.ToString());

return code;
}

Expand Down Expand Up @@ -413,18 +422,6 @@ private void ICOurl_TextChanged(object sender, EventArgs e)
}
}

private string FileDialog(string InitialDir, string Filter)
{
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.InitialDirectory = InitialDir;
dialog.Filter = Filter + "|All files (*.*)|*.*";
dialog.FilterIndex = 1;

return dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null;
}
}

bool InputIsCommand = false;
private void ICOurl_KeyPress(object sender, KeyPressEventArgs e)
{
Expand Down Expand Up @@ -457,6 +454,46 @@ private void ICOurl_KeyPress(object sender, KeyPressEventArgs e)
catch { }
}

private string FileDialog(string InitialDir, string Filter)
{
Edirbox.Enabled = Gdirbox.Enabled = false;
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.InitialDirectory = InitialDir;
dialog.Filter = Filter + "|All files (*.*)|*.*";
dialog.FilterIndex = 1;
var result = dialog.ShowDialog();

Timer.Start();
return result == DialogResult.OK ? dialog.FileName : null;
}
}

private Color GetAverageColor(Image image)
{
int r = 0; int g = 0; int b = 0;
Bitmap bmp = new Bitmap(image);
int total = 0;

for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color clr = bmp.GetPixel(x, y);

r += clr.R;
g += clr.G;
b += clr.B;

total++;
}
}

//Calculate average
r /= total; g /= total; b /= total;
return Color.FromArgb(r, g, b);
}

//UI things not that important
private void ICOurl_KeyDown(object sender, KeyEventArgs e)
{
Expand Down Expand Up @@ -586,6 +623,12 @@ private void ClearSCSelected_Click(object sender, EventArgs e)
Shortcutbox.Focus();
}

private void Timer_Tick(object sender, EventArgs e)
{
Timer.Stop();
Gdirbox.Enabled = Edirbox.Enabled = true;
}

private void Shortcutbox_Focus(object sender, EventArgs e)
{
Shortcutbox.Focus();
Expand All @@ -605,7 +648,7 @@ private void Shortcutbox_TextChanged(object sender, EventArgs e)
}
private void Shortcutbox_KeyPress(object sender, KeyPressEventArgs e)
{
if (containsABadCharacter.IsMatch(e.KeyChar.ToString()) && !Char.IsControl(e.KeyChar))
if (containsABadCharacter.IsMatch(e.KeyChar.ToString()) && !char.IsControl(e.KeyChar))
{
MessageForm.Error("Invalid filename!\n Cannot contain: " + InvalidFileNameChars);
e.Handled = true;
Expand Down
3 changes: 3 additions & 0 deletions ShortCutes/ShortCutesForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
1 change: 1 addition & 0 deletions ShortCutes/UI-forms/CropImage_Tool.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions ShortCutes/UI-forms/CropImage_Tool.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace ShortCutes
{
Expand Down Expand Up @@ -260,5 +260,19 @@ private void panel1_MouseDown(object sender, MouseEventArgs e)

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);


//Let the form to be moved
[DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();

[DllImport("user32.DLL", EntryPoint = "SendMessage")]
private extern static void SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);

private void CropImage_Tool_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
}
}
2 changes: 2 additions & 0 deletions ShortCutes/UI-forms/HistoryForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fa9a370

Please sign in to comment.