Пример #1
0
 private void CreateDrawingResources()
 {
     ColorBackground = new BasicColor(32, 40, 46);
     ColorForeground = new BasicColor(231, 76, 60);
     _brushBackground = new BasicBrush(ColorBackground);
     _brushForeground = new BasicBrush(ColorForeground);
     _penTransparent = new BasicPen();
 }
Пример #2
0
 public void DrawEllipsis(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
 {            
 }
Пример #3
0
        public void DrawRectangle(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
        {
            if(brush is BasicGradientBrush)
                _context.DrawRectangle(GenericControlHelper.ToLinearGradientBrush((BasicGradientBrush)brush), GenericControlHelper.ToPen(pen), GenericControlHelper.ToRect(rectangle));

            _context.DrawRectangle(GenericControlHelper.ToSolidColorBrush(brush), GenericControlHelper.ToPen(pen), GenericControlHelper.ToRect(rectangle));
        }
Пример #4
0
 public void DrawEllipsis(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
 {
     _context.DrawEllipse(GenericControlHelper.ToSolidColorBrush(brush), GenericControlHelper.ToPen(pen), GenericControlHelper.ToPoint(rectangle.Center()), rectangle.Width / 2, rectangle.Height / 2);
 }
Пример #5
0
 public void DrawPath(BasicPath path, BasicBrush brush, BasicPen pen)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public void DrawPath(BasicPath path, BasicBrush brush, BasicPen pen)
 {
     // TODO: Add pen
     var cgPath = GenericControlHelper.ToCGPath(path);
     var color = GenericControlHelper.ToCGColor(brush.Color);
     CoreGraphicsHelper.FillPath(Context, cgPath, color);
 }
Пример #7
0
 private void CreateDrawingResources()
 {
     _penTransparent = new BasicPen();
     _penShadowColor1 = new BasicPen(new BasicBrush(_theme.FaderShadowColor), 1);
     _penCenterLine = new BasicPen(new BasicBrush(_theme.CenterLineColor), 1);
     _penCenterLineShadow = new BasicPen(new BasicBrush(_theme.CenterLineShadowColor), 1);
     _brushBackground = new BasicBrush(_theme.BackgroundColor);
     _brushFaderColor2 = new BasicBrush(_theme.FaderColor);
 }
Пример #8
0
 public static SolidColorBrush ToSolidColorBrush(BasicBrush brush)
 {
     var solidColorBrush = new SolidColorBrush(ToColor(brush.Color));
     solidColorBrush.Freeze();
     return solidColorBrush;
 }
Пример #9
0
 private void CreateDrawingResources()
 {
     _penTransparent = new BasicPen();
     _brushBackground = new BasicBrush(_colorBackground);
 }
Пример #10
0
        /// <summary>
        /// Occurs when the control needs to be painted.
        /// </summary>
        public void Render(IGraphicsContext context)
        {
            if (_items == null)
                return;

            //var stopwatch = new Stopwatch();
            //stopwatch.Start();

            // If frame doesn't match, refresh frame and song cache
            if (Frame.Width != context.BoundsWidth || Frame.Height != context.BoundsHeight || _songCache == null)
            {
                Frame = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
                InvalidateSongCache();
            }            

            // Draw background
            context.DrawRectangle(Frame, new BasicBrush(_theme.AlbumCoverBackgroundColor), new BasicPen());

            DrawRows(context);
            DrawHeader(context);
            DrawDebugInformation(context);

            if (HorizontalScrollBar.Visible && VerticalScrollBar.Visible)
            {
                // Draw a bit of control color over the 16x16 area in the lower right corner
                var brush = new BasicBrush(new BasicColor(200, 200, 200));
                context.DrawRectangle(new BasicRectangle(Frame.Width - 16, Frame.Height - 16, 16, 16), brush, new BasicPen());
            }

            //stopwatch.Stop();
            //Console.WriteLine("SongGridViewControl - Render - Completed in {0} - frame: {1} numberOfLinesToDraw: {2}", stopwatch.Elapsed, Frame, _numberOfLinesToDraw);
        }
Пример #11
0
        private void DrawCell(IGraphicsContext context, int row, int col, AudioFile audioFile, DrawCellState state)
        {
            var rect = new BasicRectangle();
            var brush = new BasicBrush();
            var brushGradient = new BasicGradientBrush();
            var penTransparent = new BasicPen();
            var column = _songCache.ActiveColumns[col];
            if (column.Visible)
            {
                if (column.Title == "Now Playing")
                {
                    // Draw now playing icon
                    if ((_mode == SongGridViewMode.AudioFile && audioFile != null && audioFile.Id == _nowPlayingAudioFileId) ||
                        (_mode == SongGridViewMode.Playlist && _items[row].PlaylistItemId == _nowPlayingPlaylistItemId))
                    {
                        // Which size is the minimum? Width or height?                    
                        int availableWidthHeight = column.Width - 4;
                        if (_songCache.LineHeight <= column.Width)
                            availableWidthHeight = _songCache.LineHeight - 4;
                        else
                            availableWidthHeight = column.Width - 4;

                        // Calculate the icon position                                
                        float iconNowPlayingX = ((column.Width - availableWidthHeight) / 2) + state.OffsetX - HorizontalScrollBar.Value;
                        float iconNowPlayingY = state.OffsetY + ((_songCache.LineHeight - availableWidthHeight) / 2);

                        // Create NowPlaying rect (MUST be in integer)                    
                        _rectNowPlaying = new BasicRectangle((int)iconNowPlayingX, (int)iconNowPlayingY, availableWidthHeight, availableWidthHeight);
                        state.NowPlayingSongFound = true;

                        // Draw outer circle
                        brushGradient = new BasicGradientBrush(_theme.NowPlayingIndicatorBackgroundColor, _theme.NowPlayingIndicatorBackgroundColor, _timerAnimationNowPlayingCount % 360);
                        context.DrawEllipsis(_rectNowPlaying, brushGradient, penTransparent);

                        // Draw inner circle
                        rect = new BasicRectangle((int)iconNowPlayingX + 4, (int)iconNowPlayingY + 4, availableWidthHeight - 8, availableWidthHeight - 8);
                        brush = new BasicBrush(_theme.NowPlayingBackgroundColor);
                        context.DrawEllipsis(rect, brush, penTransparent);
                    }
                }
                else if (column.Title == "Album Cover")
                {
                    DrawAlbumCoverZone(context, row, audioFile, state);
                }
                else if (audioFile != null)
                {
                    // Print value depending on type
                    var propertyInfo = audioFile.GetType().GetProperty(column.FieldName);
                    if (propertyInfo != null)
                    {
                        string value = string.Empty;
                        try
                        {
                            if (propertyInfo.PropertyType.FullName == "System.String")
                            {
                                value = propertyInfo.GetValue(audioFile, null).ToString();
                            }
                            else if (propertyInfo.PropertyType.FullName.Contains("Int64") &&
                                propertyInfo.PropertyType.FullName.Contains("Nullable"))
                            {
                                long? longValue = (long?)propertyInfo.GetValue(audioFile, null);
                                if (longValue.HasValue)
                                    value = longValue.Value.ToString();
                            }
                            else if (propertyInfo.PropertyType.FullName.Contains("DateTime") &&
                                propertyInfo.PropertyType.FullName.Contains("Nullable"))
                            {
                                DateTime? dateTimeValue = (DateTime?)propertyInfo.GetValue(audioFile, null);
                                if (dateTimeValue.HasValue)
                                    value = dateTimeValue.Value.ToShortDateString() + " " + dateTimeValue.Value.ToShortTimeString();
                            }
                            else if (propertyInfo.PropertyType.FullName.Contains("System.UInt32"))
                            {
                                uint uintValue = (uint)propertyInfo.GetValue(audioFile, null);
                                value = uintValue.ToString();
                            }
                            else if (propertyInfo.PropertyType.FullName.Contains("System.Int32"))
                            {
                                int intValue = (int)propertyInfo.GetValue(audioFile, null);
                                value = intValue.ToString();
                            }
                            else if (propertyInfo.PropertyType.FullName.Contains("Sessions.Sound.AudioFileFormat"))
                            {
                                AudioFileFormat theValue = (AudioFileFormat)propertyInfo.GetValue(audioFile, null);
                                value = theValue.ToString();
                            }
                        }
                        catch
                        {
                            // Do nothing
                        }

                        //// 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);
                        //}

                        // Display text
                        rect = new BasicRectangle(state.OffsetX - HorizontalScrollBar.Value + 2, state.OffsetY + (_theme.Padding / 2), _songCache.ActiveColumns[col].Width, _songCache.LineHeight - _theme.Padding + 2);
                        //stringFormat.Trimming = StringTrimming.EllipsisCharacter;
                        //stringFormat.Alignment = StringAlignment.Near;

                        // Use bold for ArtistName and DiscTrackNumber
                        if (column.FieldName == "ArtistName" || column.FieldName == "DiscTrackNumber")
                            context.DrawText(value, rect, _theme.TextColor, _theme.FontNameBold, _theme.FontSize);
                        else
                            context.DrawText(value, rect, _theme.TextColor, _theme.FontName, _theme.FontSize);
                    }
                }

                state.OffsetX += column.Width;
            }
        }
Пример #12
0
        private void DrawDebugInformation(IGraphicsContext context)
        {
            // Display debug information if enabled
            if (_displayDebugInformation)
            {
                // Build debug string
                var sbDebug = new StringBuilder();
                sbDebug.AppendLine("Line Count: " + _items.Count.ToString());
                sbDebug.AppendLine("Line Height: " + _songCache.LineHeight.ToString());
                sbDebug.AppendLine("Lines Fit In Height: " + _songCache.NumberOfLinesFittingInControl.ToString());
                sbDebug.AppendLine("Total Width: " + _songCache.TotalWidth);
                sbDebug.AppendLine("Total Height: " + _songCache.TotalHeight);
                sbDebug.AppendLine("Scrollbar Offset Y: " + _songCache.ScrollBarOffsetY);
                sbDebug.AppendLine("HScrollbar Maximum: " + HorizontalScrollBar.Maximum.ToString());
                sbDebug.AppendLine("HScrollbar LargeChange: " + HorizontalScrollBar.LargeChange.ToString());
                sbDebug.AppendLine("HScrollbar Value: " + HorizontalScrollBar.Value.ToString());
                sbDebug.AppendLine("VScrollbar Maximum: " + VerticalScrollBar.Maximum.ToString());
                sbDebug.AppendLine("VScrollbar LargeChange: " + VerticalScrollBar.LargeChange.ToString());
                sbDebug.AppendLine("VScrollbar Value: " + VerticalScrollBar.Value.ToString());

                // Measure string
                //stringFormat.Trimming = StringTrimming.Word;
                //stringFormat.LineAlignment = StringAlignment.Near;
                //SizeF sizeDebugText = g.MeasureString(sbDebug.ToString(), fontDefault, _columns[0].Width - 1, stringFormat);
                var sizeDebugText = context.MeasureText(sbDebug.ToString(), new BasicRectangle(0, 0, _columns[0].Width, 40), _theme.FontName, _theme.FontSize);
                var rect = new BasicRectangle(0, 0, _columns[0].Width - 1, sizeDebugText.Height);

                // Draw background
                var brush = new BasicBrush(new BasicColor(200, 0, 0));
                var penTransparent = new BasicPen();
                context.DrawRectangle(rect, brush, penTransparent);

                // Draw string
                context.DrawText(sbDebug.ToString(), rect, new BasicColor(255, 255, 255), _theme.FontName, _theme.FontSize);
            }
        }
Пример #13
0
		public void DrawRectangle(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
		{
			CoreGraphicsHelper.FillRect(Context, GenericControlHelper.ToRect(rectangle), GenericControlHelper.ToColor(brush.Color).CGColor);
			// TODO: Add outline
		}
Пример #14
0
		public void DrawEllipsis(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
		{
			CoreGraphicsHelper.DrawEllipsis(Context, GenericControlHelper.ToRect(rectangle), GenericControlHelper.ToColor(pen.Brush.Color).CGColor, pen.Thickness);
			// TODO: Add fill
		}
Пример #15
0
		public void DrawPath(BasicPath path, BasicBrush brush, BasicPen pen)
		{
		}
Пример #16
0
        private void CreateDrawingResources()
        {
            FontSize = 12;
            FontFace = "Roboto Light";
            LetterFontSize = 10;
            LetterFontFace = "Roboto";
            Frame = new BasicRectangle();

            _penTransparent = new BasicPen();
            _penCursorLine = new BasicPen(new BasicBrush(_cursorColor), 1);
            _penSecondaryCursorLine = new BasicPen(new BasicBrush(_secondaryCursorColor), 1);
            _penMarkerLine = new BasicPen(new BasicBrush(_markerCursorColor), 1);
            _penLoopLine = new BasicPen(new BasicBrush(_loopCursorColor), 1);
            _penSelectedMarkerLine = new BasicPen(new BasicBrush(_markerSelectedCursorColor), 1);
            _brushLoopBackground = new BasicBrush(_loopBackgroundColor);
            _brushMarkerBackground = new BasicBrush(_markerBackgroundColor);
            _brushSelectedMarkerBackground = new BasicBrush(_markerSelectedCursorColor);
        }
Пример #17
0
 public void DrawRectangle(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
 {
     _context.SetSourceRGB(brush.Color.R / 255f, brush.Color.G / 255f, brush.Color.B / 255f);
     _context.Rectangle(GenericControlHelper.ToRect(rectangle));
     _context.Fill();
 }
Пример #18
0
 public void DrawRectangle(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
 {
     // TODO: Add outline
     var paint = new Paint
     {
         AntiAlias = true,
         Color = GenericControlHelper.ToColor(brush.Color)
     };
     paint.SetStyle(Paint.Style.Fill);
     if (brush is BasicGradientBrush)
     {
         var gradientBrush = (BasicGradientBrush) brush;
         paint.SetShader(new LinearGradient(gradientBrush.StartPoint.X, gradientBrush.StartPoint.Y, gradientBrush.EndPoint.X, gradientBrush.EndPoint.Y, GenericControlHelper.ToColor(gradientBrush.Color2), GenericControlHelper.ToColor(gradientBrush.Color), Shader.TileMode.Mirror));
     }
     _canvas.DrawRect(GenericControlHelper.ToRect(rectangle), paint);
 }
Пример #19
0
 private void CreateDrawingResources()
 {
     _penTransparent = new BasicPen();
     _penMiddleLineColor = new BasicPen(new BasicBrush(_faderMiddleLineColor), 1);
     _brushBackground = new BasicBrush(_backgroundColor);
     _brushFaderShadowColor = new BasicBrush(_faderShadowColor);
     _brushFaderGradient = new BasicGradientBrush(_faderColor1, _faderColor2, 90);
     _brushFaderColor2 = new BasicBrush(_faderColor2);
     _brushFaderShadowColor1 = new BasicBrush(_faderShadowColor1);
     _brushFaderShadowGradient = new BasicGradientBrush(_faderShadowColor1, _faderShadowColor2, 90);
 }
Пример #20
0
 private void CreateDrawingResources()
 {
     ColorBackground = new BasicColor(32, 40, 46);
     ColorForeground = new BasicColor(230, 237, 242);//174, 196, 212);
     ColorBorder = new BasicColor(83, 104, 119);
     _brushBackground = new BasicBrush(ColorBackground);
     _brushForeground = new BasicBrush(ColorForeground);
     _brushBorder = new BasicBrush(ColorBorder);
     _brushTransparent = new BasicBrush(new BasicColor(0, 0, 0, 0));
     _penBorder = new BasicPen(_brushBorder, 2);
     _penForeground = new BasicPen(_brushForeground, 2);
     _penTransparent = new BasicPen();
 }
Пример #21
0
        public void Render(IGraphicsContext context)
        {
            lock (_locker)
            {
                if (_brushBackground == null)
                {
                    _brushBackground = new BasicBrush(_backgroundColor);
                    _penTransparent = new BasicPen();
                    _penBorder = new BasicPen(new BasicBrush(_borderColor), 1);
                    _rectText = context.MeasureText("12345:678.90", new BasicRectangle(0, 0, Frame.Width, Frame.Height), "HelveticaNeue", 10);
                }
            }

            _density = context.Density;
            Frame = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
            context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);
            if (_audioFile == null || _audioFileLength == 0)
                return;

            // Check if scale type needs to be updated
            if (_lastWidth != ContentSize.Width)
            {
                _lastWidth = ContentSize.Width;
                CalculateScale(context.Density);
            }

            // Draw scale borders
            //Console.WriteLine("WaveFormScaleView - scaleType: {0} totalMinutes: {1} totalSeconds: {2} totalMinutesScaled: {3} totalSecondsScaled: {4}", scaleType.ToString(), totalMinutes, totalSeconds, totalMinutesScaled, totalSecondsScaled);
            context.SetPen(_penBorder);
            context.StrokeLine(new BasicPoint(0, ContentSize.Height - 1), new BasicPoint(ContentSize.Width, ContentSize.Height - 1));

            int firstVisibleIndex = (int)Math.Floor(ContentOffset.X / _tickWidth);
            int lastVisibleIndex = firstVisibleIndex + (int)Math.Floor(context.BoundsWidth / _tickWidth);
            float tickX = -ContentOffset.X + (firstVisibleIndex * _tickWidth);
            int majorTickIndex = (int)Math.Ceiling(firstVisibleIndex / 10f);
            //for (int a = firstVisibleIndex; a < _tickCount; a++)
            for (int a = firstVisibleIndex; a < lastVisibleIndex; a++)
            {
                // Ignore ticks out of bounds
                bool isMajorTick = ((a % 10) == 0);
                if (tickX >= 0 && tickX <= Frame.Width)
                {
                    //Console.WriteLine("####> WaveFormView - Scale - tick {0} x: {1} isMajorTick: {2} tickCount: {3}", a, tickX, isMajorTick, tickCount);

                    if(isMajorTick)
                        //    //context.DrawLine(new BasicPoint(tickX, context.BoundsHeight - (context.BoundsHeight / 1.25f)), new BasicPoint(tickX, context.BoundsHeight), _penMajorTick);
                        context.StrokeLine(new BasicPoint(tickX, 0), new BasicPoint(tickX, ContentSize.Height - 1));
                    else
                        context.StrokeLine(new BasicPoint(tickX, ContentSize.Height - (ContentSize.Height / 6) - 1), new BasicPoint(tickX, ContentSize.Height - 1));

                    if (isMajorTick)
                    {
                        // Draw dashed traversal line for major ticks
                        context.StrokeLine(new BasicPoint(tickX, ContentSize.Height - 1), new BasicPoint(tickX, ContentSize.Height - 1));

                        // Determine major scale text
                        int minutes = 0;
                        int seconds = 0;
                        switch (_scaleType)
                        {
                            case WaveFormScaleType._10minutes:
                                minutes = majorTickIndex * 10;
                                seconds = 0;
                                break;
                            case WaveFormScaleType._5minutes:
                                minutes = majorTickIndex * 5;
                                seconds = 0;
                                break;
                            case WaveFormScaleType._2minutes:
                                minutes = majorTickIndex * 2;
                                seconds = 0;
                                break;
                            case WaveFormScaleType._1minute:
                                minutes = majorTickIndex;
                                seconds = 0;
                                break;
                            case WaveFormScaleType._30seconds:
                                minutes = (int)Math.Floor(majorTickIndex / _scaleMultiplier);
                                seconds = (majorTickIndex % _scaleMultiplier == 0) ? 0 : 30;
                                break;
                            case WaveFormScaleType._10seconds:
                                minutes = (int)Math.Floor(majorTickIndex / _scaleMultiplier);
                                seconds = ((int)Math.Floor(majorTickIndex % _scaleMultiplier)) * 10;
                                break;
                            case WaveFormScaleType._5seconds:
                                minutes = (int)Math.Floor(majorTickIndex / _scaleMultiplier);
                                seconds = ((int)Math.Floor(majorTickIndex % _scaleMultiplier)) * 5;
                                break;
                            case WaveFormScaleType._1second:
                                minutes = (int)Math.Floor(majorTickIndex / _scaleMultiplier);
                                seconds = (int)Math.Floor(majorTickIndex % _scaleMultiplier);
                                break;
                        }

                        // Draw text at every major tick (minute count)
                        string scaleMajorTitle = string.Format("{0}:{1:00}", minutes, seconds);                    
                        //float y = ContentSize.Height - (ContentSize.Height/12f) - _rectText.Height - (0.5f * context.Density);                    
                        float y = 3 * context.Density;//ContentSize.Height - _rectText.Height - (10 * context.Density); 
						context.DrawText(scaleMajorTitle, new BasicPoint(tickX + (4 * context.Density), y), _textColor, FontFace, FontSize);
                    }
                }
                
                if(isMajorTick)
                    majorTickIndex++;

                tickX += _tickWidth;
            }
        }
Пример #22
0
 public void DrawRectangle(BasicRectangle rectangle, BasicBrush brush, BasicPen pen)
 {
     CoreGraphicsHelper.FillRect(Context, GenericControlHelper.ToRect(rectangle), GenericControlHelper.ToCGColor(brush.Color));
     CoreGraphicsHelper.DrawRect(Context, GenericControlHelper.ToRect(rectangle), GenericControlHelper.ToCGColor(pen.Brush.Color), pen.Thickness);
 }