public Form1() { Settings.Default.Language = Settings.Default.Language ?? Thread.CurrentThread.CurrentCulture.Name; Icon = Resources.AppIcon; InitializeComponent(); Relayout(); //FormBorderStyle = FormBorderStyle.None; ComponentResourceManager res = new ComponentResourceManager(typeof(Form1)); notifyIcon.Text = res.GetString("this.Text"); notifyIcon.Icon = Resources.AppIcon; notifyIcon.ContextMenu = new ContextMenu(); notifyIcon.ContextMenu.MenuItems.Add(res.GetString("exit"), (e, a) => { Application.Exit(); }); FormClosed += (sender, e) => { if (Settings.Default.Scoreboards != null) { Settings.Default.Scoreboards.Clear(); scoreboards.ForEach((it) => { if (!it.Removed) { Settings.Default.Scoreboards.Add(it.ToString()); } }); } Settings.Default.Save(); }; listView.ItemSelectionChanged += (sender, e) => { recordScore.Enabled = unlocked.CanChangeScore && listView.SelectedItems.Count > 0; UpdatePropertiesButtons(); DrawCharts(); }; adminBox.DropDownItemClicked += (sender, e) => { int oldIndex = adminBox.Tag != null ? (int)adminBox.Tag : adminBox.DropDownItems.Count - 1; adminBox.Tag = adminBox.SelectedIndex; if (adminBox.SelectedIndex < adminBox.DropDownItems.Count - 1) { bool isAdmin = adminBox.SelectedIndex == 0; DailyAdmin target = !isAdmin ? CurrentProject.TodaysAdmins[adminBox.SelectedIndex - 1] : null; EditValue edit = new EditValue(isAdmin ? res.GetString("password.Chief") : res.GetString("password.Speciafic").Replace("%s", target.Name), true); if (edit.ShowDialog() == DialogResult.OK) { MatchResult result = CurrentProject.MatchPassword(edit.ValueReturn); void showError() { MessageBox.Show(res.GetString("error.WrongPassword"), res.GetString("validate.Text"), MessageBoxButtons.OK, MessageBoxIcon.Error); adminBox.SelectedIndex = oldIndex; } if (isAdmin) { if (result.Permission == Permission.ChiefAdmin) { unlocked = MatchResult.ChiefAdmin; UpdateRibbonMenu(); } else { showError(); } } else { if (result.Permission == Permission.DailyAdmin && result.Admin.Equals(target)) { unlocked = result; UpdateRibbonMenu(); } else { showError(); } } } else { adminBox.SelectedIndex = oldIndex; } edit.Dispose(); } else { unlocked = MatchResult.Locked; UpdateRibbonMenu(); } }; if (Settings.Default.Scoreboards != null) { foreach (string json in Settings.Default.Scoreboards) { try { Scoreboard.Scoreboard scoreboard = Scoreboard.Scoreboard.Deserialize(json); scoreboards.Add(scoreboard); scoreboard.NewForm(this).Show(); } catch (Exception e) { MessageBox.Show(e.GetType().FullName + ": " + e.Message, res.GetString("error.LoadScoreboard"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }