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>();
            }
Пример #2
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;
        }
Пример #3
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;
 }
Пример #4
0
        private void AddPlatform(Platform pltfrm)
        {
            DesignerItem item = CreateDesignerImage(mPlatformImage);

            PropertiesWindow pw = new PlatformPropertiesWindow(pltfrm, MyDesignerCanvas, item, Level);
            MyDesignerCanvas.Children.Add(pw);
            item.OnSelected += pw.SelectionHandler;
            item.IsSelected = true;
        }
            public void AddPoint(PlatformPropertiesWindow parent, int index)
            {
                if (index == -1)
                {
                    mPlatform.Path.Add(Vector2.Zero);
                    index = mPlatform.Path.Count;
                }

                PointControl pc = new PointControl(parent, mCanvas, index, mPlatform.Path);
                parent.mPoints.Children.Add(pc);

                pc.OrderChanged += (object sender, EventArgs e) =>
                {
                    int i = 0;
                    foreach (PointControl control in parent.mPoints.Children)
                        control.ChangeIndex(++i);
                };

                mChildren.Add((pc.DataContext as MovingModel).Item);

                int j = 0;
                foreach (PointControl control in parent.mPoints.Children)
                    control.ChangeIndex(++j);
            }