Example #1
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (item == null || item.Image == null)
            {
                dc.Draw(missing, 0, 0, defaultSize.X, defaultSize.Y);
            }
            else
            {
                if (!isSizeFixed)
                {
                    FixSize();
                }
                dc.Draw(item.Image, 0, 0);
                dc.Draw(lblAmount, 1, 1);

                if (item.Meter > 0)
                {
                    double a = (item.Meter) / 100.0;
                    var    r = (byte)((1 - a) * 255);
                    var    g = (byte)(a * 255);
                    var    b = (byte)0;
                    dc.SetColor(r, g, b, 255);
                    dc.DrawRectangle(Width - 5, (int)((1 - a) * Height), 5, (int)(a * Height));
                    dc.ResetColor();
                }
            }
        }
Example #2
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (Relation == null)
            {
                return;
            }

            dc.Draw(scales[(-Relation.Balance) + 5], 0, 0);
            dc.Draw(sword, 0, 0);
            //g.aimage(intf.render(String.format("%d", rel.intns)).tex(), intc, 0.5, 0.5);

            if (Offense >= 200)
            {
                dc.SetColor(offColor);
                dc.DrawRectangle(54, 61, -Offense / 200, 5);
            }
            if (Defense >= 200)
            {
                dc.SetColor(defColor);
                dc.DrawRectangle(54, 71, -Defense / 200, 5);
            }
            dc.ResetColor();

            if (Relation.Offense >= 200)
            {
                dc.SetColor(offColor);
                dc.DrawRectangle(80, 61, Relation.Offense / 200, 5);
            }
            if (Relation.Offense >= 200)
            {
                dc.SetColor(defColor);
                dc.DrawRectangle(80, 71, Relation.Defense / 200, 5);
            }
            dc.ResetColor();
        }
Example #3
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.Draw(back, 0, 0, Width, Height);
     dc.Draw(box, 0, 0, Width, Height);
     dc.Draw(text, 4, 2, Width - 8, Height - 4);
     dc.Draw(numText, 4, 2, Width - 8, Height - 4);
 }
Example #4
0
        protected override void OnDraw(DrawingContext dc)
        {
            int i = (10000 - Value) * fg.Height / 10000;

            dc.Draw(bg, bgOffset);
            dc.Draw(fg.Slice(0, i, fg.Width, fg.Height - i), fgOffset.Add(0, i));
        }
Example #5
0
            protected override void OnDraw(DrawingContext dc)
            {
                if (Buff == null)
                {
                    return;
                }

                if (Buff.Amount >= 0)
                {
                    dc.Draw(cframe, 0, 0);
                    dc.SetColor(Color.Black);
                    dc.DrawRectangle(ameteroff.X, ameteroff.Y, ametersz.X, ametersz.Y);
                    dc.SetColor(Color.White);
                    dc.DrawRectangle(ameteroff.X, ameteroff.Y, (Buff.Amount * ametersz.X) / 100, ametersz.Y);
                    dc.ResetColor();
                }
                else
                {
                    dc.Draw(frame, 0, 0);
                }

                if (Buff.Image != null)
                {
                    dc.Draw(Buff.Image, imgoff.X, imgoff.Y);
                }
            }
Example #6
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.SetColor(backColor);
     dc.Draw(tabImage, 0, 0, Width, Height);
     dc.ResetColor();
     dc.Draw(label, TabPadding, TabPadding);
 }
