// protected override bool OnExposeEvent (object o, Gdk.EventExpose args) // { // System.Drawing.Graphics g = Gtk.DotNet.Graphics.FromDrawable (this.Connector_drawingarea.GdkWindow); // { // Pen p = new Pen (Color.Blue, 1.0f); // // for (int i = 0; i < 600; i += 60) // for (int j = 0; j < 600; j += 60) // g.DrawLine (p, i, 0, 0, j); // } // return true; // } protected void OnExpose(object o, ExposeEventArgs args) { Console.WriteLine("OnExpose"); System.Drawing.Graphics g = Gtk.DotNet.Graphics.FromDrawable(this.Connectors_drawingarea.GdkWindow); if (_mouseDown) { Pen p = new Pen(Color.Red, 1.0f); g.Clear(Color.White); int pX = 0; int pY = 0; this.Connectors_drawingarea.GetPointer(out pX, out pY); g.DrawLine(p, _anchor.X, _anchor.Y, pX, pY); } else { Pen p = new Pen(Color.Blue, 1.0f); for (int i = 0; i < 600; i += 60) { for (int j = 0; j < 600; j += 60) { g.DrawLine(p, i, 0, 0, j); } } } }
protected void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { int left = Allocation.Left; int top = Allocation.Top; int width = Allocation.Width; int height = Allocation.Height; TouchGlobal.DrawRoundedRectangle(cr, left + 4, top + 4, width - 1, height - 1, 3); var shadowColor = new TouchColor(backgroundColor); shadowColor.ModifyColor(0.5); shadowColor.A = 0.4; shadowColor.SetSource(cr); cr.Fill(); TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, 3); backgroundColor.SetSource(cr); cr.FillPreserve(); TouchColor.SetSource(cr, "grey0"); cr.LineWidth = 1; cr.Stroke(); textRender.Render(this, left + 3, top, width - 6, height); } }
public virtual void ExposeEvent(object sender, ExposeEventArgs args) { view.Glx.MakeCurrent(view.GdkWindow); Gl.glEnable(Gl.GL_CONVOLUTION_2D); Gdk.Color c = view.Style.Background(view.State); Gl.glClearColor(c.Red / (float)ushort.MaxValue, c.Blue / (float)ushort.MaxValue, c.Green / (float)ushort.MaxValue, 1.0f); if (texture == null) { float [] kernel = new float [] { .25f, .5f, .25f, .5f, 1f, .5f, .25f, .5f, .25f }; #if false bool supported = GlExtensionLoader.LoadExtension("GL_ARB_imaging"); if (!supported) { System.Console.WriteLine("GL_ARB_imaging not supported"); return; } #else GlExtensionLoader.LoadAllExtensions(); #endif Gl.glConvolutionParameteri(Gl.GL_CONVOLUTION_2D, Gl.GL_CONVOLUTION_BORDER_MODE, Gl.GL_REPLICATE_BORDER); Gl.glConvolutionFilter2D(Gl.GL_CONVOLUTION_2D, Gl.GL_INTENSITY, 3, 3, Gl.GL_INTENSITY, Gl.GL_FLOAT, kernel); texture = new Texture(view.CompletePixbuf()); } Gl.glShadeModel(Gl.GL_FLAT); Gl.glColor3f(1.0f, 1.0f, 1.0f); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glEnable(Gl.GL_NORMALIZE); Gl.glShadeModel(Gl.GL_FLAT); Gl.glEnable(Gl.GL_TEXTURE_RECTANGLE_ARB); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); transition.Draw(view.Allocation, texture, texture); view.Glx.SwapBuffers(view.GdkWindow); args.RetVal = true; Gl.glDisable(Gl.GL_CONVOLUTION_2D); }
private void ExposeHandler(object source, ExposeEventArgs args) { if (imageNeedsUpdating) { UpdatePixbuf(); } }
void HandleExposeEvent(object sender, ExposeEventArgs args) { if (!up_to_date) { Task.Run(Update); } }
// Render the dirtied window void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); // Clear background cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Paint(); // Set the coordinate system origin at bottom left cr.Translate(0, area.Allocation.Height); cr.Scale(1.0, -1.0); // Render all Drawables, resetting the coordinate transform for each foreach (Drawable d in drawable) { cr.Save(); d.Draw(cr); cr.Restore(); } cr.GetTarget().Dispose(); ((IDisposable)cr).Dispose(); }
protected void OnCanvasExposeEvent(object o, ExposeEventArgs args) { if (game.Running) { board.Render(); } }
protected void OnDrawingarea1ExposeEvent(object o, ExposeEventArgs args) { Console.WriteLine("Exposed"); DrawingArea area = (DrawingArea)o; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width = area.Allocation.Width; int height = area.Allocation.Height; int radius = (width < height ? width : height); cr.SetSourceRGB(0.0, 0.0, 0.0); cr.Rectangle(0, 0, width, height); cr.Fill(); cr.Translate(this.offsetX, this.offsetY); // move "pointer" cr.Scale(this.scale, this.scale); cr.SetSourceSurface(this.surface, 0, 0); // offset surface cr.Rectangle(0, 0, this.surface.Width, // offset cutout this.surface.Height); cr.Fill(); // apply cr.SetSourceRGB(1.0, 0.0, 0.0); cr.Arc(this.pointX, this.pointY, 2, 0, 2 * Math.PI); cr.Fill(); ((IDisposable)cr.GetTarget()).Dispose(); ((IDisposable)cr).Dispose(); }
void OnDrawingareaExposeEvent(object o, ExposeEventArgs args) { if (!this.DockItem.ContentVisible) { return; } 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; if (m_Nodes.Count == 0) { var layout = new Pango.Layout(PangoContext) { FontDescription = Pango.FontDescription.FromString("Tahoma 12") }; var gc = new Gdk.GC(win) { RgbFgColor = Color.Blue.ToGdk(), }; var text = "Add some nodes by clicking into window.\n" + "Move nodes with the mouse.\n" + "Remove nodes by moving out of inner area"; layout.SetText(text); Drawing.DrawLayout(win, gc, layout, width / 2, height / 2, Drawing.Origin.Center, Drawing.Origin.Center); } lock (m_Nodes) { using (var context = Gdk.CairoHelper.Create(win)) { // collect all straight line segments var straights = new List <PointF>(); straights.Add(m_Nodes.FirstOrDefault()); // Draw connection if (m_Properties.DrawConnections) { DrawConnections(context); } // Draw text at connections if (m_Properties.DrawInformation) { DrawInfos(context); } // Calculate & draw clothoides CalculateAndDrawClothoides(context, straights); // Draw nodes DrawNodes(win, context); } } }
protected void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { var left = Allocation.Left; var width = Allocation.Width; var top = Allocation.Top; var bottom = Allocation.Bottom; var height = Allocation.Height; TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, 4.0); var outlineColor = new TouchColor(buttonColor); outlineColor.ModifyColor(0.5); var highlightColor = new TouchColor(buttonColor); highlightColor.ModifyColor(1.4); var lowlightColor = new TouchColor(buttonColor); lowlightColor.ModifyColor(0.75); using (var grad = new LinearGradient(left, top, left, bottom)) { grad.AddColorStop(0, highlightColor.ToCairoColor()); grad.AddColorStop(0.2, buttonColor.ToCairoColor()); grad.AddColorStop(0.85, lowlightColor.ToCairoColor()); cr.SetSource(grad); cr.FillPreserve(); } outlineColor.SetSource(cr); cr.LineWidth = 1; cr.Stroke(); render.Render(this, left + 3, top, width - 6, height); } }
/// <summary>The drawing canvas is being exposed to user.</summary> private void OnDrawingAreaExpose(object sender, ExposeEventArgs args) { try { DrawingArea area = (DrawingArea)sender; Cairo.Context context = Gdk.CairoHelper.Create(area.GdkWindow); foreach (DGArc tmpArc in arcs) { tmpArc.Paint(context); } foreach (DGNode tmpNode in nodes) { tmpNode.Paint(context); } ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); } catch (Exception err) { ShowError(err); } }
protected void OnDrawingarea1ExposeEvent(object o, ExposeEventArgs args) { foreach (var rect in rects) { args.Event.Window.DrawRectangle (Style.BlackGC, true, rect); args.Event.Window.DrawRectangle (Style.WhiteGC, false, rect); } }
void HandleExposeEvent(object o, ExposeEventArgs args) { using (Cairo.Context cr = Gdk.CairoHelper.Create(window.GdkWindow)) { cr.Scale((double)size / 128, (double)size / 128); cr.AlphaPaint(); int offset; switch ((int)Math.Floor(5 * AnimationState)) { case 0: offset = 0; break; case 1: offset = 128; break; case 2: offset = 128 * 2; break; case 3: offset = 128 * 3; break; default: offset = 128 * 4; break; } Gdk.CairoHelper.SetSourcePixbuf(cr, poof, 0, -(offset)); cr.Paint(); (cr.Target as IDisposable).Dispose(); } }
protected void OnTabExpose(object o, ExposeEventArgs args) { if (needs_initial_divisors_done) { InitialDivisorPositions(); } }
private void OnExposeEvent(object sender, ExposeEventArgs args) { if (_background != null && sender is Widget w) { w.DrawResource(_background); } }
void HandleEventMinimizehandleExposeEvent(object o, ExposeEventArgs args) { if (!this.Visible) { return; } Gdk.GC button = new Gdk.GC(eventMinimize.GdkWindow); Gdk.Pixmap pixmap_mask; Pixmap pixmap; Gdk.Pixbuf pixbuf = null; if (this.MinimizeHover) { pixbuf = Images.Windows_MinimizeButton_Hover; } else { pixbuf = Images.Windows_MinimizeButton; } pixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255); button.Fill = Gdk.Fill.Tiled; button.Tile = pixmap; this.eventMinimize.GdkWindow.DrawRectangle(button, true, 0, 0, eventMinimize.WidthRequest, eventMinimize.HeightRequest); }
void HandleExposeEvent(object o, ExposeEventArgs args) { if (Capturer != null) { Capturer.Expose(); } }
void HandleWindowExposeEvent(object o, ExposeEventArgs args) { using (Cairo.Context cr = Gdk.CairoHelper.Create(args.Event.Window)) { cr.Operator = Operator.Source; if (currentSurface == null || currentSurface.Internal == null) { cr.Color = new Cairo.Color(1, 1, 1, 0); } else { if (background_buffer == null) { background_buffer = new DockySurface(currentSurface.Width, currentSurface.Height, cr.Target); DrawBackground(background_buffer); } background_buffer.Internal.Show(cr, 0, 0); cr.Operator = Operator.Over; cr.SetSource(currentSurface.Internal); } cr.Paint(); (cr.Target as IDisposable).Dispose(); } }
void HandleExposeEvent(object sender, ExposeEventArgs args) { if (!up_to_date) { update_delay.Start(); } }
private void img_Icon_ExposeEvent(object o, ExposeEventArgs args) { if ((int)this.BackGroundColor.Blue != (int)this.selectedColor.Blue) { return; } ImageBin imgIcon = this.img_Icon; int num1 = 5; int num2 = imgIcon.Allocation.X - num1; int num3 = imgIcon.Allocation.Y - num1; int num4 = imgIcon.Allocation.X + imgIcon.Allocation.Width - 1 + num1; int num5 = imgIcon.Allocation.Y - num1; int num6 = imgIcon.Allocation.X + imgIcon.Allocation.Width - 1 + num1; int num7 = imgIcon.Allocation.Y + imgIcon.Allocation.Height - 1 + num1; int num8 = imgIcon.Allocation.X - num1; int num9 = imgIcon.Allocation.Y + imgIcon.Allocation.Height - 1 + num1; EventBox parentWidget = imgIcon.GetParentWidget <EventBox>(); if (parentWidget != null) { GC gc1 = new GC((Drawable)parentWidget.GdkWindow); gc1.RgbFgColor = this.unSelectedColor; parentWidget.GdkWindow.DrawRectangle(gc1, true, new Rectangle(0, 0, parentWidget.Allocation.Width, parentWidget.Allocation.Height)); gc1.RgbFgColor = this.selectedColor; parentWidget.GdkWindow.DrawRectangle(gc1, true, new Rectangle(num2, num3, num4 - num2, num7 - num5)); GC gc2 = new GC((Drawable)parentWidget.GdkWindow); gc2.RgbFgColor = this.BorderColor; parentWidget.GdkWindow.DrawLine(gc2, num2, num3, num4, num5); parentWidget.GdkWindow.DrawLine(gc2, num4, num5, num6, num7); parentWidget.GdkWindow.DrawLine(gc2, num6, num7, num8, num9); parentWidget.GdkWindow.DrawLine(gc2, num8, num9, num2, num3); } }
public void OnExposed(object o, ExposeEventArgs args) // создание графика в области рисования { double bp = scale; // масштабирование графика label7.Text = Convert.ToString(bp); label13.Text = Convert.ToString(bp - (bp / 5)); label14.Text = Convert.ToString(bp - (bp / 5) * 2); label15.Text = Convert.ToString(bp - (bp / 5) * 3); label16.Text = Convert.ToString(bp - (bp / 5) * 4); // рисование горизонтальных линий для удобства восприятия графика for (int x = 40; x < 170; x += 40) { drawingarea1.GdkWindow.DrawLine(drawingarea1.Style.BaseGC(StateType.Normal), 0, x, 200, x); } // вывод столбцов графика int xx = 3; for (int y = 0; y < 10; y++) { drawingarea1.GdkWindow.DrawRectangle (drawingarea1.Style.BaseGC(StateType.Normal), true, xx, 200 - realData[y] + 2, 16, 200); xx += 19; } }
private void OnExposed(object o, ExposeEventArgs args) { Rectangle area = args.Event.Region.Clipbox; GdkWindow.DrawRectangle(Style.BackgroundGC(StateType.Normal), true, area.X, area.Y, area.Width, area.Height); if (field != null) { if (pixmap == null) { FieldRegion region; pixmap = new Pixmap(GdkWindow, (int)(field.Width * zoomLevel), (int)(field.Height * zoomLevel), -1); region = new FieldRegion(); region.Left = region.Bottom = 0; region.Right = field.Width - 1; region.Top = field.Height - 1; renderer.RenderToDrawable(pixmap, Style.BlackGC, region, null); } GdkWindow.DrawDrawable(Style.BlackGC, pixmap, area.X, area.Y, area.X, area.Y, area.Width, area.Height); if (selection != null) { renderer.RenderToDrawable(GdkWindow, Style.BlackGC, selection, selection); } } }
protected virtual void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { TouchColor.SetSource(cr, "grey3", 0.75); double midY = 272.5; for (int i = 0; i < 3; ++i) { cr.MoveTo(60 + (i * 185), midY); cr.LineTo(220 + (i * 185), midY); cr.ClosePath(); cr.Stroke(); cr.MoveTo(232.5 + (i * 185), 115); cr.LineTo(232.5 + (i * 185), 425); cr.ClosePath(); cr.Stroke(); } cr.MoveTo(615, midY); cr.LineTo(775, midY); cr.ClosePath(); cr.Stroke(); } }
/// <summary> /// Triggered when the drawing area is exposed. /// </summary> private void OnExposed( object sender, ExposeEventArgs args) { // Check for a sort if (sortNext) { sprites.Sort(); sortNext = false; } // Clear out the entire graphics area with black (just // because we can). This also erases the prior rendering. Rectangle region = args.Event.Area; GC gc = new GC(pixmap); gc.ClipRectangle = region; // Render ourselves viewport.Render(pixmap, region); // This performs the actual drawing args.Event.Window.DrawDrawable( Style.BlackGC, pixmap, region.X, region.Y, region.X, region.Y, region.Width, region.Height); args.RetVal = false; exposeCount++; }
void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); IcnRecode icn = new IcnRecode(project, 1920, 1080, (x, y, w, h, s) => { x *= scale; y *= scale; w *= scale; h *= scale; x += X; y += Y; w += X; h += Y; cr.Save(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = s * 0.7; cr.MoveTo(x, y); cr.LineTo(w, h); cr.ClosePath(); cr.Stroke(); cr.Restore(); }); icn.Exec(); cr.Dispose(); }
public void DrawToSpace(string name, ExposeEventArgs args) { Bitmap bm = images [name]; Gdk.Window window = args.Event.Window; int xs = 0; int ys = 0; args.Event.Window.GetSize(out xs, out ys); if (xs < bm.Width) { xs = bm.Width; } if (ys < bm.Height) { ys = bm.Height; } args.Event.Window.Resize(xs, ys); if (images.Count > 0) { Rectangle rect = new Rectangle(0, 0, bm.Width, bm.Height); using (System.Drawing.Graphics graphics = Gtk.DotNet.Graphics.FromDrawable(window)) { graphics.DrawImage(bm, rect); } } }
void OnDrawingAreaExposed(object o, ExposeEventArgs args) { if (prevSize != Allocation.Size) { if (model != null) treeMapModel = new TreeMapModel(model, Allocation.Width, Allocation.Height); } DrawingArea area = (DrawingArea)o; Cairo.Context g = Gdk.CairoHelper.Create(area.GdkWindow); if (treeMapModel != null) { foreach (var item in treeMapModel.Items) { double width = item.Rectangle.Width; double height = item.Rectangle.Height; double x1 = item.Rectangle.X; double x2 = item.Rectangle.X + item.Rectangle.Width; double y1 = item.Rectangle.Y; double y2 = item.Rectangle.Y + item.Rectangle.Height; PointD p1, p2, p3, p4; p1 = new PointD(x1, y1); p2 = new PointD(x2, y1); p3 = new PointD(x2, y2); p4 = new PointD(x1, y2); g.MoveTo(p1); g.LineTo(p2); g.LineTo(p3); g.LineTo(p4); g.LineTo(p1); g.ClosePath(); g.Save(); //using (Gradient pat = new LinearGradient(x1, y1, x2, y2)) using (Gradient pat = new RadialGradient(x1 + (x2 - x1) / 4.0, y1 + (y2 - y1) / 4.0, 3, x1 + (x2 - x1) / 4.0, y1 + (y2 - y1) / 4.0, Math.Sqrt(width*width + height*height))) { pat.AddColorStop(0, new Cairo.Color(1, 1, 1, 1)); pat.AddColorStop(1, new Cairo.Color(0, 0, 1, 1)); g.Pattern = pat; // Fill the path with pattern g.FillPreserve(); } // We "undo" the pattern setting here g.Restore(); g.Color = new Color(0, 0, 0, 0); g.Stroke(); } } ((IDisposable)g.Target).Dispose(); ((IDisposable)g).Dispose(); }
public void HandleExposeEvent (object sender, ExposeEventArgs args) { if (fade_delay == null) { fade_delay = new Delay (50, new GLib.IdleHandler (Update)); start = DateTime.Now; fade_delay.Start (); } }
void HandleExposeEvent(object o, ExposeEventArgs args) { MakeCurrent(); OnRender(); SwapBuffers(); }
protected virtual void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(this.GdkWindow)) { cr.Rectangle(Allocation.Left, Allocation.Top, Allocation.Width, Allocation.Height); color.SetSource(cr); cr.Fill(); } }
private void OnChildExposeEvent(object o, ExposeEventArgs args) { if(interactive) { InteractiveExpose((Widget)o, args.Event); } else { StaticExpose((Widget)o, args.Event); } }
// This is a workaround for bug https://bugzilla.xamarin.com/show_bug.cgi?id=10904 void HandleExposeEvent(object o, ExposeEventArgs args) { if (indeterminateMessage != null && !Widget.Numeric) { Widget.Text = indeterminateMessage; } Widget.ExposeEvent -= HandleExposeEvent; }
private void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); cr.LineWidth = 2; cr.SetSourceRGB(0.7, 0.2, 0.0); }
void OnExposed(object o, ExposeEventArgs args) { if (pos != -1) { widget.Position = pos; } pos = -1; }
void RotatedTextExposeEvent (object sender, ExposeEventArgs a) { DrawingArea drawingArea = sender as DrawingArea; int width = drawingArea.Allocation.Width; int height = drawingArea.Allocation.Height; double deviceRadius; // Get the default renderer for the screen, and set it up for drawing Gdk.PangoRenderer renderer = Gdk.PangoRenderer.GetDefault (drawingArea.Screen); renderer.Drawable = drawingArea.GdkWindow; renderer.Gc = drawingArea.Style.BlackGC; // Set up a transformation matrix so that the user space coordinates for // the centered square where we draw are [-RADIUS, RADIUS], [-RADIUS, RADIUS] // We first center, then change the scale deviceRadius = Math.Min (width, height) / 2; Matrix matrix = Pango.Matrix.Identity; matrix.Translate (deviceRadius + (width - 2 * deviceRadius) / 2, deviceRadius + (height - 2 * deviceRadius) / 2); matrix.Scale (deviceRadius / RADIUS, deviceRadius / RADIUS); // Create a PangoLayout, set the font and text Context context = drawingArea.CreatePangoContext (); Pango.Layout layout = new Pango.Layout (context); layout.SetText ("Text"); FontDescription desc = FontDescription.FromString ("Sans Bold 27"); layout.FontDescription = desc; // Draw the layout N_WORDS times in a circle for (int i = 0; i < N_WORDS; i++) { Gdk.Color color = new Gdk.Color (); Matrix rotatedMatrix = matrix; int w, h; double angle = (360 * i) / N_WORDS; // Gradient from red at angle == 60 to blue at angle == 300 color.Red = (ushort) (65535 * (1 + Math.Cos ((angle - 60) * Math.PI / 180)) / 2); color.Green = 0; color.Blue = (ushort) (65535 - color.Red); renderer.SetOverrideColor (RenderPart.Foreground, color); rotatedMatrix.Rotate (angle); context.Matrix = rotatedMatrix; // Inform Pango to re-layout the text with the new transformation matrix layout.ContextChanged (); layout.GetSize (out w, out h); renderer.DrawLayout (layout, - w / 2, (int) (- RADIUS * Pango.Scale.PangoScale)); } // Clean up default renderer, since it is shared renderer.SetOverrideColor (RenderPart.Foreground, Gdk.Color.Zero); renderer.Drawable = null; renderer.Gc = null; }
/// <summary> /// Handles ExposeEvents by obtaining a GC from the Gdk.Window /// and copying the PlotSurface from the cache to the screen /// </summary> private void da_ExposeEvent(object o, ExposeEventArgs args) { Gdk.Rectangle area = args.Event.Area; using (Graphics g = Gtk.DotNet.Graphics.FromDrawable (args.Event.Window)){ Rectangle bounds = new Rectangle (area.X, area.Y, area.Width, area.Height); g.DrawImage (bitmap_cache, bounds, bounds, GraphicsUnit.Pixel); } args.RetVal = true; }
static void ExposeEvent (object obj, ExposeEventArgs args) { Gdk.Rectangle area = args.Event.Area; args.Event.Window.DrawDrawable (darea.Style.ForegroundGC(darea.State), pixmap, area.X, area.Y, area.X, area.Y, area.Width, area.Height); args.RetVal = false; }
static void OnExposed (object o, ExposeEventArgs args) { if (current_frame == null) return; current_frame.RenderToDrawable (drawing_area.GdkWindow, drawing_area.Style.ForegroundGC (StateType.Normal), 0, 0, 0, 0, -1, -1, RgbDither.None, 0, 0); }
void HandleMyWinExposeEvent(object o, ExposeEventArgs args) { GLib.Idle.Add (new GLib.IdleHandler (delegate() { if (cr == null) { Gtk.Widget widget = ((Gtk.Widget)o); cr = Gdk.CairoHelper.Create (widget.GdkWindow); } WindowController.DrawPixbuf (cr, pixbuf); return false; })); }
protected void OnGraphEventBoxExposeEvent(object o, ExposeEventArgs args) { if (((DrawingArea)o).GdkWindow != null) { using(ImageSurface tmpSurface = new ImageSurface(Format.Rgb24, ((DrawingArea)o).Allocation.Width, ((DrawingArea)o).Allocation.Height)) using(GtkGraphDrawer drawer = new GtkGraphDrawer(Gdk.CairoHelper.Create(((DrawingArea)o).GdkWindow), new Context(tmpSurface), tmpSurface)) { BaseGraph.DrawFullGraph (drawer); } } }
static void ExposeHandler (object obj, ExposeEventArgs args) { Gdk.EventExpose ev = args.Event; Gdk.Window window = ev.Window; using (Graphics g = Gtk.DotNet.Graphics.FromDrawable (window)){ g.TranslateTransform (ev.Area.X, ev.Area.Y); using (Pen p = new Pen (Color.Red)){ g.DrawPie (p, 0, 0, rect.Width, rect.Height, 50, 90); } } }
// Expose callback for the drawing area private void ExposeEventCallback (object o, ExposeEventArgs args) { EventExpose eventExpose = args.Event; Gdk.Window window = eventExpose.Window; Rectangle area = eventExpose.Area; window.DrawRectangle (drawingArea.Style.BackgroundGC (StateType.Normal), true, area.X, area.Y, area.Width, area.Height); args.RetVal = true; }
void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width = Allocation.Width; int height = Allocation.Height; cr.Translate(width / 2, height / 2); // { cr.LineWidth = 3; cr.LineCap = LineCap.Round; const int MAX_ROT = 8; for (int i = 0; i < MAX_ROT; i++) { cr.SetSourceRGBA(0, 0, 0, trs[count%MAX_ROT, i]); cr.MoveTo(0.0, -10.0); cr.LineTo(0.0, -40.0); cr.Rotate(Math.PI / 4); cr.Stroke(); } } // draw donut { //cr.SetSourceRGBA(0, 0, 0, 1); cr.LineWidth = 0.5; cr.Arc(0, 0, 120, 0, 2 * Math.PI); cr.Stroke(); cr.Save(); const int MAX_ROT = 36; for (int i = 0; i < MAX_ROT; i++) { //cr.SetSourceRGBA(0, 0, 0, 1); cr.Rotate(i * Math.PI / MAX_ROT); cr.Scale(0.3, 1); cr.Arc(0, 0, 120, 0, 2 * Math.PI); cr.Restore(); cr.Stroke(); cr.Save(); } } ((IDisposable) cr.GetTarget()).Dispose(); ((IDisposable) cr).Dispose(); }
static void HandleExposeEvent (object sender, ExposeEventArgs expose_args) { Widget w = (Widget)sender; using (Cairo.Context ctx = CompositeHelper.Create (w.GdkWindow)){ double opacity = 0; ctx.Operator = Cairo.Operator.Source; if (moon_host.Content is Moon.Windows.Desktop.Window) opacity = ((Moon.Windows.Desktop.Window)moon_host.Content).WindowOpacity; ctx.Color = new Cairo.Color (1.0, 1.0, 1.0, opacity); CompositeHelper.Region (ctx, expose_args.Event.Region); ctx.Fill (); } }
static void ExposeHandler (object o, ExposeEventArgs args) { Console.WriteLine ("exposed"); Widget widget = o as Widget; //using (Cairo.Context cr = new Cairo.Context (surface)) { cr.Save (); cr.Rectangle (0, 0, widget.Allocation.Width, widget.Allocation.Height); //cr.Color = new Color ( 1, 1, 1, 1); Gdk.CairoHelper.SetSourceColor (cr, widget.Style.Background (widget.State)); cr.Fill (); cr.Restore (); cr.Save (); cr.LineWidth = 1; cr.MoveTo (10, 10); cr.LineTo (20, 10); cr.LineTo (20, 20); cr.LineTo (10, 20); cr.ClosePath (); cr.Color = new Cairo.Color ( 0, 0, 0, 1); cr.Fill (); cr.Restore (); //NDesk.Glitz.Context ctx = new NDesk.Glitz.Context (ggd, ggd.Format); //Console.WriteLine (ggs.ValidTarget); //Console.WriteLine ("proc ptr: " + ctx.GetProcAddress ("glBindProgramARB")); //ctx.MakeCurrent (ggd); //GlHelper.Draw (); //GlHelper.DrawT (); ggs.Flush (); if (doublebuffer) ggd.SwapBuffers (); else ggd.Flush (); args.RetVal = true; //args.RetVal = false; //} }
protected void OnDrawingarea1ExposeEvent (object o, ExposeEventArgs args) { var cw = new ContextWrapper (o); cw.Translate (cw.Center); cw.Context.LineWidth = 1; cw.Circle (0, 0, 50); cw.Context.StrokePreserve (); cw.PushColor (); cw.Color = new Color2 ("#FFC0CB"); cw.Context.Fill (); cw.Circle (-50, -50, 100); cw.PopColor (); cw.Context.StrokePreserve (); cw.Color = new Color2 ("yellow", 0.5); cw.Context.Fill (); cw.Color = new Color2 ("black"); cw.RoundedRectangle (new Rectangle(50, 50, 100, 50), 15); cw.Context.Stroke (); cw.Context.IdentityMatrix (); cw.Translate (cw.Center); var rnd = new Random (); var points = new PointD[15]; for (var i = 0; i < points.Length; i++) { var p = new PointD (rnd.Next (200) - 100, rnd.Next (200) - 100); points[i] = p; } cw.Polygon (points); cw.Context.StrokePreserve (); cw.Context.Fill (); cw.Close (); }
void OnExposed (object sender, ExposeEventArgs e) { Context cr = Gdk.CairoHelper.Create (da.GdkWindow); int w, h; da.GdkWindow.GetSize (out w, out h); // set window bg cr.ColorRgb = new Color (1, 1, 1 ); cr.Rectangle (0, 0, w, h); cr.Fill (); // reset it cr.ColorRgb = new Color (0, 0, 0); Snippets.InvokeSnippet (snips, selected, cr, w, h); e.RetVal = true; }
protected void OnDrawPlayPauseExposeEvent(object o, ExposeEventArgs args) { using(Context context = Gdk.CairoHelper.Create (((DrawingArea)o).GdkWindow)) { context.Rectangle(0, 0, 16, 16); context.SetSourceRGB(.8, .8, .8); context.Fill(); context.LineWidth = 1; if(_playing) { if (_mode == ProgramMode.Presentation) { context.SetSourceRGB (1.0, 0.0, 0.0); } else { context.SetSourceRGB (0.4, 0.4, 0.4); } context.MoveTo (2, 2); context.LineTo (2, 13); context.LineTo (13, 13); context.LineTo (13, 2); context.LineTo (2, 2); context.StrokePreserve(); context.MoveTo (7, 7); context.Fill(); } else { if (_mode == ProgramMode.Presentation) { context.SetSourceRGB (0.0, 1.0, 0.0); } else { context.SetSourceRGB (0.4, 0.4, 0.4); } context.MoveTo (3, 1); context.LineTo (3, 14); context.LineTo (12, 8); context.LineTo (12, 7); context.LineTo (3, 1); context.StrokePreserve(); context.MoveTo (7, 7); context.Fill(); } } }
// Expose callback for the drawing area void Expose (object o, ExposeEventArgs args) { Widget widget = (Widget) o; Gdk.Rectangle area = args.Event.Area; byte[] pixels; int rowstride; rowstride = frame.Rowstride; pixels = new byte[(frame.Height - area.Y) * rowstride]; IntPtr src = (IntPtr)(frame.Pixels.ToInt64 () + rowstride * area.Y + area.X * 3); Marshal.Copy (src, pixels, 0, pixels.Length); widget.GdkWindow.DrawRgbImageDithalign (widget.Style.BlackGC, area.X, area.Y, area.Width, area.Height, Gdk.RgbDither.Normal, pixels, rowstride, area.X, area.Y); args.RetVal = true; }
private void OnBannerExposed(object o, ExposeEventArgs args) { if(args.Event.Count > 0) return; Gdk.Pixbuf spb = ScaledPixbuf.ScaleSimple(iFolderScaledBanner.Allocation.Width, iFolderScaledBanner.Allocation.Height, Gdk.InterpType.Nearest); Gdk.GC gc = new Gdk.GC(iFolderScaledBanner.GdkWindow); spb.RenderToDrawable(iFolderScaledBanner.GdkWindow, gc, 0, 0, args.Event.Area.X, args.Event.Area.Y, args.Event.Area.Width, args.Event.Area.Height, Gdk.RgbDither.Normal, 0, 0); }
void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea) sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); cr.LineWidth = 9; cr.SetSourceRGB(.55,.56,0); int width, height; width = Allocation.Width; height = Allocation.Height; cr.Translate(width/2, height/2); cr.Arc(0,0, (width<height ? width : height) / 2-10,0,2*Math.PI); cr.StrokePreserve(); cr.SetSourceRGBA(.5,.35,0,1.0); cr.Fill(); ((IDisposable) cr.GetTarget()).Dispose(); ((IDisposable) cr).Dispose(); }
protected void OnCameraAreaExposeEvent(object sender, ExposeEventArgs args) { if (imagePixBuf == null) return; DrawingArea area = (DrawingArea)sender; using (Cairo.Context cx = Gdk.CairoHelper.Create(area.GdkWindow)) { var x = (area.Allocation.Width - cam_width) / 2; var y = (area.Allocation.Height - cam_height) / 2; lock (imageBuffer) { Gdk.CairoHelper.SetSourcePixbuf(cx, imagePixBuf, x, y); cx.Rectangle(x, y, cam_width, cam_height); cx.Fill(); } } }
private void Window_OnExpose(object sender, ExposeEventArgs args) { Gdk.EventExpose evnt = args.Event; Context cr = Gdk.CairoHelper.Create (GdkWindow); /*if(composeAvailable) cr.SetSourceRGBA (0, 0, 0, 0.3); else*/ cr.SetSourceRGB (0.3, 0.3, 0.3); //cr.SetSourceRGB (0.749, 0.859, 1.0); cr.Operator = Operator.Source; cr.Paint (); ((IDisposable)cr.Target).Dispose(); ((IDisposable)cr).Dispose(); args.RetVal = false; }
private void OnChildExposeEvent(object o, ExposeEventArgs args) { // NOTE: This is a little insane, but it allows packing of EventBox based widgets // into a GtkMenuItem without breaking the theme (leaving an unstyled void in the item). // This method is called before the EventBox child does its drawing and the background // is filled in with the proper style. int x, y, width, height; Widget widget = (Widget)o; if(IsSelected) { x = Allocation.X - widget.Allocation.X; y = Allocation.Y - widget.Allocation.Y; width = Allocation.Width; height = Allocation.Height; ShadowType shadow_type = (ShadowType)StyleGetProperty("selected-shadow-type"); Gtk.Style.PaintBox(Style, widget.GdkWindow, StateType.Prelight, shadow_type, args.Event.Area, widget, "menuitem", x, y, width, height); } else { // Fill only the visible area in solid color, to be most efficient widget.GdkWindow.DrawRectangle(Parent.Style.BackgroundGC(StateType.Normal), true, 0, 0, widget.Allocation.Width, widget.Allocation.Height); // FIXME: The above should not be necessary, but Clearlooks-based themes apparently // don't provide any style for the menu background so we have to fill it first with // the correct theme color. Weak. // // Do a complete style paint based on the size of the entire menu to be compatible with // themes that provide a real style for "menu" x = Parent.Allocation.X - widget.Allocation.X; y = Parent.Allocation.Y - widget.Allocation.Y; width = Parent.Allocation.Width; height = Parent.Allocation.Height; Gtk.Style.PaintBox(Style, widget.GdkWindow, StateType.Normal, ShadowType.Out, args.Event.Area, widget, "menu", x, y, width, height); } }
protected void OnDrawWeatherExposeEvent(object o, ExposeEventArgs args) { Gdk.Color back = Style.Background(StateType.Normal); Gdk.Color fore = Style.Foreground(StateType.Normal); Drawable draw = drawWeather.GdkWindow; Gdk.GC gc = new Gdk.GC(draw); try { gc.Foreground = back; gc.Background = back; int width; int height; draw.GetSize(out width, out height); draw.DrawRectangle(gc, true, 0, 0, width, height); gc.Foreground = fore; String text = ""; if (Weather.Forecasts.Count > SelectedForecast) { WeatherService.WeatherPeriod info = Weather.Forecasts[SelectedForecast]; text = info.Title + " - " + info.Forecast + "\n"; } Pango.FontDescription font = Pango.FontDescription.FromString("Serif 14"); Pango.Layout layout = drawWeather.CreatePangoLayout(text); layout.FontDescription = font; layout.Width = Pango.Units.FromPixels(width); draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back); layout.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } gc.Dispose(); }
private void OnExpose(object o, ExposeEventArgs args) { //// OpenGL BEGIN ** m_gl.MakeCurrent (); Gl.glClear (Gl.GL_COLOR_BUFFER_BIT); Gl.glBegin (Gl.GL_TRIANGLES); Gl.glIndexi ((int)ColorApp.RED.Pixel); Gl.glColor3f (1.0f, 0, 0); Gl.glVertex2i (0, 1); Gl.glIndexi ((int)ColorApp.GREEN.Pixel); Gl.glColor3f (0, 1.0f, 0); Gl.glVertex2i (-1, -1); Gl.glIndexi ((int)ColorApp.BLUE.Pixel); Gl.glColor3f (0, 0, 1.0f); Gl.glVertex2i (1, -1); Gl.glEnd (); m_gl.SwapBuffers (); //// OpenGL END ** }
void HandleExposeEvent(object o, ExposeEventArgs args) { Pixbuf frame; int width, height, allocWidth, allocHeight, logoX, logoY; float ratio; if (Background == null) return; width = Background.Width; height = Background.Height; allocWidth = Allocation.Width; allocHeight = Allocation.Height; frame = new Pixbuf (Colorspace.Rgb, false, 8, this.Allocation.Width, this.Allocation.Height); ratio = Math.Min ((float)allocWidth / (float)width, (float)allocHeight / (float)height); logoX = (int)((allocWidth / 2) - (width * ratio / 2)); logoY = (int)((allocHeight / 2) - (height * ratio / 2)); /* Scaling to available space */ Background.Composite (frame, 0, 0, allocWidth, allocHeight, logoX, logoY, ratio, ratio, InterpType.Bilinear, 255); /* Drawing our frame */ frame.RenderToDrawable (drawingarea.GdkWindow, Style.BlackGC, 0, 0, args.Event.Area.X, args.Event.Area.Y, args.Event.Area.Width, args.Event.Area.Height, RgbDither.Normal, args.Event.Area.X, args.Event.Area.Y); frame.Dispose (); return; }
static void SuppressExpose (object o, ExposeEventArgs args) { args.RetVal = true; }
private void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = sender as DrawingArea; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width = Allocation.Width; int height = Allocation.Height; // Draw Rectangle { cr.SetSourceRGB(0.2, 0.23, 0.9); cr.LineWidth = 1; cr.Rectangle(20, 20, 120, 80); cr.Rectangle(180, 20, 80, 80); cr.StrokePreserve(); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } // Draw general Circle { cr.SetSourceRGB(0.2, 0.23, 0.9); cr.Arc(330, 60, 40, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } // draw circular sector (부채꼴) { cr.SetSourceRGB(0.2, 0.23, 0.9); cr.Arc(90, 160, 40, Math.PI / 4, Math.PI); cr.ClosePath(); cr.StrokePreserve(); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } { cr.SetSourceRGB(0.2, 0.23, 0.9); cr.Translate(220, 180); cr.Scale(1, 0.7); cr.Arc(0, 0, 50, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } // draw color rectagles cr.Translate(-220, -180); { cr.SetSourceRGB(0.2, 0.23, 0.9); cr.Rectangle(200, 450, 90, 60); cr.Fill(); cr.SetSourceRGB(0.9, 0.1, 0.1); cr.Rectangle(330, 450, 90, 60); cr.Fill(); cr.SetSourceRGB(0.4, 0.9, 0.4); cr.Rectangle(460, 450, 90, 60); cr.Fill(); } // draw transparent rect { for (int i = 0; i < 10; i++) { cr.SetSourceRGBA(0, 0, 1, (i + 1) * 0.1); cr.Rectangle(50*(i + 1), 400, 40, 40); cr.Fill(); } } // show Text { cr.SetSourceRGB(0.1, 0.1, 0.1); cr.SelectFontFace("SignPainter", FontSlant.Normal, FontWeight.Bold); cr.SetFontSize(20); cr.MoveTo(20, 500); cr.ShowText("Most relationships seem so transitory "); cr.MoveTo(20, 530); cr.ShowText("They're all goot but not the permanent one"); } // Draw Filled Circle { cr.LineWidth = 9; cr.SetSourceRGB(0.7, 0.2, 0.0); // 중심점을 정중앙으로. cr.Translate(width / 2, height / 2); //cr.Arc(0, 0, (width < height ? width : height) / 2 - 10, 0, 2 * Math.PI); cr.Arc(0, 0, 50, 0, 2*Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(0.3, 0.4, 0.6); cr.Fill(); } ((IDisposable)cr.GetTarget()).Dispose(); ((IDisposable)cr).Dispose(); }
void OnExposed1 (object o, ExposeEventArgs args) { da1.GdkWindow.DrawLine(da.Style.BaseGC(StateType.Normal), 0, 0, 400, 300); }