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(); } }
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); } }
// Redraw vertical gridlines for the exposed area. void DrawVerticalGrid(Gdk.Window win, Gdk.Rectangle rect) { SampleQueue data = debugManager.PowerData; if (data == null) { return; } int usPerPx = scale * data.Period; int t = rect.X * usPerPx; // Find the first time divison before the exposed area t -= t % hSpacingUs; for (;;) { int x = t / usPerPx; if (x >= rect.X + rect.Width) { break; } win.DrawLine(gcGrid, x, 0, x, allocation.Height - 1); t += hSpacingUs; } }
/// <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 }
/// <summary> /// Fills in the content of the control showing all values of Red (0 to 255) for the given /// Green and Blue. /// </summary> private void Draw_Style_Red(Gdk.Window g) { for (int i = 0; i < this.Allocation.Height - 8; i++) // i represents the current line of pixels we want to draw horizontally { int red = 255 - Round(255 * (double)i / (this.Allocation.Height - 8)); // red is based on the current vertical position // Get the Color for this line Color c = Color.FromArgb(red, m_rgb.G, m_rgb.B); Gdk.GC gc = new Gdk.GC(g); gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(c); g.DrawLine(gc, 11, i + 4, this.Allocation.Width - 11, i + 4); // Draw the line and loop back for next line } }
void TheExposeEvent(object o, ExposeEventArgs args) { Gdk.EventExpose expose = args.Args[0] as Gdk.EventExpose; Gdk.Window win = expose.Window; Gdk.GC gc = new Gdk.GC(this.GdkWindow); gc.RgbFgColor = new Gdk.Color(150, 150, 150); int[] gripper = GripperPositions(); int dy = 8; foreach (int x in gripper) { win.DrawLine(gc, x + 2, dy, x + 2, TotalHeight - dy + 1); } }
/// <summary> /// Fills in the content of the control showing all values of Luminance (0 to 100%) for the given /// Hue and Saturation. /// </summary> private void Draw_Style_Luminance(Gdk.Window g) { GraphUtil.HSL _hsl = new GraphUtil.HSL(); _hsl.H = m_hsl.H; // Use the H and S values of the current color (m_hsl) _hsl.S = m_hsl.S; for (int i = 0; i < this.Allocation.Height - 8; i++) // i represents the current line of pixels we want to draw horizontally { _hsl.L = 1.0 - (double)i / (this.Allocation.Height - 8); // L (Luminance) is based on the current vertical position // Get the Color for this line Color c = GraphUtil.HSL_to_RGB(_hsl); Gdk.GC gc = new Gdk.GC(g); gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(c); g.DrawLine(gc, 11, i + 4, this.Allocation.Width - 11, i + 4); // Draw the line and loop back for next line } }
// The following functions do the real work of the control, drawing the primary content (the area between the slider) // /// <summary> /// Fills in the content of the control showing all values of Hue (from 0 to 360) /// </summary> private void Draw_Style_Hue(Gdk.Window g) { GraphUtil.HSL _hsl = new GraphUtil.HSL(); _hsl.S = 1.0; // S and L will both be at 100% for this DrawStyle _hsl.L = 1.0; for (int i = 0; i < this.Allocation.Height - 8; i++) // i represents the current line of pixels we want to draw horizontally { _hsl.H = 1.0 - (double)i / (this.Allocation.Height - 8); // H (hue) is based on the current vertical position Color c = GraphUtil.HSL_to_RGB(_hsl); Gdk.GC gc = new Gdk.GC(g); gc.RgbFgColor = GraphUtil.gdkColorFromWinForms(c); g.DrawLine(gc, 11, i + 4, this.Allocation.Width - 11, i + 4); // Draw the line and loop back for next line } }
// Redraw horizontal gridlines for the exposed area. void DrawHorizontalGrid(Gdk.Window win, Gdk.Rectangle rect) { int x1 = rect.X; int x2 = rect.X + rect.Width - 1; // Align the horizontal region so the dotted pattern always // appears continuous. x1 -= x1 % dotsPeriod; x2 += dotsPeriod - (x2 % dotsPeriod); for (int i = 1; i < 10; i++) { int y = allocation.Height * i / 10; win.DrawLine(gcGrid, x1, y, x2, y); } }
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); }
void TheExposeEvent(object o, ExposeEventArgs args) { Gdk.EventExpose expose = args.Args[0] as Gdk.EventExpose; Gdk.Window win = expose.Window; Gdk.GC gc = new Gdk.GC(this.GdkWindow); gc.RgbFgColor = new Gdk.Color(150, 150, 150); var gripper = GripperPositions(); foreach (var g in gripper) { int x = g.Value; win.DrawLine(gc, x + 2, Allocation.Top, x + 2, Allocation.Bottom); } TotalWidth = gripper.LastOrDefault().Value + 10; EventBox.SetSizeRequest(TotalWidth, TotalHeight); }
// Redraw power samples for the exposed area. void DrawPower(Gdk.Window win, Gdk.Rectangle rect) { SampleQueue data = debugManager.PowerData; if (data == null) { return; } int[] slice = new int[rect.Width]; int len; len = data.Fetch(rect.X * scale, slice, scale); for (int i = 0; i < len; i++) { int x = rect.X + i; int h = slice[i] * allocation.Height / vertMax; win.DrawLine(gcBar, x, allocation.Height - 1 - h, x, allocation.Height - 1); } }