Пример #1
0
        private void OnButtonApplyClick(object sender, EventArgs e)
        {
            string    name        = _textBoxName.Text;
            ChessFont font        = (ChessFont)_chessFonts[_listBoxSettings.SelectedIndex];
            bool      nameChanged = name != font.Name;

            if (nameChanged && _listBoxSettings.Items.Contains(name))
            {
                MessageBox.Show(this, "Setting with this name already exists.", "Zentropy", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (double.TryParse(_textBoxScaleFactor.Text, out double factor))
            {
                font.SizeFactor = factor;
            }

            if (_listBoxSettings.SelectedIndex != 0)
            {
                if (nameChanged)
                {
                    font.Name = name;
                    UpdateList(_listBoxSettings.SelectedIndex);
                }

                font.IsUnicode       = _checkBoxUnicodeFont.Checked;
                font.FontFamily      = _comboBoxSelectFont.Text;
                font.PieceCharacters = _textBoxFontChars.Text;
            }
            FontSelected?.Invoke();
            _applied = true;
        }
Пример #2
0
        private void OnButtonAddNewClick(object sender, EventArgs e)
        {
            ChessFont newFont = new ChessFont();

            string name = _textBoxName.Text;

            bool warn = false;

            while (_listBoxSettings.Items.Contains(name))
            {
                if (warn)
                {
                    MessageBox.Show(this, "Setting with this name already exists.", "Zentropy", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    warn = true;
                }

                string input = Interaction.InputBox("Enter new name for setting:", "Zentropy - Setting name");

                if (string.IsNullOrWhiteSpace(input))
                {
                    return;
                }
                else
                {
                    name = input;
                }
            }

            if (double.TryParse(_textBoxScaleFactor.Text, out double factor))
            {
                newFont.SizeFactor = factor;
            }
            else
            {
                newFont.SizeFactor = 1;
            }

            newFont.Name            = name;
            newFont.IsUnicode       = _checkBoxUnicodeFont.Checked;
            newFont.FontFamily      = _comboBoxSelectFont.Text;
            newFont.PieceCharacters = _textBoxFontChars.Text;

            SerializedInfo.Instance.ChessFonts.Add(newFont);
            SerializedInfo.Instance.SelectedFontIndex = SerializedInfo.Instance.ChessFonts.Count - 1;

            _listBoxSettings.Items.Add(newFont.Name);
            _listBoxSettings.SelectedIndex = _listBoxSettings.Items.Count - 1;

            FontSelected?.Invoke();
        }
Пример #3
0
        private void OpenFontConfig(int index)
        {
            if (index < 0)
            {
                index = 0;
            }

            bool notDefault = index > 4;

            _textBoxName.Enabled  = notDefault;
            _buttonRemove.Enabled = notDefault;

            ChessFont font = (ChessFont)_chessFonts[index];

            _textBoxName.Text            = font.Name;
            _textBoxScaleFactor.Text     = font.SizeFactor.ToString();
            _textBoxFontChars.Text       = font.PieceCharacters;
            _checkBoxUnicodeFont.Checked = font.IsUnicode;
            _comboBoxSelectFont.Text     = font.FontFamily;

            SerializedInfo.Instance.SelectedFontIndex = index;
            FontSelected?.Invoke();
        }