private void fStats_FormClosed(object sender, FormClosedEventArgs e) { formTooltipStats old_window = sender as formTooltipStats; if (old_window != null && this.stat_windows.ContainsValue(old_window)) this.stat_windows.Remove(this.stat_windows.FirstOrDefault(item => item.Value == old_window).Key); return; }
private void itmShowStats_CheckedChanged(object sender, EventArgs e) { if(this.last_champ_name == null) return; if (this.itmShowStats.Checked) { if (!this.stat_windows.ContainsKey(this.last_champ_name)) { formTooltipStats last_window = null; formTooltipStats fStats = new formTooltipStats(); if(this.stat_windows.Count<1) fStats.Location = new Point(this.fTooltip.Left, this.fTooltip.Bottom + 10); else { last_window = this.stat_windows[this.stat_windows.Keys.ToArray()[this.stat_windows.Keys.Count - 1]]; Point location = new Point(last_window.Left, last_window.Bottom + 10); bool on_screen = false; foreach (Screen screen in Screen.AllScreens) { if (screen.WorkingArea.Contains(new Rectangle(location, fStats.Size))) { on_screen = true; break; } } if(!on_screen) location = new Point(this.Left + 50, this.Top + 50); fStats.Location = location; } fStats.FormClosed += this.fStats_FormClosed; fStats.GridSelectionChanged += this.fStats_GridSelectionChanged; fStats.GridScrolled += this.fStats_GridScrolled; fStats.ShowTooltip(this.champions[this.last_champ_name].Name, "Stats", this.champions[this.last_champ_name], this); if (last_window != null) { fStats.Selections = last_window.Selections; fStats.ScrollIndex = last_window.ScrollIndex; } this.stat_windows.Add(this.last_champ_name, fStats); } } else if(this.stat_windows.ContainsKey(this.last_champ_name)) { this.stat_windows[this.last_champ_name].Close(); } return; }