コード例 #1
0
        protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            double x = e.GetPosition(TileEditorGroup).X, y = e.GetPosition(TileEditorGroup).Y;
            int locX = (int)x / 64;
            int locY = (int)y / 64;
            if (x < 0 || x >= baseImage.ActualWidth || y < 0 || y >= baseImage.ActualHeight) return;

            if (!Editable) return;

            if (createTileInProgress)
            {
                if (findOriginInProgress)
                {
                    TileEditor t = new TileEditor(); t.Tile = new Tile(); t.Editable = Editable;
                    t.Tile.LeftX = (int)Area.Margin.Left / 64; t.Tile.TopY = (int)Area.Margin.Top / 64;
                    t.Tile.RightX = t.Tile.LeftX + (int)Area.Width / 64 - 1; t.Tile.BottomY = t.Tile.TopY + (int)Area.Height / 64 - 1;
                    t.Tile.OriginX = (int)Origin.Margin.Left / 64; t.Tile.OriginY = (int)Origin.Margin.Top / 64;
                    t.Changed += HandleTileChanged;
                    TileEditorGroup.Children.Add(t);
                    OnModify();
                    endCreateTile();
                }
                else
                {
                    if (Area.Width == 64 && Area.Height == 64)
                    {
                        TileEditor t = new TileEditor(); t.Tile = new Tile(); t.Editable = Editable;
                        t.Tile.PositionX = (int)Area.Margin.Left / 64;
                        t.Tile.PositionY = (int)Area.Margin.Top / 64;
                        t.Changed += HandleTileChanged;
                        TileEditorGroup.Children.Add(t);
                        OnModify();
                        endCreateTile();
                    }
                    else
                    {
                        if (isValidBounds((int)Area.Margin.Left / 64, (int)Area.Margin.Top / 64, locX, locY))
                        {
                            findOriginInProgress = true;
                        }
                        else
                        {
                            endCreateTile();
                        }
                    }
                }
            }
        }
コード例 #2
0
 public void OpenFromTileSet(TileSet tset)
 {
     baseTileSet = tset;
     baseImage.Source = new BitmapImage(new Uri(BaseTexturePath));
     foreach (Tile t in baseTileSet)
     {
         TileEditor ed = new TileEditor(); ed.Editable = Editable;
         ed.Tile = t; ed.Changed += HandleTileChanged;
         TileEditorGroup.Children.Add(ed);
     }
 }