예제 #1
0
 public void DrawText(string text, BasicPoint point, BasicColor color, string fontFace, float fontSize)
 {
     _context.SetSourceRGB(color.R / 255f, color.G / 255f, color.B / 255f);
     _context.SelectFontFace(fontFace, FontSlant.Normal, FontWeight.Normal);
     _context.SetFontSize(fontSize);
     _context.MoveTo(point.X, point.Y);
     _context.ShowText(text);
 }
예제 #2
0
 public void DrawLine(BasicPoint point, BasicPoint point2, BasicPen pen)
 {
     _context.SetSourceRGB(pen.Brush.Color.R / 255f, pen.Brush.Color.G / 255f, pen.Brush.Color.B / 255f);
     _context.LineTo(point.X, point.Y);
     _context.LineTo(point2.X, point2.Y);
     _context.LineWidth = pen.Thickness;
     _context.Stroke();
 }
예제 #3
0
 public static Point ToPoint(BasicPoint point)
 {
     return new Point((int) point.X, (int) point.Y);
 }
예제 #4
0
 public void StrokeLine(BasicPoint point, BasicPoint point2)
 {
     //TryToCreatePen();
     _context.DrawLine(_currentPen, GenericControlHelper.ToPoint(point), GenericControlHelper.ToPoint(point2));
 }
예제 #5
0
 public void DrawLine(BasicPoint point, BasicPoint point2, BasicPen pen)
 {
     _context.DrawLine(GenericControlHelper.ToPen(pen), GenericControlHelper.ToPoint(point), GenericControlHelper.ToPoint(point2));
 }
예제 #6
0
		private void HandlePinchGestureRecognizer(UIPinchGestureRecognizer sender)
		{
			if (sender.State == UIGestureRecognizerState.Began)
			{
				_initialZoom = Zoom;
				_initialContentOffset = WaveFormView.ContentOffset;
				UIView.Animate(0.2, () => _lblZoom.Alpha = 0.9f);
			}
			else if (sender.State == UIGestureRecognizerState.Ended)
			{
				UIView.Animate(0.2, 0.8, UIViewAnimationOptions.CurveEaseOut, () => _lblZoom.Alpha = 0, () => {});
			}

			var location = sender.LocationInView(this);
			float newZoom = _initialZoom * _pinchGesture.Scale;
			float deltaZoom = newZoom / Zoom;
			float originPointX = IsAutoScrollEnabled ? WaveFormView.ContentOffset.X + (Frame.Width / 2) : location.X + WaveFormView.ContentOffset.X;
			float distanceToOffsetX = originPointX - WaveFormView.ContentOffset.X;
			float contentOffsetX = (originPointX * deltaZoom) - distanceToOffsetX;
			Zoom = Math.Max(1, newZoom);
			SetContentOffsetX(contentOffsetX);
			_lblZoom.Text = (Zoom * 100).ToString("0") + "%";
			//Console.WriteLine("HandlePinchGestureRecognizer - initialZoom: {0} newZoom: {1}", _initialZoom, newZoom);
		}
예제 #7
0
        public void DrawText(string text, BasicPoint point, BasicColor color, string fontFace, float fontSize)
        {
            // Very ugly fix for Roboto which is rendered too low on OS X
            var newPt = new BasicPoint(point.X, point.Y);
            if(fontFace.ToUpper().Contains("ROBOTO"))
                newPt.Y -= 2;

            // NSString.DrawString needs to be run on the UI thread... weird
            InvokeOnMainThread(() => {
                CoreGraphicsHelper.DrawTextAtPoint(Context, GenericControlHelper.ToPoint(newPt), text, fontFace, fontSize, GenericControlHelper.ToNSColor(color));
            });
        }
예제 #8
0
 public void DrawLine(BasicPoint point, BasicPoint point2, BasicPen pen)
 {
     var paint = new Paint
     {
         AntiAlias = true,
         Color = GenericControlHelper.ToColor(pen.Brush.Color),
         StrokeWidth = pen.Thickness * Density
     };
     paint.SetStyle(Paint.Style.Fill);
     _canvas.DrawLine(point.X, point.Y, point2.X, point2.Y, paint);
 }
예제 #9
0
 public void DrawText(string text, BasicPoint point, BasicColor color, string fontFace, float fontSize)
 {
     var paint = new Paint
     {
         AntiAlias = true,
         Color = GenericControlHelper.ToColor(color),
         TextSize = fontSize * Density,
     };
     var boundsText = new Rect();
     paint.GetTextBounds(text, 0, text.Length, boundsText);
     _canvas.DrawText(text, point.X - boundsText.Left, point.Y - boundsText.Top, paint);
     //_canvas.DrawText(text, point.X, point.Y, paint);
 }
