当前位置: 首页>>代码示例>>C#>>正文


C# IGraphicsContext.DrawRectangle方法代码示例

本文整理汇总了C#中IGraphicsContext.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext.DrawRectangle方法的具体用法?C# IGraphicsContext.DrawRectangle怎么用?C# IGraphicsContext.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphicsContext的用法示例。


在下文中一共展示了IGraphicsContext.DrawRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public override void Draw(IGraphicsContext gc)
 {
     if (_SelectionBand.Width > 0 || _SelectionBand.Height > 0)
     {
         if (_DrawDirection)
         {
             gc.Color = Color.LightGray;
             gc.DrawRectangle (_SelectionBand);
             gc.DrawLine (StartPoint, EndPoint, Color.LightGray, Color.DarkGray);
             gc.DrawTrianglePointer (StartPoint, EndPoint, 5, 5);
         }
         else
         {
             gc.Color = Color.Gray;
             gc.DrawRectangle (_SelectionBand);
         }
     }
 }
开发者ID:poobalan-arumugam,项目名称:stateproto,代码行数:18,代码来源:UISelectorBand.cs

示例2: Render

        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);
                    }
//.........这里部分代码省略.........
开发者ID:pascalfr,项目名称:MPfm,代码行数:101,代码来源:WaveFormScaleControl.cs

示例3: Render

        public void Render(IGraphicsContext context)
        {
            context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);

        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:5,代码来源:CircularProgressBarControl.cs

示例4: Render

        public void Render(IGraphicsContext context)
        {
            // Value range is the size between max and min track bar value.
            // Ex: Min = 50, Max = 150. Value range = 100 + 1 (because we include 50 and 100)
            _valueRange = (Maximum - Minimum) + 1;

            // Get track bar value relative to value range (value - minimum value).
            // Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50.
            _valueRelativeToValueRange = Value - Minimum;

            // Draw background
            context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);

            // Return if value range is zero
            if (_valueRange == 0)
                return;

            // Draw fader track
            float trackX = context.BoundsWidth / 2;
            float trackY = Margin;
            float trackY2 = context.BoundsHeight - Margin;

            // Draw shadow track
            context.DrawLine(new BasicPoint(trackX + 1, trackY + 1), new BasicPoint(trackX + 1, trackY2 + 1), new BasicPen(new BasicBrush(_centerLineShadowColor), 1));

            // Draw track
            context.DrawLine(new BasicPoint(trackX, trackY), new BasicPoint(trackX, trackY2), new BasicPen(new BasicBrush(_centerLineColor), 1));

            // Get the track height (remove margin from top and bottom)            
            _trackHeight = context.BoundsHeight - (Margin * 2);

            // Get tick width
            float tickHeight = _trackHeight / _valueRange;

            // Get the percentage of the value relative to value range (needed to draw the fader).
            // We need to divide the value relative to value range to the value range to get the ratio.
            // Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50. Value range = 100. Value ratio = 0.5
            _valueRatio = (_valueRelativeToValueRange / _valueRange);

            // Calculate fader position
            // We need to invert the values (i.e. max is on top, min is bottom)
            //float valueY = (valueRatio * trackHeight) + Margin;            
            float valueY = _trackHeight - (_valueRatio * _trackHeight) + Margin;
            float faderY = valueY + ((tickHeight - FaderHeight) / 2);
            float tickCenterY = valueY + (tickHeight / 2);

            // Create fader rectangle            
            _rectFader = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY, FaderWidth, FaderHeight);

            //    // Draw tick zone (for debug)
            //    //RectangleF rectTickZone = new RectangleF(valueX, 0, tickWidth, Height);
            //    //g.FillRectangle(Brushes.DarkGray, rectTickZone);            

            var rectFaderShadowTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 1, FaderWidth, 8);
            var rectFaderShadowBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 8 + 1, FaderWidth, 8);
            var rectFaderShadowCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 4 + 1, FaderWidth, FaderHeight - 8);

            context.DrawEllipsis(rectFaderShadowTop, _brushFaderShadowColor, _penTransparent);
            context.DrawEllipsis(rectFaderShadowBottom, _brushFaderShadowColor, _penTransparent);
            context.DrawRectangle(rectFaderShadowCenter, _brushFaderShadowColor, _penTransparent);

            // Draw fader outline (with 8px border)            
            var rectFaderTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY, FaderWidth, 8);
            var rectFaderBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + FaderHeight - 8, FaderWidth, 8);
            var rectFaderBottomCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + FaderHeight - 10, FaderWidth, 6);
            var rectFaderCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2), faderY + 4, FaderWidth, FaderHeight - 8);

            context.DrawEllipsis(rectFaderTop, _brushFaderGradient, _penTransparent);
            context.DrawEllipsis(rectFaderBottom, _brushFaderShadowColor1, _penTransparent);
            context.DrawRectangle(rectFaderCenter, _brushFaderColor2, _penTransparent);
            context.DrawRectangle(rectFaderBottomCenter, _brushFaderShadowColor1, _penTransparent);

            // Draw fader inside (with 4px border)
            var rectFaderInsideBottom = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 8, FaderWidth - 2, 4);
            var rectFaderInsideBottomCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + FaderHeight - 12, FaderWidth - 2, FaderHeight - 24);
            var rectFaderInsideTop = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 4, FaderWidth - 2, 8);
            var rectFaderInsideTopCenter = new BasicRectangle((context.BoundsWidth / 2) - (FaderWidth / 2) + 1, faderY + 8, FaderWidth - 2, FaderHeight - 24);

            context.DrawEllipsis(rectFaderInsideTop, _brushFaderShadowColor1, _penTransparent);
            context.DrawEllipsis(rectFaderInsideTopCenter, _brushFaderShadowGradient, _penTransparent);
            context.DrawEllipsis(rectFaderInsideBottom, _brushFaderColor2, _penTransparent);
            context.DrawRectangle(rectFaderInsideBottomCenter, _brushFaderColor2, _penTransparent);
            context.DrawLine(new BasicPoint((context.BoundsWidth / 2) - (FaderWidth / 2), tickCenterY), new BasicPoint((context.BoundsWidth / 2) - (FaderWidth / 2) + FaderWidth, tickCenterY), _penMiddleLineColor);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:84,代码来源:FaderControl.cs

