void CreateColumnChart (RectangleF 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;

		}
		public TimedAnimation (RectangleF frame) : base(frame)
		{
			float xInset = frame.Width / 3;
			float yInset = frame.Height / 3;
			
			RectangleF aniFrame = frame.Inset (xInset, yInset);
			
			// photo1 starts and the left edge
			PointF 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);
		}
			public override void Draw (RectangleF rect)
			{
				rect = rect.Inset (2, 2);
				float bodyWidth = rect.Size.Width / 2;
				UIBezierPath path = UIBezierPath.FromRoundedRect (new RectangleF ((rect.Size.Width - bodyWidth) / 2, 0, bodyWidth, rect.Size.Height), UIRectCorner.TopLeft | UIRectCorner.TopRight, new SizeF (8, 8));
				UIColor.Black.SetStroke ();
				UIColor.White.SetFill ();
				path.Fill ();
				path.LineWidth = 2;
				path.Stroke ();
			}
		public override void Draw (RectangleF rect)
		{
			rect = rect.Inset (4, 4);
			UIBezierPath path = UIBezierPath.FromArc (new PointF (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 (RectangleF aniFrame)
		{
			CAKeyFrameAnimation frameAni = new CAKeyFrameAnimation ();
			
			frameAni.KeyPath = "frame";
			RectangleF start = aniFrame;
			RectangleF end = aniFrame.Inset (-start.Width * .5f, -start.Height * 0.5f);
			frameAni.Values = new NSObject[] { 
				NSValue.FromRectangleF (start),
				NSValue.FromRectangleF (end) };
			return frameAni;
		}
		public KeyFrameView(RectangleF frame) : base(frame)
		{
			float xInset = 3 * (frame.Width / 8);
			float yInset = 3 * (frame.Height / 8);
			
			RectangleF moverFrame = frame.Inset (xInset, yInset);

			mover = new NSImageView (moverFrame);
			
			mover.ImageScaling = NSImageScale.AxesIndependently;
			mover.Image = NSImage.ImageNamed ("photo.jpg");
			AddSubview (mover);
			addBounceAnimation ();
		}
        public override void Draw(RectangleF rect)
        {
            base.Draw (rect);

            float margins = 4;
            RectangleF drawRect = new RectangleF(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);
        }
		/*
		 * 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 RectangleF [] RenderPage (Page page, SizeF size, bool unstyledDrawing)
		{
			var pageRect = new RectangleF (0, 0, size.Width, size.Height);
			var paragraphBounds = new RectangleF [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 RectangleF (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 GroupAnimationView(RectangleF frame) : base(frame)
		{
			float xInset = 3 * (frame.Width / 8);
			float yInset = 3 * (frame.Height / 8);
			
			RectangleF moverFrame = frame.Inset (xInset, yInset);
		
			PointF 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);
		}
Beispiel #10
0
			public override void Draw (RectangleF rect)
			{
				rect = rect.Inset (4, 4);

				rect = new RectangleF ((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 PointF (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true);
					leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true);

					mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
					mouth.AddLineTo (new PointF (rect.GetMidX () + 13, rect.Y + 30));
				} else {
					rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
					leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true);

					mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
					mouth.AddLineTo (new PointF (rect.GetMidX () - 13, rect.Y + 30));
				
				}
				rightEye.LineWidth = 2;
				rightEye.Stroke ();
			
				leftEye.LineWidth = 2;
				leftEye.Stroke ();
			
				mouth.LineWidth = 2;
				mouth.Stroke ();
			}
Beispiel #11
0
		public override void Draw (RectangleF rectB)
		{
			CGColorSpace cs = null;
			CGContext ctx = null;
			RectangleF bds;
			
			ctx = UIGraphics.GetCurrentContext ();
			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 RectangleF (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 RectangleF (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 = 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;
					RectangleF 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 RectangleF (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;
				}
			}
			cs.Dispose ();
		}
		void CreatePieChart (RectangleF 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);
		}
Beispiel #13
0
 private static RectangleF  RectangleFOffset(RectangleF rect, float dx, float dy)
 {
     // todo: is this correct
     return rect.Inset(dx, dy);
 }
Beispiel #14
0
        public override void Draw(RectangleF a_rect)
        {
            CGColorSpace cs;
            CGContext cxt;
            RectangleF bds;

            cxt = UIGraphics.GetCurrentContext ();
            cs = CGColorSpace.CreateDeviceRGB();

            if (_vertical)
            {
                cxt.TranslateCTM (0, this.Bounds.Size.Height);
                cxt.ScaleCTM (1f, -1f);
                bds = this.Bounds;
            }
            else
            {
                cxt.TranslateCTM (0, this.Bounds.Size.Height);
                cxt.RotateCTM ((float)(-Math.PI / 2f) );
                bds = new RectangleF (0f, 0f, this.Bounds.Size.Height, this.Bounds.Size.Width);
            }

            cxt.SetFillColorSpace (cs);
            cxt.SetStrokeColorSpace (cs);

            if (_numLights == 0)
            {
                int i;
                float currentTop = 0f;

                if (_bgColor != null)
                {
                    _bgColor.SetColor ();
                    cxt.FillRect (bds);
                }

                for (i=0; i<_colorThresholds.Length; i++)
                {
                    LevelMeterColorThreshold thisThresh = _colorThresholds[i];
                    float val = Math.Min (thisThresh.maxValue, _level);

                    RectangleF rect = new RectangleF(
                                             0,
                                             (bds.Height) * currentTop,
                                             bds.Width,
                                             (bds.Height) * (val - currentTop)
                                             );

                    CGColor clr = new CGColor (thisThresh.color.CGColor, _maxIntensity);
                    cxt.SetFillColor (clr);
                    cxt.FillRect(rect);

                    if (_level < thisThresh.maxValue)
                        break;

                    currentTop = val;
                }

                if (_borderColor != null)
                {
                    _borderColor.SetColor ();
                    cxt.StrokeRect( bds.Inset (.5f, .5f));
                }

            }
            else
            {
                int light_i;
                float lightMinVal = 0f;
                float insetAmount, lightVSpace;
                lightVSpace = bds.Height / (float)_numLights;
                if (lightVSpace < 4f) insetAmount = 0f;
                else if (lightVSpace < 8f) insetAmount = 0.5f;
                else insetAmount = 1f;

                int peakLight = -1;
                if (_peakLevel > 0f)
                {
                    peakLight = (int)(_peakLevel * _numLights);
                    if (peakLight >= _numLights)
                        peakLight = (int)(_numLights - 1);
                }

                for (light_i=0; light_i<_numLights; light_i++)
                {
                    float lightMaxVal = (float)(light_i + 1) / (float)_numLights;
                    float lightIntensity;
                    RectangleF lightRect;
                    UIColor lightColor;

                    if (light_i == peakLight)
                    {
                        lightIntensity = _maxIntensity;
                    }
                    else
                    {
                        lightIntensity = (_level - lightMinVal) / (lightMaxVal - lightMinVal);
                        lightIntensity = LEVELMETER_CLAMP(0f, lightIntensity, _maxIntensity);

                        if ((!_variableLightIntensity) && (lightIntensity > 0f))
                            lightIntensity = _maxIntensity;
                    }

                    lightColor = _colorThresholds[0].color;
                    int color_i;
                    for (color_i=0; color_i<(_colorThresholds.Length-1); color_i++)
                    {
                        LevelMeterColorThreshold thisThresh = _colorThresholds[color_i];
                        LevelMeterColorThreshold nextThresh = _colorThresholds[color_i + 1];
                        if (thisThresh.maxValue <= lightMaxVal)
                            lightColor = nextThresh.color;
                    }

                    lightRect = new RectangleF(
                                           0f,
                                           bds.Height * ((float)(light_i) / (float)_numLights),
                                           bds.Width,
                                           bds.Height * (1f / (float)_numLights)
                                           );
                    lightRect = lightRect.Inset (insetAmount, insetAmount);

                    if (_bgColor != null)
                    {
                        _bgColor.SetColor ();
                        cxt.FillRect (lightRect);
                    }

                    if (lightIntensity == 1f)
                    {
                        lightColor.SetColor ();
                        cxt.FillRect (lightRect);
                    }
                    else if (lightIntensity > 0f)
                    {
                        CGColor clr = new CGColor (lightColor.CGColor, lightIntensity);
                        cxt.SetFillColor (clr);
                        cxt.FillRect (lightRect);
                        clr.Dispose ();
                    }

                    if (_borderColor != null)
                    {
                        _borderColor.SetColor ();
                        cxt.StrokeRect (lightRect.Inset (0.5f, 0.5f));
                    }

                    lightMinVal = lightMaxVal;
                }

            }

            cs.Dispose ();
        }
Beispiel #15
0
        public override void Draw(RectangleF a_rect)
        {
            // Set the back color to black
            GL.ClearColor (0.0f, 0.0f, 0.0f, 1.0f);

            // Clear all old bits
            GL.Clear ((int)(All.ColorBufferBit));

            GL.PushMatrix();

            RectangleF bds;

            if (_vertical)
            {
                GL.Scale (1f, -1f, 1f);
                bds = new RectangleF (0f, -1f,
                          	this.Bounds.Width * _scaleFactor,
                            this.Bounds.Height * _scaleFactor);
            } else {
                GL.Translate(0f, this.Bounds.Height * _scaleFactor, 0f);
                GL.Rotate(-90f, 0f, 0f, 1f);
                bds = new RectangleF (0f, 1f,
                            this.Bounds.Height * _scaleFactor,
                          	this.Bounds.Width * _scaleFactor);
            }

            if (_numLights == 0)
            {
                int i;
                float currentTop = 0f;

                for (i=0; i<_colorThresholds.Length; i++)
                {
                    LevelMeterColorThreshold thisThresh = _colorThresholds[i];
                    float val = Math.Min (thisThresh.maxValue, _level);

                    RectangleF rect = new RectangleF(
                                             0,
                                             (bds.Height) * currentTop,
                                             bds.Width,
                                             (bds.Height) * (val - currentTop)
                                             );

                    float [] vertices = new float[] {
                        rect.GetMinX (), rect.GetMinY (),
                        rect.GetMaxX (), rect.GetMinY (),
                        rect.GetMinX (), rect.GetMaxY (),
                        rect.GetMaxX (), rect.GetMaxY ()
                    };

                    CGColor clr = thisThresh.color.CGColor;
                    if (clr.NumberOfComponents != 4)
                        goto bail;
                    float [] rgba;
                    rgba = clr.Components;
                    GL.Color4 (rgba[0], rgba[1], rgba[2], _maxIntensity);

                    GL.VertexPointer(2, All.Float, 0, vertices);
                    GL.EnableClientState (All.VertexArray);

                    GL.DrawArrays(All.TriangleStrip, 0, 4);

                    if (_level < thisThresh.maxValue)
                        break;

                    currentTop = val;
                }
            }
            else
            {
                int light_i;
                float lightMinVal = 0f;
                float insetAmount, lightVSpace;
                lightVSpace = bds.Height / (float)_numLights;

                if (lightVSpace < 4f)
                    insetAmount = 0f;
                else if (lightVSpace < 8f)
                    insetAmount = 0.5f;
                else
                    insetAmount = 1f;

                int peakLight = -1;
                if (_peakLevel > 0f)
                {
                    peakLight = (int)(_peakLevel * _numLights);
                    if (peakLight >= _numLights)
                        peakLight = (int)(_numLights - 1);
                }

                for (light_i=0; light_i<_numLights; light_i++)
                {
                    float lightMaxVal = (float)(light_i + 1) / (float)_numLights;
                    float lightIntensity;
                    RectangleF lightRect;
                    UIColor lightColor;

                    if (light_i == peakLight)
                    {
                        lightIntensity = _maxIntensity;
                    }
                    else
                    {
                        lightIntensity = (_level - lightMinVal) / (lightMaxVal - lightMinVal);
                        lightIntensity = LevelMeter.LEVELMETER_CLAMP(0f, lightIntensity, _maxIntensity);
                        if ((!_variableLightIntensity) && (lightIntensity > 0f)) lightIntensity = _maxIntensity;
                    }

                    lightColor = _colorThresholds[0].color;
                    int color_i;
                    for (color_i=0; color_i<(_colorThresholds.Length-1); color_i++)
                    {
                        LevelMeterColorThreshold thisThresh = _colorThresholds[color_i];
                        LevelMeterColorThreshold nextThresh = _colorThresholds[color_i + 1];
                        if (thisThresh.maxValue <= lightMaxVal)
                            lightColor = nextThresh.color;
                    }

                    lightRect = new RectangleF(
                                           0f,
                                           bds.Y * (bds.Height * ((float)(light_i) / (float)_numLights)),
                                           bds.Width,
                                           bds.Height * (1f / (float)_numLights)
                                           );
                    lightRect = lightRect.Inset (insetAmount, insetAmount);

                    float [] vertices = {
                        lightRect.GetMinX (), lightRect.GetMinY (),
                        lightRect.GetMaxX (), lightRect.GetMinY (),
                        lightRect.GetMinX (), lightRect.GetMaxY (),
                        lightRect.GetMaxX (), lightRect.GetMaxY ()
                    };

                    GL.VertexPointer(2, All.Float, 0, vertices);
                    GL.EnableClientState (All.VertexArray);

                    if (lightIntensity == 1f)
                    {
                        CGColor clr = lightColor.CGColor;
                        if (clr.NumberOfComponents != 4)
                            goto bail;

                        float []  rgba;
                        rgba = clr.Components;
                        GL.Color4 (rgba[0], rgba[1], rgba[2], 1f);
                        GL.DrawArrays(All.TriangleStrip, 0, 4);
                    } else if (lightIntensity > 0f) {
                        CGColor clr = lightColor.CGColor;
                        if (clr.NumberOfComponents != 4)
                            goto bail;

                        float []  rgba;
                        rgba = clr.Components;
                        GL.Color4(rgba[0], rgba[1], rgba[2], lightIntensity);
                        GL.DrawArrays(All.TriangleStrip, 0, 4);
                    }

                    lightMinVal = lightMaxVal;
                }
            }

            bail:
            GL.PopMatrix ();

            GL.Flush ();
        }