Example #7
0
        protected override void OnDraw(DrawingContext dc)
        {
            bool missing = false;

            dc.SetClip(0, 0, Width, Height);
            dc.Draw(bg, 0, 0, Width, Height);

            var tc = Geometry.MapToTile(session.WorldPosition);

            int bx = (tc.X - Width / 2).Div(Geometry.GridWidth);
            int by = (tc.Y - Height / 2).Div(Geometry.GridHeight);
            int ex = (tc.X + Width / 2).Div(Geometry.GridWidth);
            int ey = (tc.Y + Height / 2).Div(Geometry.GridHeight);

            for (int gx = bx; gx <= ex; gx++)
            {
                for (int gy = by; gy <= ey; gy++)
                {
                    var grid = session.Map.GetGrid(gx, gy);
                    if (grid == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(grid.MinimapName))
                    {
                        missing = true;
                        break;
                    }

                    var image = GetMinimap(grid);
                    if (image != null)
                    {
                        var tx = gx * Geometry.GridWidth;
                        var ty = gy * Geometry.GridHeight;
                        dc.Draw(image, tx - tc.X + Width / 2, ty - tc.Y + Height / 2);
                    }
                }
            }

            if (!missing)
            {
                foreach (var member in session.Party.Members)
                {
                    if (!member.Location.HasValue)
                    {
                        continue;
                    }
                    var p = Geometry.MapToTile(member.Location.Value).Sub(tc);
                    int x = p.X + Width / 2;
                    int y = p.Y + Height / 2;
                    dc.SetColor(Color.FromArgb(128, member.Color));
                    dc.Draw(mark, x - mark.Width / 2, y - mark.Height / 2);
                    dc.ResetColor();
                }
            }

            dc.ResetClip();
        }
Example #8
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.Draw(box, 0, 0);
     if (IsChecked)
     {
         dc.Draw(mark, 0, 0);
     }
 }
Example #9
0
 public void Draw(DrawingContext dc, int x, int y, int itemHeight)
 {
     if (Image != null)
     {
         dc.Draw(Image, x, y, itemHeight, itemHeight);
     }
     dc.Draw(label, x + itemHeight + 2, y + (itemHeight - label.Font.Height) / 2);
 }
Example #10
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.Draw(background, 0, 0);
     if (Image != null)
     {
         dc.Draw(Image, 6, (Height - Image.Height) / 2);
     }
 }
Example #11
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.Draw(background, 0, 0);
     if (image.Value != null)
     {
         dc.Draw(image.Value, 1, 1, Width - 2, Height - 2);
     }
 }
Example #12
0
        public void Draw(DrawingContext dc, int x, int y)
        {
            var p = offset.Add(x - 3, y - 8 - Fonts.Text.Height);
            var w = Math.Max(text.TextWidth + Padding * 2, 10);
            var h = Fonts.Text.Height + Padding * 2;

            dc.Draw(bubble, p.X, p.Y, w, h + 2);
            dc.Draw(text, p.X + Padding, p.Y + Padding);
        }
Example #13
0
 public override void Draw(DrawingContext ctx)
 {
     if (_spritePressed != null && _isDown)
     {
         ctx.Draw(_spritePressed, ActualPosition);
     }
     else
     {
         ctx.Draw(_sprite, ActualPosition);
     }
 }
Example #14
0
        protected override void OnDraw(DrawingContext dc)
        {
            dc.Draw(background, 0, 0, Width, Height);
            dc.Draw(box, 0, 0, Width, Height);

            if (titleLine != null)
            {
                int hw = 48 + titleLine.TextWidth;
                dc.Draw(cap, (Width - hw) / 2, -7, hw, 21);
                dc.Draw(titleLine, (Width - titleLine.TextWidth) / 2, -5);
            }
        }
Example #15
0
        protected override void OnDraw(DrawingContext dc)
        {
            dc.Draw(background, 0, 0);
            dc.SetColor(Color);
            int h = Height - 6;

            h = (h * Amount) / 100;
            dc.SetClip(0, Height - 3 - h, Width, h);
            dc.Draw(foreground, 0, 0);
            dc.ResetClip();
            dc.ResetColor();
        }
Example #16
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.Draw(background, 0, 0);
     if (Image != null)
     {
         dc.Draw(Image, 1, 1, Width - 2, Height - 2);
         if (isPressed)
         {
             dc.SetColor(0, 0, 0, 128);
             dc.DrawRectangle(1, 1, Width - 2, Height - 2);
             dc.ResetColor();
         }
     }
 }
