protected virtual void OnDrawingareaBalanceExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window window = args.Event.Window;
            Gdk.GC     gc     = drawingareaBalance.Style.BlackGC;
            window.Background = new Gdk.Color(0, 0, 0);
            gc.RgbFgColor     = new Gdk.Color(255, 255, 255);
            float width  = args.Event.Area.Width;
            float height = args.Event.Area.Height;

            // draw grid
            window.DrawLine(gc, (int)(width / 2), 0, (int)(width / 2), (int)height);
            window.DrawLine(gc, 0, (int)(height / 2), (int)width, (int)(height / 2));

            // draw box
            int boxX = (int)(_BoxX * width - 5);
            int boxY = (int)(_BoxY * height - 5);

            window.DrawRectangle(gc, false, boxX, boxY, 10, 10);

            // draw balance point
            float total = _Board.BottomLeftWeight + _Board.BottomRightWeight + _Board.TopLeftWeight + _Board.TopRightWeight;
            float x     = ((_Board.BottomRightWeight + _Board.TopRightWeight) - (_Board.BottomLeftWeight + _Board.TopLeftWeight)) / total * width / 2f;
            float y     = ((_Board.BottomLeftWeight + _Board.BottomRightWeight) - (_Board.TopRightWeight + _Board.TopLeftWeight)) / total * height / 2f;
            int   dotX  = (int)(x + width / 2f - 1);
            int   dotY  = (int)(y + height / 2f - 1);

            window.DrawRectangle(gc, true, dotX, dotY, 3, 3);

            // test for collision, and relocate box on collision
            if (dotX + 2 > boxX && dotX + 2 < boxX + 10 && dotY + 2 > boxY && dotY + 2 < boxY + 10)
            {
                _BoxX = (float)_Random.NextDouble();
                _BoxY = (float)_Random.NextDouble();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Redraws the background over the slider area on both sides of the control
 /// </summary>
 private void ClearSlider(Gdk.Window g)
 {
     //Brush brush = System.Drawing.SystemBrushes.Control;
     Gdk.Color color = this.Style.Background(this.State);
     Gdk.GC    gc    = new Gdk.GC(g);
     gc.RgbBgColor = color;
     gc.RgbFgColor = color;
     g.DrawRectangle(gc, true, 0, 0, 8, this.Allocation.Height);                                         //	clear left hand slider
     g.DrawRectangle(gc, true, this.Allocation.Width - 8, 0, 8, this.Allocation.Height);                 //	clear right hand slider
 }
        protected virtual void OnDrawingareaIRExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window window = args.Event.Window;
            Gdk.GC     gc     = drawingareaIR.Style.BlackGC;
            window.Background = new Gdk.Color(0, 0, 0);
            gc.RgbFgColor     = new Gdk.Color(255, 255, 255);

            float scaleFactor = (float)args.Event.Area.Width / 1024f;

            int count = 0;

            foreach (BasicIRBeacon irBeacon in _Wiimote.IRBeacons)
            {
                if (irBeacon == null)
                {
                    continue;
                }
                window.DrawRectangle(gc, true, new Gdk.Rectangle(args.Event.Area.Width - (int)(scaleFactor * irBeacon.X - 2), (int)(scaleFactor * irBeacon.Y - 2), 4, 4));
                count++;
            }

            if (count == 0)
            {
                gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                window.DrawLine(gc, 0, 0, args.Event.Area.Width, args.Event.Area.Height);
                window.DrawLine(gc, args.Event.Area.Width, 0, 0, args.Event.Area.Height);
            }
        }
Esempio n. 4
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Gdk.Window    win  = args.Window;
            Gdk.Rectangle area = args.Area;


            win.DrawRectangle(Style.DarkGC(StateType.Normal), true, area);
            win.DrawRectangle(Style.BlackGC, false, area);
            win.DrawRectangle(Style.MidGC(StateType.Normal), true, 0, 15, 1000, 1000);
            win.DrawLine(Style.BlackGC, 0, 15, 1000, 15);
            //win.DrawLayout(Style.BlackGC,2,2,titleLayout);

            if (!string.IsNullOrEmpty(body))
            {
                win.DrawLayout(Style.BlackGC, 2, 17, GetLayout(body));
            }
            return(true);
        }
