Example #1
0
        public SettingsWindow()
        {
            ControlBox  = false;
            AddChild(ok = new StoneButton
            {
                Anchor   = global::Graphics.Orientation.Bottom,
                Position = new SlimDX.Vector2(-130, 15),
                Text     = Locale.Resource.GenOk
            });
            AddChild(cancel = new StoneButton
            {
                Anchor   = global::Graphics.Orientation.Bottom,
                Position = new SlimDX.Vector2(0, 15),
                Text     = Locale.Resource.GenCancel
            });
            AddChild(apply = new StoneButton
            {
                Anchor   = global::Graphics.Orientation.Bottom,
                Position = new SlimDX.Vector2(130, 15),
                Text     = Locale.Resource.GenApply
            });

            ok.Click     += new EventHandler(ok_Click);
            cancel.Click += new EventHandler(cancel_Click);
            apply.Click  += new EventHandler(apply_Click);
        }
        protected override void OnConstruct()
        {
            base.OnConstruct();
            ClearChildren();
            flow.Size = new Vector2(Size.X, Size.Y - 40);
            AddChild(flow);
            int nPerPage;
            if (controls.Count == 0)
                nPerPage = 1000;
            else
                nPerPage = ((int)(flow.Size.X / (controls[0].Size.X + controls[0].Margin.Horizontal))) *
                    ((int)(flow.Size.Y / (controls[0].Size.Y + controls[0].Margin.Vertical)));
            if (nPerPage == 0) nPerPage = 1;
            flow.ClearChildren();
            int i = 0;
            foreach(var v in controls)
            {
                if (i / nPerPage == page)
                {
                    flow.AddChild(v);
                }
                i++;
            }

            if ((page + 1) * nPerPage < i)
            {
                var nextPage = new StoneButton
                {
                    Text = Locale.Resource.GenNext,
                    Anchor = global::Graphics.Orientation.BottomRight
                };
                nextPage.Click += new EventHandler((o, e) => Page++);
                AddChild(nextPage);
            }

            if (page > 0)
            {
                var prevPage = new StoneButton
                {
                    Text = Locale.Resource.GenPrev,
                    Anchor = global::Graphics.Orientation.BottomLeft
                };
                prevPage.Click += new EventHandler((o, e) => Page--);
                AddChild(prevPage);
            }
            int nPages = (int)Math.Ceiling(controls.Count / (float)nPerPage);
            if (nPages > 1)
            {
                AddChild(new Label
                {
                    Anchor = global::Graphics.Orientation.Bottom,
                    AutoSize = AutoSizeMode.Full,
                    Position = new Vector2(0, 10),
                    Text = Locale.Resource.GenPage + " " + (page + 1) + "/" + nPages,
                    Background = null,
                });
            }
        }
        protected override void OnConstruct()
        {
            base.OnConstruct();
            ClearChildren();
            flow.Size = new Vector2(Size.X, Size.Y - 40);
            AddChild(flow);
            int nPerPage;

            if (controls.Count == 0)
            {
                nPerPage = 1000;
            }
            else
            {
                nPerPage = ((int)(flow.Size.X / (controls[0].Size.X + controls[0].Margin.Horizontal))) *
                           ((int)(flow.Size.Y / (controls[0].Size.Y + controls[0].Margin.Vertical)));
            }
            if (nPerPage == 0)
            {
                nPerPage = 1;
            }
            flow.ClearChildren();
            int i = 0;

            foreach (var v in controls)
            {
                if (i / nPerPage == page)
                {
                    flow.AddChild(v);
                }
                i++;
            }

            if ((page + 1) * nPerPage < i)
            {
                var nextPage = new StoneButton
                {
                    Text   = Locale.Resource.GenNext,
                    Anchor = global::Graphics.Orientation.BottomRight
                };
                nextPage.Click += new EventHandler((o, e) => Page++);
                AddChild(nextPage);
            }

            if (page > 0)
            {
                var prevPage = new StoneButton
                {
                    Text   = Locale.Resource.GenPrev,
                    Anchor = global::Graphics.Orientation.BottomLeft
                };
                prevPage.Click += new EventHandler((o, e) => Page--);
                AddChild(prevPage);
            }
            int nPages = (int)Math.Ceiling(controls.Count / (float)nPerPage);

            if (nPages > 1)
            {
                AddChild(new Label
                {
                    Anchor     = global::Graphics.Orientation.Bottom,
                    AutoSize   = AutoSizeMode.Full,
                    Position   = new Vector2(0, 10),
                    Text       = Locale.Resource.GenPage + " " + (page + 1) + "/" + nPages,
                    Background = null,
                });
            }
        }