コード例 #1
0
ファイル: VMap.cs プロジェクト: songgod/WPF_Demo
        private void UpdateLayerSource(int index, ILayer layer)
        {
            if (layer == null)
            {
                throw new Exception("UpdateLayerSource para newlayer invalid");
            }

            VLayer oldlyrcanvas = this.Children[index] as VLayer;

            if (oldlyrcanvas == null)
            {
                throw new Exception("UpdateLayerSource para child is not VLayer");
            }

            Binding binding = new Binding("Objects")
            {
                Source = layer
            };

            BindingOperations.SetBinding(oldlyrcanvas, VLayer.ObjectsSourceProperty, binding);
            Binding bdname = new Binding("Name")
            {
                Source = layer
            };

            BindingOperations.SetBinding(oldlyrcanvas, FrameworkElement.NameProperty, binding);
        }
コード例 #2
0
ファイル: VMap.cs プロジェクト: songgod/WPF_Demo
        private void InsertLayer(int index, ILayer layer)
        {
            if (layer == null)
            {
                throw new Exception("InsertLayer para layer invalid");
            }
            VLayer laycanvas = new VLayer();

            this.Children.Insert(index, laycanvas);
            UpdateLayerSource(index, layer);
        }
コード例 #3
0
ファイル: VLayer.cs プロジェクト: songgod/WPF_Demo
        private static void OnObjectSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VLayer layer = (VLayer)d;

            layer.Children.Clear();
            if (layer.ObjectsSource != null)
            {
                layer.ObjectsSource.OnItemAdded    += layer.ObjectsSource_OnItemAdded;
                layer.ObjectsSource.OnItemMoved    += layer.ObjectsSource_OnItemMoved;
                layer.ObjectsSource.OnItemRemoved  += layer.ObjectsSource_OnItemRemoved;
                layer.ObjectsSource.OnItemReplaced += layer.ObjectsSource_OnItemReplaced;
                layer.ObjectsSource.OnCleared      += layer.ObjectsSource_OnCleared;
                for (int i = 0; i < layer.ObjectsSource.Count; i++)
                {
                    layer.InsertObject(i, layer.ObjectsSource[i]);
                }
            }
        }