public DisplayModule.RectSprite AddRectSprite(Color color, int x, int y, int width, int height)
                {
                    var retval = new RectSprite(this, color, x, y, width, height);

                    AddSprite(retval);
                    return(retval);
                }
Esempio n. 2
0
 public HelpText(IContainer Parent) : base(Parent)
 {
     Sprites["rect"] = new RectSprite(this.Viewport);
     (Sprites["rect"] as RectSprite).SetOuterColor(55, 187, 255);
     (Sprites["rect"] as RectSprite).SetInnerColor(48, 96, 148);
     Sprites["text"]   = new Sprite(this.Viewport);
     Sprites["text"].X = Sprites["text"].Y = 7;
 }
Esempio n. 3
0
        protected override void Draw()
        {
            RectSprite box = Sprites["box"] as RectSprite;

            box.SetInnerColor(InnerColor);
            box.SetOuterColor(OuterColor);
            box.SetSize(this.Size, Thickness);
            base.Draw();
        }
Esempio n. 4
0
 public PopupWindow() : base(((MainEditorWindow)Graphics.Windows[0]).UI)
 {
     Window.SetOverlayOpacity(128);
     Sprites["window"] = new RectSprite(this.Viewport, new Size(this.Size.Width - 14, this.Size.Height - 14),
                                        new Color(59, 227, 255), new Color(40, 62, 84));
     Sprites["title"]   = new Sprite(this.Viewport);
     Sprites["title"].X = 5;
     Sprites["title"].Y = 3;
     this.WindowLayer   = Window.ActiveWidget.WindowLayer + 1;
     this.Window.SetActiveWidget(this);
     Window.SetOverlayZIndex(WindowLayer * 10 - 1);
     this.SetZIndex(WindowLayer * 10);
 }
        public ActionResult CreateSprite(string button)
        {
            RectSprite sprite = new RectSprite
            {
                SpriteID = "Sprite1",
                Width = 100,
                Height = 100,
                X = 150,
                Y = 150,
                FillStyle = "green"
            };

            var container = this.GetCmp<DrawContainer>("Draw1");
            container.Add(sprite);
            container.RenderFrame();

            return this.Direct();
        }
        public ActionResult CreateSprite(string button)
        {
            RectSprite sprite = new RectSprite
            {
                SpriteID  = "Sprite1",
                Width     = 100,
                Height    = 100,
                X         = 150,
                Y         = 150,
                FillStyle = "green"
            };

            var container = this.GetCmp <DrawContainer>("Draw1");

            container.Add(sprite);
            container.RenderFrame();

            return(this.Direct());
        }
