コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////
        public void Init()
        {
            // Create and setup Window control.
            window = new Window(manager);
            window.Init();
            window.Text = "Please Wait";
            window.Width = 300;
            window.Height = 175;
            window.Center();
            window.Visible = true;
            window.CloseButtonVisible = false;

            text = new Label(manager);
            text.Init();
            text.Text = "";
            text.Width = 250;
            text.Height = 24;
            text.Left = 20;
            text.Top = 20;
            text.Anchor = Anchors.Left;
            text.Parent = window;

            bar = new ProgressBar(manager);
            bar.Init();
            bar.Width = 260;
            bar.Height = 15;
            bar.Left = 20;
            bar.Top = 60;
            bar.Anchor = Anchors.Left;
            bar.Parent = window;
            bar.Value = 0;
            bar.Mode = ProgressBarMode.Default;

            cancel = new Button(manager);
            cancel.Init();
            cancel.Left = window.Width - cancel.Width - 20;
            cancel.Top = 110;
            cancel.Text = "Cancel";
            cancel.Anchor = Anchors.Right;
            cancel.Parent = window;
        }
コード例 #2
0
ファイル: TankList.cs プロジェクト: summer-of-software/vtank
        public void Init()
        {
            texture = new Texture2D(manager.GraphicsDevice, 1, 1);
            texture.SetData<Color>(new Color[] { Color.White });

            window = new Window(manager) ;
            window.Init();
            window.Text = "Tank List";
            window.Width = 600;
            window.Height = 500;
            window.Center();
            window.Visible = true;
            window.CloseButtonVisible = false;

            play = new Button(manager);
            play.Init();
            play.Text = "Play";
            play.Width = 100;
            play.Height = 24;
            play.Left = window.Width - play.Width - 40;
            play.Top = window.Height - 90;
            play.Anchor = Anchors.Right;
            play.Parent = window;

            create = new Button(manager);
            create.Init();
            create.Text = "Create New Tank";
            create.Width = 150;
            create.Height = 24;
            create.Left = 30;
            create.Top = window.Height - 160;
            create.Anchor = Anchors.Left;
            create.Parent = window;

            edit = new Button(manager);
            edit.Init();
            edit.Text = "Edit Tank";
            edit.Width = 100;
            edit.Height = 24;
            edit.Left = 30;
            edit.Top = window.Height - 125;
            edit.Anchor = Anchors.Left;
            edit.Parent = window;

            delete = new Button(manager);
            delete.Init();
            delete.Text = "Delete Tank";
            delete.Width = 100;
            delete.Height = 24;
            delete.Left = edit.Left + edit.Width + 30;
            delete.Top = edit.Top;
            delete.Anchor = Anchors.Left;
            delete.Parent = window;

            back = new Button(manager);
            back.Init();
            back.Text = "Back";
            back.Width = 150;
            back.Height = 24;
            back.Left = 30;
            back.Top = play.Top;
            back.Anchor = Anchors.Left;
            back.Parent = window;

            listbox = new ListBox(manager);
            listbox.Init();
            listbox.Width = 225;
            listbox.Height = 275;
            listbox.Left = 30;
            listbox.Top = 40;
            listbox.Anchor = Anchors.Left;
            listbox.HideSelection = false;
            listbox.Parent = window;
            listbox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(listbox_ItemIndexChanged);

            image = new ImageBox(manager);
            image.Init();
            image.Image = texture;
            image.SizeMode = SizeMode.Stretched;
            image.Width = 200;
            image.Height = 150;
            image.Left = window.Width - image.Width - 70;
            image.Top = 40;
            image.Anchor = Anchors.Right;
            image.Parent = window;

            RankImage = new ImageBox(manager);
            RankImage.Init();
            //RankImage.Image = null;
            RankImage.SizeMode = SizeMode.Stretched;
            RankImage.Width = 32;
            RankImage.Height = 32;
            RankImage.Top = window.Height - 280;
            RankImage.Left = window.Width - RankImage.Width - 240;
            RankImage.Anchor = Anchors.Left;
            RankImage.Parent = window;

            rankLbl = new Label(manager);
            rankLbl.Init();
            rankLbl.Text = "Unknown";
            rankLbl.Top = window.Height - 275;
            rankLbl.Anchor = Anchors.Left;
            rankLbl.Width = 232 - RankImage.Width;
            rankLbl.Left = window.Width - rankLbl.Width - RankImage.Width;
            rankLbl.Height = 24;
            rankLbl.Parent = window;

            RankProgressBar = new ProgressBar(manager);
            RankProgressBar.Init();
            RankProgressBar.Value = 0;
            RankProgressBar.Top = window.Height - 243;
            RankProgressBar.Anchor = Anchors.Left;
            RankProgressBar.Width = 200;
            RankProgressBar.Left = window.Width - rankLbl.Width - 69;
            RankProgressBar.Height = 25;
            RankProgressBar.ToolTip = new ToolTip(manager);
            RankProgressBar.ToolTip.Text = "0 / 0";
            RankProgressBar.Parent = window;

            RankNextLabel = new Label(manager);
            RankNextLabel.Init();
            RankNextLabel.Top = window.Height - 215;
            RankNextLabel.Width = 200;
            RankNextLabel.Height = 15;
            RankNextLabel.Left = window.Width - RankImage.Width - 235;
            RankNextLabel.Text = "Progress is loading...";
            RankNextLabel.Parent = window;

            armorBar = new ProgressBar(manager);
            armorBar.Init();
            armorBar.Width = 150;
            armorBar.Height = 24;
            armorBar.Left = window.Width - armorBar.Width - 50; ;
            armorBar.Top = window.Height - 180;
            armorBar.Anchor = Anchors.Left;
            armorBar.Parent = window;
            armorBar.Value = 50;

            armorLbl = new Label(manager);
            armorLbl.Init();
            armorLbl.Text = "Armor: ";
            armorLbl.Width = 50;
            armorLbl.Height = 24;
            armorLbl.Left = armorBar.Left - armorLbl.Width - 20;
            armorLbl.Top = armorBar.Top;
            armorLbl.Anchor = Anchors.Left;
            armorLbl.Parent = window;

            speedBar = new ProgressBar(manager);
            speedBar.Init();
            speedBar.Width = 150;
            speedBar.Height = 24;
            speedBar.Left = window.Width - speedBar.Width - 50; ;
            speedBar.Top = window.Height - 150;
            speedBar.Anchor = Anchors.Left;
            speedBar.Parent = window;
            speedBar.Value = 50;

            speedLbl = new Label(manager);
            speedLbl.Init();
            speedLbl.Text = "Speed: ";
            speedLbl.Width = 50;
            speedLbl.Height = 24;
            speedLbl.Left = speedBar.Left - speedLbl.Width - 20;
            speedLbl.Top = speedBar.Top;
            speedLbl.Anchor = Anchors.Left;
            speedLbl.Parent = window;
        }
