Example #1
0
        void XListbox_FontChanged(object sender, EventArgs e)
        {
            FontTracker = new font_tracker(this.Font);
            SizeF szf = FontTracker.MeasureString(this.CreateGraphics(), "X", scale_x, scale_y);

            ItemHeight = (int)(scale_y * szf.Height);
        }
Example #2
0
        void IReflectorScale.SetScale(Fraction scale_x, Fraction scale_y)
        {
            this.scale_x = scale_x;
            this.scale_y = scale_y;
            SizeF szf = FontTracker.MeasureString(this.CreateGraphics(), "X", scale_x, scale_y);;

            ItemHeight = (int)(scale_y * szf.Height);
        }
Example #3
0
        public XListbox()
        {
            DrawMode          = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            MeasureItem      += new MeasureItemEventHandler(XListbox_MeasureItem);
            DrawItem         += new DrawItemEventHandler(XListbox_DrawItem);
            this.FontChanged += new EventHandler(XListbox_FontChanged);

            Scale(new SizeF(scale_x.ToFloat(), scale_y.ToFloat()));

            FontTracker = new font_tracker(this.Font);
            SizeF szf = FontTracker.MeasureString(this.CreateGraphics(), "X", scale_x, scale_y);

            ItemHeight = (int)(scale_y * szf.Height);
        }
Example #4
0
        void DrawText(Graphics gout, bool offset_text, int Width, int Height, String outputText)
        {
            {
                int    offset   = 0;
                String realtext = outputText;

                List <SizeF>  output_size;
                List <string> output;
                output      = new List <string>();
                output_size = new List <SizeF>();
                int idx;
                do
                {
                    int idx_a = realtext.IndexOf('\n', offset);
                    int idx_b = realtext.IndexOf('_', offset);
                    if (idx_a >= 0)
                    {
                        if (idx_b >= 0)
                        {
                            if (idx_a < idx_b)
                            {
                                idx = idx_a;
                            }
                            else
                            {
                                idx = idx_b;
                            }
                        }
                        else
                        {
                            idx = idx_a;
                        }
                    }
                    else
                    {
                        idx = idx_b;
                    }
                    //idx = realtext.IndexOf( '_', offset );

                    if (idx >= 0)
                    {
                        output.Add(realtext.Substring(offset, idx - offset));
                        offset = idx + 1;
                    }
                    else
                    {
                        output.Add(realtext.Substring(offset, realtext.Length - offset));
                    }
                } while(idx >= 0);
                int height     = 0;
                int lineheight = 0;
                foreach (string s in output)
                {
                    SizeF size;
                    output_size.Add(size = FontTracker.MeasureString(gout, s, scale_x, scale_y));
                    //output_size.Add( size = new SizeF( gout.MeasureString( s, c.FontTracker ) ) );
                    height += (int)((lineheight = (int)size.Height) + (height > 0 ? 0 : 0));
                }

                Point _point = new Point(Width, Height);
                Point point  = new Point();

                if (!offset_text)
                {
                    //SizeF size = new SizeF(gout.MeasureString(realtext, c.Font));
                    _point.X /= 2;
                    _point.Y /= 2;
                    _point.Y -= (int)((height - lineheight) / 2);
                }
                else
                {
                    _point.X /= 2;
                    _point.Y /= 3;
                    _point.Y -= (int)((height - lineheight) / 2);
                }

                point.Y = _point.Y;
                int n = 0;
                foreach (string s in output)
                {
                    point.X = _point.X /*- (int)(output_size[n].Width / 2)*/;
                    FontTracker.DrawString(gout, s, new SolidBrush(ForeColor), point, scale_x, scale_y);
                    //gout.DrawString( s
                    //	 , c.FontTracker
                    //	 , attrib.text_output
                    //		 , point );
                    point.Y += (int)(output_size[n].Height) + ((n > 0) ? 2 : 0);
                    n++;
                }
            }
        }