/// <summary> /// Divides this rectangle into two new rectangles. /// </summary> public void DivideRect(ref CGRect slice, ref CGRect remainder, CGFloat amount, CGRectEdge edge) { CGRectDivide(this, ref slice, ref remainder, amount, edge); }
public KeyboardKeyBackground(CGFloat cornerRadius, CGFloat underOffset) : base(frame: CGRect.Empty) { attached = null; hideDirectionIsOpposite = false; dirty = false; startingPoints = new List <CGPoint>(); segmentPoints = new List <Tuple <CGPoint, CGPoint> >(); arcCenters = new List <CGPoint>(); arcStartingAngles = new List <CGFloat>(); startingPoints.Capacity = (4); segmentPoints.Capacity = (4); arcCenters.Capacity = (4); arcStartingAngles.Capacity = (4); for (int i = 0; i < 4; i++) { startingPoints.Add(CGPoint.Empty); segmentPoints.Add(new Tuple <CGPoint, CGPoint>(CGPoint.Empty, CGPoint.Empty)); arcCenters.Add(CGPoint.Empty); arcStartingAngles.Add(0); } this.cornerRadius = cornerRadius; this.underOffset = underOffset; this.UserInteractionEnabled = false; }
// TODO: until bug is fixed, make sure start/end and startConnectable/endConnectable are the same object; public KeyboardConnector(CGFloat cornerRadius, CGFloat underOffset, UIView s, UIView e, Connectable sC, Connectable eC, Direction startDirection, Direction endDirection) : base(cornerRadius: cornerRadius, underOffset: underOffset) { start = s; end = e; startDir = startDirection; endDir = endDirection; startConnectable = sC; endConnectable = eC; offset = CGPoint.Empty; }
// TODO: there's a bit of "stickiness" to Apple's implementation UIView findNearestView(CGPoint position) { if (!this.Bounds.Contains(position)) { return(null); } UIView closest = null; CGFloat closestDist = nfloat.MaxValue; foreach (var anyView in this.Subviews) { var view = anyView; if (view.Hidden) { continue; } view.Alpha = 1; var distance = distanceBetween(view.Frame, position); if (closest != null) { if (distance < closestDist) { closest = view; closestDist = distance; } } else { closest = view; closestDist = distance; } } if (closest != null) { return(closest); } else { return(null); } }
void setHeight(CGFloat height) { if (this.heightConstraint == null) { this.heightConstraint = NSLayoutConstraint.Create( view1: this.View, attribute1: NSLayoutAttribute.Height, relation: NSLayoutRelation.Equal, view2: null, attribute2: NSLayoutAttribute.NoAttribute, multiplier: 0, constant: height); this.heightConstraint.Priority = 1000; this.View.AddConstraint(this.heightConstraint); // TODO: what if(view already has constraint added? } else { this.heightConstraint.Constant = height; } }
public void resizeFrame() { generateConvertedPoints(); CGFloat buffer = 32; this.offset = new CGPoint(buffer / 2, buffer / 2); var minX = Math.Min(convertedStartPoints.Item1.X, Math.Min(convertedStartPoints.Item2.X, Math.Min(convertedEndPoints.Item1.X, convertedEndPoints.Item2.X))); var minY = Math.Min(convertedStartPoints.Item1.Y, Math.Min(convertedStartPoints.Item2.Y, Math.Min(convertedEndPoints.Item1.Y, convertedEndPoints.Item2.Y))); var maxX = Math.Max(convertedStartPoints.Item1.X, Math.Min(convertedStartPoints.Item2.X, Math.Min(convertedEndPoints.Item1.X, convertedEndPoints.Item2.X))); var maxY = Math.Max(convertedStartPoints.Item1.Y, Math.Min(convertedStartPoints.Item2.Y, Math.Min(convertedEndPoints.Item1.Y, convertedEndPoints.Item2.Y))); var width = maxX - minX; var height = maxY - minY; this.Frame = new CGRect(minX - buffer / 2, minY - buffer / 2, width + buffer, height + buffer); }
void setHeight(CGFloat height) { if (this.heightConstraint == null) { Console.WriteLine(String.Format("setHeight1: {0}", height)); this.heightConstraint = NSLayoutConstraint.Create( view1: this.View, attribute1: NSLayoutAttribute.Height, relation: NSLayoutRelation.Equal, view2: null, attribute2: NSLayoutAttribute.NoAttribute, multiplier: 1, constant: height); this.heightConstraint.SetIdentifier("idHC1"); this.heightConstraint.Priority = (float)UILayoutPriority.Required; this.View.AddConstraint(this.heightConstraint); // TODO: what if(view already has constraint added? } else { Console.WriteLine(String.Format("setHeight2: {0}", height)); this.heightConstraint.Constant = height; } }
public void redrawShape() { var shape = this.shape; if (shape != null) { this.text = ""; shape.RemoveFromSuperview(); this.AddSubview(shape); CGFloat pointOffset = 4; var size = new CGSize(this.Bounds.Width - pointOffset - pointOffset, this.Bounds.Height - pointOffset - pointOffset); shape.Frame = new CGRect( (CGFloat)((this.Bounds.Width - size.Width) / 2.0), (CGFloat)((this.Bounds.Height - size.Height) / 2.0), size.Width, size.Height); shape.SetNeedsLayout(); } }
public static UIFont ItalicSystemFontOfSize(CGFloat fontSize) { return(default(UIFont)); }
public static NSImage createGradientImageWidth(CGFloat pixelsWide) height(CGFloat pixelsHigh) fromColor(NSColor fromColor) toColor(NSColor toColor)
/// <summary> /// Returns the product of the size instance by the given factor. /// </summary> /// <param name="size">The size.</param> /// <param name="factor">The factor.</param> /// <returns></returns> public static CGSize Multiply(CGSize size, CGFloat factor) { return new CGSize(size.width*factor, size.height*factor); }
public virtual void generatePointsForDrawing(CGRect Bounds) { var segmentWidth = Bounds.Width; var segmentHeight = Bounds.Height - (CGFloat)(underOffset); // base, untranslated corner points; this.startingPoints[0] = new CGPoint(0, segmentHeight); this.startingPoints[1] = new CGPoint(0, 0); this.startingPoints[2] = new CGPoint(segmentWidth, 0); this.startingPoints[3] = new CGPoint(segmentWidth, segmentHeight); this.arcStartingAngles[0] = floatPiDiv2; this.arcStartingAngles[2] = floatPiDivNeg2; this.arcStartingAngles[1] = floatPi; this.arcStartingAngles[3] = 0; //// actual coordinates for each edge, including translation; //this.segmentPoints.removeAll(keepCapacity: true); // //// actual coordinates for arc centers for each corner; //this.arcCenters.removeAll(keepCapacity: true); // //this.arcStartingAngles.removeAll(keepCapacity: true); for (int i = 0; i < this.startingPoints.Count; i++) { var currentPoint = this.startingPoints[i]; var nextPoint = this.startingPoints[(i + 1) % this.startingPoints.Count]; CGFloat floatXCorner = 0; CGFloat floatYCorner = 0; if (i == 1) { floatXCorner = cornerRadius; } else if (i == 3) { floatXCorner = -cornerRadius; } if ((i == 0)) { floatYCorner = -cornerRadius; } else if ((i == 2)) { floatYCorner = cornerRadius; } var p0 = new CGPoint( currentPoint.X + (floatXCorner), currentPoint.Y + underOffset + (floatYCorner)); var p1 = new CGPoint( nextPoint.X - (floatXCorner), nextPoint.Y + underOffset - (floatYCorner)); this.segmentPoints[i] = new Tuple <CoreGraphics.CGPoint, CoreGraphics.CGPoint>(p0, p1); var c = new CGPoint( p0.X - (floatYCorner), p0.Y + (floatXCorner)); this.arcCenters[i] = c; } // order of edge drawing: left edge, down edge, right edge, up edge; // We need to have separate paths for all the edges so we can toggle them as needed. // Unfortunately, it doesn't seem possible to assemble the connected fill path; // by simply using CGPathAddPath, since it closes all the subpaths, so we have to; // duplicate the code a little bit. var fillPath = new UIBezierPath(); var edgePaths = new List <UIBezierPath>(); CGPoint?prevPoint = null; for (int i = 0; i < 4; i++) { UIBezierPath edgePath = null; var segmentPoint = this.segmentPoints[i]; if (this.attached != null && (this.hideDirectionIsOpposite? ((int)this.attached != i) : ((int)this.attached == i))) { // do nothing; // TODO: quick hack; if (!this.hideDirectionIsOpposite) { continue; } } else { edgePath = new UIBezierPath(); // TODO: figure out if(this is ncessary; if (prevPoint == null || !prevPoint.HasValue) { prevPoint = segmentPoint.Item1; fillPath.MoveTo(prevPoint.Value); } fillPath.AddLineTo(new CGPoint(segmentPoint.Item1.X, segmentPoint.Item1.Y)); fillPath.AddLineTo(segmentPoint.Item2); edgePath.MoveTo(segmentPoint.Item1); edgePath.AddLineTo(segmentPoint.Item2); prevPoint = segmentPoint.Item2; } int attachedval = -1; if (this.attached.HasValue) { attachedval = (int)this.attached.Value; } //let shouldDrawArcInOppositeMode = (self.attached != nil ? (self.attached!.rawValue == i) || (self.attached!.rawValue == ((i + 1) % 4)) : false) var shouldDrawArcInOppositeMode = (this.attached.HasValue ? ((int)this.attached == i) || (attachedval == ((i + 1) % 4)) : false); if (this.attached.HasValue && (this.hideDirectionIsOpposite ? !shouldDrawArcInOppositeMode : attachedval == ((i + 1) % 4))) { // do nothing; } else { edgePath = (edgePath == null? new UIBezierPath() : edgePath); if (prevPoint == null || !prevPoint.HasValue) { prevPoint = segmentPoint.Item2; fillPath.MoveTo(prevPoint.Value); } var startAngle1 = this.arcStartingAngles[(i + 1) % 4]; var endAngle1 = startAngle1 + floatPiDiv2; var arcCenter = this.arcCenters[(i + 1) % 4]; fillPath.AddLineTo(prevPoint.Value); fillPath.AddArc(arcCenter, radius: this.cornerRadius, startAngle: startAngle1, endAngle: endAngle1, clockWise: true); if (edgePath != null) { edgePath.MoveTo(prevPoint.Value); edgePath.AddArc(arcCenter, radius: this.cornerRadius, startAngle: startAngle1, endAngle: endAngle1, clockWise: true); } prevPoint = this.segmentPoints[(i + 1) % 4].Item1; } if (edgePath != null) { edgePath.ApplyTransform(CGAffineTransform.MakeTranslation(0, -this.underOffset)); edgePaths.Add(edgePath); } } fillPath.ClosePath(); fillPath.ApplyTransform(CGAffineTransform.MakeTranslation(0, -this.underOffset)); Func <UIBezierPath> underPathProc = () => { var underPath = new UIBezierPath(); underPath.MoveTo(this.segmentPoints[2].Item2); var startAngle = this.arcStartingAngles[3]; var endAngle = startAngle + (CGFloat)(Math.PI / 2.0); underPath.AddArc(this.arcCenters[3], radius: (CGFloat)(this.cornerRadius), startAngle: startAngle, endAngle: endAngle, clockWise: true); underPath.AddLineTo(this.segmentPoints[3].Item2); startAngle = this.arcStartingAngles[0]; endAngle = startAngle + (CGFloat)(Math.PI / 2.0); underPath.AddArc(this.arcCenters[0], radius: (CGFloat)(this.cornerRadius), startAngle: startAngle, endAngle: endAngle, clockWise: true); underPath.AddLineTo(new CGPoint(this.segmentPoints[0].Item1.X, this.segmentPoints[0].Item1.Y - this.underOffset)); startAngle = this.arcStartingAngles[1]; endAngle = startAngle - (CGFloat)(Math.PI / 2.0); underPath.AddArc(new CGPoint(this.arcCenters[0].X, this.arcCenters[0].Y - this.underOffset), radius: (CGFloat)(this.cornerRadius), startAngle: startAngle, endAngle: endAngle, clockWise: false); underPath.AddLineTo(new CGPoint(this.segmentPoints[2].Item2.X - this.cornerRadius, this.segmentPoints[2].Item2.Y + this.cornerRadius - this.underOffset)); startAngle = this.arcStartingAngles[0]; endAngle = startAngle - (CGFloat)(Math.PI / 2.0); underPath.AddArc(new CGPoint(this.arcCenters[3].X, this.arcCenters[3].Y - this.underOffset), radius: (CGFloat)(this.cornerRadius), startAngle: startAngle, endAngle: endAngle, clockWise: false); underPath.ClosePath(); return(underPath); }; this.fillPath = fillPath; this.edgePaths = edgePaths.ToArray(); this.underPath = underPathProc(); }
public virtual void SetAngle(CGFloat angle, CGFloat magnitude) { }
public virtual void SetLineDash(UnsafePointer <CGFloat> pattern, int count, CGFloat phase) { }
public UITraitCollection(CGFloat displayScale) { }
public virtual void StrokeWithBlendMode(CGBlendMode blendMode, CGFloat alpha) { }
/// <summary> /// Returns a point structure constructed from coordinate values you provide. /// </summary> /// <param name="x">The x-coordinate of the point to construct.</param> /// <param name="y">The y-coordinate of the point to construct.</param> /// <returns>Returns a CGPoint structure, representing a single (x,y) coordinate pair.</returns> /// <remarks>Original declaration is : CGPoint CGPointMake ( float x, float y );</remarks> public static CGPoint CGPointMake(CGFloat x, CGFloat y) { return new CGPoint(x, y); }
/// <summary> /// Creates a rectangle that insets this rectangle by a specified amount. /// </summary> public CGRect InsetRect(CGFloat dX, CGFloat dY) { return CGRectInset(this, dX, dY); }
public UIFontDescriptor(string name, CGFloat size) { }
public virtual UIFontDescriptor FontDescriptorWithSize(CGFloat newPointSize) { return(default(UIFontDescriptor)); }
public virtual void DrawAtPoint(CGPoint point, CGBlendMode blendMode, CGFloat alpha) { }
public virtual void DrawInRect(CGRect rect, CGBlendMode blendMode, CGFloat alpha) { }
public UIBezierPath(CGPoint arcCenter, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise) { }
public virtual void AddArcWithCenter(CGPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise) { }
public virtual void UpdateInteractiveTransition(CGFloat percentComplete) { }
public virtual void FillWithBlendMode(CGBlendMode blendMode, CGFloat alpha) { }
public virtual void SetBackgroundVerticalPositionAdjustment(CGFloat adjustment, UIBarMetrics forBarMetrics) { }
public UIBezierPath(CGRect roundedRect, CGFloat cornerRadius) { }
private CGFloat splitView(NSSplitView splitView) constrainSplitPosition(CGFloat proposedPosition) ofSubviewAt(NSInteger dividerIndex)
public virtual void UpdateValue(CGFloat value, string forAnimatedKey) { }
private CGFloat splitView(NSSplitView splitView) constrainMaxCoordinate(CGFloat proposedMax) ofSubviewAt(NSInteger dividerIndex)
public CGPoint(double x, double y) { this.x = x; this.y = y; }
public NSLayoutConstraint(AnyObject item, NSLayoutAttribute attribute2, NSLayoutRelation relatedBy, [Optional] AnyObject toItem, NSLayoutAttribute attribute, CGFloat multiplier, CGFloat constant) { }
public virtual void SetWidth(CGFloat width, int forSegmentAtIndex) { }
public virtual void DrawUnderlineForGlyphRange(NSRange glyphRange, NSUnderlineStyle underlineType, CGFloat baselineOffset, CGRect lineFragmentRect, NSRange lineFragmentGlyphRange, CGPoint containerOrigin) { }
public UIFont(UIFontDescriptor descriptor, CGFloat size) { }
public virtual UIFont FontWithSize(CGFloat fontSize) { return(default(UIFont)); }
/// <summary> /// Returns the result of the division of the size instance by the given factor. /// </summary> /// <param name="size">The size.</param> /// <param name="factor">The factor.</param> /// <returns></returns> public static CGSize Divide(CGSize size, CGFloat factor) { return new CGSize(size.width/factor, size.height/factor); }
/// <summary> /// Returns a size structure constructed from dimension values you provide. /// </summary> /// <param name="width">A width value.</param> /// <param name="height">A height value.</param> /// <returns>Returns a CGSize structure with the specified width and height.</returns> /// <remarks>Original declaration is : CGSize CGSizeMake ( float width, float height );</remarks> public static CGSize CGSizeMake(CGFloat width, CGFloat height) { return new CGSize(width, height); }