void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            Region = (Region)DataContext;
            foreach (var unit in MainWindow.Instance.Mission.AllUnits)
            {
                UnitIcon.PlaceSimplifiedUnit(canvas, unit);
            }

            foreach (var area in Region.Areas)
            {
                if (area is Cylinder)
                {
                    var cylinder = (Cylinder)area;
                    AddCylinder(cylinder);
                }
                else if (area is RectangularArea)
                {
                    AddRectangle((RectangularArea)area);
                }
                else
                {
                    throw new Exception("Unexpected Area");
                }
            }
        }
        void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            condition = (UnitsAreInAreaCondition)MainWindow.Instance.CurrentLogic;
            playerList.BindCollection(condition.Players);
            groupsList.BindCollection(condition.Groups);

            foreach (var unit in MainWindow.Instance.Mission.AllUnits)
            {
                UnitIcon.PlaceSimplifiedUnit(canvas, unit);
            }

            foreach (var area in condition.Areas)
            {
                if (area is Cylinder)
                {
                    var cylinder = (Cylinder)area;
                    AddCylinder(cylinder);
                }
                else if (area is RectangularArea)
                {
                    AddRectangle((RectangularArea)area);
                }
                else
                {
                    throw new Exception("Unexpected Area");
                }
            }
        }
Esempio n. 3
0
        void MarkerPointCanvas_Loaded(object sender, RoutedEventArgs e)
        {
            var currentLogic = MainWindow.Instance.CurrentLogic;

            if (currentLogic is MarkerPointAction)
            {
                var flagPole = new Ellipse {
                    Height = 20, Width = 20, Stroke = Brushes.Red, StrokeThickness = 5
                };
                var action       = (MarkerPointAction)currentLogic;
                var markerCanvas = (Canvas)e.Source;
                markerCanvas.Children.Add(flagPole);
                foreach (var unit in MainWindow.Instance.Mission.AllUnits)
                {
                    UnitIcon.PlaceSimplifiedUnit(markerCanvas, unit);
                }
                Action refreshPosition = delegate
                {
                    Canvas.SetLeft(flagPole, action.X - flagPole.Width / 2);
                    Canvas.SetTop(flagPole, action.Y - flagPole.Height / 2);
                };
                refreshPosition();
                markerCanvas.MouseDown += (s, ea) =>
                {
                    var mousePos = ea.GetPosition(markerCanvas);
                    action.X = mousePos.X;
                    action.Y = mousePos.Y;
                    refreshPosition();
                };
                markerCanvas.Unloaded += (s, ea) => markerCanvas.Children.Clear();
            }
            else if (currentLogic is SetCameraPointTargetAction)
            {
                var camera = new Ellipse {
                    Height = 20, Width = 20, Stroke = Brushes.Red, StrokeThickness = 5
                };
                var action       = (SetCameraPointTargetAction)currentLogic;
                var markerCanvas = (Canvas)e.Source;
                markerCanvas.Children.Add(camera);
                foreach (var unit in MainWindow.Instance.Mission.AllUnits)
                {
                    UnitIcon.PlaceSimplifiedUnit(markerCanvas, unit);
                }
                Action refreshPosition = delegate
                {
                    Canvas.SetLeft(camera, action.X - camera.Width / 2);
                    Canvas.SetTop(camera, action.Y - camera.Height / 2);
                };
                refreshPosition();
                markerCanvas.MouseDown += (s, ea) =>
                {
                    var mousePos = ea.GetPosition(markerCanvas);
                    action.X = mousePos.X;
                    action.Y = mousePos.Y;
                    refreshPosition();
                };
            }
        }
Esempio n. 4
0
        void CreateUnitsPane_Loaded(object sender, RoutedEventArgs e)
        {
            action = (CreateUnitsAction)MainWindow.Instance.CurrentLogic;

            var missionUnits = MainWindow.Instance.Mission.AllUnits.ToArray();
            var triggerUnits = action.Units.ToArray();

            foreach (var unit in missionUnits)
            {
                if (triggerUnits.Contains(unit))
                {
                    PlaceUnitIcon(unit);
                }
                else
                {
                    UnitIcon.PlaceSimplifiedUnit(unitCanvas, unit, true);
                }
            }
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            action  = (GiveOrdersAction)MainWindow.Instance.CurrentLogic;
            trigger = MainWindow.Instance.Mission.FindLogicOwner(action);

            var missionUnits = MainWindow.Instance.Mission.AllUnits.ToArray();
            var triggerUnits = trigger.AllUnits.ToArray();

            foreach (var unit in missionUnits)
            {
                UnitIcon.PlaceSimplifiedUnit(canvas, unit, !triggerUnits.Contains(unit));
            }

            UpdateLines();

            action.Groups.CollectionChanged += (s, ea) => UpdateLines();
            trigger.Logic.CollectionChanged += (s, ea) => UpdateLines();

            NotifyCollectionChangedEventHandler handler = (s, ea) => UpdateLines();

            action.Orders.CollectionChanged += handler;
            canvas.Unloaded += (s, ea) => action.Orders.CollectionChanged -= handler;
        }