private bool DragUpdate() { if (!dragging) { return(false); } if (!rotate) { return(MoveWindow()); } else { Gdk.Point initial = start_root; Gdk.Point hot = start_hot; Gdk.Point win = Gdk.Point.Zero; hot.X += win.X; hot.Y += win.Y; initial.X -= hot.X; initial.Y -= hot.Y; Gdk.Point now = root_pos; now.X -= hot.X; now.Y -= hot.Y; Vector v1 = new Vector(initial); Vector v2 = new Vector(now); double angle = Vector.AngleBetween(v1, v2); Angle = start_angle + angle; return(false); } }
private void HandleButtonPressEvent(object sender, ButtonPressEventArgs args) { switch (args.Event.Type) { case Gdk.EventType.ButtonPress: if (args.Event.Button == 1) { start = new Gdk.Point((int)args.Event.X, (int)args.Event.Y); start_root = new Gdk.Point((int)args.Event.XRoot, (int)args.Event.YRoot); start_hot = hotspot; Gdk.Point win; GdkWindow.GetOrigin(out win.X, out win.Y); start_hot.X += win.X; start_hot.Y += win.Y; dragging = true; rotate = (args.Event.State & Gdk.ModifierType.ShiftMask) > 0; start_angle = Angle; } else { Angle += Math.PI / 8; } break; case Gdk.EventType.TwoButtonPress: dragging = false; this.Destroy(); break; } }
public void UpdatePosition() { if (_contentElement == null || _currentInputWidget == null) { return; } var textInputLayer = GetWindowTextInputLayer(); if (!textInputLayer.Children.Contains(_currentInputWidget)) { return; } var transformToRoot = _contentElement.TransformToVisual(Windows.UI.Xaml.Window.Current.Content); var point = transformToRoot.TransformPoint(new Point(0, 0)); var pointX = point.X; var pointY = point.Y; if (_lastPosition.X != pointX || _lastPosition.Y != pointY) { _lastPosition = new GdkPoint((int)pointX, (int)pointY); textInputLayer.Move(_currentInputWidget, _lastPosition.X, _lastPosition.Y); } }
private void HandleImageViewMotion(object sender, MotionNotifyEventArgs args) { Gdk.Point coords; coords = new Gdk.Point((int)args.Event.X, (int)args.Event.Y); SetSamplePoint(view.WindowCoordsToImage(coords)); }
unsafe void DrawPickerCircle(Cairo.ImageSurface surface, int radius) { int width = surface.Width; int height = surface.Height; byte *data = (byte *)surface.DataPtr; Gdk.Point center = new Gdk.Point(width / 2, height / 2); Color pixelColor = new Color(); pixelColor.Saturation = Saturation; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { double deltaX = x - center.X; double deltaY = y - center.Y; double lumin = 1.0 - Math.Sqrt(deltaX * deltaX + deltaY * deltaY) / (radius); if (lumin < -0.1) { continue; } pixelColor.Hue = ConvertAngleToHue(Math.Atan2(deltaY, deltaX)); pixelColor.Luminosity = lumin; byte *pixelData = data + y * surface.Stride + x * 4; pixelData [0] = (byte)(byte.MaxValue * pixelColor.B); pixelData [1] = (byte)(byte.MaxValue * pixelColor.G); pixelData [2] = (byte)(byte.MaxValue * pixelColor.R); } } }
void DrawColorOverlay(Cairo.Context context, Gdk.Point center, Color color) { double radius = 14.5; double angle = ConvertHueToAngle(color.Hue); double y = Math.Sin(angle) * Radius * (1.0 - color.Luminosity); double x = Math.Cos(angle) * Radius * (1.0 - color.Luminosity); context.Translate(x + center.X, y + center.Y + 1); context.Arc(0, 0, radius, 0, Math.PI * 2); context.Color = new Color(0, 0, 0, 0.3); context.LineWidth = 1; context.Stroke(); context.Translate(-(x + center.X), -(y + center.Y + 1)); context.Translate(x + center.X, y + center.Y); context.Arc(0, 0, radius, 0, Math.PI * 2); context.Color = color; context.Fill(); context.Translate(-(x + center.X), -(y + center.Y)); context.Translate(x + center.X, y + center.Y); context.Arc(0, 0, radius, 0, Math.PI * 2); context.Color = new Color(1, 1, 1); context.LineWidth = 1; context.Stroke(); context.Translate(-(x + center.X), -(y + center.Y)); }
/// <summary> /// Provides a default implementation for performing dst = F(dst, src) or F(src) over some rectangle /// of interest. May be slightly faster than calling the other multi-parameter Apply method, as less /// variables are used in the implementation, thus inducing less register pressure. /// </summary> /// <param name="dst">The Surface to write pixels to, and from which pixels are read and used as the lhs parameter for calling the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param> /// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param> /// <param name="src">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>b>.</param></param> /// <param name="srcOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the src Surface.</param> /// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param> public void ApplyBase(ImageSurface dst, Gdk.Point dstOffset, ImageSurface src, Gdk.Point srcOffset, Gdk.Size roiSize) { // Create bounding rectangles for each Surface Gdk.Rectangle dstRect = new Gdk.Rectangle(dstOffset, roiSize); if (dstRect.Width == 0 || dstRect.Height == 0) { return; } Gdk.Rectangle srcRect = new Gdk.Rectangle(srcOffset, roiSize); if (srcRect.Width == 0 || srcRect.Height == 0) { return; } // Clip those rectangles to those Surface's bounding rectangles Gdk.Rectangle dstClip = Gdk.Rectangle.Intersect(dstRect, dst.GetBounds()); Gdk.Rectangle srcClip = Gdk.Rectangle.Intersect(srcRect, src.GetBounds()); // If any of those Rectangles actually got clipped, then throw an exception if (dstRect != dstClip) { throw new ArgumentOutOfRangeException ( "roiSize", "Destination roi out of bounds" + string.Format(", dst.Size=({0},{1}", dst.Width, dst.Height) + ", dst.Bounds=" + dst.GetBounds().ToString() + ", dstOffset=" + dstOffset.ToString() + string.Format(", src.Size=({0},{1}", src.Width, src.Height) + ", srcOffset=" + srcOffset.ToString() + ", roiSize=" + roiSize.ToString() + ", dstRect=" + dstRect.ToString() + ", dstClip=" + dstClip.ToString() + ", srcRect=" + srcRect.ToString() + ", srcClip=" + srcClip.ToString() ); } if (srcRect != srcClip) { throw new ArgumentOutOfRangeException("roiSize", "Source roi out of bounds"); } // Cache the width and height properties int width = roiSize.Width; int height = roiSize.Height; // Do the work. unsafe { for (int row = 0; row < height; ++row) { ColorBgra *dstPtr = dst.GetPointAddress(dstOffset.X, dstOffset.Y + row); ColorBgra *srcPtr = src.GetPointAddress(srcOffset.X, srcOffset.Y + row); Apply(dstPtr, srcPtr, width); } } }
/// <summary> /// Update window size and position stashed for preferences. /// </summary> /// <returns><c>true</c> if this timer function should continue to be executed.</returns> /// <remarks>This is a HACK. Since we get ConfigureEvent updates of intermediate /// values during window state transitions to maximize, iconify, etc. we cannot /// rely upon those values. We also don't get notifications for simple movement /// of the window, either, unlike size requests. And the final straw is that we /// also cannot get the 'restore' size and position. So, the HACK is thus: /// When a ConfigureEvent arrives, if we haven't already, attach this timer /// object to the window. Otherwise, mark the timer's Continue value to <c>true</c>. /// When the timer fires, we *MIGHT* update the stored position and size. /// The kernel of this HACK is that WindowStateEvent fires in the time between the /// last 'valid' ConfigureEvent and the first firing of the timer.</remarks> private bool Tick() { var currentState = (Gdk.WindowState)Window.Data[Properties.Settings.WindowStateSettingName]; var ignore = (currentState & (SupportedRestoreStates | Gdk.WindowState.Iconified)) != 0; var keepGoing = Continue && !ignore; Continue = false; if (!ignore) { int width = 0; int height = 0; Window.GetSize(out width, out height); var newSize = new Gdk.Size(width, height); Window.Data[Properties.Settings.WindowSizeSettingName] = newSize; int top = 0; int left = 0; Window.GetPosition(out left, out top); var newPosition = new Gdk.Point(left, top); Window.Data[Properties.Settings.WindowPositionSettingName] = newPosition; } if (!keepGoing) { Window.Data.Remove(DataName); } return(keepGoing); }
/* CodeCompletionContext ICompletionWidget.CurrentCodeCompletionContext { * get { * return ICompletionWidget.CreateCodeCompletionContext (); * } * }*/ CodeCompletionContext ICompletionWidget.CreateCodeCompletionContext() { int triggerOffset = this.Caret.Offset; CodeCompletionContext result = new CodeCompletionContext(); result.TriggerOffset = triggerOffset; DocumentLocation loc = this.Document.OffsetToLocation(triggerOffset); result.TriggerLine = loc.Line + 1; result.TriggerLineOffset = loc.Column + 1; Gdk.Point p = this.DocumentToVisualLocation(loc); int tx = 0; int ty = 0; this.ParentWindow.GetOrigin(out tx, out ty); tx += this.Allocation.X; ty += this.Allocation.Y; result.TriggerXCoord = tx + p.X + this.TextViewMargin.XOffset - (int)this.HAdjustment.Value; result.TriggerYCoord = ty + p.Y - (int)this.VAdjustment.Value + this.LineHeight; result.TriggerTextHeight = this.LineHeight; return(result); }
void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity) { if (brandedIcon != null) { /* if (previewSurface == null) { * previewSurface = new SurfaceWrapper (context, brandedIcon); * } * double scale = PreviewSize / previewSurface.Width; * * context.Save (); * context.Translate (position.X, position.Y); * context.Scale (scale * IconScale, scale * IconScale); * context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2); * context.PaintWithAlpha (opacity); * context.Restore (); */ double scale = PreviewSize / brandedIcon.Width; context.Save(); context.Translate(position.X, position.Y); context.Scale(scale * IconScale, scale * IconScale); context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2); context.Restore(); } }
public WelcomePageFirstRun() { VisibleWindow = false; SetSizeRequest(WidgetSize.Width, WidgetSize.Height); string iconFile = BrandingService.GetString("ApplicationIcon"); if (iconFile != null) { iconFile = BrandingService.GetFile(iconFile); brandedIcon = Xwt.Drawing.Image.FromFile(iconFile); } TitleOffset = TextOffset = IconOffset = new Gdk.Point(); tracker = new MouseTracker(this); tracker.MouseMoved += (sender, e) => { ButtonHovered = new Gdk.Rectangle(ButtonPosistion, ButtonSize).Contains(tracker.MousePosition); }; tracker.HoveredChanged += (sender, e) => { if (!tracker.Hovered) { ButtonHovered = false; } }; }
protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { int x = (int)evnt.X; int y = (int)evnt.Y; var element = engine.InputNodeAt(root, x, y); HasFocus = true; MouseGrabNode = element; if (MouseGrabNode != null) { MouseGrabNode.CancelAnimations(); DragStart = new Gdk.Point(x, y); double dx = x; double dy = y; var point = engine.TransformPoint(MouseGrabNode.Parent, dx, dy); DragOffset = new Gdk.Point((int)(point.X - MouseGrabNode.X), (int)(point.Y - MouseGrabNode.Y)); var transformedPoint = engine.TransformPoint(MouseGrabNode, x, y); MouseGrabNode.ButtonPress(new ButtonEventArgs(transformedPoint.X, transformedPoint.Y, evnt.XRoot, evnt.YRoot, evnt.Button, (ModifierType)evnt.State)); } return(true); }
protected override bool OnKeyPressEvent(Gdk.EventKey evnt) { isInKeyStroke = true; try { // Handle keyboard menu popup if (evnt.Key == Gdk.Key.Menu || (evnt.Key == Gdk.Key.F10 && (evnt.State & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)) { this.menuPopupLocation = this.TextViewMargin.LocationToDisplayCoordinates(this.Caret.Location); this.menuPopupLocation.Y += this.TextViewMargin.LineHeight; this.ShowPopup(); return(true); } // Handle keyboard toolip popup /* if ((evnt.Key == Gdk.Key.F1 && (evnt.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask)) { * Gdk.Point p = this.TextViewMargin.LocationToDisplayCoordinates (this.Caret.Location); * this.mx = p.X; * this.my = p.Y; * this.ShowTooltip (); * return true; * } */ return(base.OnKeyPressEvent(evnt)); } finally { isInKeyStroke = false; } }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion ev) { SelectItem(null); Gdk.Point pt = new Gdk.Point((int)ev.X, (int)ev.Y); if (prelight_item != null) { if (prelight_item.Bounds.Contains(pt)) { return(true); } else { LinkItem item = prelight_item; prelight_item = null; QueueDrawArea(item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height); } } foreach (Item item in items) { if (item is LinkItem && item.Bounds.Contains(pt)) { prelight_item = item as LinkItem; QueueDrawArea(item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height); break; } } return(true); }
public MouseTracker(Gtk.Widget owner) { this.owner = owner; Hovered = false; MousePosition = new Gdk.Point(0, 0); owner.Events = owner.Events | Gdk.EventMask.PointerMotionMask; owner.MotionNotifyEvent += (object o, MotionNotifyEventArgs args) => { MousePosition = new Gdk.Point((int)args.Event.X, (int)args.Event.Y); if (MouseMoved != null) { MouseMoved(this, EventArgs.Empty); } }; owner.EnterNotifyEvent += (o, args) => { Hovered = true; if (HoveredChanged != null) { HoveredChanged(this, EventArgs.Empty); } }; owner.LeaveNotifyEvent += (o, args) => { Hovered = false; if (HoveredChanged != null) { HoveredChanged(this, EventArgs.Empty); } }; }
public MouseTracker (Gtk.Widget owner) { this.owner = owner; Hovered = false; MousePosition = new Gdk.Point(0, 0); owner.Events = owner.Events | Gdk.EventMask.PointerMotionMask; owner.MotionNotifyEvent += (object o, MotionNotifyEventArgs args) => { MousePosition = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y); if (MouseMoved != null) MouseMoved (this, EventArgs.Empty); }; owner.EnterNotifyEvent += (o, args) => { Hovered = true; if (HoveredChanged != null) HoveredChanged (this, EventArgs.Empty); }; owner.LeaveNotifyEvent += (o, args) => { Hovered = false; if (HoveredChanged != null) HoveredChanged (this, EventArgs.Empty); }; }
public void SelectSizingSide(Gdk.Point localMousePos) { Gdk.Size windowSize = Gdk.Size.Empty; { int vw, vh; this._window.GdkWindow.GetSize(out vw, out vh); windowSize.Width = vw; windowSize.Height = vh; } _isSizingSide = E_SIZING_SIDE.E_NONE; if (localMousePos.X < _marginSize) { _isSizingSide |= E_SIZING_SIDE.E_LEFT_SIDE; } else if (localMousePos.X >= windowSize.Width - _marginSize) { _isSizingSide |= E_SIZING_SIDE.E_RIGHT_SIDE; } if (localMousePos.Y < _marginSize) { _isSizingSide |= E_SIZING_SIDE.E_TOP_SIDE; } else if (localMousePos.Y >= windowSize.Height - _marginSize) { _isSizingSide |= E_SIZING_SIDE.E_BOTTOM_SIDE; } }
protected virtual void MouseDown(object o, Gtk.ButtonPressEventArgs args) { if(args.Event.Button == 1) { this.offset = new Gdk.Point((int)args.Event.X, (int)args.Event.Y); mouseDown = true; } }
void Plot(List <KeyValuePair <double, double[]> > positions) { var buffer = Context.Buffer; var gc = Context.GC; var layout = Context.Layout; var plotMargin = 10; var plotMinX = plotMargin; var plotMinY = 60; var width = Context.DrawingArea.Width; var height = Context.DrawingArea.Height; var plotWidth = width - (plotMinX + plotMargin); var plotHeight = height - (plotMargin); // Draw the rectangle area. buffer.DrawRectangle(gc, false, plotMinX, plotMinY, plotWidth, plotHeight); layout.SetMarkup("<span color='black'>{0}, {1}</span>".With(width, height)); buffer.DrawLayout(gc, plotWidth - plotMinX - 100, plotMinY + plotHeight, layout); if (Context.GA == null || positions.Count == 0) { return; } var points = new List <Gdk.Point>(); var maxX1 = positions.Max(p => p.Value[0]); var maxY1 = positions.Max(p => p.Value[1]); var maxX2 = positions.Max(p => p.Value[2]); var maxY2 = positions.Max(p => p.Value[3]); for (int i = 0; i < positions.Count; i++) { var p = positions[i]; var x1 = plotMinX + Convert.ToInt32((plotWidth * p.Value[0]) / maxX1); var y1 = plotMinY + Convert.ToInt32((plotHeight * p.Value[1]) / maxY1); var point = new Gdk.Point(x1, y1); buffer.DrawRectangle(gc, true, point.X, point.Y, 1, 1); points.Add(point); var x2 = plotMinX + Convert.ToInt32((plotWidth * p.Value[2]) / maxX2); var y2 = plotMinY + Convert.ToInt32((plotHeight * p.Value[3]) / maxY2); point = new Gdk.Point(x2, y2); buffer.DrawRectangle(gc, true, point.X, point.Y, 1, 1); points.Add(point); } // Draw all lines (black). gc.RgbFgColor = new Gdk.Color(0, 0, 0); gc.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round); buffer.DrawLines(gc, points.ToArray()); // Draw the latest best chromossome line in highlight (red). gc.RgbFgColor = new Gdk.Color(255, 0, 0); gc.SetLineAttributes(2, Gdk.LineStyle.Solid, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round); buffer.DrawLines(gc, points.Skip(points.Count - 2).ToArray()); }
public LabelItem(StartPage owner, string label, int x, int y) : base(owner) { markup = "<span foreground=\"#000099\"><b><big>" + label + "</big></b></span>"; owner.layout.SetMarkup(markup); Pango.Rectangle ink, log; owner.layout.GetPixelExtents(out ink, out log); Bounds = new Gdk.Rectangle(x + 30, y, ink.Width, ink.Height); text_offset = new Gdk.Point(ink.X, ink.Y); }
public bool GetAttachPoints(Gdk.Point points, out int n_points) { IntPtr native_points = GLib.Marshaller.StructureToPtrAlloc(points); bool raw_ret = gtk_icon_info_get_attach_points(Handle, native_points, out n_points); bool ret = raw_ret; Marshal.FreeHGlobal(native_points); return(ret); }
private Gdk.Rectangle GetCellBox (int x, int y, int cellSize) { int widthBoxNum = x % cellSize; int heightBoxNum = y % cellSize; var leftUpper = new Gdk.Point (x - widthBoxNum, y - heightBoxNum); var returnMe = new Gdk.Rectangle (leftUpper, new Gdk.Size (cellSize, cellSize)); return returnMe; }
/// <summary> /// Draws the slider arrows on both sides of the control. /// </summary> /// <param name="position">position value of the slider, lowest being at the bottom. The range /// is between 0 and the controls height-9. The values will be adjusted if too large/small</param> /// <param name="Unconditional">If Unconditional is true, the slider is drawn, otherwise some logic /// is performed to determine is drawing is really neccessary.</param> private void DrawSlider(Gdk.Window g, int position, bool Unconditional) { if (position < 0) { position = 0; } if (position > this.Allocation.Height - 9) { position = this.Allocation.Height - 9; } if (m_iMarker_Start_Y == position && !Unconditional) // If the marker position hasn't changed { return; // since the last time it was drawn and we don't HAVE to redraw } // then exit procedure m_iMarker_Start_Y = position; // Update the controls marker position this.ClearSlider(g); // Remove old slider Gdk.GC gcfill = new Gdk.GC(g); // Same gray color Photoshop uses gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.FromArgb(116, 114, 106)); Gdk.GC gcborder = new Gdk.GC(g); gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.White); // Same gray color Photoshop uses //Console.WriteLine( "position="+position ); Gdk.Point[] arrow = new Gdk.Point[7]; // GGG arrow[0] = new Gdk.Point(1, position); // G G arrow[1] = new Gdk.Point(3, position); // G G arrow[2] = new Gdk.Point(7, position + 4); // G G arrow[3] = new Gdk.Point(3, position + 8); // G G arrow[4] = new Gdk.Point(1, position + 8); // G G arrow[5] = new Gdk.Point(0, position + 7); // G G arrow[6] = new Gdk.Point(0, position + 1); // G G // GGG g.DrawPolygon(gcfill, true, arrow); // Fill left arrow with white g.DrawPolygon(gcborder, false, arrow); // Draw left arrow border with gray // GGG arrow[0] = new Gdk.Point(this.Allocation.Width - 2, position); // G G arrow[1] = new Gdk.Point(this.Allocation.Width - 4, position); // G G arrow[2] = new Gdk.Point(this.Allocation.Width - 8, position + 4); // G G arrow[3] = new Gdk.Point(this.Allocation.Width - 4, position + 8); // G G arrow[4] = new Gdk.Point(this.Allocation.Width - 2, position + 8); // G G arrow[5] = new Gdk.Point(this.Allocation.Width - 1, position + 7); // G G arrow[6] = new Gdk.Point(this.Allocation.Width - 1, position + 1); // G G // GGG g.DrawPolygon(gcfill, true, arrow); // Fill right arrow with white g.DrawPolygon(gcborder, false, arrow); // Draw right arrow border with gray }
public PlacedSurface(ImageSurface source, Gdk.Rectangle roi) { where = roi.Location; what = new ImageSurface (Format.Argb32, roi.Width, roi.Height); using (Context g = new Context (what)) { g.SetSourceSurface (source, -roi.X, -roi.Y); g.Paint (); } }
public PlacedSurface(ImageSurface source, Gdk.Rectangle roi) { where = roi.Location; what = new ImageSurface(Format.Argb32, roi.Width, roi.Height); using (Context g = new Context(what)) { g.SetSourceSurface(source, -roi.X, -roi.Y); g.Paint(); } }
private Gdk.Rectangle GetCellBox(int x, int y, int cellSize) { int widthBoxNum = x % cellSize; int heightBoxNum = y % cellSize; var leftUpper = new Gdk.Point(x - widthBoxNum, y - heightBoxNum); var returnMe = new Gdk.Rectangle(leftUpper, new Gdk.Size(cellSize, cellSize)); return(returnMe); }
void RenderShadowedText(Cairo.Context context, Gdk.Point position, double opacity, Pango.Layout layout) { context.MoveTo(position.X, position.Y + 2); context.SetSourceRGBA(0, 0, 0, 0.3 * opacity); Pango.CairoHelper.ShowLayout(context, layout); context.MoveTo(position.X, position.Y); context.SetSourceRGBA(1, 1, 1, opacity); Pango.CairoHelper.ShowLayout(context, layout); }
void DrawBuildEffect(Cairo.Context context, Gdk.Rectangle area, double progress, double opacity) { context.Save(); LayoutRoundedRectangle(context, area); context.Clip(); Gdk.Point center = new Gdk.Point(area.Left + 19, (area.Top + area.Bottom) / 2); context.Translate(center.X, center.Y); var circles = new [] { new { Radius = 200, Thickness = 12, Speed = 1, ArcLength = Math.PI * 1.50 }, new { Radius = 195, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 240, Thickness = 12, Speed = 3, ArcLength = Math.PI * 1.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 215, Thickness = 20, Speed = 2, ArcLength = Math.PI * 1.25 } }; double zmod = 1.0d; double zporg = progress; foreach (var arc in circles) { double zoom = 1.0d; zoom = (double)Math.Sin(zporg * Math.PI * 2 + zmod); zoom = ((zoom + 1) / 6.0d) + .05d; context.Rotate(Math.PI * 2 * progress * arc.Speed); context.MoveTo(arc.Radius * zoom, 0); context.Arc(0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.SetSourceColor(CairoExtensions.ParseColor("B1DDED", 0.35 * opacity)); context.Stroke(); context.Rotate(Math.PI * 2 * -progress * arc.Speed); progress = -progress; context.Rotate(Math.PI * 2 * progress * arc.Speed); context.MoveTo(arc.Radius * zoom, 0); context.Arc(0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.Stroke(); context.Rotate(Math.PI * 2 * -progress * arc.Speed); progress = -progress; zmod += (float)Math.PI / circles.Length; } context.LineWidth = 1; context.ResetClip(); context.Restore(); }
void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity) { if (brandedIcon != null) { double scale = PreviewSize / brandedIcon.Width; context.Save(); context.Translate(position.X, position.Y); context.Scale(scale * IconScale, scale * IconScale); context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2); context.Restore(); } }
// allows the user to drag the Info-Dialog, even if it is not // Decorated with a title bar protected virtual void MouseMove(object o, Gtk.MotionNotifyEventArgs args) { if (mouseDown) { Gdk.Point delta = new Gdk.Point((int)(args.Event.X - offset.X), (int)(args.Event.Y - offset.Y)); int x, y; this.GetPosition(out x, out y); this.Move(x + delta.X, y + delta.Y); } }
protected Gdk.Rectangle GetRectangleFromPoints(Gdk.Point a, Gdk.Point b) { int x = Math.Min(a.X, b.X); int y = Math.Min(a.Y, b.Y); int w = Math.Max(a.X, b.X); int h = Math.Max(a.Y, b.Y); var rect = new Gdk.Rectangle(x, y, w, h); rect.Inflate(BrushWidth, BrushWidth); return(rect); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { using (var context = Gdk.CairoHelper.Create(evnt.Window)) { if (pickerCircle == null || pickerCircle.Width != Radius * 2 + 100 || pickerCircle.Height != Radius * 2 + 100) { pickerCircle = new Cairo.ImageSurface(Cairo.Format.ARGB32, Radius * 2 + 100, Radius * 2 + 100); using (var g = new Cairo.Context(pickerCircle)) { // apparently quartz needs the surface initialized g.Color = new Color(0, 0, 0); g.Paint(); } DrawPickerCircle(pickerCircle, Radius); } Gdk.Point center = PickerCenter(); context.Arc(center.X, center.Y, Radius, 0, Math.PI * 2); context.Clip(); pickerCircle.Show(context, center.X - pickerCircle.Width / 2, center.Y - pickerCircle.Height / 2); context.ResetClip(); context.Arc(center.X, center.Y, Radius + 5, 0, Math.PI * 2); context.LineWidth = 10; using (var lg = new Cairo.LinearGradient(0, center.Y - (Radius + 30), 0, center.Y + (Radius + 30))) { lg.AddColorStop(0, new Color(0, 0, 0, 0.3)); lg.AddColorStop(1, new Color(0, 0, 0, 0.1)); context.Pattern = lg; context.Stroke(); } context.Arc(center.X, center.Y, Radius + 15, 0, Math.PI * 2); context.LineWidth = 10; using (var lg = new Cairo.LinearGradient(0, center.Y - (Radius + 30), 0, center.Y + (Radius + 30))) { lg.AddColorStop(0, new Color(0, 0, 0, 0.1)); lg.AddColorStop(1, new Color(0, 0, 0, 0.3)); context.Pattern = lg; context.Stroke(); } if (HighlightColor.HasValue) { DrawColorOverlay(context, center, HighlightColor.Value); } Gdk.Rectangle selectedRegion = new Gdk.Rectangle(Allocation.X + 40, Allocation.Bottom - 100, Allocation.Width - 80, 50); DrawSelectedColorBox(context, selectedRegion); } return(base.OnExposeEvent(evnt)); }
public override void Update(int width) { Layout layout = view.Layout; layout.FontDescription = FontDescription; layout.Alignment = Alignment.Left; layout.Width = -1; layout.SetText (heading); Rectangle ink, log; layout.GetPixelExtents (out ink, out log); ink_offset = new Gdk.Point (ink.X, ink.Y); layout.FontDescription = null; sz.Width = ink.Width; sz.Height = ink.Height; }
public MouseTracker(Gtk.Widget owner) { this.mOwner = owner; Hovered = false; MousePosition = new Gdk.Point(0, 0); UpdateEventFlags(); owner.MotionNotifyEvent += (o, args) => { MousePosition = new Gdk.Point((int)args.Event.X, (int)args.Event.Y); if (MouseMoved != null) { MouseMoved(this, args); } }; owner.EnterNotifyEvent += (o, args) => { Hovered = true; if (EnterNotify != null) { EnterNotify(this, args); } }; owner.LeaveNotifyEvent += (o, args) => { Hovered = false; if (LeaveNotify != null) { LeaveNotify(this, args); } }; owner.ButtonPressEvent += (o, args) => { if (ButtonPressed != null) { ButtonPressed(this, args); } }; owner.ButtonReleaseEvent += (o, args) => { if (ButtonPressed != null) { ButtonReleased(this, args); } }; }
void RenderButton(Cairo.Context context, Gdk.Point corner, double opacity, bool hovered) { Gdk.Rectangle region = new Gdk.Rectangle(corner.X, corner.Y, ButtonSize.Width, ButtonSize.Height); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3); using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) { if (hovered) { lg.AddColorStop(0, new Cairo.Color(.15, .76, .09, opacity)); lg.AddColorStop(1, new Cairo.Color(.41, .91, .46, opacity)); } else { lg.AddColorStop(0, new Cairo.Color(.41, .91, .46, opacity)); lg.AddColorStop(1, new Cairo.Color(.15, .76, .09, opacity)); } context.SetSource(lg); context.FillPreserve(); } context.SetSourceRGBA(.29, .79, .28, opacity); context.LineWidth = 1; context.Stroke(); region.Inflate(-1, -1); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 2); using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) { lg.AddColorStop(0, new Cairo.Color(1, 1, 1, .74 * opacity)); lg.AddColorStop(0.1, new Cairo.Color(1, 1, 1, 0)); lg.AddColorStop(0.9, new Cairo.Color(0, 0, 0, 0)); lg.AddColorStop(1, new Cairo.Color(0, 0, 0, .34 * opacity)); context.SetSource(lg); context.Stroke(); } using (var layout = ButtonLayout(PangoContext)) { int w, h; layout.GetPixelSize(out w, out h); RenderShadowedText(context, new Gdk.Point(corner.X + ButtonSize.Width / 2 - w / 2, corner.Y + ButtonSize.Height / 2 - h / 2 - 1), opacity, layout); } }
public static Gdk.Point GetScreenCoordinates(this Gtk.Widget w, Gdk.Point p) { if (w.ParentWindow == null) { return(Gdk.Point.Zero); } int x, y; w.ParentWindow.GetOrigin(out x, out y); var a = w.Allocation; x += a.X; y += a.Y; return(new Gdk.Point(x + p.X, y + p.Y)); }
private Gdk.Point[] RecalcPointOffsets (int fragments, double rotationAngle, int distance) { double pointStep = 2 * Math.PI / (double)fragments; double rotationRadians = ((rotationAngle - 90.0) * Math.PI) / 180.0; Gdk.Point[] pointOffsets = new Gdk.Point[fragments]; for (int i = 0; i < fragments; i++) { double currentRadians = rotationRadians + (pointStep * i); pointOffsets[i] = new Gdk.Point ( (int)Math.Round (distance * -Math.Sin (currentRadians), MidpointRounding.AwayFromZero), (int)Math.Round (distance * -Math.Cos (currentRadians), MidpointRounding.AwayFromZero)); } return pointOffsets; }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { logger.Debug("Button Explose"); if(item != null) { int triangleSize = 25; Gdk.Rectangle targetRectangle = this.Allocation; evnt.Window.DrawRectangle(Style.BackgroundGC(State), true, targetRectangle); Style.PaintLayout(Style, evnt.Window, State, true, targetRectangle, this, null, targetRectangle.X, targetRectangle.Y, PangoText); if (item.TagColor != "") { Gdk.Color col = new Gdk.Color(); Gdk.Color.Parse(item.TagColor, ref col); Gdk.GC TagGC = new Gdk.GC(evnt.Window); TagGC.RgbFgColor = col; Gdk.Point[] triangle = new Gdk.Point[] { new Gdk.Point(targetRectangle.X + targetRectangle.Width, targetRectangle.Top), new Gdk.Point(targetRectangle.X + targetRectangle.Width - triangleSize, targetRectangle.Top), new Gdk.Point(targetRectangle.X + targetRectangle.Width, targetRectangle.Top + triangleSize) }; evnt.Window.DrawPolygon(TagGC, true, triangle); if (Item.Tag != "") { Pango.Rectangle logicExt, inkExt; PangoTag.GetPixelExtents(out inkExt, out logicExt); evnt.Window.DrawLayout(Style.WhiteGC, targetRectangle.Right - triangleSize * 5/16 - logicExt.Width/2, targetRectangle.Top + triangleSize * 5/ 16 - logicExt.Height/2, PangoTag); } } return true; } return base.OnExposeEvent(evnt); }
protected override bool OnButtonPressEvent(Gdk.EventButton ev) { if (ev.Button != 1) return base.OnButtonPressEvent (ev); Gdk.Point pt = new Gdk.Point ((int)ev.X, (int)ev.Y); foreach (Item item in items) { if (item is LinkItem && item.Bounds.Contains (pt)) { // button press animation pressed = true; SelectItem (item as LinkItem); break; } } GrabFocus (); return base.OnButtonPressEvent (ev); }
protected override bool OnButtonReleaseEvent(Gdk.EventButton ev) { pressed = false; if (selected_item == null) return base.OnButtonReleaseEvent (ev); Gdk.Point pt = new Gdk.Point ((int)ev.X, (int)ev.Y); if (selected_item.Bounds.Contains (pt)) selected_item.OnActivated (); return base.OnButtonReleaseEvent (ev); }
protected override bool OnButtonPressEvent (Gdk.EventButton evnt) { int x = (int)evnt.X; int y = (int)evnt.Y; var element = GetInputElementAt (x, y); HasFocus = true; MouseGrabElement = element; if (MouseGrabElement != null) { MouseGrabElement.CancelAnimations (); DragStart = new Gdk.Point (x, y); double dx = x; double dy = y; var point = TransformPoint (MouseGrabElement.Parent, dx, dy); DragOffset = new Gdk.Point ((int) (point.X - MouseGrabElement.X), (int) (point.Y - MouseGrabElement.Y)); var transformedPoint = TransformPoint (MouseGrabElement, x, y); MouseGrabElement.ButtonPress (new ButtonEventArgs (transformedPoint.X, transformedPoint.Y, evnt.XRoot, evnt.YRoot, evnt.Button, evnt.State)); } return true; }
private void HandleImageViewMotion (object sender, MotionNotifyEventArgs args) { Gdk.Point coords; coords = new Gdk.Point ((int) args.Event.X, (int) args.Event.Y); SetSamplePoint (view.WindowCoordsToImage (coords)); }
public override void Update(int width) { sz.Width = width; Layout layout = view.Layout; layout.Alignment = Pango.Alignment.Left; layout.Width = width * 1024; if (attrs != null) layout.Attributes = attrs; layout.SetText (text); Rectangle ink, log; layout.GetPixelExtents (out ink, out log); ink_offset = new Gdk.Point (ink.X, ink.Y); sz.Height = ink.Height; layout.Attributes = null; }
protected LinkItem(StartPage owner, string caption, string description, int x, int y) : base(owner) { markup = "<span underline=\"single\" foreground=\"#0000FF\">" + caption + "</span>"; this.description = description; owner.layout.SetMarkup (markup); Pango.Rectangle ink, log; owner.layout.GetPixelExtents (out ink, out log); text_offset = new Gdk.Point (padding - ink.X, padding - ink.Y); if (String.IsNullOrEmpty (description)) Bounds = new Gdk.Rectangle (x + 40, y, ink.Width + 2 * padding, ink.Height + 2 * padding); else { int height = ink.Height + padding; int width = ink.Width; owner.layout.SetMarkup ("<i>" + description + "</i>"); owner.layout.GetPixelExtents (out ink, out log); description_offset = new Gdk.Point (padding - ink.X, height + text_padding - ink.Y); Bounds = new Gdk.Rectangle (x + 40, y, width > ink.Width ? width + 2 * padding : ink.Width + 2 * padding, height + ink.Height + padding + text_padding); } }
private void HandleButtonPressEvent (object sender, ButtonPressEventArgs args) { switch (args.Event.Type) { case Gdk.EventType.ButtonPress: if (args.Event.Button == 1) { start = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y); start_root = new Gdk.Point ((int)args.Event.XRoot, (int)args.Event.YRoot); start_hot = hotspot; Gdk.Point win; GdkWindow.GetOrigin (out win.X, out win.Y); start_hot.X += win.X; start_hot.Y += win.Y; dragging = true; rotate = (args.Event.State & Gdk.ModifierType.ShiftMask) > 0; start_angle = Angle; } else { Angle += Math.PI /8; } break; case Gdk.EventType.TwoButtonPress: dragging = false; this.Destroy (); break; } }
protected override void OnMapped () { base.OnMapped (); TitleOffset = TextOffset = new Gdk.Point (0, 40); ButtonOpacity = TextOpacity = TitleOpacity = IconOpacity = 0; BackgroundOpacity = 0; IconScale = 0.5; GLib.Timeout.Add (750, () => { new Animation () .AddConcurrent (new Animation ((f) => TitleOffset.Y = (int) (40 * f), start: 1, end: 0, easing: Easing.CubicInOut), 0, 0.5f) .AddConcurrent (new Animation ((f) => TextOffset.Y = (int) (40 * f), start: 1, end: 0, easing: Easing.CubicInOut), 0.1f, 0.6f) .AddConcurrent (new Animation ((f) => TitleOpacity = f, easing: Easing.CubicInOut), 0, 0.5f) .AddConcurrent (new Animation ((f) => TextOpacity = f, easing: Easing.CubicInOut), 0.1f, 0.6f) .AddConcurrent (new Animation ((f) => ButtonOpacity = f, easing: Easing.CubicInOut), 0.3f, 0.9f) .AddConcurrent (new Animation ((f) => BackgroundOpacity = f, easing: Easing.CubicInOut), 0, 0.2f) .AddConcurrent (new Animation ((f) => IconOpacity = f, easing: Easing.CubicInOut), 0.2f, 0.7f) .AddConcurrent (new Animation ((f) => IconScale = f, start: 0.5f, end: 1, easing: Easing.SpringOut), 0.2f, 0.7f) .Commit (this, "Intro", length: 1200); return false; }); }
public LabelItem(StartPage owner, string label, int x, int y) : base(owner) { markup = "<span foreground=\"#000099\"><b><big>" + label + "</big></b></span>"; owner.layout.SetMarkup (markup); Pango.Rectangle ink, log; owner.layout.GetPixelExtents (out ink, out log); Bounds = new Gdk.Rectangle (x + 30, y, ink.Width, ink.Height); text_offset = new Gdk.Point (ink.X, ink.Y); }
void OnPopupMenu (object sender, Gtk.ButtonPressEventArgs args) { if (args.Event.Button == 3) { int textEditorXOffset = (int)args.Event.X - this.TextViewMargin.XOffset; if (textEditorXOffset < 0) return; this.menuPopupLocation = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y); DocumentLocation loc= this.TextViewMargin.VisualToDocumentLocation (textEditorXOffset, (int)args.Event.Y); if (!this.IsSomethingSelected || !this.SelectionRange.Contains (Document.LocationToOffset (loc))) Caret.Location = loc; this.ShowPopup (); base.ResetMouseState (); } }
public void ShowMenu(Node node, int rootX, int rootY, uint button) { if (node.MenuItems == null || !node.MenuItems.Any ()) return; Menu menu = new Menu (); foreach (var item in node.MenuItems) { MenuItem menuItem = new MenuItem (item.Name); var tmp = item; menuItem.Activated += (sender, e) => { node.OnMenuEntryActivated (tmp); }; menu.Append (menuItem); menuItem.Show (); } menuPosition = new Gdk.Point (rootX, rootY); menu.Popup (null, null, PositionMenu, button, Global.CurrentEventTime); }
/* This will draw an arrow from the source point to the destination. * The caller has to resolve the centers of the source and destination squares * and pass them to this. * Instead of drawing the arrow to the center of the destination (which can * overlap with the piece at the destination), the arrow will be drawn in * such a way that only a limited portion of it will be inside the square. * The horizontal lines of the arrow needs to be perpendicular to the direction * of the arrow. To compute the points which are equidistant and at a distance 'alpha' * from a given point (x,y), the following formula is used: * (x + sin * alpha, y - cos * alpha) and (x - sin * alpha, y + cos * alpha) * The sin and cos are the values for the slope of the arrow. * GetPerpendicularCoords is used to get these values. * Another formula is used to find a point on the arrow at a distance 'dist' from a * point (x, y) in the reverse direction. This is used in drawing the edge of the arrow. * The formula used is: * (x - dist * cos, y - dist * sin) */ public static void DrawArrow(Gdk.Drawable map, Gdk.GC gc, int x1, int y1, int x2, int y2, int size, bool filled) { double len = Math.Sqrt ((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1)); double sin = (y2 - y1) / len; double cos = (x2 - x1) / len; int alpha = size / 4; double line_portion = 0.75 * size / 2; // the tip now touches the end of the square. // computing it like this takes care of the direction // from which the arrow is coming! Gdk.Point tip = new Gdk.Point ((int) Math. Round (x2 - line_portion * cos), (int) Math. Round (y2 - line_portion * sin)); x2 = tip.X; y2 = tip.Y; Gdk.Point[]a = new Gdk.Point[2]; GetPerpendicularCoords (x1, y1, sin, cos, alpha, out a[0], out a[1]); // This is the point where the arrow will start. // We need to draw a rectangle from the above point to this. // And the a triangle to the final dest. double factor = 1.5; Gdk.Point p = new Gdk.Point ((int) Math. Round (x2 - factor * alpha * cos), (int) Math.Round (y2 - factor * alpha * sin)); Gdk.Point[]b = new Gdk.Point[2]; GetPerpendicularCoords (p.X, p.Y, sin, cos, alpha, out b[0], out b[1]); Gdk.Point c, d; GetPerpendicularCoords (p.X, p.Y, sin, cos, 3 * alpha, out c, out d); Gdk.Point[]points = new Gdk.Point[] { a[0], a[1], b[1], d, tip, c, b[0], a[0]}; map.DrawPolygon (gc, filled, points); }
public WelcomePageFirstRun () { VisibleWindow = false; SetSizeRequest (WidgetSize.Width, WidgetSize.Height); string iconFile = BrandingService.GetString ("ApplicationIcon"); if (iconFile != null) { iconFile = BrandingService.GetFile (iconFile); brandedIcon = Xwt.Drawing.Image.FromFile (iconFile); } TitleOffset = TextOffset = IconOffset = new Gdk.Point (); tracker = new MouseTracker (this); tracker.MouseMoved += (sender, e) => { ButtonHovered = new Gdk.Rectangle (ButtonPosistion, ButtonSize).Contains (tracker.MousePosition); }; tracker.HoveredChanged += (sender, e) => { if (!tracker.Hovered) ButtonHovered = false; }; }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion ev) { SelectItem (null); Gdk.Point pt = new Gdk.Point ((int)ev.X, (int)ev.Y); if (prelight_item != null) { if (prelight_item.Bounds.Contains (pt)) return true; else { LinkItem item = prelight_item; prelight_item = null; QueueDrawArea (item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height); } } foreach (Item item in items) { if (item is LinkItem && item.Bounds.Contains (pt)) { prelight_item = item as LinkItem; QueueDrawArea (item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height); break; } } return true; }
protected override void OnShown() { base.OnShown (); Point = DefaultPoint; spinX.ValueChanged += HandleSpinXValueChanged; spinY.ValueChanged += HandleSpinYValueChanged; pointpickergraphic1.PositionChanged += HandlePointpickergraphic1PositionChanged; button1.Pressed += HandleButton1Pressed; button2.Pressed += HandleButton2Pressed; pointpickergraphic1.Init (DefaultPoint); }
public static Gdk.Point[] GetLinePoints(Gdk.Point first, Gdk.Point second) { Gdk.Point[] coords = null; int x1 = first.X; int y1 = first.Y; int x2 = second.X; int y2 = second.Y; int dx = x2 - x1; int dy = y2 - y1; int dxabs = Math.Abs(dx); int dyabs = Math.Abs(dy); int px = x1; int py = y1; int sdx = Math.Sign(dx); int sdy = Math.Sign(dy); int x = 0; int y = 0; if (dxabs > dyabs) { coords = new Gdk.Point[dxabs + 1]; for (int i = 0; i <= dxabs; i++) { y += dyabs; if (y >= dxabs) { y -= dxabs; py += sdy; } coords[i] = new Gdk.Point(px, py); px += sdx; } } else // had to add in this cludge for slopes of 1 ... wasn't drawing half the line if (dxabs == dyabs) { coords = new Gdk.Point[dxabs + 1]; for (int i = 0; i <= dxabs; i++) { coords[i] = new Gdk.Point(px, py); px += sdx; py += sdy; } } else { coords = new Gdk.Point[dyabs + 1]; for (int i = 0; i <= dyabs; i++) { x += dxabs; if (x >= dyabs) { x -= dyabs; px += sdx; } coords[i] = new Gdk.Point(px, py); py += sdy; } } return coords; }
/// <summary> /// Draws the slider arrows on both sides of the control. /// </summary> /// <param name="position">position value of the slider, lowest being at the bottom. The range /// is between 0 and the controls height-9. The values will be adjusted if too large/small</param> /// <param name="Unconditional">If Unconditional is true, the slider is drawn, otherwise some logic /// is performed to determine is drawing is really neccessary.</param> private void DrawSlider(Gdk.Window g,int position, bool Unconditional) { if ( position < 0 ) position = 0; if ( position > this.Allocation.Height - 9 ) position = this.Allocation.Height - 9; if ( m_iMarker_Start_Y == position && !Unconditional ) // If the marker position hasn't changed return; // since the last time it was drawn and we don't HAVE to redraw // then exit procedure m_iMarker_Start_Y = position; // Update the controls marker position this.ClearSlider(g); // Remove old slider Gdk.GC gcfill = new Gdk.GC( g ); // Same gray color Photoshop uses gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.FromArgb(116,114,106)); Gdk.GC gcborder = new Gdk.GC( g ); gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms( Color.White ); // Same gray color Photoshop uses //Console.WriteLine( "position="+position ); Gdk.Point[] arrow = new Gdk.Point[7]; // GGG arrow[0] = new Gdk.Point(1,position); // G G arrow[1] = new Gdk.Point(3,position); // G G arrow[2] = new Gdk.Point(7,position + 4); // G G arrow[3] = new Gdk.Point(3,position + 8); // G G arrow[4] = new Gdk.Point(1,position + 8); // G G arrow[5] = new Gdk.Point(0,position + 7); // G G arrow[6] = new Gdk.Point(0,position + 1); // G G // GGG g.DrawPolygon( gcfill , true , arrow );// Fill left arrow with white g.DrawPolygon( gcborder, false, arrow );// Draw left arrow border with gray // GGG arrow[0] = new Gdk.Point(this.Allocation.Width - 2,position); // G G arrow[1] = new Gdk.Point(this.Allocation.Width - 4,position); // G G arrow[2] = new Gdk.Point(this.Allocation.Width - 8,position + 4); // G G arrow[3] = new Gdk.Point(this.Allocation.Width - 4,position + 8); // G G arrow[4] = new Gdk.Point(this.Allocation.Width - 2,position + 8); // G G arrow[5] = new Gdk.Point(this.Allocation.Width - 1,position + 7); // G G arrow[6] = new Gdk.Point(this.Allocation.Width - 1,position + 1); // G G // GGG g.DrawPolygon(gcfill , true , arrow ); // Fill right arrow with white g.DrawPolygon(gcborder, false, arrow ); // Draw right arrow border with gray }
protected override bool OnKeyPressEvent (Gdk.EventKey evnt) { isInKeyStroke = true; try { // Handle keyboard menu popup if (evnt.Key == Gdk.Key.Menu || (evnt.Key == Gdk.Key.F10 && (evnt.State & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)) { this.menuPopupLocation = this.TextViewMargin.LocationToDisplayCoordinates (this.Caret.Location); this.menuPopupLocation.Y += this.TextViewMargin.LineHeight; this.ShowPopup (); return true; } // Handle keyboard toolip popup /* if ((evnt.Key == Gdk.Key.F1 && (evnt.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask)) { Gdk.Point p = this.TextViewMargin.LocationToDisplayCoordinates (this.Caret.Location); this.mx = p.X; this.my = p.Y; this.ShowTooltip (); return true; } */ return base.OnKeyPressEvent (evnt); } finally { isInKeyStroke = false; } }
public EventInfo(Gdk.Point pos, uint button, uint clicks) { Position = pos; Button = button; Clicks = clicks; }
public override void Update(int width) { Layout layout = view.Layout; layout.Alignment = Pango.Alignment.Left; layout.Width = -1; layout.Attributes = Attrs; layout.SetText (caption); Rectangle ink, log; layout.GetPixelExtents (out ink, out log); ink_offset = new Gdk.Point (ink.X, ink.Y); sz.Width = ink.Width; sz.Height = ink.Height; layout.Attributes = null; }
void DrawBuildEffect (Cairo.Context context, Gdk.Rectangle area, double progress, double opacity) { context.Save (); LayoutRoundedRectangle (context, area); context.Clip (); Gdk.Point center = new Gdk.Point (area.Left + 19, (area.Top + area.Bottom) / 2); context.Translate (center.X, center.Y); var circles = new [] { new { Radius = 200, Thickness = 12, Speed = 1, ArcLength = Math.PI * 1.50 }, new { Radius = 195, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 240, Thickness = 12, Speed = 3, ArcLength = Math.PI * 1.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 215, Thickness = 20, Speed = 2, ArcLength = Math.PI * 1.25 } }; double zmod = 1.0d; double zporg = progress; foreach (var arc in circles) { double zoom = 1.0d; zoom = (double) Math.Sin (zporg * Math.PI * 2 + zmod); zoom = ((zoom + 1) / 6.0d) + .05d; context.Rotate (Math.PI * 2 * progress * arc.Speed); context.MoveTo (arc.Radius * zoom, 0); context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.Color = CairoExtensions.ParseColor ("B1DDED", 0.35 * opacity); context.Stroke (); context.Rotate (Math.PI * 2 * -progress * arc.Speed); progress = -progress; context.Rotate (Math.PI * 2 * progress * arc.Speed); context.MoveTo (arc.Radius * zoom, 0); context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.Stroke (); context.Rotate (Math.PI * 2 * -progress * arc.Speed); progress = -progress; zmod += (float)Math.PI / circles.Length; } context.LineWidth = 1; context.ResetClip (); context.Restore (); }
private static void GetPerpendicularCoords(int x, int y, double sin, double cos, int width, out Gdk. Point p1, out Gdk. Point p2) { int alpha = width / 2; p1 = new Gdk.Point ((int) Math. Round (x + (alpha * sin)), (int) Math.Round (y - (alpha * cos))); p2 = new Gdk.Point ((int) Math. Round (x - (alpha * sin)), (int) Math.Round (y + (alpha * cos))); }