Archived
WIP: clean-up
This commit is contained in:
1 parent
1cdcca7267
commit
f58608fc23
14 files changed
+205
-1196
No files matched your search
@@ -1,21 +0,0 @@
|
||||
using FizzyLauncher.Text.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace FizzyLauncher.Models
|
||||
{
|
||||
public class TileGroupModel
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public bool IsExpanded { get; set; } = false;
|
||||
|
||||
public bool IsExclusive { get; set; } = false;
|
||||
|
||||
public List<TileModel> Items { get; set; } = new List<TileModel>();
|
||||
|
||||
[JsonConverter(typeof(JsonSizeConverter))]
|
||||
public Size GridSize { get; set; } = new Size(0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
using FizzyLauncher.Text.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace FizzyLauncher.Models
|
||||
{
|
||||
public class TileModel
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public string ProcessFilename { get; set; }
|
||||
|
||||
public string ProcessArgument { get; set; }
|
||||
|
||||
public string ProcessWorkingDirectory { get; set; }
|
||||
|
||||
public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal;
|
||||
|
||||
public bool ProcessAsAdmin { get; set; } = false;
|
||||
|
||||
[JsonConverter(typeof(JsonPointConverter))]
|
||||
public Point Position { get; set; }
|
||||
|
||||
public bool IsGroup { get; set; } = false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user