Exemple #1
0
        // populate the fields
        void populateControls()
        {
            // set datasources
            cbxPaddingHoriz.DataSource = Enum.GetNames(typeof(OutputConfiguration.PaddingRemoval));
            cbxPaddingVert.DataSource  = Enum.GetNames(typeof(OutputConfiguration.PaddingRemoval));
            cbxCommentStyle.DataSource = Enum.GetNames(typeof(OutputConfiguration.CommentStyle));
            cbxBitLayout.DataSource    = Enum.GetNames(typeof(OutputConfiguration.BitLayout));
            cbxByteFormat.DataSource   = Enum.GetNames(typeof(OutputConfiguration.ByteFormat));
            cbxRotation.DataSource     = OutputConfiguration.Rotation.GetNames();

            // display string arrays
            cbxCharWidthFormat.Items.AddRange(OutputConfiguration.DescriptorFormatDisplayString);
            cbxCharHeightFormat.Items.AddRange(OutputConfiguration.DescriptorFormatDisplayString);
            cbxFontHeightFormat.Items.AddRange(OutputConfiguration.DescriptorFormatDisplayString);
            cbxImgWidthFormat.Items.AddRange(OutputConfiguration.DescriptorFormatDisplayString);
            cbxImgHeightFormat.Items.AddRange(OutputConfiguration.DescriptorFormatDisplayString);

            cbxCharacterEncoding.Items.AddRange(CodePageInfo.GetEncoderNameList());

            // add leading
            cbxByteLeadingChar.Items.Add(OutputConfiguration.ByteLeadingStringBinary);
            cbxByteLeadingChar.Items.Add(OutputConfiguration.ByteLeadingStringHex);

            txtBmpVisualizerChar.Items.AddRange(OutputConfiguration.CommentVisualizerChar);

            // re-populate dropdown
            m_outputConfigurationManager.comboBoxPopulate(cbxOutputConfigurations);
        }
        // populate preformatted text
        private void populateTextInsertCheckbox()
        {
            string allEnglish = "", numbers = "", letters = "", uppercaseLetters = "", lowercaseLetters = "", symbols = "";

            // generate characters
            for (char character = ' '; character < 127; ++character)
            {
                // add to all
                allEnglish += character;

                // classify letter
                if (Char.IsNumber(character))
                {
                    numbers += character;
                }
                else if (Char.IsSymbol(character))
                {
                    symbols += character;
                }
                else if (Char.IsLetter(character) && Char.IsLower(character))
                {
                    letters += character; lowercaseLetters += character;
                }
                else if (Char.IsLetter(character) && !Char.IsLower(character))
                {
                    letters += character; uppercaseLetters += character;
                }
            }

            string allEuropean = allEnglish, extraPunctuations = "", extraSymbols = "", extraNumbers = "";

            for (char character = (char)129; character <= 255; ++character)
            {
                if (Char.IsLetter(character))
                {
                    allEuropean += character;
                }
                if (Char.IsPunctuation(character))
                {
                    extraPunctuations += character;
                }
                if (Char.IsSymbol(character))
                {
                    extraSymbols += character;
                }
                if (Char.IsNumber(character))
                {
                    extraNumbers += character;
                }
            }

            // add items
            cbxTextInsert.Items.Add(new ComboBoxItem("All European", allEuropean));
            cbxTextInsert.Items.Add(new ComboBoxItem("All English(ASCCI)", allEnglish));
            cbxTextInsert.Items.Add(new ComboBoxItem("Numbers (0-9)", numbers));
            cbxTextInsert.Items.Add(new ComboBoxItem("Letters (A-z)", letters));
            cbxTextInsert.Items.Add(new ComboBoxItem("Lowercase letters (a-z)", lowercaseLetters));
            cbxTextInsert.Items.Add(new ComboBoxItem("Uppercase letters (A-Z)", uppercaseLetters));
            cbxTextInsert.Items.Add(new ComboBoxItem("Extra Punctuations", extraPunctuations));
            cbxTextInsert.Items.Add(new ComboBoxItem("Extra Symbols", extraSymbols));
            cbxTextInsert.Items.Add(new ComboBoxItem("Extra Numbers", extraNumbers));

            foreach (string s in CodePageInfo.GetEncoderNameList())
            {
                if (s.ToLower() != "us-ascii"
                    //&& s.ToLower() != "utf-16"
                    )
                {
                    cbxTextInsert.Items.Add(new ComboBoxItem(s, new string(new CodePageInfo(s).GetAllValidCharacter())));
                }
            }

            // select the first
            cbxTextInsert.SelectedIndex = 0;
        }