Esempio n. 5
0
        private void XorRect()
        {
            rectDrawn = !rectDrawn;

            if (rectOwner != null)
            {
                Gdk.Rectangle rect = new Gdk.Rectangle(request.X,
                                                       request.Y,
                                                       request.Width,
                                                       request.Height);
                rectOwner.XorRect(rect);
                return;
            }

            Gdk.Window window = Gdk.Global.DefaultRootWindow;

            if (rootXorGC == null)
            {
                Gdk.GCValues values = new Gdk.GCValues();
                values.Function      = Gdk.Function.Invert;
                values.SubwindowMode = Gdk.SubwindowMode.IncludeInferiors;

                rootXorGC = new Gdk.GC(window);
                rootXorGC.SetValues(values, Gdk.GCValuesMask.Function |
                                    Gdk.GCValuesMask.Subwindow);
            }

            rootXorGC.SetLineAttributes(1, Gdk.LineStyle.OnOffDash,
                                        Gdk.CapStyle.NotLast,
                                        Gdk.JoinStyle.Bevel);

            rootXorGC.SetDashes(1, new sbyte[] { 1, 1 }, 2);

            window.DrawRectangle(rootXorGC, false, request.X, request.Y,
                                 request.Width, request.Height);

            rootXorGC.SetDashes(0, new sbyte[] { 1, 1 }, 2);

            window.DrawRectangle(rootXorGC, false, request.X + 1,
                                 request.Y + 1, request.Width - 2,
                                 request.Height - 2);
        }
Esempio n. 6
0
        void OnExpose(object sender, ExposeEventArgs args)
        {
            Gdk.Rectangle rect = args.Event.Area;
            Gdk.Window    win  = drawer.GdkWindow;

            win.DrawRectangle(drawer.Style.BlackGC, true,
                              rect.X, 0, rect.Width, allocation.Height);

            DrawPower(win, rect);
            DrawHorizontalGrid(win, rect);
            DrawVerticalGrid(win, rect);
        }
Esempio n. 7
0
        protected virtual void OnViewExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window win = args.Event.Window;

            // Draw the window border
            win.DrawRectangle(darkgc, false, 0, 0, dimensions + 1, dimensions + 1);

            if (arena != null)
            {
                const int d = Constants.ARENA_SIZE;

                // Clear the pixmap
                view_pixmap.DrawRectangle(whitegc, true, 0, 0, d, d);
                arena.draw(view_graphics);

                if (scaling_ == ScalingMode.None)
                {
                    win.DrawDrawable(whitegc, view_pixmap, 0, 0, 1, 1, d, d);
                }
                else
                {
                    Gdk.Pixbuf pb = Gdk.Pixbuf.FromDrawable(view_pixmap, win.Screen.DefaultColormap,
                                                            0, 0, 0, 0, d, d);

                    Gdk.Pixbuf spb = null;
                    switch (scaling_)
                    {
                    case ScalingMode.Nearest2x:
                    case ScalingMode.Nearest3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Nearest);
                        break;

                    case ScalingMode.Bilinear2x:
                    case ScalingMode.Bilinear3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Bilinear);
                        break;
                    }

                    win.DrawPixbuf(whitegc, spb, 0, 0, 1, 1, dimensions, dimensions,
                                   Gdk.RgbDither.None, 0, 0);
                }
            }

            args.RetVal = true;
        }
