Kayıtlar

Nisan, 2012 tarihine ait yayınlar gösteriliyor

Styling Microsoft’s WPF datagrid

Resim
Microsoft’s  WPF datagrid  has a lot of properties and styles you can tweak to get it looking right (if you are a designer). Below, find my cheat sheet to styling the grid.   It is not 100% comprehensive but it gets you far and has a few very useful tips & gotchas.  At the highest level in the DataGrid , you can change the look & feel by setting some of these: Property Type Values Default AlternatingRowBackground Brush Any Brush Null Background Brush Any Brush Theme default ColumnHeaderHeight Double 0 to any positive double NaN ColumnHeaderStyle Style Any Style Null ColumnWidth DataGridLength 0 to any positive double, Auto, *, SizeToCells, SizeToHeader SizeToHeader HeadersVisibility DataGridHeadersVisibility All, Row, Column, None All MaxColumnWidth Double 0 to any positive double Positive Infinity MaxRowHeight Double 0 to any positive double Positive Infinity MinColumnWidth Double 0 to any positive double 20 MinRowHeight Double 0 to any positive double 0

ascentPixel , descentPixel

public double[] Ver(             string cFontAdi,             double nFontSize,             bool lKalin,             bool lItalik,             bool lAltiCizgili,             bool lUstuCizgili)         {             FontFamily fontAdi = new FontFamily(cFontAdi);             FontStyle Deneme = new FontStyle();             //Deneme = FontStyle.Regular;             if (lKalin) Deneme |= FontStyle.Bold;             if (lItalik) Deneme |= FontStyle.Italic;             if (lAltiCizgili) Deneme |= FontStyle.Underline;             if (lUstuCizgili) Deneme |= FontStyle.Strikeout;             double ascentPixel = (nFontSize * fontAdi.GetCellAscent(Deneme)) / fontAdi.GetEmHeight(Deneme);             double descentPixel = (nFontSize * fontAdi.GetCellDescent(Deneme)) / fontAdi.GetEmHeight(Deneme);             return new double[] { ascentPixel, descentPixel };         }
Resim
http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html II. Glyph metrics 1. Baseline, pens and layouts The baseline is an imaginary line that is used to "guide" glyphs when rendering text. It can be horizontal (e.g. Roman, Cyrillic, Arabic, etc.) or vertical (e.g. Chinese, Japanese, Korean, etc). Moreover, to render text, a virtual point, located on the baseline, called the pen position or origin , is used to locate glyphs. Each layout uses a different convention for glyph placement: With horizontal layout, glyphs simply "rest" on the baseline. Text is rendered by incrementing the pen position, either to the right or to the left. The distance between two successive pen positions is glyph-specific and is called the advance width . Note that its value is always positive, even for right-to-left oriented alphabets, like Arabic. This introduces

String Format for Double [C#]

http://www.csharp-examples.net/examples/ The following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString . Digits after decimal point This example formats double to string with fixed number of decimal places . For two decimal places use pattern „ 0.00 “. If a float number has less decimal places, the rest digits on the right will be zeroes. If it has more decimal places, the number will be rounded. [C#] // just two decimal places String .Format( "{0:0.00}" , 123.4567); // "123.46" String .Format( "{0:0.00}" , 123.4); // "123.40" String .Format( "{0:0.00}" , 123.0); // "123.00" Next example formats double to string with floating number of decimal places . E.g. for maximal two decimal places use pattern „ 0.## “. [C#] // max. two decimal places String .Format( "{0:0.##}" , 1