コード例 #3
0
        public void Init(Control parent, Manager manager)
        {
            switch (Type)
            {
                case "Container":
                    Container container = new Container(manager);
                    container.Init();

                    SetProperties(container, parent, manager);

                    container.AutoScroll = true;
                    break;
                case "ImageBox":
                    ImageBox box = new ImageBox(manager);
                    box.Init();

                    SetProperties(box, parent, manager);

                    box.SizeMode = ImageMode;

                    if (!string.IsNullOrEmpty(ImageAsset))
                        box.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            box.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            box.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    if (!string.IsNullOrEmpty(Draw))
                        box.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };
                    break;
                case "Label":
                    Label label = new Label(manager);
                    label.Init();

                    SetProperties(label, parent, manager);

                    label.Text = Text.StartsWith("TXT_KEY_") ? Provider.Instance.Translate(Text) : Text;

                    break;
                case "GameMapBox":
                    GameMapBox mapBox = new GameMapBox(manager);
                    mapBox.Init();

                    SetProperties(mapBox, parent, manager);

                    break;
                case "SideBar":
                    SideBar sideBar = new SideBar(manager);
                    sideBar.Init();

                    SetProperties(sideBar, parent, manager);

                    if (!string.IsNullOrEmpty(Draw))
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();

                    SetProperties(policyButton, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyName))
                        policyButton.Policy = Provider.GetPolicy(PolicyName);

                    break;
                case "PolicyTypeBox":
                    PolicyTypeBox policyTypeBox = new PolicyTypeBox(manager);
                    policyTypeBox.Init();

                    SetProperties(policyTypeBox, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyTypeName))
                        policyTypeBox.PolicyType = Provider.GetPolicyType(PolicyTypeName);

                    if (!string.IsNullOrEmpty(ImageAsset))
                        policyTypeBox.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            policyTypeBox.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            policyTypeBox.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    break;
                case "ImageButton":
                    ImageButton button = new ImageButton(manager);
                    button.Init();

                    ApplyStyle(button, manager);
                    SetProperties(button, parent, manager);
                    SetAnimation(button, manager);

                    button.Text = Text;
                    break;
                case "ProgressBar":
                    ProgressBar progress = new ProgressBar(manager);
                    progress.Init();

                    SetProperties(progress, parent, manager);
                    break;
                case "CheckBox":
                    CheckBox check = new CheckBox(manager);
                    check.Init();

                    SetProperties(check, parent, manager);

                    check.Text = Text;
                    break;
                case "Graph":
                    Graph graph = new Graph(manager);
                    graph.Init();

                    SetProperties(graph, parent, manager);

                    break;
                case "RankingRow":
                    RankingRow rank = new RankingRow(manager);
                    rank.Init();

                    SetProperties(rank, parent, manager);
                    break;
                case "Include":
                    List<ControlItem> children = manager.Content.Load<List<ControlItem>>(Import);

                    foreach (ControlItem item in children)
                        item.Init(parent, manager);
                    break;
                default:
                    throw new Exception("No handling for " + Type);
            }
        }