Esempio n. 7
0
        public AutotilePickerMap()
        {
            SetTitle("Individual Tile Combinations");
            MinimumSize = MaximumSize = new Size(313, 285);
            SetSize(MaximumSize);
            Center();

            RectSprite bg1 = new RectSprite(this.Viewport);

            bg1.SetOuterColor(59, 91, 124);
            bg1.SetSize(278, 210);
            bg1.X          = 19;
            bg1.Y          = 34;
            Sprites["bg1"] = bg1;
            RectSprite bg2 = new RectSprite(this.Viewport);

            bg2.SetSize(276, 208);
            bg2.X = 20;
            bg2.Y = 35;
            bg2.SetOuterColor(17, 27, 38);
            bg2.SetInnerColor(24, 38, 53);
            Sprites["bg2"] = bg2;

            CreateButton("Cancel", delegate(BaseEventArgs e)
            {
                SelectedTileID = -1;
                Close();
            });

            CreateButton("OK", delegate(BaseEventArgs e)
            {
                Close();
            });

            Sprites["tiles"]   = new Sprite(this.Viewport);
            Sprites["tiles"].X = 23;
            Sprites["tiles"].Y = 38;

            Cursor = new CursorWidget(this);
            Cursor.SetPosition(Sprites["tiles"].X - 7, Sprites["tiles"].Y - 7);
            Cursor.SetSize(32 + 14, 32 + 14);
        }
        private DrawContainer Draw(List<int> labels, List<int> data)
        {
            DrawContainer draw = new DrawContainer
            {
                ID = "Draw1",
                Border = false
            };

            int width = 800;
            int height = 250;
            int leftgutter = 30;
            int bottomgutter = 20;
            int topgutter = 20;
            double colorhue = 0.6;
            string color = System.Drawing.ColorTranslator.ToHtml(this.ColorFromHSB(colorhue, 0.5, 0.5));

            double x = (width - leftgutter) / (labels.Count * 1.0);
            int max = data.Max();
            double y = (height - bottomgutter - topgutter) / (max * 1.0);

            draw.Items.Add(this.GridPath(leftgutter + y * 0.5 + 0.5, topgutter + 0.5, width - leftgutter - x, height - topgutter - bottomgutter, 10, 10, "#000"));

            PathSprite pathSprite = new PathSprite
            {
                StrokeStyle = color,
                LineWidth = 4,
                Linejoin = StrokeLinejoin.Round
            };
            draw.Items.Add(pathSprite);

            PathSprite bgpSprite = new PathSprite
            {
                StrokeStyle = "none",
                GlobalAlpha = 0.3,
                FillStyle = color
            };

            draw.Items.Add(bgpSprite);

            List<string> p = new List<string>();
            List<string> bgpp = new List<string>();

            for (int i = 0; i < labels.Count; i++)
            {
                int yc = Convert.ToInt32(Math.Round(height - bottomgutter - y * data[i]));
                int xc = Convert.ToInt32(Math.Round(leftgutter - 10 + x * (i + 0.5)));
                int heightCraph = height - bottomgutter;
                draw.Items.Add(new TextSprite
                {
                    X = Convert.ToInt32(xc),
                    Y = height - 6,
                    Text = labels[i].ToString(),
                    FillStyle = "#000",
                    Font = "12px Helvetica, Arial"
                });

                if (i == 0)
                {
                    p.AddRange(new string[]{"M", JSON.Serialize(xc), JSON.Serialize(yc),
                                            "C", JSON.Serialize(xc), JSON.Serialize(yc)});

                    bgpp.AddRange(new string[]{"M", JSON.Serialize(leftgutter - 10 + x * 0.5), JSON.Serialize(height - bottomgutter),
                                               "L", JSON.Serialize(xc), JSON.Serialize(yc),
                                               "C", JSON.Serialize(xc), JSON.Serialize(yc)});
                }

                if (i > 0 && i < (labels.Count - 1))
                {
                    double Y0 = Math.Round(height - bottomgutter - y * data[i - 1]);
                    double X0 = Math.Round(leftgutter + x * (i - 0.5));
                    double Y2 = Math.Round(height - bottomgutter - y * data[i + 1]);
                    double X2 = Math.Round(leftgutter + x * (i + 1.5));
                    double[] a = this.GetAnchors(X0, Y0, xc, yc, X2, Y2);

                    p.AddRange(new string[] { JSON.Serialize(a[0]), JSON.Serialize(a[1]), JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(a[2]), JSON.Serialize(a[3]) });
                    bgpp.AddRange(new string[] { JSON.Serialize(a[0]), JSON.Serialize(a[1]), JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(a[2]), JSON.Serialize(a[3]) });
                }

                draw.Items.Add(new CircleSprite
                {
                    SpriteID = "dot_" + i,
                    CX = Convert.ToInt32(xc),
                    CY = Convert.ToInt32(yc),
                    Radius = 4,
                    FillStyle = "#333",
                    StrokeStyle = color,
                    LineWidth = 2
                });

                AbstractSprite rect = new RectSprite
                {
                    X = Convert.ToInt32(leftgutter + x * i),
                    Y = 0,
                    Width = Convert.ToInt32(xc),
                    Height = heightCraph,
                    StrokeStyle = "none",
                    FillStyle = "#fff",
                    GlobalAlpha = 0
                };

                //rect.Listeners.MouseOver.Handler = string.Format("onMouseOver(this, {0}, {1}, {2});", data[i], labels[i], i);
                //rect.Listeners.MouseOut.Handler = string.Format("onMouseOut(this, {0});", i);

                draw.Items.Add(rect);

                if (i == (labels.Count - 1))
                {
                    p.AddRange(new string[] { JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(xc), JSON.Serialize(yc) });
                    bgpp.AddRange(new string[] { JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(xc), JSON.Serialize(yc), "L", JSON.Serialize(xc), JSON.Serialize(height - bottomgutter), "z" });
                    pathSprite.Path = string.Join(" ", p);
                    bgpSprite.Path = string.Join(" ", bgpp);
                }
            }

            draw.Width = width;
            draw.Height = height;

            return draw;
        }
        private DrawContainer Draw(List <int> labels, List <int> data)
        {
            DrawContainer draw = new DrawContainer
            {
                ID     = "Draw1",
                Border = false
            };

            int    width        = 800;
            int    height       = 250;
            int    leftgutter   = 30;
            int    bottomgutter = 20;
            int    topgutter    = 20;
            double colorhue     = 0.6;
            string color        = System.Drawing.ColorTranslator.ToHtml(this.ColorFromHSB(colorhue, 0.5, 0.5));

            double x   = (width - leftgutter) / (labels.Count * 1.0);
            int    max = data.Max();
            double y   = (height - bottomgutter - topgutter) / (max * 1.0);

            draw.Items.Add(this.GridPath(leftgutter + y * 0.5 + 0.5, topgutter + 0.5, width - leftgutter - x, height - topgutter - bottomgutter, 10, 10, "#000"));

            PathSprite pathSprite = new PathSprite
            {
                StrokeStyle = color,
                LineWidth   = 4,
                Linejoin    = StrokeLinejoin.Round
            };

            draw.Items.Add(pathSprite);

            PathSprite bgpSprite = new PathSprite
            {
                StrokeStyle = "none",
                GlobalAlpha = 0.3,
                FillStyle   = color
            };

            draw.Items.Add(bgpSprite);

            List <string> p    = new List <string>();
            List <string> bgpp = new List <string>();

            for (int i = 0; i < labels.Count; i++)
            {
                int yc          = Convert.ToInt32(Math.Round(height - bottomgutter - y * data[i]));
                int xc          = Convert.ToInt32(Math.Round(leftgutter - 10 + x * (i + 0.5)));
                int heightCraph = height - bottomgutter;
                draw.Items.Add(new TextSprite
                {
                    X         = Convert.ToInt32(xc),
                    Y         = height - 6,
                    Text      = labels[i].ToString(),
                    FillStyle = "#000",
                    Font      = "12px Helvetica, Arial"
                });

                if (i == 0)
                {
                    p.AddRange(new string[] { "M", JSON.Serialize(xc), JSON.Serialize(yc),
                                              "C", JSON.Serialize(xc), JSON.Serialize(yc) });

                    bgpp.AddRange(new string[] { "M", JSON.Serialize(leftgutter - 10 + x * 0.5), JSON.Serialize(height - bottomgutter),
                                                 "L", JSON.Serialize(xc), JSON.Serialize(yc),
                                                 "C", JSON.Serialize(xc), JSON.Serialize(yc) });
                }

                if (i > 0 && i < (labels.Count - 1))
                {
                    double   Y0 = Math.Round(height - bottomgutter - y * data[i - 1]);
                    double   X0 = Math.Round(leftgutter + x * (i - 0.5));
                    double   Y2 = Math.Round(height - bottomgutter - y * data[i + 1]);
                    double   X2 = Math.Round(leftgutter + x * (i + 1.5));
                    double[] a  = this.GetAnchors(X0, Y0, xc, yc, X2, Y2);

                    p.AddRange(new string[] { JSON.Serialize(a[0]), JSON.Serialize(a[1]), JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(a[2]), JSON.Serialize(a[3]) });
                    bgpp.AddRange(new string[] { JSON.Serialize(a[0]), JSON.Serialize(a[1]), JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(a[2]), JSON.Serialize(a[3]) });
                }

                draw.Items.Add(new CircleSprite
                {
                    SpriteID    = "dot_" + i,
                    CX          = Convert.ToInt32(xc),
                    CY          = Convert.ToInt32(yc),
                    Radius      = 4,
                    FillStyle   = "#333",
                    StrokeStyle = color,
                    LineWidth   = 2
                });

                AbstractSprite rect = new RectSprite
                {
                    X           = Convert.ToInt32(leftgutter + x * i),
                    Y           = 0,
                    Width       = Convert.ToInt32(xc),
                    Height      = heightCraph,
                    StrokeStyle = "none",
                    FillStyle   = "#fff",
                    GlobalAlpha = 0
                };

                //rect.Listeners.MouseOver.Handler = string.Format("onMouseOver(this, {0}, {1}, {2});", data[i], labels[i], i);
                //rect.Listeners.MouseOut.Handler = string.Format("onMouseOut(this, {0});", i);

                draw.Items.Add(rect);

                if (i == (labels.Count - 1))
                {
                    p.AddRange(new string[] { JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(xc), JSON.Serialize(yc) });
                    bgpp.AddRange(new string[] { JSON.Serialize(xc), JSON.Serialize(yc), JSON.Serialize(xc), JSON.Serialize(yc), "L", JSON.Serialize(xc), JSON.Serialize(height - bottomgutter), "z" });
                    pathSprite.Path = string.Join(" ", p);
                    bgpSprite.Path  = string.Join(" ", bgpp);
                }
            }

            draw.Width  = width;
            draw.Height = height;

            return(draw);
        }
