Skip to content

Commit

Permalink
Updated to 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Dec 20, 2020
1 parent 2e1537f commit c636f2f
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 93 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.


## [1.3] - 2020-12-20
- Added: Support for shortcuts
- Added: Optional parameters
- Added: App icons
- Added: You can now auto-update the app

## [1.2] - 2018-03-10
- Added: Modify an app entry
- Added: Check if another instance is running
Expand Down
8 changes: 4 additions & 4 deletions Mint/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private void t2_Tick(object sender, EventArgs e)
string s9 = "deadmoon © ";
string s10 = "deadmoon © 2";
string s11 = "deadmoon © 20";
string s12 = "deadmoon © 201";
string s13 = "deadmoon © 2018";
string s12 = "deadmoon © 202";
string s13 = "deadmoon © 2021";

switch (l2.Text)
{
Expand Down Expand Up @@ -88,12 +88,12 @@ private void t2_Tick(object sender, EventArgs e)
case "deadmoon © 20":
l2.Text = s12;
break;
case "deadmoon © 201":
case "deadmoon © 202":
l2.Text = s13;
t2.Stop();
//t1.Start();
break;
case "deadmoon © 2018":
case "deadmoon © 2021":
l2.Text = s0;
break;
}
Expand Down
1 change: 1 addition & 0 deletions Mint/AppsStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public class App
{
public string AppTitle { get; set; }
public string AppLink { get; set; }
public string AppParams { get; set; }
}
}
194 changes: 130 additions & 64 deletions Mint/MainForm.Designer.cs

Large diffs are not rendered by default.

114 changes: 94 additions & 20 deletions Mint/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Net;
using System.Diagnostics;
using Newtonsoft.Json;
using IWshRuntimeLibrary;
using System.Reflection;

