Пример #1
0
        private void LoadLibrary()
        {
            Items.Clear();

            AddAdder();

            var settings = Settings.Default;

            if (settings.Library == null)
            {
                settings.Library = new StringCollection();
                settings.Save();
            }

            foreach (var libitem in settings.Library)
            {
                var data = new PrefabTileData();
                data.FromSerialized(JObject.Parse(libitem));

                var item = new MenuItem
                {
                    Header = data.Name,
                    Icon   = new Border {
                        Background = data.Color
                    }
                };

                var use = new MenuItem {
                    Header = "_Use"
                };
                use.Click += delegate
                {
                    var room      = this.GetParent <PrefabEditor>();
                    var paintData = (PrefabTileData)room.Room.PaintTile.DataContext;

                    paintData.Reassign(data);
                };
                item.Items.Add(use);

                item.Items.Add(new MenuItem {
                    Header = "_Meta: " + data.Metadata
                });

                var remove = new MenuItem {
                    Header = "_Remove"
                };
                var str = libitem;
                remove.Click += delegate
                {
                    settings.Library.Remove(str);
                    settings.Save();
                    LoadLibrary();
                };
                item.Items.Add(remove);

                Items.Add(item);
            }

            AddImportExport();
        }
Пример #2
0
        public void SetEmpty(int size = 10, bool resetFile = true)
        {
            if (resetFile)
            {
                _file = null;
            }
            _size = size;

            var data = new PrefabTileData[size][];

            for (var i = 0; i < size; ++i)
            {
                data[i] = new PrefabTileData[size];
                for (var j = 0; j < size; ++j)
                {
                    data[i][j] = (PrefabTileData)Tiles.Prefabs[0];
                }
            }
            Items.ItemsSource = data;
        }