コード例 #4
0
        ////////////////////////////////////////////////////////////////////////////   
        public TaskControls(Manager manager)
            : base(manager)
        {
            MinimumWidth = 340;
              MinimumHeight = 140;
              Height = 480;
              Center();
              Text = "Controls Test";

              TopPanel.Visible = true;
              Caption.Text = "Information";
              Description.Text = "Demonstration of various controls available in Neoforce Controls library.";
              Caption.TextColor = Description.TextColor = new Color(96, 96, 96);

              grpEdit = new GroupPanel(Manager);
              grpEdit.Init();
              grpEdit.Parent = this;
              grpEdit.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              grpEdit.Width = ClientWidth - 200;
              grpEdit.Height = 160;
              grpEdit.Left = 8;
              grpEdit.Top = TopPanel.Height + 8;
              grpEdit.Text = "EditBox";

              pnlControls = new Panel(Manager);
              pnlControls.Init();
              pnlControls.Passive = true;
              pnlControls.Parent = this;
              pnlControls.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              pnlControls.Left = 8;
              pnlControls.Top = grpEdit.Top + grpEdit.Height + 8;
              pnlControls.Width = ClientWidth - 200;
              pnlControls.Height = BottomPanel.Top - 32 - pnlControls.Top;
              pnlControls.BevelBorder = BevelBorder.All;
              pnlControls.BevelMargin = 1;
              pnlControls.BevelStyle = BevelStyle.Etched;
              pnlControls.Color = Color.Transparent;

              lblEdit = new Label(manager);
              lblEdit.Init();
              lblEdit.Parent = grpEdit;
              lblEdit.Left = 16;
              lblEdit.Top = 8;
              lblEdit.Text = "Testing field:";
              lblEdit.Width = 128;
              lblEdit.Height = 16;

              txtEdit = new TextBox(manager);
              txtEdit.Init();
              txtEdit.Parent = grpEdit;
              txtEdit.Left = 16;
              txtEdit.Top = 24;
              txtEdit.Width = grpEdit.ClientWidth - 32;
              txtEdit.Height = 20;
              txtEdit.Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom;
              txtEdit.Text = "Text";

              rdbNormal = new RadioButton(manager);
              rdbNormal.Init();
              rdbNormal.Parent = grpEdit;
              rdbNormal.Left = 16;
              rdbNormal.Top = 52;
              rdbNormal.Width = grpEdit.ClientWidth - 32;
              rdbNormal.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
              rdbNormal.Checked = true;
              rdbNormal.Text = "Normal mode";
              rdbNormal.ToolTip.Text = "Enables normal mode for TextBox control.";
              rdbNormal.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(ModeChanged);

              rdbPassword = new RadioButton(manager);
              rdbPassword.Init();
              rdbPassword.Parent = grpEdit;
              rdbPassword.Left = 16;
              rdbPassword.Top = 68;
              rdbPassword.Width = grpEdit.ClientWidth - 32;
              rdbPassword.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
              rdbPassword.Checked = false;
              rdbPassword.Text = "Password mode";
              rdbPassword.ToolTip.Text = "Enables password mode for TextBox control.";
              rdbPassword.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(ModeChanged);

              chkBorders = new CheckBox(manager);
              chkBorders.Init();
              chkBorders.Parent = grpEdit;
              chkBorders.Left = 16;
              chkBorders.Top = 96;
              chkBorders.Width = grpEdit.ClientWidth - 32;
              chkBorders.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
              chkBorders.Checked = false;
              chkBorders.Text = "Borderless mode";
              chkBorders.ToolTip.Text = "Enables or disables borderless mode for TextBox control.";
              chkBorders.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkBorders_CheckedChanged);

              chkReadOnly = new CheckBox(manager);
              chkReadOnly.Init();
              chkReadOnly.Parent = grpEdit;
              chkReadOnly.Left = 16;
              chkReadOnly.Top = 110;
              chkReadOnly.Width = grpEdit.ClientWidth - 32;
              chkReadOnly.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
              chkReadOnly.Checked = false;
              chkReadOnly.Text = "Read only mode";
              chkReadOnly.ToolTip.Text = "Enables or disables read only mode for TextBox control.\nThis mode is necessary to enable explicitly.";
              chkReadOnly.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkReadOnly_CheckedChanged);

              string[] colors = new string[] {"Red", "Green", "Blue", "Yellow", "Orange", "Purple", "White", "Black", "Magenta", "Cyan",
                                      "Brown", "Aqua", "Beige", "Coral", "Crimson", "Gray", "Azure", "Ivory", "Indigo", "Khaki",
                                      "Orchid", "Plum", "Salmon", "Silver", "Gold", "Pink", "Linen", "Lime", "Olive", "Slate"};

              spnMain = new SpinBox(manager, SpinBoxMode.List);
              spnMain.Init();
              spnMain.Parent = pnlControls;
              spnMain.Left = 16;
              spnMain.Top = 16;
              spnMain.Width = pnlControls.Width - 32;
              spnMain.Height = 20;
              spnMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              spnMain.Items.AddRange(colors);
              spnMain.Mode = SpinBoxMode.Range;

              spnMain.ItemIndex = 0;

              cmbMain = new ComboBox(manager);
              cmbMain.Init();
              cmbMain.Parent = pnlControls;
              cmbMain.Left = 16;
              cmbMain.Top = 44;
              cmbMain.Width = pnlControls.Width - 32;
              cmbMain.Height = 20;
              cmbMain.ReadOnly = true;
              cmbMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              cmbMain.Items.AddRange(colors);
              cmbMain.ItemIndex = 0;
              cmbMain.MaxItems = 5;
              cmbMain.ToolTip.Color = Color.Yellow;
              cmbMain.Movable = cmbMain.Resizable = true;
              cmbMain.OutlineMoving = cmbMain.OutlineResizing = true;

              trkMain = new TrackBar(manager);
              trkMain.Init();
              trkMain.Parent = pnlControls;
              trkMain.Left = 16;
              trkMain.Top = 72;
              trkMain.Width = pnlControls.Width - 32;
              trkMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              trkMain.Range = 64;
              trkMain.Value = 16;
              trkMain.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(trkMain_ValueChanged);

              lblTrack = new Label(manager);
              lblTrack.Init();
              lblTrack.Parent = pnlControls;
              lblTrack.Left = 16;
              lblTrack.Top = 96;
              lblTrack.Width = pnlControls.Width - 32;
              lblTrack.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
              lblTrack.Alignment = Alignment.TopRight;
              lblTrack.TextColor = new Color(32, 32, 32);
              trkMain_ValueChanged(this, null); // forcing label redraw with init values

              mnuListBox = new ContextMenu(manager);

              MenuItem i1 = new MenuItem("This is very long text");
              MenuItem i2 = new MenuItem("Menu", true);
              MenuItem i3 = new MenuItem("Item", false);
              //i3.Enabled = false;
              MenuItem i4 = new MenuItem("Separated", true);

              MenuItem i11 = new MenuItem();
              MenuItem i12 = new MenuItem();
              MenuItem i13 = new MenuItem();
              MenuItem i14 = new MenuItem();

              MenuItem i111 = new MenuItem();
              MenuItem i112 = new MenuItem();
              MenuItem i113 = new MenuItem();

              mnuListBox.Items.AddRange(new MenuItem[]{i1,i2, i3, i4});
              i2.Items.AddRange(new MenuItem[] { i11, i12, i13, i14 });
              i13.Items.AddRange(new MenuItem[] { i111, i112, i113 });

              lstMain = new ListBox(manager);
              lstMain.Init();
              lstMain.Parent = this;
              lstMain.Top = TopPanel.Height + 8;
              lstMain.Left = grpEdit.Left + grpEdit.Width + 8;
              lstMain.Width = ClientWidth - lstMain.Left - 8;
              lstMain.Height = ClientHeight - 16 - BottomPanel.Height - TopPanel.Height;
              lstMain.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;
              lstMain.HideSelection = false;
              lstMain.Items.AddRange(colors);
              lstMain.ContextMenu = mnuListBox;

              prgMain = new ProgressBar(manager);
              prgMain.Init();
              prgMain.Parent = this.BottomPanel;
              prgMain.Left = lstMain.Left;
              prgMain.Top = 10;
              prgMain.Width = lstMain.Width;
              prgMain.Height = 16;
              prgMain.Anchor = Anchors.Top | Anchors.Right;
              prgMain.Mode = ProgressBarMode.Infinite;
              prgMain.Passive = false;

              btnDisable = new Button(manager);
              btnDisable.Init();
              btnDisable.Parent = BottomPanel;
              btnDisable.Left = 8;
              btnDisable.Top = 8;
              btnDisable.Text = "Disable";
              btnDisable.Click += new Controls.EventHandler(btnDisable_Click);
              btnDisable.TextColor = Color.FromNonPremultiplied(255, 64, 32, 200);

              btnProgress = new Button(manager);
              btnProgress.Init();
              btnProgress.Parent = BottomPanel;
              btnProgress.Left = prgMain.Left - 16;
              btnProgress.Top = prgMain.Top;
              btnProgress.Height = 16;
              btnProgress.Width = 16;
              btnProgress.Text = "!";
              btnProgress.Anchor = Anchors.Top | Anchors.Right;
              btnProgress.Click += new Controls.EventHandler(btnProgress_Click);

              mnuMain = new MainMenu(manager);

              mnuMain.Items.Add(i2);
              mnuMain.Items.Add(i13);
              mnuMain.Items.Add(i3);
              mnuMain.Items.Add(i4);

              MainMenu = mnuMain;

              ToolBarPanel tlp = new ToolBarPanel(manager);
              ToolBarPanel = tlp;

              ToolBar tlb = new ToolBar(manager);
              ToolBar tlbx = new ToolBar(manager);
              tlb.FullRow = true;
              tlbx.Row = 1;
              tlbx.FullRow = false;

              tlp.Add(tlb);
              tlp.Add(tlbx);

              /*
              tlb.Init();
              tlb.Width = 256;
              tlb.Parent = ToolBarPanel;*/

              //tlbx.Init();
              /*
              tlbx.Width = 512;
              tlbx.Top = 25;
              tlbx.Parent = ToolBarPanel;*/

             /*
              ToolBarButton tb1 = new ToolBarButton(manager);
              tb1.Init();
              tb1.Parent = tlb;
              tb1.Left = 10;
              tb1.Top = 1;
              tb1.Glyph = new Glyph(Manager.Skin.Images["Icon.Warning"].Resource);
              tb1.Glyph.SizeMode = SizeMode.Stretched;  */

              StatusBar stb = new StatusBar(Manager);
              StatusBar = stb;

              DefaultControl = txtEdit;

              OutlineMoving = true;
              OutlineResizing = true;

              BottomPanel.BringToFront();

              SkinChanged += new TomShane.Neoforce.Controls.EventHandler(TaskControls_SkinChanged);
              TaskControls_SkinChanged(null, null);
        }
