Пример #1
0
        /// <summary>
        /// Get user choice and save to fontSettings
        /// </summary>
        /// <returns>if validation failured return false</returns>
        private bool getSettings()
        {
            if (fontSettings != null)
            {
                fontSettings.Dispose();
                vScrollBar1.Value = 0;
            }

            try
            {
                fontSettings = new FontSettings();
                fontSettings.SetForeColor(textBoxForecolor.Text);
                fontSettings.SetBackColor(textBoxBackgroundColor.Text);

                FontStyle fntStyle = radioButton1.Checked ? FontStyle.Regular :
                                     radioButton2.Checked ? FontStyle.Italic :
                                     radioButton3.Checked ? FontStyle.Bold : FontStyle.Bold | FontStyle.Italic;
                fontSettings.SetFont(listBoxSystemFont.SelectedItem, fntStyle, listBoxSize.SelectedItem);

                fontSettings.RenderingHint = radioButton5.Checked ? System.Drawing.Text.TextRenderingHint.SingleBitPerPixel :
                                             radioButton6.Checked ? System.Drawing.Text.TextRenderingHint.AntiAliasGridFit :
                                             radioButton7.Checked ? System.Drawing.Text.TextRenderingHint.ClearTypeGridFit :
                                             System.Drawing.Text.TextRenderingHint.SystemDefault;

                fontSettings.TextFormatFlags = ButtonAlignChecked == button1 ? TextFormatFlags.Left | TextFormatFlags.Top :
                                               ButtonAlignChecked == button2 ? TextFormatFlags.HorizontalCenter | TextFormatFlags.Top :
                                               ButtonAlignChecked == button3 ? TextFormatFlags.Right | TextFormatFlags.Top :
                                               ButtonAlignChecked == button4 ? TextFormatFlags.Left | TextFormatFlags.VerticalCenter :
                                               ButtonAlignChecked == button6 ? TextFormatFlags.Right | TextFormatFlags.VerticalCenter :
                                               ButtonAlignChecked == button7 ? TextFormatFlags.Left | TextFormatFlags.Bottom :
                                               ButtonAlignChecked == button8 ? TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom :
                                               ButtonAlignChecked == button9 ? TextFormatFlags.Right | TextFormatFlags.Bottom :
                                               TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter;

                fontSettings.SetBlockSize(numericUpDownBlockWidth.Value, numericUpDownBlockHeight.Value);
                fontSettings.SetOffset(numericUpDownOffsetX.Value, numericUpDownOffsetY.Value);
                fontSettings.gs_threashold = Convert.ToInt16(numericUpDownThreshold.Value);

                fontSettings.Chars = richTextBoxCharInput.Text;
                fontSettings.processChars(checkBoxIgnoreNewLine.Checked, checkBoxInsertNewLine.Checked,
                                          checkBoxSortChars.Checked, checkBoxFilterChars.Checked);

                // clear zoom image
                if (pictureBoxZoom.Image != null)
                {
                    pictureBoxZoom.Image.Dispose();
                    pictureBoxZoom.Image = null;
                    pictureBoxZoom.Refresh();
                    labelCurrent.Text = "";
                }
            }
            catch (Exception ex)
            {
                Misc.MsgErr(ex.Message);
                return(false);
            }

            return(true);
        }