Ejemplo n.º 1
0
 private void confirm_Click(object sender, EventArgs e)
 {
     DialogResult = DialogResult.OK;
     if (AddMode)
     {
         ValueReturn = new Scoreboard.Scoreboard(nameBox.Text, (ScoreboardType)typeBox.SelectedIndex, overflowCheckbox.Checked);
     }
     else
     {
         ValueReturn.Name     = nameBox.Text;
         ValueReturn.Overflow = overflowCheckbox.Checked;
         ValueReturn.Type     = (ScoreboardType)typeBox.SelectedIndex;
     }
     Close();
 }
Ejemplo n.º 2
0
        public ScoreboardForm(Scoreboard.Scoreboard info, Form1 parent)
        {
            InitializeComponent();
            ComponentResourceManager res = Utility.ApplySource(this);

            if (info.Name != "")
            {
                Text = info.Name;
            }
            Info = info;

            parent.ProjectOpen += Draw;
            LocationChanged    += ScoreboardForm_LocationChanged;
            ResizeEnd          += ScoreboardForm_ResizeEnd;
            StartPosition       = FormStartPosition.Manual;
            Size          = info.Size;
            ShowInTaskbar = false;

            Draw(parent.CurrentProject);

            ContextMenu = new ContextMenu();
            ContextMenu.MenuItems.Add(res.GetString("properties"), (e, g) =>
            {
                ScoreboardConfigForm configForm = new ScoreboardConfigForm(Info);
                switch (configForm.ShowDialog())
                {
                case DialogResult.OK:
                    Draw(LastProject);
                    break;

                case DialogResult.Abort:
                    Info.Removed        = true;
                    parent.ProjectOpen -= Draw;
                    LocationChanged    -= ScoreboardForm_LocationChanged;
                    ResizeEnd          -= ScoreboardForm_ResizeEnd;
                    if (LastDrawEvent != null)
                    {
                        parent.CurrentProject.OperationHeaderChanged -= LastDrawEvent;
                    }
                    Close();
                    break;
                }
                configForm.Dispose();
            });
        }
Ejemplo n.º 3
0
        public ScoreboardConfigForm(Scoreboard.Scoreboard scoreboard)
        {
            InitializeComponent();
            ValueReturn = scoreboard;

            ComponentResourceManager res = Utility.ApplySource(this);

            foreach (string name in Enum.GetNames(typeof(ScoreboardType)))
            {
                typeBox.Items.Add(res.GetString("type." + name));
            }

            typeBox.SelectedIndex    = (int)scoreboard.Type;
            nameBox.Text             = scoreboard.Name;
            overflowCheckbox.Checked = scoreboard.Overflow;
            AddMode = false;

            TopMost        = scoreboard.Overflow;
            delete.Visible = true;
        }
Ejemplo n.º 4
0
        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);
                    }
                }
            }
        }