using System.Application.Models;
using System.Collections.Generic;
using System.Diagnostics;
using ResizeMode = System.Int32;
namespace System.Application.Services
{
public interface IDesktopPlatformService
{
const string TAG = "DesktopPlatformS";
void SetResizeMode(IntPtr hWnd, ResizeMode value);
///
/// 获取一个正在运行的进程的命令行参数。
/// 与 一样,使用此方法获取的参数是包含应用程序路径的。
/// 关于 可参见:
/// .NET 命令行参数包含应用程序路径吗?https://blog.walterlv.com/post/when-will-the-command-line-args-contain-the-executable-path.html
///
/// 一个正在运行的进程。
/// 表示应用程序运行命令行参数的字符串。
string GetCommandLineArgs(Process process);
///
/// hosts 文件所在目录
///
string HostsFilePath => "/etc/hosts";
void StartProcess(string name, string filePath) => Process.Start(name, filePath);
///
/// 使用文本阅读器打开文件
///
///
void OpenFileByTextReader(string filePath)
{
TextReaderProvider? userProvider = null;
var p = IConfigFileService.Instance.UserSettings.TextReaderProvider;
if (p != null)
{
var platform = DI.Platform;
if (p.ContainsKey(platform))
{
var value = p[platform];
if (!string.IsNullOrWhiteSpace(value))
{
if (Enum.TryParse(value, out var enumValue))
{
userProvider = enumValue;
}
else
{
try
{
StartProcess(value, filePath);
return;
}
catch (Exception e)
{
Log.Error(TAG, e, "UserSettings OpenFileByTextReader Fail.");
}
}
}
}
}
var providers = new List() {
TextReaderProvider.VSCode,
TextReaderProvider.NotepadPlusPlus,
TextReaderProvider.Notepad };
if (userProvider.HasValue)
{
providers.Remove(userProvider.Value);
providers.Insert(0, userProvider.Value);
}
foreach (var item in providers)
{
try
{
var fileName = GetFileName(item);
if (fileName == null) continue;
StartProcess(fileName, filePath);
return;
}
catch (Exception e)
{
if (item == TextReaderProvider.Notepad)
{
Log.Error(TAG, e, "OpenFileByTextReader Fail.");
}
}
}
}
///
/// 获取文本阅读器提供商程序文件路径或文件名(如果提供程序已注册环境变量)
///
///
///
string? GetFileName(TextReaderProvider provider);
///
/// 设置开机自启动
///
/// 开启、关闭
///
void SetBootAutoStart(bool isAutoStart, string name);
#region Steam
///
string? GetSteamDirPath();
///
string? GetSteamProgramPath();
///
string GetLastSteamLoginUserName();
#endregion
public const ResizeMode ResizeMode_NoResize = 0;
public const ResizeMode ResizeMode_CanMinimize = 1;
public const ResizeMode ResizeMode_CanResize = 2;
public const ResizeMode ResizeMode_CanResizeWithGrip = 3;
}
}