public CheckpointPropertiesWindow(Checkpoint checkpoint, Canvas canvas, DesignerItem item, Level level)
     : base()
 {
     InitializeComponent();
     item.PropertyWindow = this;
     DataContext = new CheckpointModel(checkpoint, item, level, canvas);
     (DataContext as CheckpointModel).RespawnIndicator.OnSelected += HandleSelection;
 }
 public TilePropertiesWindow(Tile tile, DesignerItem item, Level level)
     : base()
 {
     InitializeComponent();
     item.PropertyWindow = this;
     DataContext = new TileModel(tile, item, level);
     item.SizeChanged += new SizeChangedEventHandler(item_SizeChanged);
 }
Exemplo n.º 3
0
        private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem = DataContext as DesignerItem;

            if (this.designerItem != null)
            {
                this.designerCanvas = VisualTreeHelper.GetParent(this.designerItem) as DesignerCanvas;
            }
        }
        public PlatformPropertiesWindow(Platform platform, Canvas canvas, DesignerItem item, Level level)
        {
            InitializeComponent();
            item.PropertyWindow = this;
            DataContext = new PlatformModel(this, platform, canvas, item, level);

            for(int i = 1; i <= platform.Path.Count; i++)
                (DataContext as PlatformModel).AddPoint(this, i);
        }
        public DoorModel(Door door, DesignerItem item, Level level)
            : base(item, level)
        {
            Data = mDoor = door;

            if(!level.Obstacles.Contains(door))
                level.Obstacles.Add(door);
            X = (int)door.InitialPosition.X;
            Y = (int)door.InitialPosition.Y;
        }
        public SwitchPropertiesWindow(Switch mswitch, DesignerItem item, Level level)
            : base()
        {
            InitializeComponent();
            item.PropertyWindow = this;
            DataContext = new SwitchModel(mswitch, item, level);

            foreach(Obstacle target in level.Obstacles.Where(o => o.Actions.Any(pair => pair.Key == mswitch.Guid)))
                mTriggers.Children.Add(new ActionControl(mTriggers, mswitch, level, target));

            UpdatePossibleActions();
        }
            public CheckpointModel(Checkpoint checkpoint, DesignerItem item, Level level, Canvas canvas)
                : base(item, level)
            {
                IsCentered = true;

                if(!level.Checkpoints.Contains(checkpoint))
                    level.Checkpoints.Add(checkpoint);

                Data = mCheckpoint = checkpoint;
                mCanvas = canvas;

                mCheckpointRegion = new System.Windows.Shapes.Rectangle();
                mCheckpointRegion.Fill = new SolidColorBrush(Colors.Yellow);
                mCheckpointRegion.Fill.Opacity = .25;
                mCheckpointRegion.IsHitTestVisible = false;

                Ellipse rindicator = new Ellipse();
                rindicator.Fill = Brushes.SpringGreen;
                rindicator.Stroke = Brushes.Black;

                TextBlock txt = new TextBlock();
                txt.Text = "R";
                txt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                txt.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                Grid gr = new Grid();
                gr.Children.Add(rindicator);
                gr.Children.Add(txt);
                gr.IsHitTestVisible = false;

                mRespawnIndicator = new DesignerItem();
                mRespawnIndicator.CanResize = false;
                mRespawnIndicator.CanDelete = false;
                mRespawnIndicator.Model = this;
                mRespawnIndicator.Height = 30;
                mRespawnIndicator.Width = 30;
                mRespawnIndicator.MinWidth = 30;
                mRespawnIndicator.MinHeight = 30;
                mRespawnIndicator.Content = gr;

                canvas.Children.Add(mCheckpointRegion);
                canvas.Children.Add(mRespawnIndicator);

                X = (int)checkpoint.Bound.X;
                Y = (int)checkpoint.Bound.Y;
                LocationX = (int)checkpoint.Location.X;
                LocationY = (int)checkpoint.Location.Y;
                Quadrant = Quadrant;

                Canvas.SetZIndex(mRespawnIndicator, 1);
                Canvas.SetZIndex(mCheckpointRegion, -9);
            }
        public EnemyModel(Enemy enemy, Ellipse rangeFinder, DesignerItem item, Level level)
            : base(item, level)
        {
            IsCentered = true;
            Data = mEnemy = enemy;
            mRangeFinder = rangeFinder;

            if(!level.Actors.Contains(mEnemy))
                level.Actors.Add(mEnemy);

            X = (int)enemy.InitialPosition.X;
            Y = (int)enemy.InitialPosition.Y;
            Range = Range;
        }
            public TileModel(Tile tile, DesignerItem item, Level level)
                : base(item, level)
            {
                Data = mTile = tile;

                if(!level.Tiles.Contains(mTile))
                    level.Tiles.Add(mTile);

                Type = Type;
                Width = tile.Dimensions.Width;
                Height = tile.Dimensions.Height;
                X = tile.Dimensions.X;
                Y = tile.Dimensions.Y;
            }
            public PlatformModel(PlatformPropertiesWindow ppw, Platform platform, Canvas canvas, DesignerItem item, Level level)
                : base(item, level)
            {
                Data = mPlatform = platform;
                mCanvas = canvas;

                if (!level.Obstacles.Contains(platform))
                {
                    level.Obstacles.Add(platform);
                }

                X = (int)platform.InitialPosition.X;
                Y = (int)platform.InitialPosition.Y;

                mChildren = new List<DesignerItem>();
            }