예제 #10
0
		public void DrawText(string text, BasicPoint point, BasicColor color, string fontFace, float fontSize)
		{
			CoreGraphicsHelper.DrawTextAtPoint(Context, GenericControlHelper.ToPoint(point), text, fontFace, fontSize, GenericControlHelper.ToColor(color).CGColor);
		}
예제 #11
0
        private void DrawHeader(IGraphicsContext context)
        {
            var rect = new BasicRectangle();
            var pen = new BasicPen();
            var penTransparent = new BasicPen();
            var brushGradient = new BasicGradientBrush(_theme.HeaderBackgroundColor, _theme.HeaderBackgroundColor, 90);

            // Draw header (for some reason, the Y must be set -1 to cover an area which isn't supposed to be displayed)
            var rectBackgroundHeader = new BasicRectangle(0, -1, Frame.Width, _songCache.LineHeight + 1);
            context.DrawRectangle(rectBackgroundHeader, brushGradient, penTransparent);

            // Loop through columns
            int offsetX = 0;
            for (int b = 0; b < _songCache.ActiveColumns.Count; b++)
            {
                var column = _songCache.ActiveColumns[b];
                if (column.Visible)
                {
                    // The last column always take the remaining width
                    int columnWidth = column.Width;
                    if (b == _songCache.ActiveColumns.Count - 1)
                    {
                        // Calculate the remaining width
                        int columnsWidth = 0;
                        for (int c = 0; c < _songCache.ActiveColumns.Count - 1; c++)
                            columnsWidth += _songCache.ActiveColumns[c].Width;
                        columnWidth = (int) (Frame.Width - columnsWidth + HorizontalScrollBar.Value);
                    }

                    // Check if mouse is over this column header
                    if (column.IsMouseOverColumnHeader)
                    {
                        // Draw header (for some reason, the Y must be set -1 to cover an area which isn't supposed to be displayed)                        
                        rect = new BasicRectangle(offsetX - HorizontalScrollBar.Value, -1, column.Width, _songCache.LineHeight + 1);
                        brushGradient = new BasicGradientBrush(_theme.MouseOverHeaderBackgroundColor, _theme.MouseOverHeaderBackgroundColor, 90);
                        context.DrawRectangle(rect, brushGradient, penTransparent);
                    }
                    else if (column.IsUserMovingColumn)
                    {
                        // Draw header (for some reason, the Y must be set -1 to cover an area which isn't supposed to be displayed)                        
                        rect = new BasicRectangle(offsetX - HorizontalScrollBar.Value, -1, column.Width, _songCache.LineHeight + 1);
                        brushGradient = new BasicGradientBrush(new BasicColor(0, 0, 255), new BasicColor(0, 255, 0), 90);
                        context.DrawRectangle(rect, brushGradient, penTransparent);
                    }

                    // Check if the header title must be displayed
                    if (_songCache.ActiveColumns[b].IsHeaderTitleVisible)
                    {
                        // Display title                
                        var rectTitle = new BasicRectangle(offsetX - HorizontalScrollBar.Value + 2, _theme.Padding / 2, column.Width, _songCache.LineHeight - _theme.Padding + 2);
                        //stringFormat.Trimming = StringTrimming.EllipsisCharacter;
                        context.DrawText(column.Title, rectTitle, _theme.HeaderTextColor, _theme.FontNameBold, _theme.FontSize);
                    }

                    // Draw column separator line; determine the height of the line
                    int columnHeight = (int) Frame.Height;

                    // Determine the height of the line; if the items don't fit the control height...
                    if (_items.Count < _songCache.NumberOfLinesFittingInControl)
                    {
                        // Set height as the number of items (plus header)
                        columnHeight = (_items.Count + 1) * _songCache.LineHeight;
                    }

                    // Draw column line
                    //g.DrawLine(Pens.DarkGray, new Point(offsetX + column.Width - HorizontalScrollBar.Value, 0), new Point(offsetX + column.Width - HorizontalScrollBar.Value, columnHeight));

                    // Check if the column is ordered by
                    if (column.FieldName == _orderByFieldName && !String.IsNullOrEmpty(column.FieldName))
                    {
                        // Create triangle points,,,
                        var ptTriangle = new BasicPoint[3];

                        // ... depending on the order by ascending value
                        int triangleWidthHeight = 8;
                        int trianglePadding = (_songCache.LineHeight - triangleWidthHeight) / 2;
                        if (_orderByAscending)
                        {
                            // Create points for ascending
                            ptTriangle[0] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - (triangleWidthHeight / 2) - HorizontalScrollBar.Value, trianglePadding);
                            ptTriangle[1] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - HorizontalScrollBar.Value, _songCache.LineHeight - trianglePadding);
                            ptTriangle[2] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - triangleWidthHeight - HorizontalScrollBar.Value, _songCache.LineHeight - trianglePadding);
                        }
                        else
                        {
                            // Create points for descending
                            ptTriangle[0] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - (triangleWidthHeight / 2) - HorizontalScrollBar.Value, _songCache.LineHeight - trianglePadding);
                            ptTriangle[1] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - HorizontalScrollBar.Value, trianglePadding);
                            ptTriangle[2] = new BasicPoint(offsetX + column.Width - triangleWidthHeight - triangleWidthHeight - HorizontalScrollBar.Value, trianglePadding);
                        }

                        // Draw triangle
                        pen = new BasicPen(new BasicBrush(new BasicColor(255, 0, 0)), 1);
                    }

                    // Increment offset by the column width
                    offsetX += column.Width;
                }
            }

            // Display column move marker
            if (IsColumnMoving)
            {
                // Draw marker
                pen = new BasicPen(new BasicBrush(new BasicColor(255, 0, 0)), 1);
                context.DrawRectangle(new BasicRectangle(_columnMoveMarkerX - HorizontalScrollBar.Value, 0, 1, Frame.Height), new BasicBrush(), pen);
            }
        }
