-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceIconManager.cs
More file actions
87 lines (76 loc) · 2.65 KB
/
ServiceIconManager.cs
File metadata and controls
87 lines (76 loc) · 2.65 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
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace NodaStack
{
public static class ServiceIconManager
{
private static readonly Dictionary<string, string> ServiceIcons = new()
{
{ "Apache", "🌐" },
{ "PHP", "🐘" },
{ "MySQL", "🗃️" },
{ "phpMyAdmin", "🛠️" },
{ "Docker", "🐳" },
{ "Project", "📁" },
{ "Log", "📋" },
{ "Configuration", "⚙️" },
{ "Monitoring", "📊" },
{ "Success", "✅" },
{ "Error", "❌" },
{ "Warning", "⚠️" },
{ "Info", "ℹ️" }
};
public static string GetIcon(string serviceName)
{
return ServiceIcons.TryGetValue(serviceName, out var icon) ? icon : "🔧";
}
public static TextBlock CreateIconTextBlock(string serviceName, double fontSize = 16)
{
return new TextBlock
{
Text = GetIcon(serviceName),
FontSize = fontSize,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(0, 0, 5, 0)
};
}
public static void UpdateButtonWithIcon(Button button, string serviceName, string text)
{
var stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Center
};
var icon = CreateIconTextBlock(serviceName, 14);
var textBlock = new TextBlock
{
Text = text,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(5, 0, 0, 0)
};
stackPanel.Children.Add(icon);
stackPanel.Children.Add(textBlock);
button.Content = stackPanel;
}
public static Grid CreateServiceIndicator(string serviceName, bool isRunning)
{
var grid = new Grid();
var ellipse = new System.Windows.Shapes.Ellipse
{
Width = 12,
Height = 12,
Fill = isRunning ? Brushes.LimeGreen : Brushes.Red,
Margin = new Thickness(0, 0, 5, 0)
};
var icon = CreateIconTextBlock(serviceName, 12);
icon.Margin = new Thickness(0, -2, 0, 0);
grid.Children.Add(ellipse);
grid.Children.Add(icon);
return grid;
}
}
}