Exemplo n.º 11
0
        public EnemyPropertiesWindow(Enemy enemy, DesignerCanvas canvas, DesignerItem item, Level level)
            : base()
        {
            InitializeComponent();
            item.PropertyWindow = this;

            Ellipse rangeFinder = new Ellipse();
            Canvas.SetZIndex(rangeFinder, -10);

            var fadedRed = System.Windows.Media.Color.FromArgb(0, 255, 0, 50);

            rangeFinder.Fill = new RadialGradientBrush(System.Windows.Media.Colors.Red, fadedRed);
            rangeFinder.Stroke = Brushes.Green;
            rangeFinder.IsHitTestVisible = false;

            canvas.Children.Add(rangeFinder);

            DataContext = new EnemyModel(enemy, rangeFinder, item, level);
        }
Exemplo n.º 12
0
        public PointControl(PlatformPropertiesWindow parent, Canvas canvas, int index, List<Vector2> path)
            : base()
        {
            InitializeComponent();
            mPath = path;

            DesignerItem pointIndicator;

            Ellipse rindicator = new Ellipse();
            rindicator.Fill = Brushes.SpringGreen;
            rindicator.Stroke = Brushes.Black;

            TextBlock txt = new TextBlock();
            txt.Text = "" + index;
            txt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txt.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            Grid gr = new Grid();
            gr.Children.Add(rindicator);
            gr.Children.Add(txt);
            gr.IsHitTestVisible = false;

            pointIndicator = new DesignerItem();
            pointIndicator.CanResize = false;
            pointIndicator.Height = 15;
            pointIndicator.Width = 15;
            pointIndicator.Content = gr;
            pointIndicator.MinHeight = 2;
            pointIndicator.MinWidth = 2;

            Canvas.SetLeft(pointIndicator, path[index-1].X);
            Canvas.SetTop(pointIndicator, path[index-1].Y);
            Canvas.SetZIndex(pointIndicator, 1);

            canvas.Children.Add(pointIndicator);

            this.DataContext = pointIndicator.Model = mData = new PointControlModel(parent.mPoints, canvas, path, index, pointIndicator, txt);
            mData.Delete += RemoveItem;
            mData.Item.OnSelected += parent.HandleSelection;

            PointBlock.Text += index;
        }
Exemplo n.º 13
0
        private DesignerItem CreateDesignerImage(Image source)
        {
            DesignerItem item = new DesignerItem();
            item.IsSelected = true;
            item.CanResize = false;
            Image img = new Image();
            img.IsHitTestVisible = false;
            img.Source = source.Source;
            item.Content = img;
            item.Width = img.Source.Width;
            item.Height = img.Source.Height;

            item.MinWidth = 2;
            item.MinHeight = 2;

            MyDesignerCanvas.Children.Add(item);
            return item;
        }
Exemplo n.º 14
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            string xamlString = e.Data.GetData("DESIGNER_ITEM") as string;
            if (!String.IsNullOrEmpty(xamlString))
            {
                DesignerItem newItem = null;
                FrameworkElement content = XamlReader.Load(XmlReader.Create(new StringReader(xamlString))) as FrameworkElement;

                if (content != null)
                {
                    newItem = new DesignerItem();
                    newItem.Content = content;
                    newItem.TabIndex = mTabCount++;

                    Point position = e.GetPosition(this);

                    Image image = content as Image;

                    if (image != null && !image.ToolTip.ToString().Contains("Tile"))
                    {
                        newItem.CanResize = false;
                        newItem.Height = newItem.MinHeight = newItem.MaxHeight = image.Source.Height;
                        newItem.Width = newItem.MinWidth = newItem.MaxWidth = image.Source.Width;
                    }
                    else
                    {
                        newItem.Width = 50;
                        newItem.Height = 50;
                        newItem.MinHeight = 2;
                        newItem.MinWidth = 2;
                    }

                    this.Children.Add(newItem);

                    switch (image.ToolTip.ToString())
                    {
                        case "Tile":
                            newItem.OnSelected += NewTileHandler(newItem);
                            break;
                        case "Door":
                            newItem.OnSelected += NewDoorHandler(newItem);
                            break;
                        case "Enemy":
                            newItem.OnSelected += NewEnemyHandler(newItem);
                            break;
                        case "Checkpoint":
                            newItem.OnSelected += NewCheckpointHandler(newItem);
                            break;
                        case "Switch":
                            newItem.OnSelected += NewSwitchHandler(newItem);
                            break;
                        case "Platform":
                            newItem.OnSelected += NewPlatformHandler(newItem);
                            break;
                        default:
                            break;
                    }

                    DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                    DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));

                    if (newItem.PropertyWindow != null)
                        newItem.PropertyWindow.Moved();
                    else if (newItem.Model != null)
                        newItem.Model.Moved();

                    this.DeselectAll();
                    newItem.IsSelected = true;
                }

                e.Handled = true;
            }
        }
