Beispiel #1
0
        public void ContainsTest()
        {
            var a = new[] { new EClass(1), new EClass(2) };
            var l = new EventedList <EClass>(a);

            Assert.That(l.Contains(a[0]));
            Assert.That(!l.Contains(new EClass()));
        }
Beispiel #2
0
        private void map_CollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (IsDisposed)
            {
                return;
            }

            // hack: some tools add extra tools and can remove them in response to a layer
            // change. For example NetworkEditorMapTool adds NewLineTool for NetworkMapLayer
            foreach (var tool in tools.ToArray().Where(tool => tools.Contains(tool)))
            {
                tool.OnMapCollectionChanged(sender, e);
            }

            var layer = e.Item as ILayer;

            if (layer == null)
            {
                return;
            }

            if (Map == null)
            {
                return; // may happen in multi-threaded environment
            }

            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Add:
                var allLayersWereEmpty = Map.Layers.Except(new[] { layer }).All(l => l.Envelope != null && l.Envelope.IsNull);
                if (allLayersWereEmpty && layer.Envelope != null && !layer.Envelope.IsNull)
                {
                    map.ZoomToExtents();     //HACK: OOPS, changing domain model from separate thread!
                }

                break;

            case NotifyCollectionChangeAction.Replace:
                throw new NotImplementedException();
            }

            Refresh();
        }
Beispiel #3
0
        private void map_CollectionChanged_Delayed(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (IsDisposed)
            {
                return;
            }

            // hack: some tools add extra tools and can remove them in response to a layer
            // change. For example NetworkEditorMapTool adds NewLineTool for NetworkMapLayer
            foreach (IMapTool tool in tools.ToArray())
            {
                if (tools.Contains(tool)) // ???
                {
                    tool.OnMapCollectionChanged(sender, e);
                }
            }

            var layer = e.Item as ILayer;

            if (layer == null)
            {
                return;
            }

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                bool allLayersWereEmpty = Map.Layers.Except(new[] { layer }).All(l => l.Envelope.IsNull);
                if (allLayersWereEmpty && !layer.Envelope.IsNull)
                {
                    map.ZoomToExtents();
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                throw new NotImplementedException();
            }

            Refresh();
        }