Example #17
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (Session == null)
            {
                return;
            }

            camera.Update();

            RequestMaps();
            DrawTiles(dc);
            DrawScene(dc);

            // draw placed object
            if (placeGob != null && placeRadius > 0)
            {
                var p = ToRelative(Geometry.MapToScreen(placeGob.Position));
                int w = (int)(placeRadius * 4 * Math.Sqrt(0.5)) * 2;
                int h = (int)(placeRadius * 2 * Math.Sqrt(0.5)) * 2;
                dc.SetColor(0, 255, 0, 32);
                dc.Draw(circle, p.X - (w / 2), p.Y - (h / 2), w, h);
                dc.ResetColor();
            }

            // draw owner name
            var span = (DateTime.Now - ownerShowTime).TotalSeconds;

            if (span < 6)
            {
                byte a;
                if (span < 1)
                {
                    a = (byte)(255 * span);
                }
                else if (span < 4)
                {
                    a = 255;
                }
                else
                {
                    a = (byte)((255 * (2 - (span - 4))) / 2);
                }

                ownerNameText.TextColor    = Color.FromArgb(a, Color.White);
                ownerNameText.OutlineColor = Color.FromArgb(a, Color.Black);
                dc.Draw(ownerNameText,
                        (Width - ownerNameText.TextWidth) / 2,
                        (Height - ownerNameText.Font.Height) / 2);
            }
        }
