Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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]);
                }
            }
        }