public FirstTimeWizard(INgrokManager ngrokManager) { InitializeComponent(); foreach (var tabItem in tabcl.Items) { ((TabItem)tabItem).IsEnabled = false; } comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Usa", Flag = "/Assets/Locations/icons8-usa-48.png", Region = NgrokManager.Region.UnitedStates }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Germany", Flag = "/Assets/Locations/icons8-germany-48.png", Region = NgrokManager.Region.Europe }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Singapore", Flag = "/Assets/Locations/icons8-singapore-48.png", Region = NgrokManager.Region.AsiaPacific }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Australia", Flag = "/Assets/Locations/icons8-australia-48.png", Region = NgrokManager.Region.Australia }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Brazil", Flag = "/Assets/Locations/icons8-brazil-48.png", Region = NgrokManager.Region.SouthAmerica }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "Japan", Flag = "/Assets/Locations/icons8-japan-48.png", Region = NgrokManager.Region.Japan }); comboBoxTunnelDataTemplates.Add(new ComboBoxTunnelDataTemplate() { Country = "India", Flag = "/Assets/Locations/icons8-india-48.png", Region = NgrokManager.Region.India }); cmbTunnelExit.ItemsSource = comboBoxTunnelDataTemplates; cmbTunnelExit.SelectedIndex = 0; _ngrokManager = ngrokManager; _ngrokManager.DownloadAndUnZipDone += _ngrokManager_DownloadAndUnZipDone; }
public MainWindow() { InitializeComponent(); _tunnelDescriptions = new ObservableCollection <TunnelDescription>(); DataContext = _tunnelDescriptions; _ngrokManager = new NgrokManager(); Settings settings; try { //Load settings settings = JsonConvert.DeserializeObject <Settings>(File.ReadAllText("Settings.json")); if (settings.FirstTimeSetupDone == false) { var firstTimeWizard = new FirstTimeWizard(_ngrokManager); firstTimeWizard.ShowDialog(); if (firstTimeWizard.DialogResult == true) { settings.FirstTimeSetupDone = true; settings.DataCenterRegion = firstTimeWizard.cmbTunnelExit.SelectedIndex; File.WriteAllText("Settings.json", JsonConvert.SerializeObject(settings)); } } _ngrokManager.StartNgrok((NgrokManager.Region)settings.DataCenterRegion); } catch (Exception e) { MessageBox.Show($"Something went wrong while loading the settings: {e}"); Close(); } }