Updated usage of ReplaceSymbolChars to use an index

The buttons in the symbol gallery now use an image of each symbol so that we can show the FreeMono representation
This commit is contained in:
2017-06-01 14:31:16 +00:00
parent b9e3448fe5
commit dd4c099741
11 changed files with 345 additions and 298 deletions

View File

@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Data;
using System.Text;
using System.Windows.Forms;
@@ -823,30 +825,75 @@ namespace Volian.Controls.Library
//{
// //SetButtonAndMenuEnabling(false);
//}
private Bitmap createTextBitmap(char ch)
{
string txt = string.Format("{0}", ch);
Bitmap objBmpImage = new Bitmap(1, 1);
int intWidth = 0;
int intHeight = 0;
// Create the Font object for the image text drawing.
// later on, we could add logic to use either FreeMono or Arial Unicode MS based on the format being used
// but for now, we are going to use FreeMono to create the symbol list
Font objFont = new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
//Font objFont = new Font("Arial Unicode MS", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
// Create a graphics object to measure the text's width and height.
Graphics objGraphics = Graphics.FromImage(objBmpImage);
// This is where the bitmap size is determined.
intWidth = (int)objGraphics.MeasureString(txt, objFont).Width;
intHeight = (int)objGraphics.MeasureString(txt, objFont).Height;
// Create the bmpImage again with the correct size for the text and font.
objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
// Add the colors to the new bitmap.
objGraphics = Graphics.FromImage(objBmpImage);
// Set Background color
objGraphics.Clear(Color.Transparent); //.White);
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextContrast = 0;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//objGraphics.DrawString(txt, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.DrawString(txt, objFont, new SolidBrush(Color.Black),0,0);
objGraphics.Flush();
return (objBmpImage);
}
private void BuildSymbolGallery(SymbolList sl, DevComponents.DotNetBar.GalleryContainer gc1, DevComponents.DotNetBar.GalleryContainer gc2, DevComponents.DotNetBar.GalleryContainer gc3, DevComponents.DotNetBar.GalleryContainer gc4)
{
foreach (Symbol sym in sl)
{
// get an image of the symbol character
// found the we cannot change the font being used for the button text
Bitmap symCharBtmp = createTextBitmap((char)sym.Unicode);
DevComponents.DotNetBar.ButtonItem btn = new DevComponents.DotNetBar.ButtonItem();
btn.Text = string.Format("{0}", (char)sym.Unicode);
btn.Image = symCharBtmp;
//btn.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btn.Name = "btn" + sym.Unicode.ToString();
btn.Tooltip = sym.Desc;
btn.Tag = string.Format(@"{0}", sym.Unicode);
btn.FontBold = true;
//btn.FontBold = true;
btn.Click += new System.EventHandler(btnSym_Click);
galleryContainerSymbols.SubItems.Add(btn);
DevComponents.DotNetBar.ButtonItem btnCM1 = GetCMButton(sym);
btnCM1.Image = symCharBtmp;
btnCM1.Click += new System.EventHandler(btnSym_Click);
gc1.SubItems.Add(btnCM1);
DevComponents.DotNetBar.ButtonItem btnCM2 = GetCMButton(sym);
btnCM2.Image = symCharBtmp;
btnCM2.Click += new System.EventHandler(btnSym_Click);
gc2.SubItems.Add(btnCM2);
DevComponents.DotNetBar.ButtonItem btnCM3 = GetCMButton(sym);
btnCM3.Image = symCharBtmp;
btnCM3.Click += new System.EventHandler(btnSym_Click);
gc3.SubItems.Add(btnCM3);
DevComponents.DotNetBar.ButtonItem btnCM4 = GetCMButton(sym);
btnCM4.Image = symCharBtmp;
btnCM4.Click += new System.EventHandler(btnSym_Click);
gc4.SubItems.Add(btnCM4);
}
@@ -855,12 +902,12 @@ namespace Volian.Controls.Library
private static DevComponents.DotNetBar.ButtonItem GetCMButton(Symbol sym)
{
DevComponents.DotNetBar.ButtonItem btnCM3 = new DevComponents.DotNetBar.ButtonItem();
btnCM3.Text = string.Format("{0}", (char)sym.Unicode);
//btnCM3.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btnCM3.Name = "btnCM" + sym.Unicode.ToString();
btnCM3.Tooltip = sym.Desc;
btnCM3.Tag = string.Format(@"{0}", sym.Unicode);
btnCM3.FontBold = true;
//btnCM3.FontBold = true;
return btnCM3;
}
//void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args)