Example #1
0
        public KeyHandler(MasterMapControl mapControl)
        {
            m_mapControl = mapControl;

            mapControl.KeyDown += OnKeyDown;
            mapControl.KeyUp += OnKeyUp;
            mapControl.TextInput += OnTextInput;

            var dpd = DependencyPropertyDescriptor.FromProperty(GameData.WorldProperty, typeof(GameData));
            dpd.AddValueChanged(GameData.Data, (s, e) =>
            {
                var world = GameData.Data.World;

                if (world == null || world.GameMode == GameMode.Undefined)
                    this.Mode = KeyHandlerMode.None;
                else if (world.GameMode == GameMode.Adventure)
                    this.Mode = KeyHandlerMode.LivingControl;
                else if (world.GameMode == GameMode.Fortress)
                    this.Mode = KeyHandlerMode.MapControl;
                else
                    throw new Exception();
            });

            this.Mode = KeyHandlerMode.LivingControl;
        }
        public MapControlSelectionService(MasterMapControl mapControl, Canvas canvas)
        {
            m_canvas = canvas;
            m_mapControl = mapControl;

            var brush = new LinearGradientBrush();
            brush.GradientStops.Add(new GradientStop(Colors.Blue, 0.0));
            brush.GradientStops.Add(new GradientStop(Colors.LightBlue, 0.5));
            brush.GradientStops.Add(new GradientStop(Colors.Blue, 1.0));
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);

            m_selectionRect = new Rectangle();
            m_selectionRect.Visibility = Visibility.Hidden;
            m_selectionRect.Stroke = new SolidColorBrush(Colors.Blue);
            m_selectionRect.Stroke.Opacity = 0.6;
            m_selectionRect.Stroke.Freeze();
            m_selectionRect.StrokeThickness = 1;
            m_selectionRect.Fill = brush;
            m_selectionRect.Fill.Opacity = 0.2;
            m_selectionRect.Fill.Freeze();
            m_selectionRect.IsHitTestVisible = false;
            m_canvas.Children.Add(m_selectionRect);
        }
 public MapControlDragService(MasterMapControl mapControl)
 {
     m_mapControl = mapControl;
 }