Пример #1
0
        /// <summary>
        /// 繪製到Graphics
        /// </summary>
        /// <param name="g">Graphics物件</param>
        /// <param name="rectangle">繪製區域</param>
        protected override void OnDraw(Graphics g, Rectangle rectangle)
        {
            Rectangle drawRectangle = GetScaleRectangle(rectangle);

            SolidBrush brushBack = Colors.GetBrush("Back");

            GetBackFrame(drawRectangle);
            g.FillPath(brushBack, _BackFrame);

            g.Clip = _BackRegion;
            if (DrawObjectInside != DrawNull.Value)
            {
                DrawObjectInside.Draw(g, drawRectangle);
            }
            SolidBrush brushText   = Colors.GetBrush("Text");
            SolidBrush brushShadow = Colors.GetBrush("Shadow");

            Rectangle textRectangle = GetScaleRectangle(new Rectangle(rectangle.X + TextPadding.Left, rectangle.Y + TextPadding.Top, rectangle.Width - TextPadding.Horizontal, rectangle.Height - TextPadding.Vertical));

            g.DrawString(Text, Font, brushShadow, new Rectangle(textRectangle.X + 1, textRectangle.Y + 1, textRectangle.Width, textRectangle.Height), DrawFormat);
            g.DrawString(Text, Font, brushText, textRectangle, DrawFormat);
            g.ResetClip();

            if (BorderWidth > 0)
            {
                g.DrawPath(Colors.GetPen("Border", BorderWidth), _BackFrame);
            }
        }
Пример #2
0
        /// <summary>
        /// 繪製到Graphics
        /// </summary>
        /// <param name="g">Graphics物件</param>
        /// <param name="rectangle">繪製區域</param>
        protected override void OnDraw(Graphics g, Rectangle rectangle)
        {
            Rectangle drawRectangle = GetScaleRectangle(rectangle);
            Brush     brushBack     = Colors.GetBrush("Back");

            GetBackFrame(drawRectangle);
            g.FillPath(brushBack, _BackFrame);

            g.Clip = _BackRegion;
            if (DrawObjectInside != DrawNull.Value)
            {
                DrawObjectInside.Draw(g, drawRectangle);
            }

            if (Animation.IsFull && _LastTexts.Count > 0)
            {
                _LastText       = _DisplayText;
                _DisplayText    = _LastTexts.Dequeue();
                Animation.Value = 0;
            }
            Animation.Value += Scene.IntervalOfRound;

            Brush brushText   = Colors.GetBrush("Text");
            Brush brushShadow = Colors.GetBrush("Shadow");

            Rectangle textRectangle = GetScaleRectangle(new Rectangle(rectangle.X + TextPadding.Left, rectangle.Y + TextPadding.Top, rectangle.Width - TextPadding.Horizontal, rectangle.Height - TextPadding.Vertical));

            if (Animation.IsFull)
            {
                textRectangle.Offset(1, 1);
                g.DrawString(_DisplayText, Font, brushShadow, textRectangle, DrawFormat);
                textRectangle.Offset(-1, -1);
                g.DrawString(_DisplayText, Font, brushText, textRectangle, DrawFormat);
            }
            else
            {
                int moveMaxY = textRectangle.Height + rectangle.Height / 2;
                textRectangle.Offset(1, (int)(1 - Animation.GetRatio() * moveMaxY));
                g.DrawString(_LastText, Font, brushShadow, textRectangle, DrawFormat);
                textRectangle.Offset(-1, -1);
                g.DrawString(_LastText, Font, brushText, textRectangle, DrawFormat);

                textRectangle.Offset(1, moveMaxY);
                g.DrawString(_DisplayText, Font, brushShadow, textRectangle, DrawFormat);
                textRectangle.Offset(-1, -1);
                g.DrawString(_DisplayText, Font, brushText, textRectangle, DrawFormat);
            }

            g.ResetClip();
            if (BorderWidth > 0)
            {
                g.DrawPath(Colors.GetPen("Border", BorderWidth), _BackFrame);
            }
        }