Esempio n. 10
0
        public AutotilePicker(Map Map)
        {
            SetTitle("Change Autotiles");
            MinimumSize = MaximumSize = new Size(506, 498);
            SetSize(MaximumSize);
            Center();

            OldIDs = new List <int>(Map.AutotileIDs);

            RectSprite bg1 = new RectSprite(this.Viewport);

            bg1.SetOuterColor(59, 91, 124);
            bg1.SetSize(280, 409);
            bg1.X          = 200;
            bg1.Y          = 44;
            Sprites["bg1"] = bg1;
            RectSprite bg2 = new RectSprite(this.Viewport);

            bg2.SetSize(278, 407);
            bg2.X = 201;
            bg2.Y = 45;
            bg2.SetOuterColor(17, 27, 38);
            bg2.SetInnerColor(24, 38, 53);
            Sprites["bg2"] = bg2;

            Sprites["preview"] = new Sprite(this.Viewport);

            Font f = Font.Get("Fonts/Ubuntu-B", 14);

            Label labelavail = new Label(this);

            labelavail.SetText("Available");
            labelavail.SetPosition(16, 24);
            labelavail.SetFont(f);

            Label labelinuse = new Label(this);

            labelinuse.SetText("In-use");
            labelinuse.SetPosition(16, 250);
            labelinuse.SetFont(f);

            Label labelprev = new Label(this);

            labelprev.SetText("Preview");
            labelprev.SetPosition(192, 24);
            labelprev.SetFont(f);

            ActionButton = new Button(this);
            ActionButton.SetPosition(52, 225);
            ActionButton.SetSize(85, 30);
            ActionButton.OnClicked += ActionButtonClicked;

            Available = new ListBox(this);
            Available.SetPosition(25, 44);
            Available.SetSize(151, 179);
            Available.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                if (Available.SelectedIndex != -1)
                {
                    InUse.SetSelectedIndex(-1);
                    SelectionChanged(e);
                }
            };
            Available.ListDrawer.SetContextMenuList(new List <IMenuItem>()
            {
                new MenuItem("Add Autotile")
                {
                    IsClickable = delegate(BoolEventArgs e)
                    {
                        e.Value = !(SelectedAutotile is null);
                    },
                    OnLeftClick = ActionButtonClicked
                }
            });
Esempio n. 11
0
 public ColoredBox(IContainer Parent) : base(Parent)
 {
     Sprites["box"] = new RectSprite(this.Viewport);
 }