Beispiel #1
0
        private MenuItem CreateCardPassToItem()
        {
            var passToItem = new MenuItem {
                Header = "Pass control to"
            };

            passToItem.Items.Add(new MenuItem()); // dummy item
            passToItem.SubmenuOpened += delegate
            {
                passToItem.Items.Clear();
                foreach (MenuItem playerItem in from player in Player.AllExceptGlobal
                         where player != Player.LocalPlayer
                         select new MenuItem
                {
                    Header = player.Name,
                    Tag = player
                })
                {
                    playerItem.Click += delegate(object sender, RoutedEventArgs e)
                    {
                        var p =
                            (Player)((MenuItem)sender).Tag;
                        Selection.Do(
                            c => c.PassControlTo(p),
                            ContextCard);
                    };
                    passToItem.Items.Add(playerItem);
                }
                if (passToItem.HasItems)
                {
                }
                else
                {
                    var emptyItem = new MenuItem
                    {
                        Header = "no player", IsEnabled = false
                    };
                    passToItem.Items.Add(emptyItem);
                }
            };
            return(passToItem);
        }
Beispiel #2
0
        protected override List <Control> CreateCardMenuItems(DataNew.Entities.Group def)
        {
            List <Control> items = base.CreateCardMenuItems(def);

            var item = new MenuItem {
                Header = "Move to"
            };
            var subItem = new MenuItem
            {
                Header           = Program.GameEngine.Definition.Player.Hand.Name,
                InputGestureText = Program.GameEngine.Definition.Player.Hand.Shortcut
            };

            subItem.Click += delegate { Selection.Do(c => c.MoveTo(Player.LocalPlayer.Hand, true, false), ContextCard); };
            item.Items.Add(subItem);
            var groupDefs         = Program.GameEngine.Definition.Player.Groups.ToArray();
            var moveToBottomItems = new List <MenuItem>();

            for (int i = 0; i < groupDefs.Length; ++i)
            {
                var   groupDef     = groupDefs[i];
                Group indexedGroup = Player.LocalPlayer.IndexedGroups[i + 1]; // 0 is hand
                subItem = new MenuItem {
                    Header = groupDef.Name, InputGestureText = groupDef.Shortcut
                };
                subItem.Click += delegate { Selection.Do(c => c.MoveTo(indexedGroup, true, false), ContextCard); };
                item.Items.Add(subItem);
                subItem = new MenuItem
                {
                    Header           = string.Format("Bottom of {0}", groupDef.Name),
                    InputGestureText =
                        string.IsNullOrEmpty(groupDef.Shortcut) ? null : "Alt+" + groupDef.Shortcut
                };
                subItem.Click +=
                    delegate { Selection.Do(c => c.MoveTo(indexedGroup, true, indexedGroup.Count, false), ContextCard); };
                moveToBottomItems.Add(subItem);
            }
            if (moveToBottomItems.Count > 0)
            {
                item.Items.Add(new Separator());
            }
            foreach (MenuItem x in moveToBottomItems)
            {
                item.Items.Add(x);
            }
            items.Add(item);

            item = new MenuItem {
                Header = "Bring to front", InputGestureText = "PgUp"
            };
            item.Click += delegate { Selection.Do(c => Program.GameEngine.Table.BringToFront(c), ContextCard); };
            items.Add(item);

            item = new MenuItem {
                Header = "Send to back", InputGestureText = "PgDn"
            };
            item.Click += delegate { Selection.Do(c => Program.GameEngine.Table.SendToBack(c), ContextCard); };
            items.Add(item);

            return(items);
        }