Пример #3
0
        /// <summary>
        /// 繪製到Graphics
        /// </summary>
        /// <param name="g">Graphics物件</param>
        /// <param name="rectangle">繪製區域</param>
        protected override void OnDraw(Graphics g, Rectangle rectangle)
        {
            Rectangle drawRectangle = GetScaleRectangle(rectangle);

            GetBackFrame(drawRectangle);
            DrawSkillBase drawSkillBase = DrawObjectInside as DrawSkillBase;
            SkillBase     bindingSkill  = drawSkillBase == null ? null : drawSkillBase.BindingSkill; // 取得綁定技能

            g.FillPath(Colors.GetBrush("Back"), _BackFrame);
            g.Clip = _BackRegion;
            if (bindingSkill != null && !StaticMode)
            {
                switch (bindingSkill.Status)
                {
                case SkillStatus.Disabled:
                    if (bindingSkill.Owner != null && bindingSkill.Owner.Energy.Value < bindingSkill.CostEnergy)
                    {
                        g.FillRectangle(Brushes.LightPink, drawRectangle);
                    }
                    else
                    {
                        using (LinearGradientBrush brush2 = new LinearGradientBrush(drawRectangle, Color.FromArgb(255, 255, 200), Color.FromArgb(255, 255, 240), 315))
                        {
                            g.FillRectangle(brush2, drawRectangle);
                        }
                    }
                    break;

                case SkillStatus.Cooldown:
                    float cooldownSize = (1F - bindingSkill.Cooldown.GetRatio()) * drawRectangle.Height;
                    g.FillRectangle(Brushes.AliceBlue, drawRectangle);
                    g.FillRectangle(Brushes.LightSlateGray, drawRectangle.X, drawRectangle.Y + drawRectangle.Height - cooldownSize, drawRectangle.Width, cooldownSize);
                    break;

                case SkillStatus.Channeled:
                    if (bindingSkill.Channeled.Limit < 0)
                    {
                        if (_Animation > 20)
                        {
                            _Animation %= 20;
                        }
                        int angle = _Animation * 18;
                        using (LinearGradientBrush brush2 = new LinearGradientBrush(drawRectangle, GlobalColors.Channeled, Color.FromArgb(245, 255, 240), angle))
                        {
                            g.FillRectangle(brush2, drawRectangle);
                        }
                        _Animation++;
                    }
                    else
                    {
                        float channeledSize = (1F - bindingSkill.Channeled.GetRatio()) * drawRectangle.Height;
                        Brush brushChannel  = Colors.GetBrush("Channel");
                        g.FillRectangle(brushChannel, drawRectangle.X, drawRectangle.Y + drawRectangle.Height - channeledSize, drawRectangle.Width, channeledSize);
                    }
                    break;
                }
            }

            if (DrawObjectInside != DrawNull.Value)
            {
                DrawObjectInside.Draw(g, drawRectangle);
            }
            g.ResetClip();
            g.DrawPath(Colors.GetPen("Border", BorderWidth), _BackFrame);

            if (DrawButton != RunningBox.SkillKeyType.None)
            {
                Pen       penBlack     = Colors.GetPen("Button", 2);
                Rectangle keyRectangle = new Rectangle(drawRectangle.Left + drawRectangle.Width - 15, drawRectangle.Top + drawRectangle.Height - 15, 20, 25);
                g.FillEllipse(Brushes.White, keyRectangle);

                switch (DrawButton)
                {
                case RunningBox.SkillKeyType.MouseButtonLeft:
                    g.FillPie(Brushes.SkyBlue, keyRectangle, 180, 90);

                    break;

                case RunningBox.SkillKeyType.MouseButtonRight:
                    g.FillPie(Brushes.SkyBlue, keyRectangle, 270, 90);

                    break;
                }
                g.DrawEllipse(penBlack, keyRectangle);
                penBlack.Width = 1;
                g.DrawLine(penBlack, keyRectangle.Left, keyRectangle.Top + keyRectangle.Height / 2, keyRectangle.Left + keyRectangle.Width, keyRectangle.Top + keyRectangle.Height / 2);
                g.DrawLine(penBlack, keyRectangle.Left + keyRectangle.Width / 2, keyRectangle.Top, keyRectangle.Left + keyRectangle.Width / 2, keyRectangle.Top + keyRectangle.Height / 2);
            }
        }
