Exemplo n.º 1
0
        internal Font GetFont(TFlxFont Fx, real Adj)
        {
            // Not really need to keep a cache in WPF.
            Font NewFont = ExcelFont.CreateFont(Fx, Adj);

            return(NewFont);
        }
Exemplo n.º 2
0
        private static real DoFullGetFont0Width(TFlxFont Fx)
        {
            TextBlock tb = new TextBlock();

            ExcelFont.SetFont(tb, Fx);
            tb.Text = "0";
            return((real)tb.ActualWidth); //Result is in silverlight pixels. Note that no transformation applies to TextBlock
        }
Exemplo n.º 3
0
        private static int DoFullGetRowHeight(TFlxFont Fx)
        {
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
#if (MONOTOUCH)
                real h = MyFont.LineHeight;
#else
                real h = MyFont.GetHeight(75);
#endif
                return((int)(h * 20.87 + 5));
            }
        }
Exemplo n.º 4
0
        private static real DoFullGetFont0Width(TFlxFont Fx)
        {
#if (MONOTOUCH)
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
                using (MonoTouch.Foundation.NSString o = new MonoTouch.Foundation.NSString("0"))
                {
                    return(o.StringSize(MyFont).Width);
                }
            }
#else
            using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx)))
            {
                using (Bitmap bm = new Bitmap(1, 1))
                {
                    using (Graphics gr = Graphics.FromImage(bm))
                        using (StringFormat sfTemplate = StringFormat.GenericTypographic)                 //GenericTypographic returns a NEW instance. It has to be disposed.
                        {
                            using (StringFormat sf = (StringFormat)sfTemplate.Clone())                    //Even when sfTemplate is a new instance, changing directly on it will change the standard generic typographic :(
                            {
                                //sf.SetMeasurableCharacterRanges was causing a deadlock here.
                                //DONT DO!!

                                /*CharacterRange[] r = {new CharacterRange(0,1)};
                                 * sf.SetMeasurableCharacterRanges(r);*/

                                sf.Alignment     = StringAlignment.Near; //this should be set, but just in case someone changed it.
                                sf.LineAlignment = StringAlignment.Far;  //this should be set, but just in case someone changed it.
                                sf.FormatFlags   = 0;
                                gr.PageUnit      = GraphicsUnit.Pixel;
                                SizeF sz = gr.MeasureString("0", MyFont, 1000, sf);
                                return((real)Math.Round(sz.Width));
                            }
                        }
                }
            }
#endif
        }