コード例 #1
0
        private static void _mezzanine(LayerageCollection layerageCollection, Layerage mezzanineLayer, IEnumerable <Layerage> mezzanineLayers)
        {
            //Layerages
            IEnumerable <Layerage> selectedLayerages = LayerageCollection.GetAllSelected(layerageCollection);
            Layerage outermost = LayerageCollection.FindOutermostLayerage(selectedLayerages);
            //if (outermost == null) return; // If count = 0, it will be useless.
            IList <Layerage> parentsChildren = layerageCollection.GetParentsChildren(outermost);
            int index = parentsChildren.IndexOf(outermost);

            if (index < 0)
            {
                index = 0;
            }

            if (mezzanineLayer != null)
            {
                mezzanineLayer.Self.IsSelected = true;
                parentsChildren.Insert(index, mezzanineLayer);//Insert
            }
            else if (mezzanineLayers != null)
            {
                foreach (Layerage child in mezzanineLayers)
                {
                    child.Self.IsSelected = true;
                    parentsChildren.Insert(index, child);//Insert
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Group all selected layerages.
        /// </summary>
        /// <param name="customDevice"> The custom-device. </param>
        /// <param name="layerageCollection"> The layerage-collection. </param>
        public static void GroupAllSelectedLayers(CanvasDevice customDevice, LayerageCollection layerageCollection)
        {
            //Layerages
            IEnumerable <Layerage> selectedLayerages = LayerageCollection.GetAllSelected(layerageCollection);
            Layerage outermost = LayerageCollection.FindOutermostLayerage(selectedLayerages);

            if (outermost == null)
            {
                return;
            }
            IList <Layerage> parentsChildren = layerageCollection.GetParentsChildren(outermost);
            int index = parentsChildren.IndexOf(outermost);

            if (index < 0)
            {
                index = 0;
            }


            //GroupLayer
            GroupLayer groupLayer = new GroupLayer(customDevice)
            {
                IsSelected = true,
                IsExpand   = false,
                //Refactoring
                IsRefactoringTransformer = true,
            };
            Layerage groupLayerage = groupLayer.ToLayerage();

            LayerBase.Instances.Add(groupLayer);


            //Temp
            foreach (Layerage layerage in selectedLayerages)
            {
                ILayer layer = layerage.Self;

                IList <Layerage> childParentsChildren = layerageCollection.GetParentsChildren(layerage);
                childParentsChildren.Remove(layerage);
                layer.IsSelected = false;

                groupLayerage.Children.Add(layerage);
            }

            //Insert
            parentsChildren.Insert(index, groupLayerage);
        }
コード例 #3
0
        /// <summary>
        /// Un group all group layerage
        /// </summary>
        public static void UnGroupAllSelectedLayer(LayerageCollection layerageCollection)
        {
            //Layerages
            IEnumerable <Layerage> selectedLayerages = LayerageCollection.GetAllSelected(layerageCollection);
            Layerage outermost = LayerageCollection.FindOutermostLayerage(selectedLayerages);

            if (outermost == null)
            {
                return;
            }
            IList <Layerage> parentsChildren = layerageCollection.GetParentsChildren(outermost);
            int index = parentsChildren.IndexOf(outermost);

            if (index < 0)
            {
                index = 0;
            }


            do
            {
                Layerage groupLayerage = selectedLayerages.FirstOrDefault(l => l.Self.Type == LayerType.Group);
                if (groupLayerage == null)
                {
                    break;
                }
                ILayer groupLayer = groupLayerage.Self;

                //Insert
                foreach (Layerage layerage in groupLayerage.Children)
                {
                    ILayer layer = layerage.Self;

                    layer.IsSelected = true;
                    parentsChildren.Insert(index, layerage);
                }
                groupLayerage.Children.Clear();

                //Remove
                {
                    IList <Layerage> groupLayerageParentsChildren = layerageCollection.GetParentsChildren(groupLayerage);
                    groupLayerageParentsChildren.Remove(groupLayerage);
                }
            } while (selectedLayerages.Any(l => l.Self.Type == LayerType.Group) == false);
        }
コード例 #4
0
        /// <summary>
        ///  Sets the mode and notify all properties.
        ///  and copy all selected layerage.
        /// </summary>
        /// <param name="customDevice"> The custom-device. </param>
        /// <param name="layerageCollection"> The layerage-collection. </param>
        public void SetMode(CanvasDevice customDevice, LayerageCollection layerageCollection)
        {
            //Layerages
            IEnumerable <Layerage> selectedLayerages = LayerageCollection.GetAllSelected(layerageCollection);
            int count = selectedLayerages.Count();

            if (count == 0)
            {
                this.SelectionMode = ListViewSelectionMode.None;//None

                this.Layerage  = null;
                this.Layerages = null;

                Clipboard.Instances.Clear();
            }
            else if (count == 1)
            {
                this.SelectionMode = ListViewSelectionMode.Single;//None

                Layerage layerage = selectedLayerages.Single();
                this.Layerage  = layerage.Clone();
                this.Layerages = null;

                Clipboard.Instances.Clear();
                LayerageCollection.CopyLayerage(customDevice, this.Layerage);
            }
            else if (count >= 2)
            {
                this.SelectionMode = ListViewSelectionMode.Multiple;//None
                this.Layerage      = null;
                this.Layerages     = from layerage in selectedLayerages select layerage.Clone();

                Clipboard.Instances.Clear();
                LayerageCollection.CopyLayerages(customDevice, this.Layerages);
            }
        }
        /// <summary>
        /// Drag complete.
        /// </summary>
        /// <param name="layerageCollection"> The layerage-collection. </param>
        /// <param name="destination"> The destination layerage. </param>
        /// <param name="source"> The source layerage. </param>
        /// <param name="destinationOverlayMode"> The destination OverlayMode. </param>
        /// <param name="sourceIsSelected"> The source SelectMode. </param>
        public static void DragComplete(LayerageCollection layerageCollection, Layerage destination, Layerage source, OverlayMode destinationOverlayMode, bool sourceIsSelected)
        {
            if (source == null)
            {
                return;
            }
            if (destination == null)
            {
                return;
            }
            ILayer destinationLayer = destination.Self;
            ILayer sourceLayer      = source.Self;

            destinationLayer.Control.OverlayMode = OverlayMode.None;
            if (destinationLayer.IsSelected)
            {
                return;
            }
            if (destinationOverlayMode == OverlayMode.None)
            {
                return;
            }

            if (source == destination)
            {
                return;
            }


            bool isSelected = sourceLayer.IsSelected;

            if (isSelected == false)
            {
                switch (destinationOverlayMode)
                {
                case OverlayMode.Top:
                    LayerageCollection.Insert(layerageCollection, destination, source, isBottomInsert: false);
                    break;

                case OverlayMode.Center:
                    LayerageCollection.Add(layerageCollection, destination, source);
                    break;

                case OverlayMode.Bottom:
                    LayerageCollection.Insert(layerageCollection, destination, source, isBottomInsert: true);
                    break;
                }
            }
            else
            {
                //Layerages
                IEnumerable <Layerage> selectedLayerages = LayerageCollection.GetAllSelected(layerageCollection);

                switch (destinationOverlayMode)
                {
                case OverlayMode.Top:
                    LayerageCollection.InsertRange(layerageCollection, destination, selectedLayerages, isBottomInsert: false);
                    break;

                case OverlayMode.Center:
                    LayerageCollection.AddRange(layerageCollection, destination, selectedLayerages);
                    break;

                case OverlayMode.Bottom:
                    LayerageCollection.InsertRange(layerageCollection, destination, selectedLayerages, isBottomInsert: true);
                    break;
                }
            }
        }