Example #18
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var gfx = dc.Ultraviolet.GetGraphics();

            // Calculate the shadow's offset from the element
            var cumulativeTransform = target.VisualTransform;

            var shadowVectorStart = new Vector2(0, 0);

            Vector2.Transform(ref shadowVectorStart, ref cumulativeTransform, out shadowVectorStart);

            var shadowVectorEnd = Vector2.Transform(new Vector2(1, 0), Matrix.CreateRotationZ(Radians.FromDegrees(-Direction)));

            Vector2.Transform(ref shadowVectorEnd, ref cumulativeTransform, out shadowVectorEnd);

            var shadowDepth  = (Int32)element.View.Display.DipsToPixels(ShadowDepth);
            var shadowVector = Vector2.Normalize(shadowVectorEnd - shadowVectorStart) * shadowDepth;

            // Draw the horizontal blur pass
            var pass1Target = target.Next;

            gfx.SetRenderTarget(pass1Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius    = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color);
            dc.End();

            // Draw the vertical blur pass
            var pass2Target = target.Next.Next;

            gfx.SetRenderTarget(pass2Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius    = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(pass1Target.ColorBuffer, shadowVector, null, Color, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();

            // Draw the element on top of the shadow
            dc.Begin(SpriteSortMode.Immediate, null, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();
        }
Example #19
0
        public void Draw(DrawingContext dc, int x, int y)
        {
            if (textLine == null)
            {
                return;
            }

            int w = textLine.TextWidth;
            int h = textLine.Font.Height;

            x = Math.Max(x - w, 0);
            y = Math.Max(y - h, 0);

            dc.Draw(background, x - 3, y - 3, w + 6, h + 6);
            dc.Draw(textLine, x, y);
        }
Example #20
0
        protected virtual void OnDraw(DrawingContext dc)
        {
            if (hoveredWidget != null)
            {
                var cursor = hoveredWidget.Cursor ?? Cursors.Default;
                if (Window.Cursor != cursor)
                {
                    Window.Cursor = cursor;
                }
                Tooltip = hoveredWidget.Tooltip;
            }
            else
            {
                Window.Cursor = Cursors.Default;
                Tooltip       = null;
            }

            rootWidget.Draw(dc);

            if (tooltip != null)
            {
                tooltip.Draw(dc, mousePosition.X, mousePosition.Y);
            }

            if (drag != null)
            {
                dc.Draw(drag.Image,
                        mousePosition.X - drag.Image.Width / 2,
                        mousePosition.Y - drag.Image.Height / 2);
            }
        }
Example #21
0
 protected override void OnDraw(DrawingContext dc)
 {
     if (Drawable == null)
     {
         return;
     }
     dc.Draw(Drawable, 0, 0);
 }
Example #22
0
        protected override void OnDraw(DrawingContext dc)
        {
            base.OnDraw(dc);

            // offset contents
            dc.PushMatrix();
            dc.Translate(Margin, Margin);
            dc.Draw(background, avatarPosition);
            if (gobId != -1)
            {
                var gob = gobCache.Get(gobId);
                if (gob != null && gob.Avatar != null)
                {
                    dc.Draw(gob.Avatar, avatarPosition);
                }
            }
            dc.PopMatrix();
        }
Example #23
0
 protected override void OnDraw(DrawingContext dc)
 {
     dc.SetColor(Color.Black);
     dc.DrawRectangle(4, 4, Width - 8, Height - 8);
     dc.SetColor(255, 255, 255, 128);
     dc.Draw(background, 0, 0);
     int x = 4;
     foreach (var el in els)
     {
         int w = (174 * el.Amount) / cap;
         dc.SetColor(el.Color);
         dc.DrawRectangle(x, 4, w, 24);
         x += w;
     }
     dc.SetColor(255, 255, 255, 128);
     dc.Draw(background, 0, 0);
     dc.ResetColor();
 }
Example #24
0
        protected override void OnDraw(DrawingContext dc)
        {
            int y = 0;

            for (int i = 0; i < buttonCount; i++)
            {
                dc.Draw(background, 0, y);
                y += background.Height - 1;
            }
        }
Example #25
0
 protected override void OnDraw(DrawingContext dc)
 {
     for (int x = 0; x < inventorySize.X; x++)
     {
         for (int y = 0; y < inventorySize.Y; y++)
         {
             dc.Draw(tile, (tile.Width - 1) * x, (tile.Height - 1) * y);
         }
     }
 }
Example #26
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (Session == null)
            {
                return;
            }

            var astro = Session.Time;
            var mp    = (int)(astro.MoonPhase * moons.Length);
            var moon  = moons[mp];

            var mc = MathUtils.PolarToCartesian((astro.DayTime + 0.25) * 2 * Math.PI, hbr);
            var sc = MathUtils.PolarToCartesian((astro.DayTime + 0.75) * 2 * Math.PI, hbr);

            dc.Draw(background, 0, 0);
            dc.Draw(astro.IsNight ? nightSky : daySky, 0, 0);
            dc.Draw(moon, mc.X + (Width - moon.Width) / 2, mc.Y + (Height - moon.Height) / 2);
            dc.Draw(sun, sc.X + (Width - sun.Width) / 2, sc.Y + (Height - sun.Height) / 2);
            dc.Draw(astro.IsNight ? nightScape : dayScape, 0, 0);
        }
Example #27
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (State == 0)
            {
                dc.SetColor(255, 192, 192, 255);
            }
            else if (State == 1)
            {
                dc.SetColor(192, 192, 255, 255);
            }
            else if (State == 2)
            {
                dc.SetColor(192, 255, 192, 255);
            }

            dc.Draw(bg, 0, 0, Width, Height);
            dc.ResetColor();

            dc.Draw((State & 1) != 0 ? ol : sl, 0, 0, Width, Height);
            dc.Draw((State & 2) != 0 ? or : sr, 0, 0, Width, Height);
        }
Example #28
0
        protected override void OnDraw(DrawingContext dc)
        {
            dc.SetClip(5, 5, defaultSize.X, defaultSize.Y);

            var image = Avatar?.Image;

            if (image != null)
            {
                dc.Draw(background, -(background.Width - Width) / 2, -20 + 5);
                dc.Draw(image, -(background.Width - Width) / 2, -20 + 5);
            }
            else
            {
                dc.Draw(missing, 5, 5, Width - 10, Height - 10);
            }

            dc.ResetClip();
            dc.SetColor(BorderColor);
            dc.Draw(box, 0, 0, Width, Height);
            dc.ResetColor();
        }
