コード例 #1
0
        public override void LoadXmlElement(string aName, string aValue)
        {
            switch (aName)
            {
            case "RenderDirection":
                _renderDirection = (RenderDirections)Byte.Parse(aValue);
                break;

            case "UseAlpha":
                _useAlpha = Boolean.Parse(aValue);
                break;

            case "BackgroundColour":
                _backgroundColour = StringToColour(aValue);
                break;

            case "ForegroundColour":
                _foregroundColour = StringToColour(aValue);
                break;
            }
        }
コード例 #2
0
ファイル: RendererImage.cs プロジェクト: RiskyKen/tray-usage
        public override void LoadXmlElement(string aName, string aValue)
        {
            switch (aName)
            {
            case "RenderDirection":
                _renderDirection = (RenderDirections)Byte.Parse(aValue);
                break;

            case "BackgroundImagePath":
                _backgroundImagePath = aValue;
                break;

            case "ActiveImagePath":
                _activeImagePath = aValue;
                break;

            case "ForegroundImagePath":
                _foregroundImagePath = aValue;
                break;

            case "PaddingTop":
                _paddingTop = int.Parse(aValue);
                break;

            case "PaddingBottom":
                _paddingBottom = int.Parse(aValue);
                break;

            case "PaddingLeft":
                _paddingLeft = int.Parse(aValue);
                break;

            case "PaddingRight":
                _paddingRight = int.Parse(aValue);
                break;
            }
        }
コード例 #3
0
        //TODO move into base class.
        private void RenderBar(Bitmap buffer, Brush brush, Int32 barWidth, Int32 barValue, Int32 barOffset, RenderDirections renderDirection)
        {
            int xOffset = 0;
            int yOffset = 0;

            switch (renderDirection)
            {
            case RenderDirections.UP:
                yOffset = 1;
                break;

            case RenderDirections.DOWN:
                yOffset = 1;
                break;

            case RenderDirections.RIGHT:
                xOffset = 1;
                break;

            case RenderDirections.LEFT:
                xOffset = 1;
                break;
            }

            int x;
            int y;
            int width;
            int height;

            x = 1 + (barOffset * yOffset);
            y = 1 + (barOffset * xOffset);

            if (!UseAlpha)
            {
                width  = (barWidth * yOffset) + (barValue * xOffset);
                height = (barWidth * xOffset) + (barValue * yOffset);

                if (renderDirection == RenderDirections.UP)
                {
                    y += 14 - barValue;
                }
                if (renderDirection == RenderDirections.RIGHT)
                {
                    x += 14 - barValue;
                }

                Graphics.FromImage(buffer).FillRectangle(brush, x, y, width, height);
            }
            else
            {
                Int32 normalDrawAmount = (Int32)Math.Floor((Double)(barValue / 256));
                Int32 alphaDrawAmount  = barValue - (normalDrawAmount * 256);

                width  = (barWidth * yOffset) + (normalDrawAmount * xOffset);
                height = (barWidth * xOffset) + (normalDrawAmount * yOffset);

                if (renderDirection == RenderDirections.UP)
                {
                    y += 14 - normalDrawAmount;
                }
                if (renderDirection == RenderDirections.RIGHT)
                {
                    x += 14 - normalDrawAmount;
                }

                Graphics.FromImage(buffer).FillRectangle(brush, x, y, width, height);

                SolidBrush alphaBrush = new SolidBrush(Color.FromArgb(alphaDrawAmount, ForegroundColour.R, ForegroundColour.G, ForegroundColour.B));

                switch (renderDirection)
                {
                case RenderDirections.UP:
                    Graphics.FromImage(buffer).FillRectangle(alphaBrush, x, y - 1, width, 1);
                    break;

                case RenderDirections.DOWN:
                    Graphics.FromImage(buffer).FillRectangle(alphaBrush, x, y + 1, width, 1);
                    break;

                case RenderDirections.RIGHT:
                    Graphics.FromImage(buffer).FillRectangle(alphaBrush, x - 1, y, 1, height);
                    break;

                case RenderDirections.LEFT:
                    Graphics.FromImage(buffer).FillRectangle(alphaBrush, x + 1, y, 1, height);
                    break;
                }

                alphaBrush.Dispose();
            }
        }
