private void validate_Click(object sender, EventArgs e) { ComponentResourceManager res = new ComponentResourceManager(typeof(Form1)); if (!unlocked.CanChangeScore) { EditValue edit = new EditValue(res.GetString("password"), true); if (edit.ShowDialog() == DialogResult.OK) { unlocked = CurrentProject.MatchPassword(edit.ValueReturn); if (!unlocked.CanChangeScore) { MessageBox.Show(res.GetString("error.WrongPassword"), res.GetString("error.WPC"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { UpdateRibbonMenu(); validate.Text = res.GetString("lock"); } } edit.Dispose(); } else { unlocked = MatchResult.Locked; UpdateRibbonMenu(); validate.Text = res.GetString("validate.Text"); } }
private void Add_Click(object sender, EventArgs e) { ComponentResourceManager res = new ComponentResourceManager(typeof(GroupForm)); EditValue dialog = new EditValue(res.GetString("personName")) { CheckEmpty = true }; void show() { if (dialog.ShowDialog() == DialogResult.OK) { foreach (ListViewItem item in memberList.Items) { if (item.Text == dialog.ValueReturn) { MessageBox.Show(res.GetString("error.MemberExist"), res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); show(); return; } } memberList.Items.Add(dialog.ValueReturn); } dialog.Dispose(); } show(); }
private void importItem_Click(object sender, EventArgs e) { var dialog = NewOpenSMPDialog(); if (dialog.ShowDialog() == DialogResult.OK) { try { Project project = Open(dialog.FileName); var res = new ComponentResourceManager(typeof(Form1)); void doImport() { var import = new ImportForm(project, CurrentProject); import.ShowDialog(); import.Dispose(); } if (project.Encryted) { var edit = new EditValue(res.GetString("password.Chief"), true); if (edit.ShowDialog() == DialogResult.OK) { if (project.MatchPassword(edit.ValueReturn).CanChangeMember) { doImport(); } else { MessageBox.Show(res.GetString("error.WrongPassword"), res.GetString("error.WPC"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } edit.Dispose(); } else { doImport(); } } catch (Exception exception) { ShowErrorWhileReading(exception); } finally { CurrentProject.CanBeSaved = true; UpdateGroupView(); UpdateRibbonMenu(true); DrawCharts(); } } dialog.Dispose(); }
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); } } } }
private void scurityButton_Click(object sender, EventArgs e) { void switchPanel() { securityPanel.Visible = !securityPanel.Visible; Timer timer = new Timer { Interval = 5 }; securityButton.Enabled = false; if (securityPanel.Visible) { int oldHeight = Height; int oldY = confirm.Location.Y; timer.Tick += (s, ea) => { Height += 10; if (Height - oldHeight >= securityPanel.Height) { timer.Stop(); timer.Dispose(); securityButton.Enabled = true; Height = oldHeight + securityPanel.Height; } }; } else { int oldHeight = Height; int oldY = confirm.Location.Y; timer.Tick += (s, ea) => { Height -= 10; if (oldHeight - Height >= securityPanel.Height) { timer.Stop(); timer.Dispose(); securityButton.Enabled = true; Height = oldHeight - securityPanel.Height; } }; } timer.Enabled = true; timer.Start(); } if (AddMode) { switchPanel(); } else { if (!securityPanel.Visible && ReturnValue.Encryted) { ComponentResourceManager res = new ComponentResourceManager(typeof(ProjectForm)); EditValue edit = new EditValue(res.GetString("password"), true); if (edit.ShowDialog() == DialogResult.OK) { if (ReturnValue.MatchPassword(edit.ValueReturn).Permission == Permission.ChiefAdmin) { switchPanel(); } else { MessageBox.Show(res.GetString("error.Password"), res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } edit.Dispose(); } else { switchPanel(); } } }