Esempio n. 1
0
        private void Canvas_ClientSizeChanged(object sender, EventArgs e)
        {
#if look_at_font_families
            FontFamily[] families = FontFamily.Families;
            foreach (FontFamily f in families)
            {
                //Log.log( f.Name );
            }
#endif
            font_scale_x = new Fraction(Width, 1024);
            font_scale_y = new Fraction(Height, 768);
            if (ScaleChanged != null)
            {
                ScaleChanged();
            }


            font_tracker default_font = Xperdex.GetFontTracker("Default");
            // some 3/4 aspect ratio... the font scale is based against this... so we'd have double applied scaling
            // to the default font.
            SizeF    target_size = new SizeF(1024 / 40, 768 / 20);
            int      height      = (int)target_size.Height;
            Font     NewFont;
            Graphics g = this.CreateGraphics();
            if (current_page != null)
            {
                g.Clear(current_page.background_color);
            }
            NewFont        = new Font("Lucida Console", height, GraphicsUnit.Pixel);
            default_font.f = NewFont;
        }
Esempio n. 2
0
        public Class1()
        {
            Paint += new System.Windows.Forms.PaintEventHandler(Class1_Paint);
            Timer t = new Timer();

            t.Interval = 50;
            t.Tick    += new EventHandler(t_Tick);
            t.Start();
            f = Xperdex.GetFontTracker("test tracker").f;
        }
Esempio n. 3
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // do nothing
            if (BackgroundImage != null)              // guess we can let it paint the image...
            {
                e.Graphics.DrawImage(this.BackgroundImage, this.ClientRectangle
                                     , new RectangleF(0, 0, this.BackgroundImage.Size.Width, this.BackgroundImage.Size.Height), GraphicsUnit.Pixel
                                     );

                base.OnPaintBackground(e);
            }

            if (current_page == null)
            {
                current_page = new page(this);
            }

            if (current_page.Count == 0)
            {
                font_tracker ft = Xperdex.GetFontTracker("Default");
                ft.DrawString(e.Graphics, "No Objects\nALT-V to Configure\nLeft click drag region\nRight click in region to add control"
                              , new SolidBrush(Color.Azure)
                              , new Point(0, 0)
                              , font_scale_x, font_scale_y
                              //, StringFormat.GenericTypographic
                              );
            }

            if (flags.editing)
            {
                // hazy green edit...
                Brush b  = new SolidBrush(Color.FromArgb(32, 0, 84, 84));
                Pen   p  = new Pen(Color.FromArgb(43, 255, 255, 255));
                Pen   p2 = new Pen(Color.FromArgb(43, 0, 0, 0));
                // r is a global variable that determines scaling for parts.
                current_page.rect = this.ClientRectangle;

                e.Graphics.FillRectangle(b, this.ClientRectangle);


                {
                    int x, y;

                    for (x = 0; x <= current_page.partsX; x++)
                    {
                        e.Graphics.DrawLine(p
                                            , current_page.PARTX(x), 0
                                            , current_page.PARTX(x), current_page.PARTY(current_page.partsY));
                        e.Graphics.DrawLine(p2, current_page.PARTX(x) + 1, 0
                                            , current_page.PARTX(x) + 1, current_page.PARTY(current_page.partsY));
                    }

                    for (y = 0; y <= current_page.partsY; y++)
                    {
                        e.Graphics.DrawLine(p, 0, current_page.PARTY(y)
                                            , current_page.PARTX(current_page.partsX), current_page.PARTY(y));
                        e.Graphics.DrawLine(p2, 0, current_page.PARTY(y) + 1
                                            , current_page.PARTX(current_page.partsX), current_page.PARTY(y) + 1);
                    }

                    Font c_label = Xperdex.GetFontTracker("Default Fixed(Fixed)", "Lucida Console", 10);
                    foreach (ControlTracker c in current_page)
                    {
                        Brush selected_brush = new SolidBrush(Color.FromArgb(80, 0, 128, 0));
                        //lprintf( WIDE("Our fancy coords could be %d,%d %d,%d"), PARTX( selection.x ), PARTY( selection.y )
                        //		 , PARTW( selection.x, selection.w )
                        //		 , PARTH( selection.y, selection.h ));
                        // and to look really pretty select the outer edge on the bottom, also

                        //e.Graphics.FillRectangle(selected_brush, rect);
                        e.Graphics.FillRectangle(selected_brush, current_page.PARTX(c.grid_rect.X), current_page.PARTY(c.grid_rect.Y)
                                                 , current_page.PARTW(c.grid_rect.X, c.grid_rect.Width) + 1
                                                 , current_page.PARTH(c.grid_rect.Y, c.grid_rect.Height) + 1
                                                 );
                        {
                            selected_brush = new SolidBrush(Color.FromArgb(84, 128, 0, 0));
                            e.Graphics.FillRectangle(selected_brush
                                                     , current_page.PARTX(c.grid_rect.X)
                                                     , current_page.PARTY(c.grid_rect.Y)
                                                     , current_page.PARTW(c.grid_rect.X, 1) + 1
                                                     , current_page.PARTH(c.grid_rect.Y, 1) + 1
                                                     );
                            e.Graphics.FillRectangle(selected_brush
                                                     , current_page.PARTX(c.grid_rect.Right - 1)
                                                     , current_page.PARTY(c.grid_rect.Top)
                                                     , current_page.PARTW(c.grid_rect.Right - 1, 1) + 1
                                                     , current_page.PARTH(c.grid_rect.Top, 1) + 1
                                                     );
                            e.Graphics.FillRectangle(selected_brush
                                                     , current_page.PARTX(c.grid_rect.X)
                                                     , current_page.PARTY(c.grid_rect.Bottom - 1)
                                                     , current_page.PARTW(c.grid_rect.X, 1) + 1
                                                     , current_page.PARTH(c.grid_rect.Bottom - 1, 1) + 1
                                                     );
                            e.Graphics.FillRectangle(selected_brush
                                                     , current_page.PARTX(c.grid_rect.Right - 1)
                                                     , current_page.PARTY(c.grid_rect.Bottom - 1)
                                                     , current_page.PARTW(c.grid_rect.Right - 1, 1) + 1
                                                     , current_page.PARTH(c.grid_rect.Bottom - 1, 1) + 1
                                                     );
                            e.Graphics.DrawString(c.o.ToString(), c_label, Brushes.White, new PointF(c.c.Location.X, c.c.Location.Y));
                        }
                    }
                    if (flags.selecting)
                    {
                        Brush selected_brush = new SolidBrush(Color.FromArgb(170, 0, 0, Color.Blue.B));
                        //lprintf( WIDE("Our fancy coords could be %d,%d %d,%d"), PARTX( selection.x ), PARTY( selection.y )
                        //		 , PARTW( selection.x, selection.w )
                        //		 , PARTH( selection.y, selection.h ));
                        // and to look really pretty select the outer edge on the bottom, also
                        e.Graphics.FillRectangle(selected_brush, current_page.PARTX(selection.X), current_page.PARTY(selection.Y)
                                                 , current_page.PARTW(selection.X, selection.Width) + 1
                                                 , current_page.PARTH(selection.Y, selection.Height) + 1
                                                 );
                    }
                }
            }
        }