示例5: Render

        public void Render(IGraphicsContext context)
        {
            // Value range is the size between max and min track bar value.
            // Ex: Min = 50, Max = 150. Value range = 100 + 1 (because we include 50 and 100)
            _valueRange = (Maximum - Minimum) + 1;

            // Get track bar value relative to value range (value - minimum value).
            // Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50.            
            _valueRelativeToValueRange = Value - Minimum;

            // Draw background
            context.DrawRectangle(new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight), _brushBackground, _penTransparent);

            // Return if value range is zero
            if (_valueRange == 0)
                return;

            // Draw fader track
            float trackX = Margin; // add margin from left
            float trackX2 = context.BoundsWidth - Margin; // add margin from right
            float trackY = context.BoundsHeight / 2; // right in the center

            context.DrawLine(new BasicPoint(trackX + 1, trackY + 1), new BasicPoint(trackX2 + 1, trackY + 1), _penCenterLineShadow);
            context.DrawLine(new BasicPoint(trackX, trackY), new BasicPoint(trackX2, trackY), _penCenterLine);

            // Get the track width (remove margin from left and right)
            _trackWidth = context.BoundsWidth - (Margin * 2);

            // Get tick width
            float tickWidth = _trackWidth / _valueRange;

            // Get the percentage of the value relative to value range (needed to draw the fader).
            // We need to divide the value relative to value range to the value range to get the ratio.
            // Ex: Min = 50, Max = 150, Value = 100. Value relative to value range = 50. Value range = 100. Value ratio = 0.5
            _valueRatio = (_valueRelativeToValueRange / _valueRange);

            // Get the value X coordinate by multiplying the value ratio to the track bar width (removed 3 pixels from left
            // and right). Add margin from left.
            float valueX = (_valueRatio * _trackWidth) + Margin; // this gives the LEFT x for our zone
            float faderX = valueX + ((tickWidth - FaderWidth) / 2);
            float tickCenterX = valueX + (tickWidth / 2);

            // Create fader rectangle
            _rectFader = new BasicRectangle(faderX, (context.BoundsHeight / 2) - (FaderHeight / 2), FaderWidth, FaderHeight);

            //// Draw tick zone (for debug)
            ////RectangleF rectTickZone = new RectangleF(valueX, 0, tickWidth, Height);
            ////g.FillRectangle(Brushes.DarkGray, rectTickZone);            

            // Draw fader outline (with 8px border)
            //var rectFaderLeft = new BasicRectangle(faderX, (context.BoundsHeight / 2) - (FaderHeight / 2), 8, FaderHeight);
            //var rectFaderRight = new BasicRectangle(faderX + FaderWidth - 8, (context.BoundsHeight / 2) - (FaderHeight / 2), 8, FaderHeight);
            var rectFaderCenter = new BasicRectangle(faderX + 4, (context.BoundsHeight / 2) - (FaderHeight / 2), FaderWidth - 8, FaderHeight);

            //context.DrawEllipsis(rectFaderLeft, new BasicGradientBrush(_faderColor1, _faderColor, 90), new BasicPen());
            //context.DrawEllipsis(rectFaderLeft, new BasicGradientBrush(new BasicColor(255, 0, 0), new BasicColor(0, 0, 255), 90), new BasicPen());
            //context.DrawEllipsis(rectFaderRight, new BasicGradientBrush(_faderColor1, _faderColor, 90), new BasicPen());
            //context.DrawEllipsis(rectFaderRight, new BasicGradientBrush(new BasicColor(0, 255, 0), new BasicColor(255, 0, 255), 90), new BasicPen());
            context.DrawEllipsis(rectFaderCenter, _brushFaderColor2, _penShadowColor1);
            //context.DrawEllipsis(rectFaderCenter, new BasicBrush(_faderColor), new BasicPen());

            // Draw fader inside (with 4px border)
            //var rectFaderInsideLeft = new BasicRectangle(faderX + 2, (context.BoundsHeight / 2) - (FaderHeight / 2) + 2, 4, FaderHeight - 4);
            //var rectFaderInsideRight = new BasicRectangle(faderX + FaderWidth - 6, (context.BoundsHeight / 2) - (FaderHeight / 2) + 2, 4, FaderHeight - 4);
            //context.DrawEllipsis(rectFaderInsideLeft, new BasicGradientBrush(_faderShadowColor, _faderShadowColor, 90), new BasicPen());
            //context.DrawEllipsis(rectFaderInsideRight, new BasicGradientBrush(_faderShadowColor, _faderShadowColor, 90), new BasicPen());
            
            context.DrawLine(new BasicPoint(tickCenterX, (context.BoundsHeight / 2) - (FaderHeight / 2)), new BasicPoint(tickCenterX, (context.BoundsHeight / 2) - (FaderHeight / 2) + FaderHeight), _penShadowColor1);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:69,代码来源:TrackBarControl.cs

