Ejemplo n.º 1
0
        private void LayerCheckBox_Click(object sender, RoutedEventArgs e)
        {
            if (OnLayerCheckBoxClick != null)
            {
                CheckBox tickedCheckBox = sender as CheckBox;

                LayerItem item = new LayerItem();
                if (tickedCheckBox.Content != null)
                    item.Name = tickedCheckBox.Content.ToString();
                item.Visibility = (bool)tickedCheckBox.IsChecked;
                item.LayerObject = tickedCheckBox.Tag;

                LayerCheckBoxClickArgs args = new LayerCheckBoxClickArgs();
                args.Item = item;

                OnLayerCheckBoxClick(this, args);
            }
        }
        private void LayerCheckBox_Click(object sender, RoutedEventArgs e)
        {
            if (OnLayerCheckBoxClick != null)
            {
                CheckBox tickedCheckBox = sender as CheckBox;

                LayerItem item = new LayerItem();
                if (tickedCheckBox.Content != null)
                {
                    item.Name = tickedCheckBox.Content.ToString();
                }
                item.Visibility  = (bool)tickedCheckBox.IsChecked;
                item.LayerObject = tickedCheckBox.Tag;

                LayerCheckBoxClickArgs args = new LayerCheckBoxClickArgs();
                args.Item = item;

                OnLayerCheckBoxClick(this, args);
            }
        }
Ejemplo n.º 3
0
        private void LayersButton_Click(object sender, RoutedEventArgs e)
        {
            if (_layersWindow != null)
            {
                _layersWindow.Show();
                return;
            }

            List<LayerItem> items = new List<LayerItem>();
            foreach (var layer in _view.map.Layers)
            {
                LayerItem item = new LayerItem();
                item.Name = layer.DisplayName;
                item.Visibility = layer.IsVisible;
                item.LayerObject = layer;
                items.Add(item);
            }
            _layersWindow = new LayersWindow(items);
            _layersWindow.Owner = App.Current.MainWindow;
            _layersWindow.Title = _view.eMap.MapID + ":Layers";

            // Two ways to use delegate
            //_layersWindow.Closed += delegate { _layersWindow = null; };
            //_layersWindow.Closed += delegate(object o, EventArgs args) { _layersWindow = null; };

            // Use lamda function
            _layersWindow.Closed += (o, args) =>
            {
                _layersWindow = null;
            };
            _layersWindow.OnLayerCheckBoxClick += (o, args) =>
            {
                Layer layer = args.Item.LayerObject as Layer;
                if (layer != null)
                    layer.IsVisible = !layer.IsVisible;
            };

            _layersWindow.Show();
        }