コード例 #1
0
        public VillagesContextMenu(Map map, ICollection <Village> villages, Action <VillageType> onVillageTypeChangeDelegate = null)
        {
            _villages = villages;
            _map      = map;
            _onVillageTypeChangeDelegate = onVillageTypeChangeDelegate;

            _menu = JanusContextMenu.Create();
            // TODO: hehe, the ActiveVillageManipulator takes the first player and selects all his villages...
            //if (map.Display.IsVisible(_villages))
            //{
            //    _menu.AddCommand(ControlsRes.ContextMenu_Pinpoint, OnPinPoint);
            //}
            //_menu.AddCommand(ControlsRes.ContextMenu_PinpointAndCenter, OnPinpointAndCenter, Properties.Resources.TeleportIcon);
            //_menu.AddSeparator();

            _menu.AddSetVillageTypeCommand(OnVillageTypeChange, null);
            _menu.AddCommand(ControlsRes.VillageContextMenu_RemovePurpose, OnRemovePurpose);

            if (World.Default.Settings.Church)
            {
                VillageContextMenu.AddChurchCommands(_menu, null, ChurchChange_Click);
            }

            _menu.AddSeparator();
            if (!World.Default.You.Empty && villages.All(x => x.Player == World.Default.You))
            {
                _menu.AddCommand(ControlsRes.VillagesContextMenu_DefendThem, OnAddTargets, Properties.Resources.swordsman);

                AttackersPoolContextMenuCommandCreator.Add(_menu, _villages);
            }
            else
            {
                _menu.AddCommand(ControlsRes.VillagesContextMenu_AttackThem, OnAddTargets, Properties.Resources.barracks);
            }
            _menu.AddSeparator();

            _menu.AddCommand(ControlsRes.ContextMenu_ToBbCode, OnBbCode, Properties.Resources.clipboard);
        }
コード例 #2
0
 private void AttackPlanFromControl_MouseClick(object sender, MouseEventArgs e)
 {
     if (Attacker.Attacker != null)
     {
         if (e.Button == MouseButtons.Right)
         {
             var cm = new VillageContextMenu(World.Default.Map, Attacker.Attacker);
             cm.Show(_Village, e.Location);
         }
         else if (e.Button == MouseButtons.Left)
         {
             World.Default.Map.Manipulators.SetManipulator(ManipulatorManagerTypes.Attack);
             World.Default.Map.EventPublisher.AttackSelect(null, Attacker);
             World.Default.Map.GiveFocus();
         }
     }
 }
コード例 #3
0
ファイル: VillageTableRow.cs プロジェクト: kindam/TWTactics
 public void ShowContext(Point p)
 {
     if (TableModel != null)
     {
         var context = new VillageContextMenu(_map, _village, () => Cells[1].Image = _village.Type.GetImage(true));
         context.Show(TableModel.Table, p);
     }
 }
コード例 #4
0
ファイル: AttackPlanControl.cs プロジェクト: kindam/TWTactics
 private void _Village_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         var cm = new VillageContextMenu(World.Default.Map, Plan.Target);
         cm.Show(_Village, e.Location);
     }
     else if (e.Button == MouseButtons.Left)
     {
         World.Default.Map.Manipulators.SetManipulator(ManipulatorManagerTypes.Attack);
         World.Default.Map.EventPublisher.AttackSelect(this, Plan);
     }
 }
コード例 #5
0
ファイル: PolygonControl.cs プロジェクト: kindam/TWTactics
        /// <summary>
        /// Provide right click context menu
        /// </summary>
        private void GridExVillage_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                var rowCount = GridExVillage.SelectedItems.Count;
                if (rowCount == 1)
                {
                    var row = GridExVillage.CurrentRow;
                    if (row != null && row.RowType == RowType.Record)
                    {
                        var record = row.GetDataRow<PolygonDataSet.VILLAGERow>();

                        var contextMenu = new VillageContextMenu(World.Default.Map, record.Village, () => GridExVillage.Refresh());
                        contextMenu.Show(GridExVillage, e.Location);
                    }
                }
                else if (rowCount > 1)
                {
                    IEnumerable<Village> villages = GridExVillage.SelectedItems.GetDataSetRows<PolygonDataSet.VILLAGERow>().Select(x => x.Village);

                    var contextMenu = new VillagesContextMenu(World.Default.Map, villages.ToArray(), type => GridExVillage.Refresh());
                    contextMenu.Show(GridExVillage, e.Location);
                }
            }
        }