示例6: Render

        public void Render(IGraphicsContext context)
        {
            Frame = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
            var rectBackground = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
            //context.DrawRectangle(rectBackground, _brushBackground, _penTransparent);

            const float padding = 2;
            const float checkPadding = padding + 4;
            var rectForeground = new BasicRectangle(padding, padding, context.BoundsWidth - (padding * 2), context.BoundsHeight - (padding * 2));
            context.DrawRectangle(rectForeground, _brushTransparent, _penBorder);

            if (_value)
            {
                context.DrawLine(new BasicPoint(checkPadding, checkPadding), new BasicPoint(context.BoundsWidth - checkPadding, context.BoundsHeight - checkPadding), _penForeground);
                context.DrawLine(new BasicPoint(context.BoundsWidth - checkPadding, checkPadding), new BasicPoint(checkPadding, context.BoundsHeight - checkPadding), _penForeground);
            }
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:17,代码来源:CheckBoxControl.cs

示例7: DrawLoops

        private void DrawLoops(IGraphicsContext context, float cursorHeight, float realScrollBarHeight)
        {
            if (_loop != null)
            {
                for (int a = 0; a < _loop.Segments.Count; a++)
                {
                    var nextSegment = _loop.GetNextSegment(a);

                    float segmentPositionPercentage = (float)_loop.Segments[a].PositionBytes / (float)Length;
                    float startX = (segmentPositionPercentage * ContentSize.Width) - ContentOffset.X;

                    float nextSegmentPositionPercentage = 0;
                    float endX = 0;
                    if (nextSegment != null)
                    {
                        nextSegmentPositionPercentage = (float)nextSegment.PositionBytes / (float)Length;
                        endX = (nextSegmentPositionPercentage * ContentSize.Width) - ContentOffset.X;
                    }

                    // Draw loop lines
                    //var pen = _markers[a].MarkerId == _activeMarkerId ? _penSelectedMarkerLine : _penMarkerLine;
                    context.SetPen(_penLoopLine);
                    context.StrokeLine(new BasicPoint(startX, 0), new BasicPoint(startX, cursorHeight));

                    // Draw text
                    //var rectText = new BasicRectangle(startX, Frame.Height - 12, 12, 12);
                    var rectText = new BasicRectangle(startX, Frame.Height - realScrollBarHeight -12, endX > startX ? endX - startX : 12, 12);
                    //var brush = _markers [a].MarkerId == _activeMarkerId ? _brushSelectedMarkerBackground : _brushMarkerBackground;
                    context.DrawRectangle(rectText, _brushLoopBackground, _penTransparent);
                    context.DrawText((a+1).ToString(), new BasicPoint(startX + 2, Frame.Height - realScrollBarHeight - 12), _textColor, LetterFontFace, LetterFontSize);
                }
            }
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:33,代码来源:WaveFormControl.cs

示例8: DrawScrollBar

        private void DrawScrollBar(IGraphicsContext context, int tileSize, float realScrollBarHeight)
        {
            if (ShowScrollBar && Zoom > 1)
            {
                int startTile = 0;
                int numberOfTilesToFillWidth = (int)Math.Ceiling(Frame.Width / tileSize);// + 1; // maybe a bug here? when one of the tile is partially drawn, you need another one?
                var requestScrollBar = new WaveFormBitmapRequest()
                {
                    StartTile = startTile,
                    EndTile = numberOfTilesToFillWidth,
                    TileSize = tileSize,
                    BoundsWaveForm = new BasicRectangle(0, 0, Frame.Width, ScrollBarHeight), // Frame
                    Zoom = 1,
                    IsScrollBar = true,
                    DisplayType = _displayType
                };
                // TODO: Cache those tiles, we do not need to request them continually since these tiles are always at 100%
                var tilesScrollBar = _waveFormCacheService.GetTiles(requestScrollBar);
                foreach (var tile in tilesScrollBar)
                {
                    context.DrawImage(new BasicRectangle(tile.ContentOffset.X, Frame.Height - realScrollBarHeight, tileSize, realScrollBarHeight), tile.Image.ImageSize, tile.Image.Image);
                }

                // Draw a veil over the area that's not visible. The veil alpha gets stronger as the zoom progresses.
                byte startAlpha = 170;
                byte maxAlpha = 210;
                byte alpha = (byte)Math.Min(maxAlpha, (startAlpha + (60 * (Zoom / 10))));
                var colorVisibleArea = new BasicColor(32, 40, 46, alpha);
                float visibleAreaWidth = (1 / Zoom) * Frame.Width;
                float visibleAreaX = (1 / Zoom) * ContentOffset.X;
                var rectLeftArea = new BasicRectangle(0, Frame.Height - realScrollBarHeight, visibleAreaX, realScrollBarHeight);
                var rectRightArea = new BasicRectangle(visibleAreaX + visibleAreaWidth, Frame.Height - realScrollBarHeight, Frame.Width - visibleAreaX - visibleAreaWidth, realScrollBarHeight);
                //context.DrawRectangle(new BasicRectangle(visibleAreaX, Frame.Height - scrollBarHeight, visibleAreaWidth, scrollBarHeight), new BasicBrush(colorVisibleArea), new BasicPen());
                context.DrawRectangle(rectLeftArea, new BasicBrush(colorVisibleArea), new BasicPen());
                context.DrawRectangle(rectRightArea, new BasicBrush(colorVisibleArea), new BasicPen());
            }
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:37,代码来源:WaveFormControl.cs

示例9: DrawMarkers

        private void DrawMarkers(IGraphicsContext context, float cursorHeight)
        {
            for (int a = 0; a < _markers.Count; a++)
            {
                float xPct = (float)_markers[a].PositionBytes / (float)Length;
                float x = (xPct * ContentSize.Width) - ContentOffset.X;

                // Draw cursor line
                var pen = _markers[a].MarkerId == _activeMarkerId ? _penSelectedMarkerLine : _penMarkerLine;
                context.SetPen(pen);
                context.StrokeLine(new BasicPoint(x, 0), new BasicPoint(x, cursorHeight));

                // Draw text
                var rectText = new BasicRectangle(x, 0, 12, 12);
                var brush = _markers[a].MarkerId == _activeMarkerId ? _brushSelectedMarkerBackground : _brushMarkerBackground;
                context.DrawRectangle(rectText, brush, _penTransparent);
                string letter = Conversion.IndexToLetter(a).ToString();
                context.DrawText(letter, new BasicPoint(x + 2, 0), _textColor, LetterFontFace, LetterFontSize);
            }
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:20,代码来源:WaveFormControl.cs

示例10: DrawRows

        private void DrawRows(IGraphicsContext context)
        {
            var state = new DrawCellState();
            BasicGradientBrush brushGradient = null;
            var penTransparent = new BasicPen();    

            // Calculate how many lines must be skipped because of the scrollbar position
            _startLineNumber = Math.Max((int) Math.Floor((double) VerticalScrollBar.Value/(double) (_songCache.LineHeight)), 0);

            // Check if the total number of lines exceeds the number of icons fitting in height
            _numberOfLinesToDraw = 0;
            if (_startLineNumber + _songCache.NumberOfLinesFittingInControl > _items.Count)
            {
                // There aren't enough lines to fill the screen
                _numberOfLinesToDraw = _items.Count - _startLineNumber;
            }
            else
            {
                // Fill up screen 
                _numberOfLinesToDraw = _songCache.NumberOfLinesFittingInControl;
            }

            // Add one line for overflow; however, make sure we aren't adding a line without content 
            if (_startLineNumber + _numberOfLinesToDraw + 1 <= _items.Count)
                _numberOfLinesToDraw++;

            // Loop through lines
            for (int a = _startLineNumber; a < _startLineNumber + _numberOfLinesToDraw; a++)
            {                
                // Calculate offsets, widths and other variants
                state.OffsetX = 0;
                state.OffsetY = (a * _songCache.LineHeight) - VerticalScrollBar.Value + _songCache.LineHeight; // compensate for scrollbar position
                int albumArtColumnWidth = _columns[0].Visible ? _columns[0].Width : 0;
                int lineBackgroundWidth = (int) (Frame.Width + HorizontalScrollBar.Value - albumArtColumnWidth);
                if (VerticalScrollBar.Visible)
                    lineBackgroundWidth -= VerticalScrollBar.Width;

                // Check conditions to determine background color
                var audioFile = _items[a].AudioFile;
                var colorBackground1 = _theme.BackgroundColor;
                var colorBackground2 = _theme.BackgroundColor;
                if ((_mode == SongGridViewMode.AudioFile && audioFile != null && audioFile.Id == _nowPlayingAudioFileId) || 
                    (_mode == SongGridViewMode.Playlist && _items[a].PlaylistItemId == _nowPlayingPlaylistItemId))
                {
                    colorBackground1 = _theme.NowPlayingBackgroundColor;
                    colorBackground2 = _theme.NowPlayingBackgroundColor;
                }

                if (_items[a].IsSelected)
                {
                    colorBackground1 = _theme.SelectedBackgroundColor;
                    colorBackground2 = _theme.SelectedBackgroundColor;

//                    // Use darker color
//                    byte diff = 4;
//                    colorBackground1 = new BasicColor(255,
//                        (byte)((colorBackground1.R - diff < 0) ? 0 : colorBackground1.R - diff),
//                        (byte)((colorBackground1.G - diff < 0) ? 0 : colorBackground1.G - diff),
//                        (byte)((colorBackground1.B - diff < 0) ? 0 : colorBackground1.B - diff));
//                    colorBackground2 = new BasicColor(255,
//                        (byte)((colorBackground2.R - diff < 0) ? 0 : colorBackground2.R - diff),
//                        (byte)((colorBackground2.G - diff < 0) ? 0 : colorBackground2.G - diff),
//                        (byte)((colorBackground2.B - diff < 0) ? 0 : colorBackground2.B - diff));
                }

                //// Check if mouse is over item
                //if (items[a].IsMouseOverItem)
                //{
                //    // Use lighter color
                //    int diff = 20;
                //    colorBackground1 = Color.FromArgb(255,
                //        (colorBackground1.R + diff > 255) ? 255 : colorBackground1.R + diff,
                //        (colorBackground1.G + diff > 255) ? 255 : colorBackground1.G + diff,
                //        (colorBackground1.B + diff > 255) ? 255 : colorBackground1.B + diff);
                //    colorBackground2 = Color.FromArgb(255,
                //        (colorBackground2.R + diff > 255) ? 255 : colorBackground2.R + diff,
                //        (colorBackground2.G + diff > 255) ? 255 : colorBackground2.G + diff,
                //        (colorBackground2.B + diff > 255) ? 255 : colorBackground2.B + diff);
                //}

                //// Check conditions to determine background color
                //if ((_mode == SongGridViewMode.AudioFile && audioFile.Id == _nowPlayingAudioFileId) ||
                //    (_mode == SongGridViewMode.Playlist && _items[a].PlaylistItemId == _nowPlayingPlaylistItemId))
                //{
                //    colorNowPlaying1 = colorBackground1;
                //    colorNowPlaying2 = colorBackground2;
                //}

                // Draw row background
                var rectBackground = new BasicRectangle(albumArtColumnWidth - HorizontalScrollBar.Value, state.OffsetY, lineBackgroundWidth, _songCache.LineHeight + 1);
                brushGradient = new BasicGradientBrush(colorBackground1, colorBackground2, 90);
                context.DrawRectangle(rectBackground, brushGradient, penTransparent);

                // Loop through columns                
                for (int b = 0; b < _songCache.ActiveColumns.Count; b++)
                {
                    DrawCell(context, a, b, audioFile, state);
                }
            }

//.........这里部分代码省略.........
开发者ID:pascalfr,项目名称:MPfm,代码行数:101,代码来源:SongGridViewControl.cs

示例11: DrawStatus

        private void DrawStatus(IGraphicsContext context, string status)
        {
            //Console.WriteLine("WaveFormControl - DrawStatus - status: {0}", status);
            context.DrawRectangle(Frame, new BasicBrush(_backgroundColor), new BasicPen());            
			var rectText = context.MeasureText(status, new BasicRectangle(0, 0, Frame.Width, 30), FontFace, FontSize);                
            float x = (context.BoundsWidth - rectText.Width) / 2;
            float y = context.BoundsHeight / 2;
            context.DrawText(status, new BasicPoint(x, y), _textColor, FontFace, FontSize);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:WaveFormControl.cs

示例12: Render

        /// <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);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:35,代码来源:SongGridViewControl.cs

示例13: DrawDebugInformation

        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);
            }
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:36,代码来源:SongGridViewControl.cs

示例14: DrawHeader

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

//.........这里部分代码省略.........
开发者ID:pascalfr,项目名称:MPfm,代码行数:101,代码来源:SongGridViewControl.cs

示例15: DrawAlbumCoverZone

        private void DrawAlbumCoverZone(IGraphicsContext context, int row, AudioFile audioFile2, DrawCellState state)
        {
            var pen = new BasicPen();
            var penTransparent = new BasicPen();
            var brushGradient = new BasicGradientBrush();
            var item = _items[row];
            //string albumTitle = audioFile != null ? audioFile.AlbumTitle : state.CurrentAlbumTitle; // if this is an empty row, keep last album title

            // Check for an album title change (or the last item of the grid)
            if (state.CurrentAlbumArtKey == item.AlbumArtKey)
                return;

            state.CurrentAlbumArtKey = item.AlbumArtKey;

            int albumCoverStartIndex = 0;
            int albumCoverEndIndex = 0;

            // For displaying the album cover, we need to know how many songs of the same album are bundled together
            // Start by getting the start index
            for (int c = row; c > 0; c--)
            {
                var previousItem = _items[c];
                if (previousItem.AlbumArtKey != item.AlbumArtKey)
                {
                    albumCoverStartIndex = c + 1;
                    break;
                }
            }

            // Find the end index
            for (int c = row + 1; c < _items.Count; c++)
            {
                var nextItem = _items[c];

                // If the album title is different, this means we found the next album title
                if (nextItem.AlbumArtKey != item.AlbumArtKey)
                {
                    albumCoverEndIndex = c - 1;
                    break;
                }
                // If this is the last item of the grid...
                else if (c == _items.Count - 1)
                {
                    albumCoverEndIndex = c;
                    break;
                }
            }

            var audioFile = _items[albumCoverStartIndex].AudioFile;

            // Calculate y and height
            int scrollbarOffsetY = (_startLineNumber * _songCache.LineHeight) - VerticalScrollBar.Value;
            int y = ((albumCoverStartIndex - _startLineNumber) * _songCache.LineHeight) + _songCache.LineHeight + scrollbarOffsetY;

            // Calculate the height of the album cover zone (+1 on end index because the array is zero-based)
            int linesToCover = Math.Min(MinimumRowsPerAlbum, (albumCoverEndIndex + 1 - albumCoverStartIndex));
            int albumCoverZoneHeight = linesToCover * _songCache.LineHeight;
            int heightWithPadding = Math.Min(albumCoverZoneHeight - (_theme.Padding * 2), _songCache.ActiveColumns[0].Width - (_theme.Padding * 2));

            // Make sure the height is at least zero (not necessary to draw anything!)
            if (albumCoverZoneHeight > 0)
            {
                // Draw album cover background
                var rectAlbumCover = new BasicRectangle(0 - HorizontalScrollBar.Value, y, _songCache.ActiveColumns[0].Width, albumCoverZoneHeight);
                brushGradient = new BasicGradientBrush(_theme.AlbumCoverBackgroundColor, _theme.AlbumCoverBackgroundColor, 90);
                context.DrawRectangle(rectAlbumCover, brushGradient, penTransparent);

                // Measure available width for text
                int widthAvailableForText = _columns[0].Width - (_theme.Padding * 2);

                // Display titles depending on if an album art was found
                var rectAlbumCoverArt = new BasicRectangle();
                var rectAlbumTitleText = new BasicRectangle();
                var rectArtistNameText = new BasicRectangle();
                var sizeAlbumTitle = new BasicRectangle();
                var sizeArtistName = new BasicRectangle();
                bool useAlbumArtOverlay = false;
                bool displayArtistNameAndAlbumTitle = false;

                // Try to extract image from cache
                IBasicImage imageAlbumCover = null;
                SongGridViewImageCache cachedImage = null;
                try
                {
                    cachedImage = _imageCache.FirstOrDefault(x => x.Key == item.AlbumArtKey);
                }
                catch (Exception ex)
                {
                    Tracing.Log(ex);
                }

                if (cachedImage != null)
                    imageAlbumCover = cachedImage.Image;

                // Album art not found in cache; try to find an album cover in one of the file
                if (cachedImage == null)
                {
                    try
                    {
                        // Check if the album cover is already in the pile
//.........这里部分代码省略.........
开发者ID:pascalfr,项目名称:MPfm,代码行数:101,代码来源:SongGridViewControl.cs


注:本文中的IGraphicsContext.DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。