I have to write text with coefficient value like C1, C2, C3 on label text, so please tell me how can i write ???
thanks
Shashi Jaiswal
You need a font that comes with glyphs for Unicode codepoints U+2080 to U+2089:
label1.Font = new Font("DejaVu Sans", 10);
label1.Text = "C₁"; // or "C\u2081"
(assuming WinForms)
In WinForms you need to emulate that with a RichTextBox
// Appearance as a label
var subscriptFont = new System.Drawing.Font(
richTextBox1.Font.FontFamily,
richTextBox1.Font.Size - 2);
richTextBox1.BackColor = System.Drawing.SystemColors.Control;
richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
richTextBox1.ReadOnly = true;
richTextBox1.Text = "C1, C2, C3";
// subscript 1
richTextBox1.Select(1, 1);
richTextBox1.SelectionCharOffset = -3;
richTextBox1.SelectionFont = subscriptFont;
// subscript 2
richTextBox1.Select(5, 1);
richTextBox1.SelectionCharOffset = -3;
richTextBox1.SelectionFont =subscriptFont;
// subscript 3
richTextBox1.Select(9, 1);
richTextBox1.SelectionCharOffset = -3;
richTextBox1.SelectionFont = subscriptFont;
subscriptFont.Dispose();
You could try using a different font that haves subindexes...
You can't. Plain and simple.
(But you could use two labels, positioned and sized accordingly, or use a label that supports complex markup... Or use UTF-8, which allows them...)
But a stock C# Winforms project? Nah.
Related
I tried setting all related properties ExcelLineChartSerie has to offer, but still cannot set or change the color of the Excel marker from default ugly blue.
ExcelChart ec = ws.Drawings.AddChart("LineChart01", eChartType.LineMarkers);
var rangeX = ws.Cells["A2:A11"]; // X-Axis
var range1 = ws.Cells["B2:B11"]; // 1st LineSerie
ExcelLineChartSerie serie1 = (ExcelLineChartSerie)ec.Series.Add(range1, rangeX);
serie1.MarkerLineColor = System.Drawing.Color.Gray;
serie1.MarkerSize = 10;
serie1.Fill.Color = System.Drawing.Color.Gray;
serie1.LineColor = System.Drawing.Color.Gray;
serie1.Border.LineStyle = eLineStyle.Solid;
It is available in EPPlus (current source!). Just convert your base series to specific one.
var chartType3 = (ExcelLineChart)chart.PlotArea.ChartTypes.Add(eChartType.Line);
var serie5 = (ExcelLineChartSerie)chartType3.Series.Add(worksheet.Cells["F1:F12"], worksheet.Cells["A1:A12"]);
serie5.Marker = eMarkerStyle.Circle;
serie5.MarkerLineColor = Color.FromArgb(165, 165, 165);
serie5.MarkerSize = 5;
From looking at the current source code, it looks like this functionality is not implemented in EPPlus yet.
This discussion points to a SO post which shows how to implement an extension method to add functionality to change line thickness and color. It should be possible to adapt this code to change the marker fill color. The property paths you will need for this are at the end of the discussion on codeplex (second link above).
Have researched outputting to Excel and can successfully do so. My question is more if I am missing something simpler.
Currently, if I want to set the font, cell color, size, etc. of a single cell, I am doing so like this:
range = (Range)ws.Cells[10, 12];
range.Formula = "=SUM(R10C10:R10C11)";
range.Calculate();
range.Font.Bold = true;
range.Font.Underline = true;
range.Style = wb.Styles["Currency"];
range.Font.Color = Color.Red;
range.Font.Name = "Arial";
range.Font.Size = 26;
borders = range.Borders;
borders.LineStyle = XlLineStyle.xlContinuous;
borders.Weight = 2d;
Did I miss something in the documentation that allows me to do this on a SINGLE cell without having to create a Range?
No, C# requires an object qualifier (see What's the C# equivalent to the With statement in VB?. So your current code is to protocol.
I have a syncfusion chart in my winform application.
I add a series of data.
I want to highlight a specific point of the series (let's say the 25th data point of the first series) with a red circle and the "Focus" text.
ChartCustomPoint cp = new ChartCustomPoint();
cp.CustomType = ChartCustomPointType.PointFollow;
cp.PointIndex=25;
cp.SeriesIndex=1;
cp.Symbol.Shape = ChartSymbolShape.Circle;
cp.Symbol.Color = Color.Red;
cp.Symbol.Marker.LineInfo.Width = 4;
cp.Alignment = ChartTextOrientation.Up;
cp.Text = "Focus";
chartControl1.CustomPoints.Add(cp);
but, the displayed text is stuck to the symbol. I would like to add space between the label and the symbol.
Is there a property I missed ?
Thank you
Thanks for using Syncfusion Products.
We have analyzed your query. While using the Custom Points the space between the text and the symbol can be provided by using the Alignment property of the Custom points.
The alignment property is used to align the text in the center, top, topleft , topright ,left ,right ,bottom ,bottomleft ,bottomright and when the symbol is present the RegionUp, RegionDown, RegionCenter will consider the symbol and the align the text accordingly.
When the RegionUp is set to the alignment the space is provided between the symbol and the text
ChartCustomPoint cp1 = new ChartCustomPoint();
// Point that follows a series point:
cp1.PointIndex = 2;
cp1.SeriesIndex = 0;
cp1.CustomType = ChartCustomPointType.PointFollow;
cp1.Symbol.Shape = ChartSymbolShape.Circle;
cp1.Offset = 20;
cp1.Font.Facename = "Times New Roman";
cp1.Font.Bold = true;
cp1.Font.Size = 11f;
cp1.Symbol.Color = Color.FromArgb(0Xc1, 0X39, 0x2b);
// Provide space between the symbol and the text
cp1.Alignment = ChartTextOrientation.RegionUp;
cp1.Text = "Circle";
cp1.Symbol.Marker.LineInfo.Width = 4;
chart.CustomPoints.Add(cp1);
We have attached the sample for your reference.
Sample link:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Custom_points-2112217385
Please let us know if you have any concerns.
Regards,
Deepaa.
I have a great question for you. I searched all the Google and MSDN and didn't find anything.
I'm trying to do a program that exports a font to single PNG images per character. I'm currently testing it with new Windows font, Segoe UI Symbol. Please note I know the font license terms and I won't distribute that font in the internet.
Well, the real problem is happening when I call the method DrawString, member of Graphics. I convert the unicode integer value to a char then to a string. I already tried to convert the integer to char with char.ConvertFromUtf32() and with Convert.ToChar().
The program is working good during 26 characters (starting from 57344 = 0xE000), the problem doesn't appear when I use numeric values until 57370. After this, there is not a single number that is not written with a white box char.
After some search, I found an overload to Font constructor, with the attribute gdiCharset and tried to use its value as 2, but nothing was happened.
I'm showing the source code for you below. Please, if there is someone who can help me, I will be happy.
UPDATE
When I use escape sequences (like "\uE1FF" instead of char conversion it works! But I don't know how to make escape sequences within a for loop.
Font segoe = new Font("Segoe UI Symbol", 800, FontStyle.Regular, GraphicsUnit.Pixel, 2);
Bitmap bmedidor = new Bitmap(1000, 1000, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics gmedidor = Graphics.FromImage(bmedidor);
// This line below doesn't matter, see the method DrawString
Size tamanho = gmedidor.MeasureString(char.ConvertFromUtf32(57344).ToString(), segoe).ToSize();
int[] reducoes = new int[6] {512, 256, 128, 64, 32, 16};
string caminho = "C:\\InoMetro";
for (int u = 57344; u < 57896; u++)
{
Bitmap caractere = new Bitmap(tamanho.Width, tamanho.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics criador = Graphics.FromImage(caractere);
criador.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
criador.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
criador.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
criador.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Here we have the problem
criador.DrawString(Convert.ToChar(u).ToString(), segoe, new SolidBrush(Color.Black), new PointF(0, 0));
for (int r = 0; r < reducoes.Length; r++)
{
int taR = reducoes[r];
Bitmap reducao = new Bitmap(taR, taR, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics redutor = Graphics.FromImage(reducao);
redutor.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
redutor.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
redutor.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
redutor.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
redutor.DrawImage(caractere, 0, 0, taR, taR);
reducao.Save(caminho + "\\" + taR.ToString() + "\\" + u.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
}
U+E000-U+F8FF (57344-63743 decimal) are Private Use Area characters.
Most fonts (including Segoe UI Symbol) don't provide glyphs for any code points in this range, so the typical fallback behavior is for the font renderer to display a white box () or a question mark in a black diamond (�) when asked to draw one of these code points.
Segoe UI Symbol on Windows 8 only defines glyphs for U+E000-U+E019, then provides no glyphs for U+E01A-U+E051; that's why white boxes are displayed for 57370 (0xE01A) through 57425 (0xE051).
Hy my example code:
Bold b = new Bold(new Run("TODO"));
b.FontSize = 50;
My Question is:
How to center the bold element?
I assume this is in reference to classes in System.Windows.Documents. You need to set the TextAlignment property on the thing (a Paragraph usually) that b is contained in.
The paragraph around the Run should define the alignment.
Bold b = new Bold(new Run("TODO"));
b.FontSize = 50;
var p = new Paragraph(b) {TextAlignment = TextAlignment.Center};