This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.xaml.cs
129 lines (113 loc) · 5.13 KB
/
Setup.xaml.cs
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MapleRIL
{
/// <summary>
/// Interaction logic for Setup.xaml
/// </summary>
public partial class Setup : Window
{
public Setup()
{
InitializeComponent();
loadRegions();
}
public string[] Regions = new string[] { "GMS", "KMS", "MSEA" };
private void loadRegions()
{
foreach (string r in Regions)
{
sourceRegionBox.Items.Add(r);
targetRegionBox.Items.Add(r);
}
if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.sourceFolder))
{
sourceRegionBox.Text = Properties.Settings.Default.sourceRegion;
targetRegionBox.Text = Properties.Settings.Default.targetRegion;
sourceLabel.Content = "OK";
sourceLabel.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
targetLabel.Content = "OK";
targetLabel.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
else
{
sourceRegionBox.Text = "GMS";
targetRegionBox.Text = "KMS";
}
}
private void sourceButton_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.sourceFolder = getFolder();
sourceLabel.Content = "OK";
sourceLabel.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
private void targetButton_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.targetFolder = getFolder();
targetLabel.Content = "OK";
targetLabel.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
private string getFolder()
{
string folder = "";
using (var fbd = new System.Windows.Forms.FolderBrowserDialog())
{
while (String.IsNullOrWhiteSpace(folder))
{
System.Windows.Forms.DialogResult res = fbd.ShowDialog();
if (res == System.Windows.Forms.DialogResult.OK && !String.IsNullOrWhiteSpace(fbd.SelectedPath))
{
if (!File.Exists(Path.Combine(fbd.SelectedPath, "Item.wz")))
MessageBox.Show("This directory does not seem like a MapleStory directory. Please choose a valid path. (if you are using Nexon Launcher, make sure you select the 'appdata' path, not just the 'maplestory' path.)", "MapleRIL - Invalid Path", MessageBoxButton.OK, MessageBoxImage.Error);
else
folder = fbd.SelectedPath;
}
else
{
MessageBox.Show("Please select a folder.", "MapleRIL - Invalid Selection", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
return folder;
}
private void doneButton_Click(object sender, RoutedEventArgs e)
{
if (String.IsNullOrWhiteSpace(Properties.Settings.Default.sourceFolder)
|| String.IsNullOrWhiteSpace(Properties.Settings.Default.targetFolder))
{
MessageBox.Show("You need to select a source and target folder.", "MapleRIL - Invalid Selection", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (sourceRegionBox.Text == targetRegionBox.Text)
{
MessageBox.Show("The source region and target region is the same... are you sure you know what this tool is for...", "MapleRIL - Invalid Selection", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
Properties.Settings.Default.sourceRegion = sourceRegionBox.Text;
Properties.Settings.Default.targetRegion = targetRegionBox.Text;
Properties.Settings.Default.Save();
MessageBox.Show("Setup complete. If at any time you need to return to this setup menu, simply click the MapleRIL \"logo\" on the main search window. Thanks for using and welcome to MapleRIL!", "MapleRIL - Setup Complete", MessageBoxButton.OK, MessageBoxImage.Information);
Close();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.sourceFolder))
return; // this is only intended for first time setups
e.Cancel = true;
MessageBoxResult mbr = MessageBox.Show("If you close setup now, you will not be able to use MapleRIL. Still close?", "Warning", MessageBoxButton.YesNo);
if (mbr == MessageBoxResult.Yes)
Environment.Exit(0);
}
}
}