2021-11-09 23:27:16 +00:00
|
|
|
|
using System;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
2021-07-23 13:38:07 +00:00
|
|
|
|
using System.Text.Json.Serialization;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-06 15:30:37 +00:00
|
|
|
|
namespace RokettoLaunch.Models
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
public class TileModel
|
|
|
|
|
{
|
|
|
|
|
public string Title { get; set; }
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public string ProcessFilename { get; set; }
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public string ProcessArgument { get; set; }
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public string ProcessWorkingDirectory { get; set; }
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal;
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public bool ProcessAsAdmin { get; set; } = false;
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-11-09 23:27:16 +00:00
|
|
|
|
[JsonConverter(typeof(RyzStudio.Text.Json.JsonPointConverter))]
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public Point Position { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsGroup { get; set; } = false;
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
public List<TileModel> Items { get; set; } = new List<TileModel>();
|
|
|
|
|
|
|
|
|
|
public override string ToString() => this.Title ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
public string CleanProcessFilename => (string.IsNullOrWhiteSpace(this.ProcessFilename) ? string.Empty : resolvePath(this.ProcessFilename));
|
|
|
|
|
|
|
|
|
|
public string CleanProcessArgument => (string.IsNullOrWhiteSpace(this.ProcessArgument) ? string.Empty : resolvePath(this.ProcessArgument));
|
|
|
|
|
|
|
|
|
|
public string CleanProcessWorkingDirectory => (string.IsNullOrWhiteSpace(this.ProcessWorkingDirectory) ? string.Empty : resolvePath(this.ProcessWorkingDirectory));
|
|
|
|
|
|
|
|
|
|
protected string resolvePath(string value)
|
|
|
|
|
{
|
|
|
|
|
string rv = Environment.ExpandEnvironmentVariables(value);
|
|
|
|
|
|
|
|
|
|
rv = resolveFirstPath(rv);
|
|
|
|
|
rv = resolveLastPath(rv);
|
|
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected string resolveFirstPath(string value)
|
|
|
|
|
{
|
|
|
|
|
const string last = "%FIRST%";
|
|
|
|
|
if (!value.Contains(last))
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string head = value.Substring(0, value.IndexOf(last));
|
|
|
|
|
string tail = value.Substring(value.IndexOf(last) + last.Length);
|
|
|
|
|
|
|
|
|
|
string[] dirList = new string[0];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dirList = System.IO.Directory.GetDirectories(head, "*", System.IO.SearchOption.TopDirectoryOnly);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dirList.Length <= 0)
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dirList[0] + tail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected string resolveLastPath(string value)
|
|
|
|
|
{
|
|
|
|
|
const string last = "%LAST%";
|
|
|
|
|
if (!value.Contains(last))
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string head = value.Substring(0, value.IndexOf(last));
|
|
|
|
|
string tail = value.Substring(value.IndexOf(last) + last.Length);
|
|
|
|
|
|
|
|
|
|
string[] dirList = new string[0];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dirList = System.IO.Directory.GetDirectories(head, "*", System.IO.SearchOption.TopDirectoryOnly);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dirList.Length <= 0)
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dirList[(dirList.Length - 1)] + tail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|