namespace Mint
{
Expand All @@ -19,7 +21,6 @@ public partial class MainForm : Form
internal AppsStructure AppsStructure;

readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/mint/master/version.txt";
readonly string _releasesLink = "https://github.com/hellzerg/mint/releases";

readonly string _noNewVersionMessage = "You already have the latest version!";
readonly string _betaVersionMessage = "You are using an experimental version!";
Expand All @@ -34,6 +35,8 @@ public MainForm()
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Options.ApplyTheme(this);
launcherMenu.Renderer = new ToolStripRendererMaterial();

Expand All @@ -51,16 +54,16 @@ private void MainForm_Load(object sender, EventArgs e)

private void LoadAppsStructure()
{
if (File.Exists(Options.AppsStructureFile))
if (System.IO.File.Exists(Options.AppsStructureFile))
{
AppsStructure = JsonConvert.DeserializeObject<AppsStructure>(File.ReadAllText(Options.AppsStructureFile));
AppsStructure = JsonConvert.DeserializeObject<AppsStructure>(System.IO.File.ReadAllText(Options.AppsStructureFile));
}
else
{
AppsStructure = new AppsStructure();
AppsStructure.Apps = new List<App>();

using (FileStream fs = File.Open(Options.AppsStructureFile, FileMode.CreateNew))
using (FileStream fs = System.IO.File.Open(Options.AppsStructureFile, FileMode.CreateNew))
using (StreamWriter sw = new StreamWriter(fs))
using (JsonWriter jw = new JsonTextWriter(sw))
{
Expand All @@ -74,9 +77,9 @@ private void LoadAppsStructure()

private void SaveAppsStructure()
{
File.WriteAllText(Options.AppsStructureFile, string.Empty);
System.IO.File.WriteAllText(Options.AppsStructureFile, string.Empty);

using (FileStream fs = File.Open(Options.AppsStructureFile, FileMode.OpenOrCreate))
using (FileStream fs = System.IO.File.Open(Options.AppsStructureFile, FileMode.OpenOrCreate))
using (StreamWriter sw = new StreamWriter(fs))
using (JsonWriter jw = new JsonTextWriter(sw))
{
Expand All @@ -101,6 +104,8 @@ private void LoadAppsList()
}
}
}

label3.Text = string.Format("Apps ({0})", AppsStructure.Apps.Count);
}

private void LoadOptions()
Expand Down Expand Up @@ -138,13 +143,15 @@ private void BuildLauncherMenu()
{
foreach (App x in AppsStructure.Apps)
{
launcherMenu.Items.Add(x.AppTitle);

ToolStripMenuItem i = new ToolStripMenuItem(x.AppTitle, (Icon.ExtractAssociatedIcon(x.AppLink)).ToBitmap());
launcherMenu.Items.Add(i);
}
}

launcherMenu.Items.Add("Exit");

foreach (ToolStripItem y in launcherMenu.Items)
foreach (ToolStripMenuItem y in launcherMenu.Items)
{
y.ForeColor = Color.White;
}
Expand All @@ -154,7 +161,7 @@ private void AddApp()
{
if (!string.IsNullOrEmpty(txtAppLink.Text) && !string.IsNullOrEmpty(txtAppTitle.Text))
{
if (File.Exists(txtAppLink.Text))
if (System.IO.File.Exists(txtAppLink.Text))
{
if (AppsStructure.Apps.Find(x => x.AppLink == txtAppLink.Text) != null)
{
Expand All @@ -171,6 +178,7 @@ private void AddApp()
App app = new App();
app.AppLink = txtAppLink.Text;
app.AppTitle = txtAppTitle.Text;
app.AppParams = txtParams.Text;

AppsStructure.Apps.Add(app);
SaveAppsStructure();
Expand All @@ -181,6 +189,7 @@ private void AddApp()

txtAppLink.Clear();
txtAppTitle.Clear();
txtParams.Clear();
}
else
{
Expand All @@ -193,9 +202,14 @@ private void AddApp()
}
}

private string NewVersionMessage(string latest)
private string NewVersionMessage(string latestVersion)
{
return string.Format("There is a new version available!\n\nLatest version: {0}\nCurrent version: {1}\n\nDo you want to download it now?", latestVersion, Program.GetCurrentVersionToString());
}

private string NewDownloadLink(string latestVersion)
{
return string.Format("There is a new version available!\n\nLatest version: {0}\nCurrent version: {1}\n\nDo you want to download it now?", latest, Program.GetCurrentVersionToString());
return string.Format("https://github.com/hellzerg/mint/releases/download/{0}/Mint-{0}.exe", latestVersion);
}

private void CheckForUpdate()
Expand All @@ -221,11 +235,48 @@ private void CheckForUpdate()
{
if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
// PATCHING PROCESS
try
{
Process.Start(_releasesLink);
Assembly currentAssembly = Assembly.GetEntryAssembly();

if (currentAssembly == null)
{
currentAssembly = Assembly.GetCallingAssembly();
}

string appFolder = Path.GetDirectoryName(currentAssembly.Location);
string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
string appExtension = Path.GetExtension(currentAssembly.Location);

string archiveFile = Path.Combine(appFolder, appName + "_old" + appExtension);
string appFile = Path.Combine(appFolder, appName + appExtension);
string tempFile = Path.Combine(appFolder, appName + "_tmp" + appExtension);

// DOWNLOAD NEW VERSION
client.DownloadFile(NewDownloadLink(latestVersion), tempFile);

// ALLOW MINT TO EXIT
_allowExit = true;

// DELETE PREVIOUS BACK-UP
if (System.IO.File.Exists(archiveFile))
{
System.IO.File.Delete(archiveFile);
}

// MAKE BACK-UP
System.IO.File.Move(appFile, archiveFile);

// PATCH
System.IO.File.Move(tempFile, appFile);

Application.Restart();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
catch { }
}
}
else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
Expand Down Expand Up @@ -273,12 +324,12 @@ private void LaunchApp(string app)
{
try
{
string fileName = AppsStructure.Apps.Find(x => x.AppTitle == app).AppLink;
string filePath = Path.GetDirectoryName(fileName);
App appX = AppsStructure.Apps.Find(x => x.AppTitle == app);

Process p = new Process();
p.StartInfo.WorkingDirectory = filePath;
p.StartInfo.FileName = fileName;
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(appX.AppLink);
p.StartInfo.Arguments = appX.AppParams;
p.StartInfo.FileName = appX.AppLink;
p.Start();
}
catch (Exception ex)
Expand Down Expand Up @@ -380,12 +431,24 @@ private void btnLocate_Click(object sender, EventArgs e)
OpenFileDialog dialog = new OpenFileDialog();

dialog.Title = "Mint | Select an application...";
dialog.Filter = "Applications | *.exe";
dialog.Filter = "Applications | *.exe; *.lnk";

if (dialog.ShowDialog() == DialogResult.OK)
{
txtAppLink.Text = dialog.FileName;
if (string.IsNullOrEmpty(txtAppTitle.Text)) txtAppTitle.Text = dialog.SafeFileName.Replace(".exe", string.Empty);
if (dialog.FileName.EndsWith(".lnk"))
{
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(dialog.FileName);

txtAppLink.Text = link.TargetPath;
txtAppTitle.Text = Path.GetFileNameWithoutExtension(dialog.FileName).Replace(".exe", string.Empty);
txtParams.Text = link.Arguments;
}
else
{
txtAppLink.Text = dialog.FileName;
if (string.IsNullOrEmpty(txtAppTitle.Text)) txtAppTitle.Text = dialog.SafeFileName.Replace(".exe", string.Empty);
}
}
}

Expand Down Expand Up @@ -437,5 +500,16 @@ private void btnEdit_Click(object sender, EventArgs e)
BuildLauncherMenu();
}
}

private void btnSort_Click(object sender, EventArgs e)
{
AppsStructure.Apps = AppsStructure.Apps.OrderBy(x => x.AppTitle).ToList();

SaveAppsStructure();

LoadAppsStructure();
LoadAppsList();
BuildLauncherMenu();
}
}
}
11 changes: 11 additions & 0 deletions Mint/Mint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,16 @@
<ItemGroup>
<Content Include="mint.ico" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion Mint/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static class Program

// Enter current version here
internal readonly static float Major = 1;
internal readonly static float Minor = 2;
internal readonly static float Minor = 3;

/* END OF VERSION PROPERTIES */

Expand Down
2 changes: 1 addition & 1 deletion Mint/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mint")]
[assembly: AssemblyCopyright("deadmoon © 2018")]
[assembly: AssemblyCopyright("deadmoon © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
22 changes: 22 additions & 0 deletions Mint/ToolStripRendererMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ internal ToolStripRendererMaterial() : base(new ColorsMaterial())

internal class ColorsMaterial : ProfessionalColorTable
{
public override Color ImageMarginGradientBegin
{
get
{
return Options.BackgroundColor;
}
}
public override Color ImageMarginGradientMiddle
{
get
{
return Options.BackgroundColor;
}
}
public override Color ImageMarginGradientEnd
{
get
{
return Options.BackgroundColor;
}
}

public override Color ToolStripBorder
{
get
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Compatible with Windows 7, 8.1, 10

## Details: ##

Latest version: 1.2
Latest version: 1.3

Released: March 10, 2018
Released: December 20, 2020
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.3

0 comments on commit c636f2f

Please sign in to comment.