コード例 #4
0
ファイル: RendererBasic.cs プロジェクト: RiskyKen/tray-usage
        private void RenderBar(Bitmap buffer, Brush brush, Int32 barWidth, Int32 barValue, Int32 barOffset, RenderDirections renderDirection)
        {
            int xOffset = 0;
            int yOffset = 0;

            switch (renderDirection)
            {
                case RenderDirections.UP:
                    yOffset = 1;
                    break;
                case RenderDirections.DOWN:
                    yOffset = 1;
                    break;
                case RenderDirections.RIGHT:
                    xOffset = 1;
                    break;
                case RenderDirections.LEFT:
                    xOffset = 1;
                    break;
            }

            int x;
            int y;
            int width;
            int height;

            x = 1 + (barOffset * yOffset);
            y = 1 + (barOffset * xOffset);

            if (!UseAlpha)
            {
                width = (barWidth * yOffset) + (barValue * xOffset);
                height = (barWidth * xOffset) + (barValue * yOffset);

                if (renderDirection == RenderDirections.UP) { y += 14 - barValue; }
                if (renderDirection == RenderDirections.RIGHT) { x += 14 - barValue; }

                Graphics.FromImage(buffer).FillRectangle(brush, x, y, width, height);
            }
            else
            {
                Int32 normalDrawAmount = (Int32)Math.Floor((Double)(barValue / 256));
                Int32 alphaDrawAmount = barValue - (normalDrawAmount * 256);

                width = (barWidth * yOffset) + (normalDrawAmount * xOffset);
                height = (barWidth * xOffset) + (normalDrawAmount * yOffset);

                if (renderDirection == RenderDirections.UP) { y += 14 - normalDrawAmount; }
                if (renderDirection == RenderDirections.RIGHT) { x += 14 - normalDrawAmount; }

                Graphics.FromImage(buffer).FillRectangle(brush, x, y, width, height);

                SolidBrush alphaBrush = new SolidBrush(Color.FromArgb(alphaDrawAmount, ForegroundColour.R, ForegroundColour.G, ForegroundColour.B));

                switch (renderDirection)
                {
                    case RenderDirections.UP:
                        Graphics.FromImage(buffer).FillRectangle(alphaBrush, x, y - 1, width, 1);
                        break;
                    case RenderDirections.DOWN:
                        Graphics.FromImage(buffer).FillRectangle(alphaBrush, x, y + 1, width, 1);
                        break;
                    case RenderDirections.RIGHT:
                        Graphics.FromImage(buffer).FillRectangle(alphaBrush, x - 1, y, 1, height);
                        break;
                    case RenderDirections.LEFT:
                        Graphics.FromImage(buffer).FillRectangle(alphaBrush, x + 1, y, 1, height);
                        break;
                }

                alphaBrush.Dispose();
            }
        }
コード例 #5
0
ファイル: RendererBasic.cs プロジェクト: RiskyKen/tray-usage
 public override void LoadXmlElement(string aName, string aValue)
 {
     switch (aName)
     {
         case "RenderDirection":
             _renderDirection = (RenderDirections)Byte.Parse(aValue);
             break;
         case "UseAlpha":
             _useAlpha = Boolean.Parse(aValue);
             break;
         case "BackgroundColour":
             pBackgroundColour = StringToColour(aValue);
             break;
         case "ForegroundColour":
             pForegroundColour = StringToColour(aValue);
             break;
     }
 }
コード例 #6
0
ファイル: RendererImage.cs プロジェクト: RiskyKen/tray-usage
 public override void LoadXmlElement(string aName, string aValue)
 {
     switch (aName)
     {
         case "RenderDirection":
             _renderDirection = (RenderDirections)Byte.Parse(aValue);
             break;
         case "BackgroundImagePath":
             _backgroundImagePath = aValue;
             break;
         case "ActiveImagePath":
             _activeImagePath = aValue;
             break;
         case "ForegroundImagePath":
             _foregroundImagePath = aValue;
             break;
         case "PaddingTop":
             _paddingTop = int.Parse(aValue);
             break;
         case "PaddingBottom":
             _paddingBottom = int.Parse(aValue);
             break;
         case "PaddingLeft":
             _paddingLeft = int.Parse(aValue);
             break;
         case "PaddingRight":
             _paddingRight = int.Parse(aValue);
             break;
     }
 }