Пример #4
0
        /// <summary>
        /// 繪製到Graphics
        /// </summary>
        /// <param name="g">Graphics物件</param>
        /// <param name="rectangle">繪製區域</param>
        protected override void OnDraw(Graphics g, Rectangle rectangle)
        {
            Rectangle drawRectangle = GetScaleRectangle(rectangle);

            SolidBrush brushBack = Colors.GetBrush("Back");

            GetBackFrame(drawRectangle);
            g.FillPath(brushBack, _BackFrame);

            g.Clip = _BackRegion;
            if (DrawObjectInside != DrawNull.Value)
            {
                DrawObjectInside.Draw(g, drawRectangle);
            }

            Rectangle insideRectangle = GetScaleRectangle(new Rectangle(rectangle.X + TextPadding.Left, rectangle.Y + TextPadding.Top, rectangle.Width - TextPadding.Horizontal, rectangle.Height - TextPadding.Vertical));
            int       insideLeft      = insideRectangle.Left;
            int       insideTop       = insideRectangle.Top;
            int       insideWidth     = insideRectangle.Width;
            int       insideHeight    = insideRectangle.Height;
            Rectangle textRectangle   = new Rectangle(insideLeft, insideTop, insideWidth, (int)(insideHeight * 0.7F));

            string     mainText    = BindingSkill.Info;
            SolidBrush brushText   = Colors.GetBrush("Text");
            SolidBrush brushShadow = Colors.GetBrush("Shadow");
            SolidBrush brushInfo1  = Colors.GetBrush("Info1");
            SolidBrush brushInfo2  = Colors.GetBrush("Info2");
            SolidBrush brushInfo3  = Colors.GetBrush("Info3");

            textRectangle.Offset(-1, -1);
            g.DrawString(mainText, _MainFont, brushShadow, textRectangle, GlobalFormat.MiddleLeft);
            textRectangle.Offset(1, 1);
            g.DrawString(mainText, _MainFont, brushText, textRectangle, GlobalFormat.MiddleLeft);

            int infoLeft = insideLeft;
            int infoTop  = insideTop + (int)(insideHeight * 0.7F);

            g.DrawString("能量", _InfoFont, brushInfo1, infoLeft, infoTop);
            infoLeft += (int)g.MeasureString("能量", _InfoFont).Width;
            string energyText = "";

            if (BindingSkill.CostEnergy > 0)
            {
                energyText = (BindingSkill.CostEnergy / 100).ToString();
            }
            if (BindingSkill.CostEnergyPerSec > 0)
            {
                energyText = (string.IsNullOrWhiteSpace(energyText) ? "" : energyText + "+") + (BindingSkill.CostEnergyPerSec / 100).ToString() + "/s";
            }

            if (string.IsNullOrWhiteSpace(energyText))
            {
                energyText = "無";
            }
            g.DrawString(energyText, _InfoFont, brushInfo2, infoLeft, infoTop);

            infoLeft = insideLeft + insideWidth / 2 + 10;
            g.DrawString("冷卻", _InfoFont, brushInfo1, infoLeft, infoTop);
            infoLeft += (int)g.MeasureString("冷卻", _InfoFont).Width;
            string cooldownText = string.Format("{0:N1}秒", BindingSkill.Cooldown.Limit / (float)Scene.Sec(1));

            g.DrawString(cooldownText, _InfoFont, brushInfo3, infoLeft, infoTop);
            g.ResetClip();

            if (BorderWidth > 0)
            {
                g.DrawPath(Colors.GetPen("Border", BorderWidth), _BackFrame);
            }
        }