示例#1
0
        public Model()
        {
            ImagePaths = new List<ImagePath>();
            LevelEditorDatabaseDataContext db = new LevelEditorDatabaseDataContext();
            IOrderedQueryable<ImagePath> imagePaths = (from a in db.ImagePaths orderby a.Id select a);

            ImagePaths.AddRange(imagePaths);
            db.Connection.Close();
        }
        public TileSelectionViewModel()
        {
            _model = Model.Model.Instance;

            TilePanel = new WrapPanel();
            DecorationPanel = new WrapPanel();

            LevelEditorDatabaseDataContext db = new LevelEditorDatabaseDataContext();
            IOrderedQueryable<ImagePath> imagePaths =
                (from a in db.ImagePaths orderby a.Id select a);
            db.Connection.Close();

            foreach (ImagePath ip in imagePaths)
            {
                if (ip.Path.Contains("/Terrain/"))
                {
                    if (ip.Description.Contains("Mid") || (ip.Description.Contains("Hill Left") &! ip.Description.Contains("Corner")))
                    {
                        TileButton tileButton = new TileButton((ushort) (ip.Id - 1), ip.Description)
                        {
                            Background = Brushes.Transparent,
                            BorderThickness = new Thickness(0)
                        };

                        tileButton.AddHandler(UIElement.MouseDownEvent, (RoutedEventHandler) SelectTile);
                        tileButton.Click += SelectTile;

                        TilePanel.Children.Add(tileButton);
                    }
                } else if (ip.Description.Contains("Object"))
                {
                    TileButton tileButton = new TileButton((ushort) (ip.Id - 1), ip.Description)
                    {
                        Background = Brushes.Transparent,
                        BorderThickness = new Thickness(0)
                    };

                    tileButton.AddHandler(UIElement.MouseDownEvent, (RoutedEventHandler)SelectTile);
                    tileButton.Click += SelectTile;
                    DecorationPanel.Children.Add(tileButton);
                }
            }
        }