/// <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>.</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); } } }
static string ColorToString (Gdk.Color color) { return color.ToString (); }
public void ShellSend(Gdk.Key key) { if (UserInputMode) { LastKeyPress = key; userkeypress.Set (); } else { if (LocalEcho) Write(key.ToString()); if (shellStream!=null && shellStream.CanWrite) { shellStream.WriteByte((byte)key); shellStream.Flush(); } } }
static string KeyToString(Gdk.Key key) { char c = (char) Gdk.Keyval.ToUnicode ((uint) key); if (c != 0) { if (c == ' ') return "Space"; return Char.ToUpper (c).ToString (); } //HACK: Page_Down and Next are synonyms for the same enum value, but alphabetically, Next gets returned // first by enum ToString(). Similarly, Page_Up and Prior are synonyms, but Page_Up is returned. Hence the // default pairing is Next and Page_Up, which is confusingly inconsistent, so we fix this here. // //The same problem applies to some other common keys, so we ensure certain values are mapped // to the most common name. switch (key) { case Gdk.Key.Next: return "Page_Down"; case Gdk.Key.L1: return "F11"; case Gdk.Key.L2: return "F12"; } return key.ToString (); }
static string AppleMapModifierToSymbols (Gdk.ModifierType mod) { string ret = ""; if ((mod & Gdk.ModifierType.ControlMask) != 0) { ret += "⌃"; mod ^= Gdk.ModifierType.ControlMask; } if ((mod & Gdk.ModifierType.Mod1Mask) != 0) { ret += "⌥"; mod ^= Gdk.ModifierType.Mod1Mask; } if ((mod & Gdk.ModifierType.ShiftMask) != 0) { ret += "⇧"; mod ^= Gdk.ModifierType.ShiftMask; } if ((mod & Gdk.ModifierType.MetaMask) != 0) { ret += "⌘"; mod ^= Gdk.ModifierType.MetaMask; } if (mod != 0) throw new InvalidOperationException ("Unexpected modifiers: " + mod.ToString ()); return ret; }