////////////////////////////////////////////////////////////////////////////    

        ////////////////////////////////////////////////////////////////////////////    
        public SelectPlayerNumberDialog(Manager manager)
            : base(manager)
        {
            Center();
            Text = "Select Player Number";
            Icon = IconProvider.ApplicationIcon;

            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);      

            lstMain = new ImageListBox(manager);
            lstMain.Init();
            lstMain.Parent = this;
            lstMain.Top = TopPanel.Height + 8;
            lstMain.Left = 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(entities);

            btnOk = new Button(manager);
            btnOk.Init();
            btnOk.Parent = BottomPanel;
            btnOk.Anchor = Anchors.Top | Anchors.Right;
            btnOk.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8;
            btnOk.Left = btnOk.Parent.ClientWidth - 8 - btnOk.Width * 3 - 8;
            btnOk.Text = "OK";
            btnOk.ModalResult = ModalResult.Ok;

            btnClose = new Button(manager);
            btnClose.Init();
            btnClose.Parent = BottomPanel;
            btnClose.Anchor = Anchors.Top | Anchors.Right;
            btnClose.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8;
            btnClose.Left = btnOk.Parent.ClientWidth - 4 - btnOk.Width * 2 - 8;
            btnClose.Text = "Cancel";
            btnClose.ModalResult = TomShane.Neoforce.Controls.ModalResult.Cancel;

            DefaultControl = lstMain;

            OutlineMoving = true;
            OutlineResizing = true;

            BottomPanel.BringToFront();
        }
示例#2
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);
            }
        }