public MainForm() { // bring up the UI InitializeComponent(); // Check for settings updates. if (Settings.Default.UpdateRequired) { Settings.Default.Upgrade(); Settings.Default.UpdateRequired = false; Settings.Default.Save(); // open up changelog if (Settings.Default.OpenChangelog && !DEBUG) { Process.Start("https://github.com/Myll/Dota-2-ModKit/releases"); } } // setup hooks FormClosing += MainForm_FormClosing; tabControl.Selected += TabControl_Selected; githubTextBox.KeyDown += GithubTextBox_KeyDown; tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; // check for updates updater = new Updater(this); updater.checkForUpdates(); // allow public accessibility to these AddonTile = addonTile; ProgressSpinner1 = progressSpinner1; SpellLibBtn = spellLibraryBtn; MetroToolTip1 = metroToolTip1; GameTile = gameTile; ContentTile = contentTile; FindSoundNameBtn = findSoundNameBtn; // init mainform controls stuff Size size = new Size(steamTile.Width, steamTile.Height); steamTile.TileImage = (Image)new Bitmap(Resources.steam_icon, size); luaRadioBtn.Checked = true; tabControl.SelectedIndex = 0; notificationLabel.Text = ""; versionLabel.Text = "v" + version; retrieveDotaDir(); // at this point assume valid dota dir. Debug.WriteLine("Directory: " + dotaDir); // save the dota dir Settings.Default.DotaDir = dotaDir; gamePath = Path.Combine(dotaDir, "game", "dota_addons"); contentPath = Path.Combine(dotaDir, "content", "dota_addons"); // create these dirs if they don't exist. if (!Directory.Exists(gamePath)) { Directory.CreateDirectory(gamePath); } if (!Directory.Exists(contentPath)) { Directory.CreateDirectory(contentPath); } // get all the addons in the 'game' dir. addons = getAddons(); // does this computer have any dota addons? if (addons.Count == 0) { MetroMessageBox.Show(this, "No Dota 2 addons detected. There must be one addon for D2ModKit to function properly. Exiting.", "No Dota 2 addons detected.", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } // some functions in the Tick try and use mainform's controls on another thread. so we need to allot a very small amount of time for // mainform to init its controls. this is mainly for the very first run of modkit. Timer initTimer = new Timer(); initTimer.Interval = 100; initTimer.Tick += InitTimer_Tick; initTimer.Start(); }
private void SeasonTileClicked(object sender, EventArgs e) { var clicked = (MetroTile)sender; panelEpisodes.Controls.Clear(); panelEpisodes.Refresh(); var episodeList = new SortedList<int, MetroTile>(); foreach (var ep in _dataSource.Seasons.First(s => s.SeasonNumber == int.Parse(clicked.Text)).Episodes) { var tooltip = new MetroToolTip(); var episodeTile = new MetroTile() { Text = ep.EpisodeNumber.ToString(), StyleManager = StyleManager, Size = new Size(30, 30), TextAlign = ContentAlignment.MiddleCenter }; if (!string.IsNullOrEmpty(ep.AirDate)) { tooltip.SetToolTip(episodeTile, "Airdate : " + ep.AirDate); } episodeList.Add(ep.EpisodeNumber, episodeTile); } foreach (var item in episodeList) { panelEpisodes.Controls.Add(item.Value); } }