-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
64 lines (59 loc) · 2.38 KB
/
MainWindow.xaml.cs
File metadata and controls
64 lines (59 loc) · 2.38 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
using System.Text;
using System.Windows;
namespace TemplateGenerator
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
StringBuilder howToInfo = new();
howToInfo.AppendLine("How to use:");
howToInfo.AppendLine("- Fill in the template field with the text you want to have a replaced something in with the different strings.");
howToInfo.AppendLine("Use §§§ the places where you want the strings to be placed, you can have as many as you need.");
howToInfo.AppendLine();
howToInfo.AppendLine("- Fill in the items list with the strings you want to have replaced in the template.");
howToInfo.Append("Use , to seperate the string you want to use.");
HowToUseInfo.Text = howToInfo.ToString();
}
private void GenerateButton_OnClick(object sender, RoutedEventArgs e)
{
if (!ItemsBox.Text.Contains(','))
{
MessageBox.Show("Please make sure there is a , in the items list.");
}
else if (!ItemsBox.Text.Trim().Trim(',').Contains(','))
{
MessageBox.Show("Dont just add , and hope that something magic will happen.");
}
else if (!TemplateBox.Text.Contains("§§§"))
{
MessageBox.Show("Please make sure there is §§§ in the template.");
}
else
{
GenerateButton.IsEnabled = false;
TemplateBox.IsReadOnly = true;
ItemsBox.IsReadOnly = true;
// §§§
StringBuilder newText = new();
foreach (string s in ItemsBox.Text.Trim().Trim(',').Split(','))
{
newText.AppendLine(TemplateBox.Text.Replace("§§§", s.Trim()));
newText.AppendLine();
}
ResultDialog dialog = new ResultDialog(newText.ToString());
dialog.Show();
dialog.Closed += (o, args) =>
{
GenerateButton.IsEnabled = true;
TemplateBox.IsReadOnly = false;
ItemsBox.IsReadOnly = false;
};
}
}
}
}