Example #29
0
        protected override void OnDraw(DrawingContext dc)
        {
            if (Max <= Min)
            {
                return;
            }

            dc.SetClip(0, 0, Width, Height);

            int cx = (sflarp.Width - schain.Width) / 2;

            for (int y = 0; y < Height; y += schain.Height - 1)
            {
                dc.Draw(schain, cx, y);
            }

            var a  = (double)Value / (Max - Min);
            var fy = (int)((Height - sflarp.Height) * a);

            dc.Draw(sflarp, 0, fy);

            dc.ResetClip();
        }
Example #30
0
        protected override void OnDraw(DrawingContext dc)
        {
            base.OnDraw(dc);

            dc.PushMatrix();
            dc.Translate(Margin, Margin);

            var hasMove = (AttackMove.Value != null);

            if (hasMove)
            {
                dc.Draw(AttackMove.Value.Image, 15, 20);
            }

            if (Attack.Value != null)
            {
                var p = hasMove ? new Point2D(18, 23) : new Point2D(15, 20);
                dc.Draw(Attack.Value.Image, p);
            }
            if (Maneuver.Value != null)
            {
                dc.Draw(Maneuver.Value.Image, 15, 70);
            }

            dc.Draw(iptex, 200, 32);

            var now = DateTime.Now;

            if (now < AttackCooldown)
            {
                dc.SetColor(255, 0, 128, 255);
                dc.DrawRectangle(200, 55, (int)(AttackCooldown - now).TotalMilliseconds / 100, 20);
                dc.ResetColor();
            }

            dc.PopMatrix();
        }
Example #31
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var blurTarget = target.Next.RenderTarget;

            var gfx = dc.Ultraviolet.GetGraphics();
            gfx.SetRenderTarget(blurTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color.White);
            dc.End();
        }
Example #32
0
        /// <inheritdoc/>
        protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var state = dc.GetCurrentState();
            
            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.End();

            effect.Value.Radius = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var shadowTexture = target.Next.ColorBuffer;
            dc.Draw(shadowTexture, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            
            dc.End();
            dc.Begin(state);
        }
Example #33
0
        /// <summary>
        /// Draws the specified render target at its desired visual bounds.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        /// <param name="effect">The shader effect to apply to the render target, if any.</param>
        public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
        {
            Contract.Require(dc, "dc");
            Contract.Require(element, "element");
            Contract.Require(target, "rtarget");

            if (element.View == null)
                return;

            var state = dc.GetCurrentState();

            dc.End();
            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);
            dc.Draw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var gfx = dc.Ultraviolet.GetGraphics();
            
            // Calculate the shadow's offset from the element
            var cumulativeTransform = target.VisualTransform;

            var shadowVectorStart = new Vector2(0, 0);
            Vector2.Transform(ref shadowVectorStart, ref cumulativeTransform, out shadowVectorStart);

            var shadowVectorEnd = Vector2.Transform(new Vector2(1, 0), Matrix.CreateRotationZ(Radians.FromDegrees(-Direction)));
            Vector2.Transform(ref shadowVectorEnd, ref cumulativeTransform, out shadowVectorEnd);

            var shadowDepth = (Int32)element.View.Display.DipsToPixels(ShadowDepth);
            var shadowVector = Vector2.Normalize(shadowVectorEnd - shadowVectorStart) * shadowDepth;

            // Draw the horizontal blur pass
            var pass1Target = target.Next;
            gfx.SetRenderTarget(pass1Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color);
            dc.End();

            // Draw the vertical blur pass
            var pass2Target = target.Next.Next;
            gfx.SetRenderTarget(pass2Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(pass1Target.ColorBuffer, shadowVector, null, Color, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();

            // Draw the element on top of the shadow
            dc.Begin(SpriteSortMode.Immediate, null, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();
        }