Exemplo n.º 15
0
        EventHandler<BoolEventArgs> NewTileHandler(DesignerItem item)
        {
            Rectangle rect=  new Rectangle();
            rect.IsHitTestVisible = false;
            rect.Fill = (Window.GetWindow(this) as MainWindow).Settings.NormalBrush;
            rect.MinHeight = 2;
            rect.MinWidth = 2;

            item.Content = rect;

            Tile t = new Tile();
            t.Type = Surface.Normal;
            t.Dimensions.Width = 50;
            t.Dimensions.Height = 50;

            TilePropertiesWindow tpw = new TilePropertiesWindow(t, item, Level);
            this.Children.Add(tpw);

            return tpw.SelectionHandler;
        }
Exemplo n.º 16
0
 EventHandler<BoolEventArgs> NewSwitchHandler(DesignerItem item)
 {
     Switch sw = new Switch();
     SwitchPropertiesWindow spw = new SwitchPropertiesWindow(sw, item, Level);
     this.Children.Add(spw);
     return spw.SelectionHandler;
 }
Exemplo n.º 17
0
 EventHandler<BoolEventArgs> NewPlatformHandler(DesignerItem item)
 {
     Platform en = new Platform();
     PlatformPropertiesWindow epw = new PlatformPropertiesWindow(en, this, item, Level);
     this.Children.Add(epw);
     return epw.SelectionHandler;
 }
Exemplo n.º 18
0
 EventHandler<BoolEventArgs> NewEnemyHandler(DesignerItem item)
 {
     Enemy en = new Enemy();
     EnemyPropertiesWindow epw = new EnemyPropertiesWindow(en, this, item, Level);
     this.Children.Add(epw);
     return epw.SelectionHandler;
 }
Exemplo n.º 19
0
        EventHandler<BoolEventArgs> NewDoorHandler(DesignerItem item)
        {
            DoorModel dm = new DoorModel(new Door(), item, Level);
            DoorPropertiesWindow dpw = new DoorPropertiesWindow();
            dpw.DataContext = dm;
            item.PropertyWindow = dpw;

            this.Children.Add(dpw);
            return dpw.SelectionHandler;
        }
Exemplo n.º 20
0
 EventHandler<BoolEventArgs> NewCheckpointHandler(DesignerItem item)
 {
     Checkpoint cp = new Checkpoint();
     CheckpointPropertiesWindow cpw = new CheckpointPropertiesWindow(cp, this, item, Level);
     this.Children.Add(cpw);
     return cpw.SelectionHandler;
 }
Exemplo n.º 21
0
 public MovingModel(DesignerItem item, Level level)
 {
     mLevel = level;
     mItem = item;
 }
            public SwitchModel(Switch mswitch, DesignerItem item, Level level)
                : base(item, level)
            {
                Data = mSwitch = mswitch;

                if(!level.Obstacles.Contains(mSwitch))
                    level.Obstacles.Add(mSwitch);

                X = (int)mswitch.InitialPosition.X;
                Y = (int)mswitch.InitialPosition.Y;
            }
Exemplo n.º 23
0
        private void AddTile(Tile t)
        {
            Rectangle rect = new Rectangle();
            rect.IsHitTestVisible = false;
            rect.Fill = Settings.NormalBrush;

            DesignerItem item = new DesignerItem();
            item.Content = rect;
            item.MinHeight = item.MinWidth = 1;
            MyDesignerCanvas.Children.Add(item);

            PropertiesWindow pw = new TilePropertiesWindow(t, item, Level);
            MyDesignerCanvas.Children.Add(pw);

            item.OnSelected += pw.SelectionHandler;
            item.IsSelected = true;
        }
Exemplo n.º 24
0
 public PointControlModel(StackPanel parent, Canvas canvas, List<Vector2> points, int indx, DesignerItem item, TextBlock txt)
     : base(item, null)
 {
     IsCentered = true;
     mCanvas = canvas;
     mPoints = points;
     mParent = parent;
     mLabel = txt;
     Index = indx;
 }