BetterDiscordApp-rauenzi/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2015-12-04 02:17:37 +01:00
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace BetterDiscordWI.panels
{
public partial class Panel1 : UserControl, IPanel
{
public Panel1()
{
InitializeComponent();
}
public void SetVisible()
{
GetParent().btnBack.Visible = true;
GetParent().btnNext.Enabled = true;
GetParent().btnBack.Enabled = true;
GetParent().btnNext.Text = "Install";
GetParent().lblPanelTitle.Text = "BetterDiscord Installation";
String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Discord");
String highestVersion = null;
foreach(String s in directories)
{
Debug.Print(s);
2015-12-18 17:00:52 +01:00
if (!s.Contains("app-")) continue;
if (highestVersion == null)
2015-12-04 02:17:37 +01:00
{
2015-12-18 17:00:52 +01:00
highestVersion = s;
continue;
}
2015-12-04 02:17:37 +01:00
2015-12-18 17:00:52 +01:00
if (String.CompareOrdinal(s, highestVersion) > 0)
{
highestVersion = s;
2015-12-04 02:17:37 +01:00
}
}
tbPath.Text = highestVersion;
}
public FormMain GetParent()
{
return (FormMain) ParentForm;
}
public void BtnNext()
{
GetParent().DiscordPath = tbPath.Text;
2015-12-18 17:00:52 +01:00
GetParent().RestartDiscord = cbRestart.Checked;
2015-12-04 02:17:37 +01:00
GetParent().SwitchPanel(2);
}
public void BtnPrev()
{
GetParent().SwitchPanel(0);
}
private void btnBrowser_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog {SelectedPath = tbPath.Text};
fbd.ShowDialog(GetParent());
tbPath.Text = fbd.SelectedPath;
}
}
}