Added: environment path support

This commit is contained in:
Ray 2020-11-17 22:44:02 +00:00
parent b5a404735d
commit a0147102b6
2 changed files with 14 additions and 20 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
@ -19,18 +20,11 @@ namespace AppLauncher.Models
public override string ToString() => this.Title ?? string.Empty; public override string ToString() => this.Title ?? string.Empty;
//public void Update(TileModel model) public string CleanProcessFilename => (string.IsNullOrWhiteSpace(this.ProcessFilename) ? string.Empty : Environment.ExpandEnvironmentVariables(this.ProcessFilename));
//{
// this.Title = model.Title; public string CleanProcessArgument => (string.IsNullOrWhiteSpace(this.ProcessArgument) ? string.Empty : Environment.ExpandEnvironmentVariables(this.ProcessArgument));
// this.ProcessFilename = model.ProcessFilename;
// this.ProcessArgument = model.ProcessArgument; public string CleanProcessWorkingDirectory => (string.IsNullOrWhiteSpace(this.ProcessWorkingDirectory) ? string.Empty : Environment.ExpandEnvironmentVariables(this.ProcessWorkingDirectory));
// this.ProcessWorkingDirectory = model.ProcessWorkingDirectory;
// this.ProcessWindowStyle = model.ProcessWindowStyle;
// this.ProcessAsAdmin = model.ProcessAsAdmin;
// this.Position = model.Position;
// this.IsGroup = model.IsGroup;
// this.Items = model.Items;
//}
} }
} }

View File

@ -283,21 +283,21 @@ namespace AppLauncher.Windows.Forms
return; return;
} }
if (string.IsNullOrWhiteSpace(model.ProcessFilename)) if (string.IsNullOrWhiteSpace(model.CleanProcessFilename))
{ {
return; return;
} }
if (!File.Exists(model.ProcessFilename)) if (!File.Exists(model.CleanProcessFilename))
{ {
return; return;
} }
ProcessStartInfo p = new ProcessStartInfo(); ProcessStartInfo p = new ProcessStartInfo();
p.FileName = model.ProcessFilename; p.FileName = model.CleanProcessFilename;
p.WindowStyle = model.ProcessWindowStyle; p.WindowStyle = model.ProcessWindowStyle;
if (!string.IsNullOrWhiteSpace(model.ProcessArgument)) p.Arguments = model.ProcessArgument; if (!string.IsNullOrWhiteSpace(model.CleanProcessArgument)) p.Arguments = model.CleanProcessArgument;
if (!string.IsNullOrWhiteSpace(model.ProcessWorkingDirectory)) p.WorkingDirectory = model.ProcessWorkingDirectory; if (!string.IsNullOrWhiteSpace(model.CleanProcessWorkingDirectory)) p.WorkingDirectory = model.CleanProcessWorkingDirectory;
if (model.ProcessAsAdmin) p.Verb = "runas"; if (model.ProcessAsAdmin) p.Verb = "runas";
MainForm parentForm = findMainForm(); MainForm parentForm = findMainForm();
@ -324,14 +324,14 @@ namespace AppLauncher.Windows.Forms
protected Image getIcon(TileModel model) protected Image getIcon(TileModel model)
{ {
if (!File.Exists(model.ProcessFilename)) if (!File.Exists(model.CleanProcessFilename))
{ {
return null; return null;
} }
try try
{ {
return Icon.ExtractAssociatedIcon(model.ProcessFilename)?.ToBitmap(); return Icon.ExtractAssociatedIcon(model.CleanProcessFilename)?.ToBitmap();
} }
catch catch
{ {