// output configuration to form void loadOutputConfigurationToForm(OutputConfiguration outputConfig) { // set flag m_loadingOutputConfigurationToForm = true; // load combo boxes cbxPaddingHoriz.SelectedIndex = (int)outputConfig.paddingRemovalHorizontal; cbxPaddingVert.SelectedIndex = (int)outputConfig.paddingRemovalVertical; cbxCommentStyle.SelectedIndex = (int)outputConfig.commentStyle; cbxBitLayout.SelectedIndex = (int)outputConfig.bitLayout; cbxByteOrderMsbFirst.Checked = outputConfig.byteOrderMsbFirst; cbxByteFormat.SelectedIndex = (int)outputConfig.byteFormat; cbxRotation.SelectedIndex = (int)outputConfig.rotation; cbxCharWidthFormat.SelectedIndex = (int)outputConfig.descCharWidth; cbxCharHeightFormat.SelectedIndex = (int)outputConfig.descCharHeight; cbxFontHeightFormat.SelectedIndex = (int)outputConfig.descFontHeight; cbxImgWidthFormat.SelectedIndex = (int)outputConfig.descImgWidth; cbxImgHeightFormat.SelectedIndex = (int)outputConfig.descImgHeight; // text boxes cbxByteLeadingChar.Text = outputConfig.byteLeadingString; txtSpacePixels.Text = outputConfig.spaceGenerationPixels.ToString(); txtLookupBlocksNewAfterCharCount.Text = outputConfig.lookupBlocksNewAfterCharCount.ToString(); cbxOutputConfigurations.Text = outputConfig.displayName; txtVarNfFontBitmaps.Text = outputConfig.varNfBitmaps; txtVarNfCharInfo.Text = outputConfig.varNfCharInfo; txtVarNfFontInfo.Text = outputConfig.varNfFontInfo; txtVarNfImageBitmap.Text = outputConfig.varNfImageBitmap; txtVarNfImageInfo.Text = outputConfig.varNfImageInfo; // load check boxes cbxFlipHoriz.Checked = outputConfig.flipHorizontal; cbxFlipVert.Checked = outputConfig.flipVertical; cbxCommentVarName.Checked = outputConfig.addCommentVariableName; cbxCommentCharVisual.Checked = outputConfig.addCommentCharVisualizer; cbxCommentCharDesc.Checked = outputConfig.addCommentCharDescriptor; cbxGenerateSpaceBitmap.Checked = outputConfig.generateSpaceCharacterBitmap; cbxGenerateLookupArray.Checked = outputConfig.generateLookupArray; txtBmpVisualizerChar.Text = "" + outputConfig.bmpVisualizerChar + outputConfig.bmpVisualizerCharEmpty; cbxGenerateLookupBlocks.Checked = outputConfig.generateLookupBlocks; cbxCharacterEncoding.Text = CodePageInfo.GetCodepageName(outputConfig.CodePage); cbxAddCodePage.Checked = outputConfig.addCodePage; // radio buttons // -- wrap rbnLineWrapAtColumn.Checked = (outputConfig.lineWrap == OutputConfiguration.LineWrap.AtColumn); rbnLineWrapAtBitmap.Checked = !rbnLineWrapAtColumn.Checked; // clear flag m_loadingOutputConfigurationToForm = false; }
// generate the strings private void GenerateStringsFromFontInfo() { StringBuilder sourceText = new StringBuilder(); StringBuilder headerText = new StringBuilder(); if (OutConfig.addCommentVariableName) { // add source file header sourceText.AppendFormat("{0}" + OutConfig.nl + "{1} Font data for {2}" + OutConfig.nl + "{3}" + OutConfig.nl + OutConfig.nl, OutConfig.CommentStart, OutConfig.CommentBlockMiddle, getFontName(Font, false), OutConfig.CommentBlockEnd); // add source header sourceText.AppendFormat("{0}Character bitmaps for {1} {2}" + OutConfig.nl, OutConfig.CommentStart, getFontName(Font, false), OutConfig.CommentEnd); // add header file header headerText.AppendFormat("{0}Font data for {1} {2}" + OutConfig.nl, OutConfig.CommentStart, getFontName(Font, false), OutConfig.CommentEnd); } // get bitmap name string charBitmapVarName = String.Format(OutConfig.varNfBitmaps, getFontName(Font, true)) + "[]"; // source var sourceText.AppendFormat("{0} = " + OutConfig.nl + "{{" + OutConfig.nl, charBitmapVarName); Characters.ToList().ForEach(chi => chi.GenerateCharacterDataDescriptorAndVisulazer()); Characters.Aggregate(sourceText, (sb, chi) => { // skip empty bitmaps if (chi.BitmapToGenerate == null) { return(sb); } // now add letter array sourceText.Append(chi.Descriptor); // space out if (OutConfig.addCommentCharDescriptor && chi.Character != chi.ParentFontInfo.LastChar) { // space between chars sb.Append(OutConfig.nl); } return(sb); }); // space out sourceText.Append("};" + OutConfig.nl + OutConfig.nl); // // Charater descriptor // // whether or not block lookup was generated bool blockLookupGenerated = false; // check if required by configuration if (OutConfig.generateLookupArray) { // generate the lookup array blockLookupGenerated = generateStringsFromCharacterDescriptorBlockList(sourceText, headerText); } // // Font descriptor // // according to config if (OutConfig.addCommentVariableName) { // result string sourceText.AppendFormat("{0}Font information for {1} {2}" + OutConfig.nl, OutConfig.CommentStart, getFontName(Font, false), OutConfig.CommentEnd); } // character name string fontInfoVarName = String.Format(OutConfig.varNfFontInfo, getFontName(Font, true)); // add character array for header headerText.AppendFormat("extern {0};" + OutConfig.nl, fontInfoVarName); // the font character height string fontCharHeightString = ""; // get character height sstring - displayed according to output configuration if (OutConfig.descFontHeight != OutputConfiguration.DescriptorFormat.DontDisplay) { // convert the value fontCharHeightString = String.Format("\t{0}, {1} Character height{2}" + OutConfig.nl, MyExtensions.ConvertValueByDescriptorFormat(OutConfig.descFontHeight, FixedAbsolutCharHeight), OutConfig.CommentStart, OutConfig.CommentEnd); } string fontCodePage = ""; if (OutConfig.addCodePage) { fontCodePage = string.Format("\t{0}, {1} CodePage {3}{2}" + OutConfig.nl, OutConfig.CodePage, OutConfig.CommentStart, OutConfig.CommentEnd, CodePageInfo.GetCodepageName(OutConfig.CodePage)); } string spaceCharacterPixelWidthString = ""; // get space char width, if it is up to driver to generate if (!OutConfig.generateSpaceCharacterBitmap) { // convert the value spaceCharacterPixelWidthString = String.Format("\t{0}, {1} Width, in pixels, of space character{2}" + OutConfig.nl, OutConfig.spaceGenerationPixels, OutConfig.CommentStart, OutConfig.CommentEnd); } // font info sourceText.AppendFormat("{2} =" + OutConfig.nl + "{{" + OutConfig.nl + "{3}" + "\t{4}, {0} First character '{9}'{1}" + OutConfig.nl + "\t{5}, {0} Last character '{10}'{1}" + OutConfig.nl + "{6}" + "{7}" + "\t{8}, {0} Character bitmap array{1}" + OutConfig.nl + "{11}" + "}};" + OutConfig.nl, OutConfig.CommentStart, OutConfig.CommentEnd, fontInfoVarName, fontCharHeightString, getCharacterDisplayString(CodePageInfo, FirstChar), getCharacterDisplayString(CodePageInfo, LastChar), spaceCharacterPixelWidthString, getFontInfoDescriptorsString(blockLookupGenerated, OutConfig, Font), MyExtensions.GetVariableNameFromExpression(String.Format(OutConfig.varNfBitmaps, getFontName(Font, true))), FirstChar, LastChar, fontCodePage); // add the appropriate entity to the header if (blockLookupGenerated) { // add block lookup to header headerText.AppendFormat("extern const FONT_CHAR_INFO_LOOKUP {0}[];" + OutConfig.nl, getCharacterDescriptorArrayLookupDisplayString(Font)); } else { // add block lookup to header headerText.AppendFormat("extern {0}[];" + OutConfig.nl, String.Format(OutConfig.varNfCharInfo, getFontName(Font, true))); } TextSource = sourceText.ToString(); TextHeader = headerText.ToString(); }