Beispiel #1
0
        public override void Update(CanvasContext2D context)
        {
            context.Save();
            context.BeginPath();
            context.Rect(0, 0, 800, 320);
            context.ClosePath();
            context.Clip();

            float speed = -(_level.Curve * _level.Speed * 50);

            if (_level.Left && _level.Speed > 0)
            {
                speed += 1;
            }
            if (_level.Right && _level.Speed > 0)
            {
                speed -= 1;
            }

            UpdateExplosions(context, speed);

            UpdateFlak(context, speed);

            foreach (Cloud cloud in _clouds)
            {
                float scale = (400 - cloud.Y) / 400;

                cloud.X = (cloud.X - (0.3f - speed) * scale + 2400) % 2400;

                context.DrawImage(
                    _cloudImage,
                    cloud.X - 1200,
                    cloud.Y - (_cloudImage.NaturalHeight / 2) * scale,
                    _cloudImage.NaturalWidth * scale,
                    _cloudImage.NaturalHeight * scale);
            }
            context.Restore();
        }
Beispiel #2
0
        public void Paint()
        {
            CanvasContext2D g = (CanvasContext2D)Canvas.GetContext(Rendering.Render2D);

            g.FillStyle = "rgb(20, 22, 31)";
            g.FillRect(0, 0, Width, Height);
            if (!ImagesLoaded)
            {
                return;
            }
            int netHeight = (Height - buffer * 2);
            int netWidth  = (Width - buffer * 2);

            RowCount = Math.Round(Math.Max(netHeight / ThumbHeight, 1));
            ColCount = Math.Round(Math.Max(netWidth / HorzSpacing, 1));

            horzMultiple = ((float)netWidth + 13) / (float)ColCount;

            startIndex = Math.Round((startIndex / ItemsPerPage) * ItemsPerPage);

            Rectangle rectf;
            int       index = startIndex;

            for (int y = 0; y < rowCount; y++)
            {
                for (int x = 0; x < colCount; x++)
                {
                    if (index >= items.Count)
                    {
                        if (items.Count == 0 || showAddButton)
                        {
                            rectf = Rectangle.Create(Left + x * horzMultiple + 3f + startOffset, Top + y * VertSpacing, ThumbWidth - 10, 60);
                            g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWide : bmpBackground, (int)((float)x * horzMultiple) + startOffset, y * VertSpacing);


                            //g.FillText(emptyText, rectf.X,rectf,Y, rectf.Width);
                            //g.DrawString(showAddButton ? addText : emptyText, UiTools.StandardRegular, (addButtonHover && showAddButton) ? UiTools.YellowTextBrush : UiTools.StadardTextBrush, rectf, UiTools.StringFormatCenterCenter);
                        }
                        break;
                    }



                    rectf = Rectangle.Create(Left + x * horzMultiple + 3 + startOffset, Top + y * VertSpacing, ThumbWidth - 14, 60);
                    //Brush textBrush = UiTools.StadardTextBrush;
                    string textBrush = "white";

                    if (index == hoverItem || (index == selectedItem && hoverItem == -1))
                    {
                        g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWideHover : bmpBackgroundHover, Left + (int)((float)x * horzMultiple) + startOffset, Top + y * VertSpacing);
                        textBrush = "yellow";
                    }
                    else
                    {
                        g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWide : bmpBackground, Left + (int)((float)x * horzMultiple) + startOffset, Top + y * VertSpacing);
                    }

                    (items[index]).Bounds = Rectangle.Create((int)(Left + x * horzMultiple) + startOffset, Top + (int)(y * VertSpacing), (int)horzMultiple, (int)VertSpacing);
                    try
                    {
                        ImageElement bmpThumb = items[index].Thumbnail;
                        if (bmpThumb != null)
                        {
                            g.DrawImage(bmpThumb, Left + (int)(x * horzMultiple) + 2 + startOffset, Top + y * VertSpacing + 3);

                            g.StrokeStyle = "rgb(0,0,0)";
                            g.Rect(Left + (int)((float)x * horzMultiple) + 2 + startOffset, Top + y * VertSpacing + 3, items[index].Thumbnail.Width, items[index].Thumbnail.Height);
                        }
                        else
                        {
                            items[index].Thumbnail     = (ImageElement)Document.CreateElement("img");
                            items[index].Thumbnail.Src = items[index].ThumbnailUrl;
                            items[index].Thumbnail.AddEventListener("load", delegate(ElementEvent e) { Refresh(); }, false);
                        }
                    }
                    // TODO FIX this!
                    catch
                    {
                    }

                    //if (((IThumbnail)items[index]).IsImage)
                    //{
                    //    g.DrawImage(Properties.Resources.InsertPictureHS, (int)((float)x * horzMultiple) + 79, y * VertSpacing + 1);
                    //}
                    //if (((IThumbnail)items[index]).IsTour)
                    //{
                    //    g.DrawImage(Properties.Resources.TourIcon, (int)((float)x * horzMultiple) + 79, y * VertSpacing + 1);
                    //}
                    //g.DrawString(((IThumbnail), UiTools.StandardRegular, textBrush, rectf, UiTools.StringFormatThumbnails);
                    g.FillStyle   = textBrush;
                    g.StrokeStyle = textBrush;
                    g.LineWidth   = 1;
                    g.Font        = "normal 8pt Arial";
                    g.FillText(items[index].Name, rectf.X, rectf.Y + rectf.Height, rectf.Width);
                    //g.FillText(items[index].Name, 10, 10);
                    index++;
                }
                if (index >= items.Count)
                {
                    break;
                }
            }
        }