Ejemplo n.º 1
0
        public static void OnSelectedLayerChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (oldValue != newValue)
            {
                var        layout   = bindable as StoryBoardLayout;
                ImageLayer imgLayer = null;
                foreach (var child in layout.Children)
                {
                    var childLayer = child as ImageLayer;
                    if (childLayer.ID == layout.SelectedLayer.ID)
                    {
                        imgLayer = childLayer;
                        break;
                    }
                }

                if (imgLayer != null)
                {
                    layout.SetLayerInFocus(imgLayer);
                }
            }
        }
Ejemplo n.º 2
0
        public static void OnLayersChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var layout           = (StoryBoardLayout)bindable;
            var notifyCollection = newValue as INotifyCollectionChanged;

            if (notifyCollection != null)
            {
                notifyCollection.CollectionChanged += (sender, args) =>
                {
                    if (args.NewItems != null)
                    {
                        foreach (var layer in args.NewItems)
                        {
                            bool found = false;
                            foreach (var child in layout.Children)
                            {
                                var childLayer = child as ImageLayer;
                                if (childLayer.ID == ((Layer)layer).ID)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                layout.DisableLayers();
                                var newLayer = new ImageLayer(((Layer)layer).ID);
                                layout.Children.Add(newLayer);
                                newLayer.SetInFocus(true);
                            }
                        }
                    }
                    if (args.OldItems != null)
                    {
                        foreach (var oldLayer in args.OldItems)
                        {
                            foreach (var child in layout.Children)
                            {
                                var childLayer = child as ImageLayer;
                                if (childLayer.ID == ((Layer)oldLayer).ID)
                                {
                                    //TODO figure what to do when the current item being deleted is the Active Layer
                                    //if (SelectedLayer != null && SelectedLayer.ID == childLayer.ID)
                                    //{
                                    //    layout.DisableLayers();
                                    //}

                                    layout.Children.Remove(childLayer);
                                    break;
                                }
                            }
                        }
                    }
                };
            }

            if (newValue == null)
            {
                return;
            }

            foreach (var layer in (IEnumerable)newValue)
            {
                var newItemLayer = new ImageLayer(((Layer)layer).ID);
                layout.Children.Add(newItemLayer);
                newItemLayer.SetInFocus(true);
            }
        }
Ejemplo n.º 3
0
 public void SetLayerInFocus(ImageLayer layer)
 {
     DisableLayers();
     layer.SetInFocus(true);
 }