예제 #12
0
		public void DrawLine(BasicPoint point, BasicPoint point2, BasicPen pen)
		{
			CoreGraphicsHelper.DrawLine(Context, new List<PointF>(){ GenericControlHelper.ToPoint(point), GenericControlHelper.ToPoint(point2) }, GenericControlHelper.ToColor(pen.Brush.Color).CGColor, pen.Thickness, true, false);
		}
예제 #13
0
		public void StrokeLine(BasicPoint point, BasicPoint point2)
		{
			Context.StrokeLineSegments(new PointF[2] { GenericControlHelper.ToPoint(point), GenericControlHelper.ToPoint(point2) });
		}
예제 #14
0
 public void StrokeLine(BasicPoint point, BasicPoint point2)
 {
     //SetViewportOrigin(false);
     Context.StrokeLineSegments(new PointF[2] { GenericControlHelper.ToPoint(point), GenericControlHelper.ToPoint(point2) });
 }
예제 #15
0
		public void StrokeLine(BasicPoint point, BasicPoint point2)
		{
		}
예제 #16
0
 public void StrokeLine(BasicPoint point, BasicPoint point2)
 {
     _canvas.DrawLine(point.X, point.Y, point2.X, point2.Y, _currentPaint);
 }
예제 #17
0
		public static PointF ToPoint(BasicPoint point)
		{
			return new PointF(point.X, point.Y);
		}
예제 #18
0
 public void DrawText(string text, BasicPoint point, BasicColor color, string fontFace, float fontSize)
 {
     var formattedText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface(fontFace), fontSize, new SolidColorBrush(GenericControlHelper.ToColor(color)));
     _context.DrawText(formattedText, GenericControlHelper.ToPoint(point));
 }
예제 #19
0
		private void HandlePanGestureRecognizer(UIPanGestureRecognizer sender)
		{
			var ptPan = sender.TranslationInView(this);

			if(sender.State == UIGestureRecognizerState.Began)
				_initialContentOffset = WaveFormView.ContentOffset;

			SetContentOffsetX(_initialContentOffset.X - ptPan.X); // invert pan direction

//			if (sender.State == UIGestureRecognizerState.Ended)
//			{
//				var velocity = sender.VelocityInView(this);
//				float velocityX = velocity.X * 0.2f;
//				float finalX = ptTranslated.X + velocityX;
//				float finalY = _initialContentOffset.Y;
//				float animationDuration = (Math.Abs(velocityX) * 0.0002f) + 0.2f;
//				Console.WriteLine("HandlePanGestureRecognizer - velocityX: {0} animationDuration: {1} finalX: {2}", velocityX, animationDuration, finalX);
//			}
			//Console.WriteLine("HandlePanGestureRecognizer - state: {0} initialContentOffset: {1} ptPan: {2}", _panGesture.State, _initialContentOffset, ptPan);
		}
예제 #20
0
 public WaveFormTile()
 {
     ContentOffset = new BasicPoint();
     Zoom = 1;
 }