Exemple #1
0
        private Gum.Widget CreateTrayIcon(int Tile, Gum.Widget Child)
        {
            var r = new NewGui.FramedIcon
            {
                Icon    = new Gum.TileReference("tool-icons", Tile),
                OnClick = (sender, args) =>
                {
                },
                OnHover = (sender) =>
                {
                    foreach (var child in sender.Parent.EnumerateChildren().Where(c => c is NewGui.FramedIcon)
                             .SelectMany(c => c.EnumerateChildren()))
                    {
                        child.Hidden = true;
                        child.Invalidate();
                    }

                    if (Child != null)
                    {
                        Child.Hidden = false;
                        Child.Invalidate();
                    }
                },
                OnLayout = (sender) =>
                {
                    if (Child != null)
                    {
                        var midPoint = sender.Rect.X + (sender.Rect.Width / 2);
                        Child.Rect.X = midPoint - (Child.Rect.Width / 2);
                        Child.Rect.Y = sender.Rect.Y - 60;
                    }
                }
            };

            GuiRoot.ConstructWidget(r);
            if (Child != null)
            {
                r.AddChild(Child);
            }
            return(r);
        }
Exemple #2
0
        private void BuildTab(Gum.Widgets.TabPanel TabPanel, String TabName, IEnumerable <BuildableItem> ItemSource,
                              Action <BuildableItem, Gum.Widget, Gum.Widget> BuildDescriptionPanel)
        {
            var panel = TabPanel.AddTab(TabName, new Widget
            {
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0)
            });

            Gum.Widgets.WidgetListView list = null;
            Gum.Widget descriptionPanel     = null;
            Gum.Widget buildButton          = null;

            list = panel.AddChild(new Gum.Widgets.WidgetListView
            {
                ItemHeight             = 32,
                MinimumSize            = new Point(256, 0),
                AutoLayout             = Gum.AutoLayout.DockLeft,
                OnSelectedIndexChanged = (sender) =>
                {
                    var selectedItem = (sender as Gum.Widgets.WidgetListView).SelectedItem;
                    if (selectedItem != null)
                    {
                        descriptionPanel.Clear();
                        buildButton.Hidden = false;
                        BuildDescriptionPanel(selectedItem.Tag as BuildableItem, descriptionPanel, buildButton);
                        descriptionPanel.Layout();
                        buildButton.Invalidate();
                    }
                }
            }) as Gum.Widgets.WidgetListView;

            var bottomRow = panel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = Gum.AutoLayout.DockBottom
            });

            buildButton = bottomRow.AddChild(new Widget
            {
                Text = "BUILD",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border = "border-button",
                //OnClick = (sender, args) => BuildClicked(list.SelectedItem.Tag as BuildableItem),
                AutoLayout = AutoLayout.DockRight
            });

            descriptionPanel = panel.AddChild(new Widget
            {
                AutoLayout = Gum.AutoLayout.DockFill,
                OnLayout   = (sender) => sender.Rect.Height -= 36
            });

            foreach (var buildableItem in ItemSource)
            {
                var row = new Gum.Widget
                {
                    Background = new TileReference("basic", 0),
                    Tag        = buildableItem
                };

                list.AddItem(row);

                if (buildableItem.Icon != null)
                {
                    row.AddChild(new Gum.Widget
                    {
                        MinimumSize = new Point(32, 32),
                        Background  = buildableItem.Icon,
                        AutoLayout  = Gum.AutoLayout.DockLeft
                    });
                }

                row.AddChild(new Gum.Widget
                {
                    Text       = buildableItem.Name,
                    AutoLayout = Gum.AutoLayout.DockFill
                });
            }

            list.SelectedIndex = 0;
        }