public override void DrawWithFrame (CGRect cellFrame, NSView inView) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) { var inset = cellFrame.Inset (0.25f, 0.25f); inset = new CGRect (inset.X, inset.Y + 2, inset.Width, inset.Height - 2); var path = NSBezierPath.FromRoundedRect (inset, 3, 3); path.LineWidth = 0.5f; Styles.DarkBorderColor.ToNSColor ().SetStroke (); path.Stroke (); inset = new CGRect (inset.X + 3, inset.Y, inset.Width, inset.Height); DrawInteriorWithFrame (inset, inView); path = new NSBezierPath (); // Draw the separators for (int segment = 1; segment < SegmentCount; segment++) { nfloat x = inset.X + (33 * segment); path.MoveTo (new CGPoint (x, 0)); path.LineTo (new CGPoint (x, inset.Y + inset.Height)); } path.LineWidth = 0.5f; path.Stroke (); } else { base.DrawWithFrame (cellFrame, inView); } }
public TimedAnimation (CGRect frame) : base(frame) { nfloat xInset = frame.Width / 3; nfloat yInset = frame.Height / 3; CGRect aniFrame = frame.Inset (xInset, yInset); // photo1 starts and the left edge CGPoint origin = frame.Location; origin.X = 0.0f; origin.Y = Bounds.GetMidY () - aniFrame.Height / 2; aniFrame.Location = origin; photo1 = new NSImageView (aniFrame); photo1.ImageScaling = NSImageScale.AxesIndependently; photo1.Image = NSImage.ImageNamed ("photo1.jpg"); AddSubview (photo1); // photo2 starts in the center origin.X = Bounds.GetMidX () - aniFrame.Width / 2; aniFrame.Location = origin; photo2 = new NSImageView (aniFrame); photo2.ImageScaling = NSImageScale.AxesIndependently; photo2.Image = NSImage.ImageNamed ("photo2.jpg"); AddSubview (photo2); }
CAShapeLayer GetMaskShape (ViewMaskerType maskType, Xamarin.Forms.Size size) { var layer = new CAShapeLayer (); layer.FillColor = UIColor.White.CGColor; layer.StrokeColor = UIColor.White.CGColor; layer.LineWidth = 0; UIBezierPath path = null; var bounds = new CGRect (0, 0, size.Width, size.Height); switch (maskType) { case ViewMaskerType.Circle: path = UIBezierPath.FromRoundedRect (bounds, (nfloat)Math.Max (size.Width, size.Height)); break; case ViewMaskerType.Triangle: var point1 = new CGPoint (0, size.Height); var point2 = new CGPoint (size.Width, size.Height); var point3 = new CGPoint (size.Width / 2, 0); path = new UIBezierPath (); path.MoveTo (point1); path.AddLineTo (point2); path.AddLineTo (point3); path.AddLineTo (point1); path.ClosePath (); path.Fill (); break; case ViewMaskerType.Square: var smallRectangle = UIBezierPath.FromRect (bounds.Inset (50, 50)); path = UIBezierPath.FromRoundedRect (bounds, 20); break; default: throw new ArgumentOutOfRangeException (); } layer.Path = path.CGPath; return layer; }
public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext) { _transitionContext = transitionContext; var containerView = transitionContext.ContainerView; FlashCardViewController toViewController; UIViewController fromViewController; if (Presenting) { fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as UIViewController; toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as FlashCardViewController; } else { toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as FlashCardViewController; fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as UIViewController; } if(Presenting) containerView.AddSubview(toViewController.View); var originRect = toViewController.SourceFrame; var circleRect = new CGRect (originRect.GetMidX(), originRect.GetMidY(), 10, 10); var circleMaskPathInitial = UIBezierPath.FromOval(circleRect); //(ovalInRect: button.frame); var extremePoint = new CGPoint(circleRect.X - toViewController.View.Bounds.Width, circleRect.Y - toViewController.View.Bounds.Height ); //CGRect.GetHeight (toViewController.view.bounds)); var radius = (float)Math.Sqrt((extremePoint.X * extremePoint.X) + (extremePoint.Y * extremePoint.Y)); var largeCircleRect = circleRect.Inset (-radius, -radius); var circleMaskPathFinal = UIBezierPath.FromOval (largeCircleRect); CGPath fromPath; CGPath toPath; if (Presenting) { fromPath = circleMaskPathInitial.CGPath; toPath = circleMaskPathFinal.CGPath; } else { var path = new CGPath (); fromPath = circleMaskPathFinal.CGPath; toPath = circleMaskPathInitial.CGPath; } var maskLayer = new CAShapeLayer(); maskLayer.Path = fromPath; if (Presenting) { toViewController.View.Layer.Mask = maskLayer; } else { toViewController.View.Layer.Mask = maskLayer; } var maskLayerAnimation = CABasicAnimation.FromKeyPath("path"); maskLayerAnimation.From = ObjCRuntime.Runtime.GetNSObject(fromPath.Handle); maskLayerAnimation.To = ObjCRuntime.Runtime.GetNSObject(toPath.Handle); maskLayerAnimation.Duration = this.TransitionDuration(transitionContext); _animDoneDelegate = new AnimDoneDelegate (transitionContext); maskLayerAnimation.Delegate = _animDoneDelegate; maskLayer.AddAnimation(maskLayerAnimation, "path"); }
public override void DrawWithFrame (CGRect cellFrame, NSView inView) { if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) { var inset = cellFrame.Inset (0.25f, 0.25f); if (!ShowsFirstResponder) { var path = NSBezierPath.FromRoundedRect (inset, 3, 3); path.LineWidth = 0.5f; Styles.DarkBorderColor.ToNSColor ().SetStroke (); path.Stroke (); } // Can't just call base.DrawInteriorWithFrame because it draws the placeholder text // with a strange emboss effect when it the view is not first responder. // Again, probably because the NSSearchField handles the not first responder state itself // rather than using NSSearchFieldCell //base.DrawInteriorWithFrame (inset, inView); // So instead, draw the various extra cells and text in the correct places SearchButtonCell.DrawWithFrame (SearchButtonRectForBounds (inset), inView); if (!ShowsFirstResponder) { PlaceholderAttributedString.DrawInRect (SearchTextRectForBounds (inset)); } if (!string.IsNullOrEmpty (StringValue)) { CancelButtonCell.DrawWithFrame (CancelButtonRectForBounds (inset), inView); } } else { if (inView.Window.Screen.BackingScaleFactor == 2) { nfloat yOffset = 0f; nfloat hOffset = 0f; if (MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan) { if (inView.Window.IsKeyWindow) { yOffset = 0.5f; hOffset = -0.5f; } else { yOffset = 0f; hOffset = 1.0f; } } else { yOffset = 1f; hOffset = -1f; } cellFrame = new CGRect (cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset); } else { nfloat yOffset = 0f; nfloat hOffset = 0f; cellFrame = new CGRect (cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset); } base.DrawWithFrame (cellFrame, inView); } }
public override void Draw (CGRect rect) { rect = rect.Inset (2, 2); float bodyWidth = (float)rect.Size.Width / 2; UIBezierPath path = UIBezierPath.FromRoundedRect (new CGRect ((rect.Size.Width - bodyWidth) / 2, 0, bodyWidth, rect.Size.Height), UIRectCorner.TopLeft | UIRectCorner.TopRight, new CGSize (8, 8)); UIColor.Black.SetStroke (); UIColor.White.SetFill (); path.Fill (); path.LineWidth = 2; path.Stroke (); }
public override void DrawImage(NSImage image, CGRect frame, NSView controlView) { NSGraphicsContext.GlobalSaveGraphicsState (); { this.shadow.Set (); CGRect imgRect = frame.Inset ((frame.Size.Width - image.Size.Width) / 2.0f, (frame.Size.Height - image.Size.Height) / 2.0f); image.Flipped = true; image.DrawInRect (imgRect, CGRect.Empty, NSCompositingOperation.SourceOver, 1.0f); } NSGraphicsContext.GlobalRestoreGraphicsState (); }
public override void Draw (CGRect rect) { rect = rect.Inset (4, 4); UIBezierPath path = UIBezierPath.FromArc (new CGPoint (rect.GetMidX (), rect.GetMidY ()), rect.Size.Width / 2, 0, 180, true); path.LineWidth = 8; UIColor.White.SetFill (); path.Fill (); UIColor.Black.SetStroke (); path.Stroke (); }
private CAAnimation frameAnimation (CGRect aniFrame) { CAKeyFrameAnimation frameAni = new CAKeyFrameAnimation (); frameAni.KeyPath = "frame"; CGRect start = aniFrame; CGRect end = aniFrame.Inset (-start.Width * .5f, -start.Height * 0.5f); frameAni.Values = new NSObject[] { NSValue.FromCGRect (start), NSValue.FromCGRect (end) }; return frameAni; }
public KeyFrameView(CGRect frame) : base(frame) { nfloat xInset = 3 * (frame.Width / 8); nfloat yInset = 3 * (frame.Height / 8); CGRect moverFrame = frame.Inset (xInset, yInset); mover = new NSImageView (moverFrame); mover.ImageScaling = NSImageScale.AxesIndependently; mover.Image = NSImage.ImageNamed ("photo.jpg"); AddSubview (mover); addBounceAnimation (); }
/* * Render the page here: we assume we are already in a normalized coordinate system which maps * our standard aspect ratio (3:4) to (1:1) * The reason why we do this is to reuse the same drawing code for both the preview and the * full screen; for full screen rendering, we map the whole view, whereas the preview maps * the whole preview image to a quarter of the page. * */ public CGRect [] RenderPage (Page page, CGSize size, bool unstyledDrawing) { var pageRect = new CGRect (0, 0, size.Width, size.Height); var paragraphBounds = new CGRect [page.Paragraphs.Count]; using (var ctxt = UIGraphics.GetCurrentContext ()) { // fill background ctxt.SetFillColor (UIColor.FromHSBA (0.11f, 0.2f, 1, 1).CGColor); ctxt.FillRect (pageRect); pageRect = pageRect.Inset (20, 20); int i = 0; foreach (var p in page.Paragraphs) { var bounds = new CGRect (pageRect.X, pageRect.Y, 0, 0); if (UnstyledDrawing) { var text = new NSString (page.StringForParagraph (p)); var font = UIFont.FromName ("HoeflerText-Regular", 24); // draw text with the old legacy path, setting the font color to black. ctxt.SetFillColor (UIColor.Black.CGColor); bounds.Size = text.DrawString (pageRect, font); } else { // TODO: draw attributed text with new string drawing var text = page.AttributedStringForParagraph (p); var textContext = new NSStringDrawingContext (); text.DrawString (pageRect, NSStringDrawingOptions.UsesLineFragmentOrigin, textContext); bounds = textContext.TotalBounds; bounds.Offset (pageRect.X, pageRect.Y); } paragraphBounds [i++] = bounds; pageRect.Y += bounds.Height; } return paragraphBounds; } }
public override void Draw(CGRect rect) { base.Draw (rect); float margins = 4; var drawRect = new CGRect(rect.X + margins, rect.Y + margins, rect.Width - margins*2, rect.Height - margins*2); CGContext context = UIGraphics.GetCurrentContext(); context.AddEllipseInRect(drawRect); context.AddEllipseInRect(drawRect.Inset(4,4)); context.SetFillColor(UIColor.Black.CGColor); context.SetStrokeColor(UIColor.White.CGColor); context.SetLineWidth(0.5f); context.ClosePath(); context.SetShadow(new SizeF(1,2),4); context.DrawPath(CGPathDrawingMode.EOFillStroke); }
public GroupAnimationView(CGRect frame) : base(frame) { nfloat xInset = 3 * (frame.Width / 8); nfloat yInset = 3 * (frame.Height / 8); CGRect moverFrame = frame.Inset (xInset, yInset); CGPoint location = moverFrame.Location; location.X = this.Bounds.GetMidX () - moverFrame.Width / 2; location.Y = this.Bounds.GetMidY () - moverFrame.Height / 2; moverFrame.Location = location; mover = new NSImageView (moverFrame); mover.ImageScaling = NSImageScale.AxesIndependently; mover.Image = NSImage.ImageNamed ("photo.jpg"); NSDictionary animations = NSDictionary.FromObjectsAndKeys ( new object[] {GroupAnimation(moverFrame)}, new object[] {"frameRotation"}); mover.Animations = animations; AddSubview (mover); }
public override void Draw (CGRect rect) { rect = rect.Inset (4, 4); rect = new CGRect ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height); UIBezierPath path = UIBezierPath.FromOval (rect); UIColor.Black.SetStroke (); UIColor.White.SetFill (); path.LineWidth = 2; path.Fill (); path.Stroke (); UIBezierPath rightEye, leftEye, mouth = new UIBezierPath (); if (MovingRight) { rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30)); mouth.AddLineTo (new CGPoint (rect.GetMidX () + 13, rect.Y + 30)); } else { rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true); leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true); mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30)); mouth.AddLineTo (new CGPoint (rect.GetMidX () - 13, rect.Y + 30)); } rightEye.LineWidth = 2; rightEye.Stroke (); leftEye.LineWidth = 2; leftEye.Stroke (); mouth.LineWidth = 2; mouth.Stroke (); }
void CreatePieChart(CGRect frame) { // Create the chart pieChart = new ShinobiChart (frame.Inset(40)) { AutoresizingMask = ~UIViewAutoresizing.None, LicenseKey = "", // TODO: add your trail licence key here! DataSource = pieChartDataSource }; UpdatePieTitle (); pieChart.Legend.Hidden = false; View.AddSubview (pieChart); }
void CreateColumnChart(CGRect frame) { // Create the chart columnChart = new ShinobiChart (frame.Inset(40)) { Title = "Grocery Sales Figures", AutoresizingMask = ~UIViewAutoresizing.None, LicenseKey = "" //TODO: add your trail licence key here! }; // Add a pair of axes var xAxis = new SChartCategoryAxis (); xAxis.Style.InterSeriesPadding = 0; columnChart.XAxis = xAxis; var yAxis = new SChartNumberAxis { Title = "Sales (1000s)", RangePaddingHigh = new NSNumber(1) }; columnChart.YAxis = yAxis; // Add to the view View.AddSubview (columnChart); var columnChartDelegate = new ColumnChartDelegate(); columnChartDelegate.ToggledSelection += ColumnChartToggledSelection; columnChart.DataSource = columnChartDataSource; columnChart.Delegate = columnChartDelegate; // Show the legend columnChart.Legend.Hidden = false; columnChart.Legend.Placement = SChartLegendPlacement.InsidePlotArea; }
//#pragma mark - Layout. public CGRect MMButtonRectMake(CGRect rect, CGRect contentRect, UIUserInterfaceIdiom interfaceIdiom){ rect.Offset( contentRect.X, contentRect.Y); if (interfaceIdiom == UIUserInterfaceIdiom.Pad) { nfloat inset = MMNumberKeyboardPadSpacing / 2.0f; rect = rect.Inset( inset, inset); } return rect; }
/// <summary> /// Draws the specified rect. /// </summary> /// <param name="rect">The rect.</param> public override void Draw(CGRect rect) { UIImage img = null; var color = _mv.StyleDescriptor.InactiveDateForegroundColor; BackgroundColor = _mv.StyleDescriptor.InactiveDateBackgroundColor; var backgroundStyle = CalendarView.BackgroundStyle.Fill; if (!Active || !Available) { if (Highlighted) { BackgroundColor = _mv.StyleDescriptor.HighlightedDateBackgroundColor; } //color = UIColor.FromRGBA(0.576f, 0.608f, 0.647f, 1f); //img = UIImage.FromBundle("Images/Calendar/datecell.png"); } else if (Today && Selected) { color = _mv.StyleDescriptor.SelectedDateForegroundColor; BackgroundColor = _mv.StyleDescriptor.SelectedDateBackgroundColor; backgroundStyle = _mv.StyleDescriptor.SelectionBackgroundStyle; //img = UIImage.FromBundle("Images/Calendar/todayselected.png").CreateResizableImage(new UIEdgeInsets(4,4,4,4)); } else if (Today) { color = _mv.StyleDescriptor.TodayForegroundColor; BackgroundColor = _mv.StyleDescriptor.TodayBackgroundColor; backgroundStyle = _mv.StyleDescriptor.TodayBackgroundStyle; //img = UIImage.FromBundle("Images/Calendar/today.png").CreateResizableImage(new UIEdgeInsets(4,4,4,4)); } else if (Selected || Marked) { //color = UIColor.White; color = _mv.StyleDescriptor.SelectedDateForegroundColor; BackgroundColor = _mv.StyleDescriptor.SelectedDateBackgroundColor; backgroundStyle = _mv.StyleDescriptor.SelectionBackgroundStyle; //img = UIImage.FromBundle("Images/Calendar/datecellselected.png").CreateResizableImage(new UIEdgeInsets(4,4,4,4)); } else if (Highlighted) { color = _mv.StyleDescriptor.HighlightedDateForegroundColor; BackgroundColor = _mv.StyleDescriptor.HighlightedDateBackgroundColor; } else { color = _mv.StyleDescriptor.DateForegroundColor; BackgroundColor = _mv.StyleDescriptor.DateBackgroundColor; //img = UIImage.FromBundle("Images/Calendar/datecell.png"); } //if (img != null) //img.Draw(new RectangleF(0, 0, _mv.BoxWidth, _mv.BoxHeight)); var context = UIGraphics.GetCurrentContext(); if (_oldBackgorundColor != BackgroundColor) { if (backgroundStyle == CalendarView.BackgroundStyle.Fill) { context.SetFillColor(BackgroundColor.CGColor); context.FillRect(new CGRect(0, 0, _mv.BoxWidth, _mv.BoxHeight)); } else { context.SetFillColor(Highlighted ? _mv.StyleDescriptor.HighlightedDateBackgroundColor.CGColor : _mv.StyleDescriptor.DateBackgroundColor.CGColor); context.FillRect(new CGRect(0, 0, _mv.BoxWidth, _mv.BoxHeight)); var smallerSide = Math.Min(_mv.BoxWidth, _mv.BoxHeight); var center = new CGPoint(_mv.BoxWidth / 2, _mv.BoxHeight / 2); var circleArea = new CGRect(center.X - smallerSide / 2, center.Y - smallerSide / 2, smallerSide, smallerSide); if (backgroundStyle == CalendarView.BackgroundStyle.CircleFill) { context.SetFillColor(BackgroundColor.CGColor); context.FillEllipseInRect(circleArea.Inset(1, 1)); } else { context.SetStrokeColor(BackgroundColor.CGColor); context.StrokeEllipseInRect(circleArea.Inset(2, 2)); } } } color.SetColor(); var inflated = new CGRect(0, 0, Bounds.Width, Bounds.Height); // var attrs = new UIStringAttributes() { // Font = _mv.StyleDescriptor.DateLabelFont, // ForegroundColor = color, // ParagraphStyle = // // }; //((NSString)Text).DrawString(inflated,attrs); //DrawString(Text, inflated,_mv.StyleDescriptor.DateLabelFont,UILineBreakMode.WordWrap, UITextAlignment.Center); DrawDateString((NSString)Text, color, inflated); // if (Marked) // { // var context = UIGraphics.GetCurrentContext(); // if (Selected || Today) // context.SetRGBFillColor(1, 1, 1, 1); // else if (!Active || !Available) // UIColor.LightGray.SetColor(); // else // context.SetRGBFillColor(75/255f, 92/255f, 111/255f, 1); // context.SetLineWidth(0); // context.AddEllipseInRect(new RectangleF(Frame.Size.Width/2 - 2, 45-10, 4, 4)); // context.FillPath(); // // } _oldBackgorundColor = BackgroundColor; //Console.WriteLine("Drawing of cell took {0} msecs",(DateTime.Now-dt).TotalMilliseconds); }
static CGRect UpdateRectForLinePoint (LinePoint point) { var rect = new CGRect (point.Location, CGSize.Empty); // The negative magnitude ensures an outset rectangle var magnitude = -3 * point.Magnitude - 2; rect = rect.Inset (magnitude, magnitude); return rect; }
public override void DrawBezelWithFrame (CGRect frame, NSView controlView) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) { var inset = frame.Inset (0.25f, 0.25f); var path = NSBezierPath.FromRoundedRect (inset, 3, 3); path.LineWidth = 0.5f; // The first time the view is drawn it has a filter of some sort attached so that the colours set here // are made lighter onscreen. // NSColor.FromRgba (0.244f, 0.247f, 0.245f, 1).SetStroke (); // would make the initial colour actually be .56,.56,.56 // // However after switching theme this filter is removed and the colour set here is the actual colour // displayed onscreen. // This also seems to happen in fullscreen mode if (MainToolbar.IsFullscreen) { Styles.DarkBorderColor.ToNSColor ().SetStroke (); } else { Styles.DarkBorderBrokenColor.ToNSColor ().SetStroke (); } path.Stroke (); } else { if (controlView.Window?.Screen?.BackingScaleFactor == 2) { frame = new CGRect (frame.X, frame.Y + 0.5f, frame.Width, frame.Height); } base.DrawBezelWithFrame (frame, controlView); } }
private static CGRect RectangleFOffset(CGRect rect, nfloat dx, nfloat dy) { // todo: is this correct return rect.Inset(dx, dy); }
static CGRect UpdateRectForLinePoint(LinePoint point, LinePoint previousPoint) { var rect = new CGRect (point.Location, CGSize.Empty); var pointMagnitude = point.Magnitude; if (previousPoint != null) { pointMagnitude = NMath.Max (pointMagnitude, previousPoint.Magnitude); rect = rect.UnionWith (new CGRect (previousPoint.Location, CGSize.Empty)); } // The negative magnitude ensures an outset rectangle. var magnitude = -3 * pointMagnitude - 2; rect = rect.Inset (magnitude, magnitude); return rect; }
public override void Draw (CGRect rectB) { CGColorSpace cs = null; CGContext ctx = null; CGRect bds; using (ctx = UIGraphics.GetCurrentContext ()) { using (cs = CGColorSpace.CreateDeviceRGB ()) { if (Vertical) { ctx.TranslateCTM (0, Bounds.Height); ctx.ScaleCTM (1, -1); bds = Bounds; } else { ctx.TranslateCTM (0, Bounds.Height); ctx.RotateCTM (-(float)Math.PI / 2); bds = new CGRect (0, 0, Bounds.Height, Bounds.Width); } ctx.SetFillColorSpace (cs); ctx.SetStrokeColorSpace (cs); if (NumLights == 0) { float currentTop = 0; if (BgColor != null) { BgColor.SetColor (); ctx.FillRect (bds); } foreach (var thisTresh in ColorThresholds) { var val = Math.Min (thisTresh.MaxValue, Level); var rect = new CGRect (0, bds.Height * currentTop, bds.Width, bds.Height * (val - currentTop)); thisTresh.Color.SetColor (); ctx.FillRect (rect); if (Level < thisTresh.MaxValue) break; currentTop = val; } if (BorderColor != null) { BorderColor.SetColor (); bds.Inflate (-0.5f, -0.5f); ctx.StrokeRect (bds); } } else { float lightMinVal = 0; float insetAmount, lightVSpace; int peakLight = -1; lightVSpace = (float)bds.Height / (float)NumLights; if (lightVSpace < 4) insetAmount = 0; else if (lightVSpace < 8) insetAmount = 0.5f; else insetAmount = 1; if (PeakLevel > 0) { peakLight = (int)(PeakLevel * NumLights); if (peakLight >= NumLights) peakLight = NumLights - 1; } for (int light_i = 0; light_i < NumLights; light_i++) { float lightMaxVal = (light_i + 1) / (float)NumLights; float lightIntensity; CGRect lightRect; UIColor lightColor; if (light_i == peakLight) lightIntensity = 1; else { lightIntensity = (Level - lightMinVal) / (lightMaxVal - lightMinVal); lightIntensity = Clamp (0, lightIntensity, 1); if (!VariableLightIntensity && lightIntensity > 0) lightIntensity = 1; } lightColor = ColorThresholds [0].Color; int color_i = 0; for (; color_i < ColorThresholds.Length - 1; color_i++) { var thisTresh = ColorThresholds [color_i]; var nextTresh = ColorThresholds [color_i + 1]; if (thisTresh.MaxValue <= lightMaxVal) { //Console.WriteLine ("PICKED COLOR at {0}", color_i); lightColor = nextTresh.Color; } } lightRect = new CGRect (0, bds.Height * light_i / (float)NumLights, bds.Width, bds.Height * (1f / NumLights)); lightRect.Inset (insetAmount, insetAmount); if (BgColor != null) { BgColor.SetColor (); ctx.FillRect (lightRect); } //Console.WriteLine ("Got: {0} {1}", lightColor, UIColor.Red); //lightColor = UIColor.Red; if (lightIntensity == 1) { lightColor.SetColor (); //Console.WriteLine ("Setting color to {0}", lightColor); ctx.FillRect (lightRect); } else if (lightIntensity > 0) { using (var clr = new CGColor (lightColor.CGColor, lightIntensity)) { ctx.SetFillColor (clr); ctx.FillRect (lightRect); } } if (BorderColor != null) { BorderColor.SetColor (); lightRect.Inset (0.5f, 0.5f); ctx.StrokeRect (lightRect); } lightMinVal = lightMaxVal; } } } } }
public void DrawSelection(CGRect frame, NSView inView) { if (this.State == NSCellStateValue.On) { kSelectionColour.Set (); } else { kSelectionHighlightColour.Set (); } CGRect strokeRect = frame.Inset (10, 10); NSBezierPath path = NSBezierPath.FromRoundedRect (strokeRect, kSelectionCornerRadius, kSelectionCornerRadius); path.LineWidth = kSelectionWidth; path.Stroke (); }