Exemplo n.º 1
0
        void Examples()
        {
            #region Color Picker

            colorPicker = new Form(10, 10, 400, 200, new Color(14, 14, 14))
            {
                IsVisible   = true,
                IsResizable = true,
            };

            colorPicker.AddNewControl(h_val = new Slider(20, 50, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });
            colorPicker.AddNewControl(s_val = new Slider(20, 70, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });
            colorPicker.AddNewControl(v_val = new Slider(20, 90, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });

            h_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };
            s_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };
            v_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };

            colorPicker.CreateLayout(hud_form_headname, hud_form_headseam, hud_form_headend, hud_form_leftborder, hud_form_rightborder, hud_form_bottomleft, hud_form_bottomseam, hud_form_bottomright);

            FormManager.AddForm("colorPicker", colorPicker);
            #endregion

            #region Calc
            var f = new Form(340, 100, 310, 320, new Color(40, 40, 40))
            {
                IsVisible = true
            };
            f.CreateLayout(hud_form_headname,
                           hud_form_headseam,
                           hud_form_headend,
                           hud_form_leftborder,
                           hud_form_rightborder,
                           hud_form_bottomleft,
                           hud_form_bottomseam,
                           hud_form_bottomright);

            Textarea lb;

            Button b1, b2, b3, b4, b5, b6, b7, b8, b9, b0,
                   bex, bdiv, bmul, bsub, bsum,
                   er;

            var buttonx = 50;
            var buttony = 40;
            f.AddNewControl(
                lb = new Textarea(buttonx + 10, buttony + 10, 140, 30)
            {
                Font = font1
            },
                er = new Button(buttonx + 160, buttony + 10, 40, 30)
            {
                Text = "<="
            },
                b1 = new Button(buttonx + 10, buttony + 50, 40, 40)
            {
                Text = "1"
            },
                b2 = new Button(buttonx + 60, buttony + 50, 40, 40)
            {
                Text = "2"
            },
                b3 = new Button(buttonx + 110, buttony + 50, 40, 40)
            {
                Text = "3"
            },
                b4 = new Button(buttonx + 10, buttony + 100, 40, 40)
            {
                Text = "4"
            },
                b5 = new Button(buttonx + 60, buttony + 100, 40, 40)
            {
                Text = "5"
            },
                b6 = new Button(buttonx + 110, buttony + 100, 40, 40)
            {
                Text = "6"
            },
                b7 = new Button(buttonx + 10, buttony + 150, 40, 40)
            {
                Text = "7"
            },
                b8 = new Button(buttonx + 60, buttony + 150, 40, 40)
            {
                Text = "8"
            },
                b9 = new Button(buttonx + 110, buttony + 150, 40, 40)
            {
                Text = "9"
            },
                b0 = new Button(buttonx + 10, buttony + 200, 90, 40)
            {
                Text = "0"
            },
                bex = new Button(buttonx + 110, buttony + 200, 40, 40)
            {
                Text = "="
            },
                bdiv = new Button(buttonx + 160, buttony + 50, 40, 40)
            {
                Text = "/"
            },
                bmul = new Button(buttonx + 160, buttony + 100, 40, 40)
            {
                Text = "*"
            },
                bsub = new Button(buttonx + 160, buttony + 150, 40, 40)
            {
                Text = "-"
            },
                bsum = new Button(buttonx + 160, buttony + 200, 40, 40)
            {
                Text = "+"
            }
                );

            lb.Text = "0";

            List <Button> digs = new List <Button>()
            {
                b1, b2, b3, b4, b5, b6, b7, b8, b9, b0
            };
            List <Button> acts = new List <Button>()
            {
                bdiv, bmul, bsub, bsum
            };
            String v1 = "";

            Func <string> div = delegate { return((int.Parse(v1) / int.Parse(lb.Text)).ToString()); };
            Func <string> mul = delegate { return((int.Parse(v1) * int.Parse(lb.Text)).ToString()); };
            Func <string> sub = delegate { return((int.Parse(v1) - int.Parse(lb.Text)).ToString()); };
            Func <string> sum = delegate { return((int.Parse(v1) + int.Parse(lb.Text)).ToString()); };

            Func <string> sel = null;

            digs.ForEach(n => n.OnLeftClick += delegate
            {
                if (lb.Text == "0")
                {
                    lb.Text = n.Text;
                }
                else
                {
                    lb.Append = n.Text;
                }
            });

            acts.ForEach(n => n.OnLeftClick += delegate
            {
                if (sel == null && lb.Text.Length > 0)
                {
                    sel     = n.Text == "/" ? div : n.Text == "*" ? mul : n.Text == "-" ? sub : sum;
                    v1      = lb.Text;
                    lb.Text = "0";
                }
            });

            bex.OnLeftClick += delegate
            {
                if (sel != null)
                {
                    lb.Text = sel();
                    sel     = null;
                }
            };

            er.OnLeftClick += delegate
            {
                lb.Text = lb.Text.Length == 1 ? "0" : lb.Text.Substring(0, lb.Text.Length - 1);
            };

            FormManager.AddForm("CalcForm", f);
            #endregion
        }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            base.Initialize();
            IsMouseVisible = true;

            uControl.SetDefaultFont = font1;

            #region Test
            Form f = new Form(30, 100, 550, 500, new Color(14, 14, 14))
            {
                IsResizable = true,
                IsVisible   = true
            };
            Button b;
            f.AddNewControl(b = new Button(460, 450, 70, 20, new Color(50, 50, 50))
            {
                Text = "Continue"
            });

            #region Sample text
            //Textarea t;
            //            f.AddNewControl(t = new Textarea(20, 55, 515, 280));

            //            (t as Textarea).Text =
            //@"How to... {#(65,160,216):p}Warp{@p}:
            //            ^n ^n1. Warp {#(65,160,216):h}tech{@p} is commonly used to travel between star systems, but for certain amount of energy or specific fuel to feed your warp core. Press Galaxy Map button (M by default) to view available stars to travel to. The sphere around your current star system shows the bounds within which you can warp.  Now click on any star. The number below star name shows, how much fuel is required to warp to this system. It's labeled as green if you have enough amount of energy and red otherwise. Now choose a reachable star to travel to and press Travel button. The Oscillation window opens. To increase travel stability and speed, you need to alter nodes of the oscillation graph according to the warp noise map: the more accuracy, the more effectivity. Since nodes values are initially precalculated, they also can be left as is, so the travel will take its usual time. Now press Apply button to launch the warp core and travel to the chosen system. Warp can take some time, depending on distance to target star and warp core properties.
            //            ^n ^n2. You also can initiate a wave overlap with the ship that has slower warp core, allowing you to stick with other ships during the travel. When this is possible, an notice appears, which displays current distance to the ship and possibility to do this maneuver: it uses significant amount of energy depending on initial warp jump point.
            //            ^n ^nHow to... Build:
            //            ^n ^n1. Buildings are primary things that makes the world live, cycle and expand. They are subdivided by their functionality: common factories, research laboratories and energy stations. All of them are consuming various resources, depending on how it is organized and supplied. To manage its work in more simple manner, node mechanic is used. Each node requires specific amount of workers and energy to function. There are three types of nodes in the game: source, processing and storage. Source nodes are consuming local resources depending on its type (mining or farming). Processing nodes are used to process incoming resources and provide the result to the next ones. Storage nodes sends all the incoming resources to the planetary storage to be distributed among other factories or for local sales or intake resources for continued processing. If there is a lack of workers or energy, the production will be limited or, in worst case, disabled, so dependency compliance and optimization are very important. If node's inner storage is overfilled, it can cause blocking state - incoming connections are filling up, keep consuming energy and spending working time, calling continued blocking chain, so the losses are increasing.
            //            ^n ^nBuilding sizes can be four types: small, large, complex or arcological. Small ones can contain up to 5 nodes plus one for storage, large can contain up to 20, complex up to 70 and arcological up to 160 nodes.
            //            ^n ^n2. The common factories can be built on wide range of surfaces, even on non-atmosphere planets or asteroids. The size is varied by small (up to 6 processing nodes) They need abundant amount of workers and energy.
            //            ";

            //            (t as Textarea).Font = font1;
            #endregion

            Panel p, pp;
            f.AddNewControl(p  = new Panel(20, 50, 200, 100, Palette.DarkenGray));
            p.AddNewControl(pp = new Panel(10, 10, 180, 80, new Color(40, 40, 40)));

            for (int i = 0; i < 5; i++)
            {
                pp.AddNewControl(b = new Button(10, 10 + 25 * i, 70, 20, new Color(50, 50, 50))
                {
                    Text = "Continue"
                });
            }

            f.CreateLayout(hud_form_headname,
                           hud_form_headseam,
                           hud_form_headend,
                           hud_form_leftborder,
                           hud_form_rightborder,
                           hud_form_bottomleft,
                           hud_form_bottomseam,
                           hud_form_bottomright);

            f.AddNewControl(new Label(10, 12, 170, 20)
            {
                Text = "How to Reference", TextSize = 0.9f, ForeColor = new Color(238, 195, 114)
            });

            FormManager.AddForm("MainForm", f);
            #endregion

            //Examples();

            Simplex.Init(GraphicsDevice);
        }