コード例 #5
0
        public void Init()
        {
            texture = new Texture2D(manager.GraphicsDevice, 1, 1);
            texture.SetData<Color>(new Color[] { Color.White });

            #region Window
            window = new Window(manager) ;
            window.Init();
            window.Text = "Tank Creation";
            window.Width = 600;
            window.Height = 500;
            window.Center();
            window.Visible = true;
            window.CloseButtonVisible = false;
            #endregion

            #region ListBoxes

            #region Tank
            tankBoxLbl = new Label(manager);
            tankBoxLbl.Init();
            tankBoxLbl.Text = "Tanks: ";
            tankBoxLbl.Width = 100;
            tankBoxLbl.Height = 10;
            tankBoxLbl.Left = 20;
            tankBoxLbl.Top = 10;
            tankBoxLbl.Anchor = Anchors.Left;
            tankBoxLbl.Parent = window;

            tankBox = new ListBox(manager);
            tankBox.Init();
            tankBox.Width = 200;
            tankBox.Height = 75;
            tankBox.Left = 30;
            tankBox.Top = 30;
            tankBox.Anchor = Anchors.Left;
            tankBox.HideSelection = false;
            tankBox.Parent = window;
            foreach (String s in tanks)
            {
                tankBox.Items.Add(s);
            }
            tankBox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(tankBox_ItemIndexChanged);
            #endregion

            #region Turret

            turretBoxLbl = new Label(manager);
            turretBoxLbl.Init();
            turretBoxLbl.Text = "Turrets: ";
            turretBoxLbl.Width = 50;
            turretBoxLbl.Height = 10;
            turretBoxLbl.Left = tankBoxLbl.Left;
            turretBoxLbl.Top = tankBox.Top + tankBox.Height + 20;
            turretBoxLbl.Anchor = Anchors.Left;
            turretBoxLbl.Parent = window;

            turretBox = new ListBox(manager);
            turretBox.Init();
            turretBox.Width = 200;
            turretBox.Height = 100;
            turretBox.Left = 30;
            turretBox.Top = turretBoxLbl.Top + turretBoxLbl.Height + 10;
            turretBox.Anchor = Anchors.Left;
            turretBox.HideSelection = false;
            turretBox.Parent = window;
            foreach (String s in tanks)
            {
                turretBox.Items.Add(s);
            }
            turretBox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(turretBox_ItemIndexChanged);

            tPowerLbl = new Label(manager);
            tPowerLbl.Init();
            tPowerLbl.Text = "Power: ";
            tPowerLbl.Width = 50;
            tPowerLbl.Height = 10;
            tPowerLbl.Left = turretBox.Left;
            tPowerLbl.Top = turretBox.Top + turretBox.Height + 10;
            tPowerLbl.Anchor = Anchors.Left;
            tPowerLbl.Parent = window;

            tPower = new ProgressBar(manager);
            tPower.Init();
            tPower.Width = 75;
            tPower.Height = 10;
            tPower.Left = tPowerLbl.Left + tPowerLbl.Width + 5;
            tPower.Top = tPowerLbl.Top;
            tPower.Anchor = Anchors.Left;
            tPower.Parent = window;
            tPower.Value = 50;

            tRateLbl = new Label(manager);
            tRateLbl.Init();
            tRateLbl.Text = "Rate: ";
            tRateLbl.Width = 50;
            tRateLbl.Height = 10;
            tRateLbl.Left = turretBox.Left;
            tRateLbl.Top = tPowerLbl.Top + tPowerLbl.Height;
            tRateLbl.Anchor = Anchors.Left;
            tRateLbl.Parent = window;

            tRate = new ProgressBar(manager);
            tRate.Init();
            tRate.Width = 75;
            tRate.Height = 10;
            tRate.Left = tRateLbl.Left + tRateLbl.Width + 5;
            tRate.Top = tRateLbl.Top;
            tRate.Anchor = Anchors.Left;
            tRate.Parent = window;
            tRate.Value = 50;

            tRangeLbl = new Label(manager);
            tRangeLbl.Init();
            tRangeLbl.Text = "Range: ";
            tRangeLbl.Width = 50;
            tRangeLbl.Height = 15;
            tRangeLbl.Left = turretBox.Left;
            tRangeLbl.Top = tRateLbl.Top + tRateLbl.Height;
            tRangeLbl.Anchor = Anchors.Left;
            tRangeLbl.Parent = window;

            tRange = new ProgressBar(manager);
            tRange.Init();
            tRange.Width = 75;
            tRange.Height = 10;
            tRange.Left = tRangeLbl.Left + tRangeLbl.Width + 5;
            tRange.Top = tRangeLbl.Top;
            tRange.Anchor = Anchors.Left;
            tRange.Parent = window;
            tRange.Value = 50;

            #endregion

            #endregion

            #region TankStats

            armorLbl = new Label(manager);
            armorLbl.Init();
            armorLbl.Text = "Armor: ";
            armorLbl.Width = 50;
            armorLbl.Height = 24;
            armorLbl.Left = 20;
            armorLbl.Top = window.Height - 160; ;
            armorLbl.Anchor = Anchors.Left;
            armorLbl.Parent = window;

            armorBar = new ProgressBar(manager);
            armorBar.Init();
            armorBar.Width = 150;
            armorBar.Height = 24;
            armorBar.Left = armorLbl.Left + armorLbl.Width + 20; ;
            armorBar.Top = armorLbl.Top;
            armorBar.Anchor = Anchors.Left;
            armorBar.Parent = window;
            armorBar.Value = 50;

            speedLbl = new Label(manager);
            speedLbl.Init();
            speedLbl.Text = "Speed: ";
            speedLbl.Width = 50;
            speedLbl.Height = 24;
            speedLbl.Left = armorLbl.Left;
            speedLbl.Top = armorLbl.Top + armorLbl.Height;
            speedLbl.Anchor = Anchors.Left;
            speedLbl.Parent = window;

            speedBar = new ProgressBar(manager);
            speedBar.Init();
            speedBar.Width = 150;
            speedBar.Height = 24;
            speedBar.Left = speedLbl.Left + speedLbl.Width + 20; ;
            speedBar.Top = speedLbl.Top;
            speedBar.Anchor = Anchors.Left;
            speedBar.Parent = window;
            speedBar.Value = 50;

            ratioLbl = new Label(manager);
            ratioLbl.Init();
            ratioLbl.Text = "Ratio: ";
            ratioLbl.Width = 50;
            ratioLbl.Height = 24;
            ratioLbl.Left = armorLbl.Left;
            ratioLbl.Top = speedLbl.Top + speedLbl.Height + 20;
            ratioLbl.Anchor = Anchors.Left;
            ratioLbl.Parent = window;

            ratioSlide = new SliderBar(manager);
            ratioSlide.Init();
            ratioSlide.Width = 150;
            ratioSlide.Height = 20;
            ratioSlide.Left = ratioLbl.Left + ratioLbl.Width + 20; ;
            ratioSlide.Top = ratioLbl.Top + 3;
            ratioSlide.Anchor = Anchors.Left;
            ratioSlide.Parent = window;
            ratioSlide.Value = 50;
            ratioSlide.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ratioSlide_ValueChanged);

            #endregion

            #region Render Region
            image = new ImageBox(manager);
            image.Init();
            image.SizeMode = SizeMode.Stretched;
            image.Width = 200;
            image.Height = 150;
            image.Left = window.Width - image.Width - 70;
            image.Top = 40;
            image.Anchor = Anchors.Right;
            image.Parent = window;
            image.Image = texture;
            #endregion

            #region Skin Scrolling (Left/Right)
            ScrollSkinLeft = new Button(manager);
            ScrollSkinLeft.Init();
            ScrollSkinLeft.Width = 25;
            ScrollSkinLeft.Height = 25;
            ScrollSkinLeft.Left = window.Width - image.Width - 70;
            ScrollSkinLeft.Top = image.Top + image.Height + 10;
            ScrollSkinLeft.Text = " < ";
            ScrollSkinLeft.Parent = window;

            ScrollSkinRight = new Button(manager);
            ScrollSkinRight.Init();
            ScrollSkinRight.Width = 25;
            ScrollSkinRight.Height = 25;
            ScrollSkinRight.Left = image.Left + image.Width - ScrollSkinRight.Width;
            ScrollSkinRight.Top = image.Top + image.Height + 10;
            ScrollSkinRight.Text = " > ";
            ScrollSkinRight.Parent = window;
            #endregion

            #region Skin Label
            SkinLabel = new Label(manager);
            SkinLabel.Init();
            SkinLabel.Alignment = Alignment.MiddleCenter;
            SkinLabel.Height = 15;
            SkinLabel.Width = 100;
            SkinLabel.Left = ScrollSkinRight.Left - 120;
            SkinLabel.Top = image.Top + image.Width - 33;
            SkinLabel.Text = "Skin";
            SkinLabel.Parent = window;
            #endregion

            #region Color Choosing
            redLbl = new Label(manager);
            redLbl.Init();
            redLbl.Text = "Red: ";
            redLbl.Width = 50;
            redLbl.Height = 24;
            redLbl.Left = image.Left;
            redLbl.Top = ScrollSkinLeft.Top + ScrollSkinLeft.Height + 20;
            redLbl.Anchor = Anchors.Left;
            redLbl.Parent = window;

            red = new SliderBar(manager);
            red.Init();
            red.Width = 120;
            red.Height = 15;
            red.Left = redLbl.Left + redLbl.Width + 20;
            red.Top = ScrollSkinLeft.Top + ScrollSkinLeft.Height + 25;
            red.Anchor = Anchors.Left;
            red.Parent = window;
            red.Value = 50;
            red.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);

            greenLbl = new Label(manager);
            greenLbl.Init();
            greenLbl.Text = "Green: ";
            greenLbl.Width = 50;
            greenLbl.Height = 24;
            greenLbl.Left = redLbl.Left;
            greenLbl.Top = redLbl.Top + redLbl.Height;
            greenLbl.Anchor = Anchors.Left;
            greenLbl.Parent = window;

            green = new SliderBar(manager);
            green.Init();
            green.Width = red.Width;
            green.Height = red.Height;
            green.Left = greenLbl.Left + greenLbl.Width + 20;
            green.Top = greenLbl.Top + 5;
            green.Anchor = Anchors.Left;
            green.Parent = window;
            green.Value = 50;
            green.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);

            blueLbl = new Label(manager);
            blueLbl.Init();
            blueLbl.Text = "Blue: ";
            blueLbl.Width = 50;
            blueLbl.Height = 24;
            blueLbl.Left = redLbl.Left;
            blueLbl.Top = greenLbl.Top + greenLbl.Height;
            blueLbl.Anchor = Anchors.Left;
            blueLbl.Parent = window;

            blue = new SliderBar(manager);
            blue.Init();
            blue.Width = red.Width;
            blue.Height = red.Height;
            blue.Left = blueLbl.Left + blueLbl.Width + 20; ;
            blue.Top = blueLbl.Top + 5;
            blue.Anchor = Anchors.Left;
            blue.Parent = window;
            blue.Value = 50;
            blue.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);
            #endregion

            #region Tank Name
            name = new Label(manager);
            name.Init();
            name.Text = "Tank Name: ";
            name.Width = 100;
            name.Height = 24;
            name.Left = redLbl.Left;
            name.Top = blueLbl.Top + blueLbl.Height + 20;
            name.Anchor = Anchors.Left;
            name.Parent = window;

            nameBox = new TextBox(manager);
            nameBox.Init();
            nameBox.Text = "";
            nameBox.Width = 180;
            nameBox.Height = 24;
            nameBox.Left = name.Left + 10;
            nameBox.Top = name.Top + name.Height;
            nameBox.Anchor = Anchors.Left;
            nameBox.Parent = window;

            #endregion

            #region Buttons
            create = new Button(manager);
            create.Init();
            create.Text = "Create";
            create.Width = 90;
            create.Height = 24;
            create.Left = window.Width - create.Width - 40; ;
            create.Top = ratioLbl.Top;
            create.Anchor = Anchors.Left;
            create.Parent = window;

            cancel = new Button(manager);
            cancel.Init();
            cancel.Text = "Cancel";
            cancel.Width = 80;
            cancel.Height = 24;
            cancel.Left = create.Left - cancel.Width - 60;
            cancel.Top = create.Top;
            cancel.Anchor = Anchors.Right;
            cancel.Parent = window;
            #endregion
        }