-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cs
More file actions
89 lines (76 loc) · 2.05 KB
/
Copy pathUtils.cs
File metadata and controls
89 lines (76 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Text.Json;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
namespace TechLogManager;
public static class Utils
{
public static List<string>? ParseJsonStringList(string json)
{
return JsonSerializer.Deserialize<List<string>>(json);
}
internal static string GetRioHostname(string teamNumber)
{
return $"roboRIO-{teamNumber}-FRC.local";
}
public static async Task ShowMessageDialog(this Window window, string title, string message)
{
var dialog = new Window
{
Title = title,
Width = 400,
Height = 150,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
CanResize = false
};
var stack = new StackPanel { Margin = new Thickness(20) };
stack.Children.Add(new TextBlock
{
Text = message,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(0, 0, 0, 20)
});
var button = new Button
{
Content = "OK",
HorizontalAlignment = HorizontalAlignment.Center,
Width = 100
};
button.Click += (_, _) => dialog.Close();
stack.Children.Add(button);
dialog.Content = stack;
await dialog.ShowDialog(window);
}
public static List<T> Reversed<T>(this List<T> list)
{
var copy = new List<T>(list);
copy.Reverse();
return copy;
}
public static void Log(string message)
{
Console.WriteLine(message);
}
extension(Action action)
{
internal bool IsDownload()
{
return action is Action.Download or Action.DownloadAndDelete;
}
internal bool IsDelete()
{
return action is Action.Delete or Action.DownloadAndDelete;
}
}
extension(string str)
{
internal string WrapPath() => str.Replace("\\", "\\\u200B").Replace("/", "/\u200B");
}
}
public enum Action
{
DownloadAndDelete,
Download,
Delete
}