コード例 #1
0
        private void OnLayersChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (Layer layer in e.NewItems)
                {
                    m_elements.AddRange(layer.DisplayedElements);
                    layer.DisplayedElements.CollectionChangedRange += OnLayerElementsChanged;
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (Layer layer in e.OldItems)
                {
                    foreach (var element in layer.DisplayedElements)
                    {
                        m_elements.Remove(element);
                    }
                    layer.DisplayedElements.CollectionChangedRange -= OnLayerElementsChanged;
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                foreach (Layer layer in e.OldItems)
                {
                    foreach (var element in layer.DisplayedElements)
                    {
                        m_elements.Remove(element);
                    }

                    layer.DisplayedElements.CollectionChangedRange -= OnLayerElementsChanged;
                }
            }
        }
コード例 #2
0
ファイル: GridLayer.cs プロジェクト: Mixi59/Stump
        public void Reset()
        {
            m_cells.Clear();

            var list = new List <DisplayedCell>();

            for (int i = 0; i < MapEditorModelView.MapCellsCount; i++)
            {
                var pixelCoords = MapModelView.GetCellPixelCoords((short)i);
                list.Add(new DisplayedCell(this, Brushes.Transparent, pixelCoords.X, pixelCoords.Y));
            }

            m_cells.AddRange(list);
        }