Exemplo n.º 1
0
        public void SetHomeport(Homeport homeport)
        {
            if (homeport == null)
            {
                return;
            }

            // Fleets & Expedition
            homeport.Organization.PropertyEvent(nameof(homeport.Organization.Fleets), () =>
            {
                var fleets = homeport.Organization.Fleets.Select(x => x.Value);

                layoutFleets.Invoke(() =>
                {
                    // 기존 목록 제거
                    layoutFleets.Controls.Clear();

                    foreach (var fleet in fleets.OrderBy(x => x.Id))
                    {
                        if (fleet == null)
                        {
                            continue;
                        }

                        FleetView fleetView = new FleetView();
                        // fleetView.Dock = DockStyle.Top;
                        fleetView.AutoSize = true;
                        fleetView.Padding  = new Padding(0, 0, 8, 8);
                        fleetView.SetFleet(fleet);

                        layoutFleets.Controls.Add(fleetView);
                    }
                });
            }, true);
        }
Exemplo n.º 2
0
        private void PopulateTaskForceOrderMenu([NotNull] FleetView fleetView)
        {
            if (fleetView == null)
            {
                throw new ArgumentNullException("fleetView");
            }

            var orderMenu = ContextMenu;

            if (orderMenu != null)
            {
                orderMenu.Items.Clear();
            }

            if (fleetView.Source.OwnerID != _appContext.LocalPlayer.EmpireID)
            {
                return;
            }

            if (orderMenu == null)
            {
                orderMenu   = new ContextMenu();
                ContextMenu = orderMenu;
            }

            if (fleetView.Source.CanCloak)
            {
                var cloakItem = new MenuItem
                {
                    IsCheckable      = true,
                    Header           = "Cloak",
                    Command          = GalaxyScreenCommands.ToggleTaskForceCloak,
                    CommandParameter = fleetView
                };

                var cloakBinding = new Binding
                {
                    Source = fleetView.Source,
                    Path   = new PropertyPath("IsCloaked", new object[0]),
                    Mode   = BindingMode.OneWay
                };

                cloakItem.SetBinding(MenuItem.IsCheckedProperty, cloakBinding);
                orderMenu.Items.Add(cloakItem);
                orderMenu.Items.Add(new Separator());
            }

            if (fleetView.Source.CanCamouflage)
            {
                var camouflagedItem = new MenuItem
                {
                    IsCheckable      = true,
                    Header           = "Camouflage",
                    Command          = GalaxyScreenCommands.ToggleTaskForceCamouflage,
                    CommandParameter = fleetView
                };

                var camouflageBinding = new Binding
                {
                    Source = fleetView.Source,
                    Path   = new PropertyPath("IsCamouflaged", new object[0]),
                    Mode   = BindingMode.OneWay
                };

                camouflagedItem.SetBinding(MenuItem.IsCheckedProperty, camouflageBinding);
                orderMenu.Items.Add(camouflagedItem);
                orderMenu.Items.Add(new Separator());
            }

            foreach (var order in FleetOrders.GetAvailableOrders(fleetView.Source))
            {
                var orderItem = new MenuItem
                {
                    Header           = order,
                    Command          = GalaxyScreenCommands.IssueTaskForceOrder,
                    CommandParameter = new Pair <FleetView, FleetOrder>(fleetView, order)
                };
                orderMenu.Items.Add(orderItem);
            }

            orderMenu.Closed += OnOrderMenuClosed;
        }