Esempio n. 8
0
        /// <summary>
        /// Draws the border around the control.
        /// </summary>
        private void DrawBorder(Gdk.Window g)
        {
            //	To make the control look like Adobe Photoshop's the border around the control will be a gray line
            //	on the top and left side, a white line on the bottom and right side, and a black rectangle (line)
            //	inside the gray/white rectangle

            Gdk.GC gc = new Gdk.GC(g);
            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.FromArgb(172, 168, 153)); //	The same gray color used by Photoshop
            g.DrawLine(gc, this.Allocation.Width - 2, 0, 0, 0);                            //	Draw top line
            g.DrawLine(gc, 0, 0, 0, this.Allocation.Height - 2);                           //	Draw left hand line

            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.White);
            g.DrawLine(gc, this.Allocation.Width - 1, 0, this.Allocation.Width - 1, this.Allocation.Height - 1);                //	Draw right hand line
            g.DrawLine(gc, this.Allocation.Width - 1, this.Allocation.Height - 1, 0, this.Allocation.Height - 1);               //	Draw bottome line

            gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.Black);
            g.DrawRectangle(gc, false, 1, 1, this.Allocation.Width - 3, this.Allocation.Height - 3);                    //	Draw inner black rectangle
        }
        protected void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.EventExpose expose = args.Args[0] as Gdk.EventExpose;
            Gdk.Window      win = expose.Window;
            int             width, height;

            win.GetSize(out width, out height);
            Gdk.Rectangle exposeRect = expose.Area;
            bool          fulldraw   = width == exposeRect.Width && height == exposeRect.Height;

            win.DrawRectangle(Style.LightGC(StateType.Normal), true, exposeRect);
            if (GetContentDelegate == null)
            {
                return; // todo: an error message could be displayed
            }
            int offset = (int)vscrollbar1.Value;

            if (fulldraw)
            {
                TopVisibleRow    = offset;
                BottomVisibleRow = offset;
            }
            int hscrollRange = 0;
            int dy           = exposeRect.Top;

            offset += dy / ConstantHeight;
            dy     -= dy % ConstantHeight;

            Gdk.GC backgound = new Gdk.GC((Gdk.Drawable)base.GdkWindow);
            Gdk.GC text      = new Gdk.GC((Gdk.Drawable)base.GdkWindow);

            ColumnControl.Column[] columns = mColumnControl.GetVisibleColumnsInDrawOrder();

            for (int row = offset; row < RowCount; row++)
            {
                int           dx   = -(int)hscrollbar1.Value;
                Gdk.Rectangle rect = new Gdk.Rectangle(dx, dy, 0, ConstantHeight);

                System.Drawing.Color backColor = System.Drawing.Color.WhiteSmoke;
                System.Drawing.Color textColor = System.Drawing.Color.Black;

                if (isRowSelected(row))
                {
                    if (HasFocus)
                    {
                        backColor = System.Drawing.Color.DarkGray;
                    }
                    else
                    {
                        backColor = System.Drawing.Color.LightGray;
                    }
                }
                else
                {
                    if (GetColorDelegate != null)
                    {
                        GetColorDelegate(row, ref backColor, ref textColor);
                    }
                }

                backgound.RgbFgColor = new Gdk.Color(backColor.R, backColor.G, backColor.B);
                text.RgbFgColor      = new Gdk.Color(textColor.R, textColor.G, textColor.B);

                for (int c = 0; c < columns.Length; c++)
                {
                    ColumnControl.Column column = columns[c];
                    int columnIndex             = column.SortOrder;
                    int xwidth = column.Width;
                    if (dx > exposeRect.Right)
                    {
                        break;
                    }
                    rect = new Gdk.Rectangle(rect.Left, rect.Top, xwidth + mColumnControl.GripperWidth, ConstantHeight);
                    if (c == columns.Length - 1)
                    {
                        rect.Width = Math.Max(rect.Width, exposeRect.Right - rect.Left + 1);
                    }
                    object content = GetContentDelegate(row, columnIndex);
                    if (content is Gdk.Pixbuf)
                    {
                        Gdk.Pixbuf image = (Gdk.Pixbuf)content;
                        win.DrawRectangle(backgound, true, rect);
                        dx += 2;
                        image.RenderToDrawable(win, text, 0, 0, dx, dy, image.Width, image.Height, Gdk.RgbDither.Normal, 0, 0);
                        dx += xwidth + mColumnControl.GripperWidth - 2;
                        rect.Offset(xwidth + mColumnControl.GripperWidth, 0);
                    }
                    else
                    {
                        LineLayout.SetText(content.ToString());
                        win.DrawRectangle(backgound, true, rect);
                        dx += 2;
                        win.DrawLayout(text, dx, dy, LineLayout);
                        dx += xwidth + mColumnControl.GripperWidth - 2;
                        rect.Offset(xwidth + mColumnControl.GripperWidth, 0);
                    }
                }
                hscrollRange = Math.Max(hscrollRange, dx + rect.Width);
                dy          += ConstantHeight;
                if (dy > exposeRect.Bottom)
                {
                    break;
                }
                if (fulldraw && exposeRect.Height - dy >= ConstantHeight)
                {
                    BottomVisibleRow++;
                }
            }

            if (fulldraw)
            {
                int pageSize = BottomVisibleRow - TopVisibleRow;
                if (vscrollbar1.Adjustment.PageSize != pageSize)
                {
                    vscrollbar1.Adjustment.PageSize      = pageSize;
                    vscrollbar1.Adjustment.PageIncrement = pageSize;
                }
                hscrollRange += (int)hscrollbar1.Value;
                if (hscrollRange > 0)
                {
                    hscrollbar1.SetRange(0, hscrollRange);
                }

                // position current row inside visible area
                // TODO: please think about, because of double redraw a more sophisticated solution could be possible
                if (CurrentRow >= 0 && CurrentRow < RowCount)
                {
                    if (CurrentRow < TopVisibleRow)
                    {
                        OffsetCursor(TopVisibleRow - CurrentRow);
                    }
                    else if (CurrentRow > BottomVisibleRow)
                    {
                        OffsetCursor(BottomVisibleRow - CurrentRow);
                    }
                }
            }

#if DEBUG2
            if (ComponentManager != null)
            {
                String t1 = String.Format("Expose.Area={0}, size={1}.{2}",
                                          expose.Area.ToString(), width, height);
                String t2 = String.Format("{0} T={1} B={2}", fulldraw ? "FULL" : "PART", TopVisibleRow, BottomVisibleRow);
                ComponentManager.MessageWriteLineInvoke(String.Format("{0} {1}", t1, t2));
            }
#endif
        }