Esempio n. 1
0
        private static ILegendItem GetInsertTarget(ILegendItem startItem, ILegendItem dropItem)
        {
            if (startItem == null)
            {
                return(null);
            }
            if (dropItem == null)
            {
                return(null);
            }
            if (startItem.CanReceiveItem(dropItem))
            {
                return(startItem);
            }
            ILegendItem item = startItem;

            while (item.GetParentItem() != null)
            {
                if (item.GetParentItem().CanReceiveItem(dropItem))
                {
                    return(item);
                }
                item = item.GetParentItem();
            }
            return(null);
        }
Esempio n. 2
0
        private void DoItemMouseDown(ItemMouseEventArgs e)
        {
            Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top);

            // Toggle expansion
            if (e.ItemBox.ExpandBox.Contains(loc))
            {
                e.ItemBox.Item.IsExpanded = !e.ItemBox.Item.IsExpanded;
                if (ExpandBoxMouseDown != null)
                {
                    ExpandBoxMouseDown(this, e);
                }

                ResetLegend();
                return;
            }

            if (e.ItemBox.Item.IsSelected)
            {
                // if we are already selected, prepare to edit in textbox
                _previousMouseDown = e.ItemBox;

                // Start dragging
                if (e.Button == MouseButtons.Left)
                {
                    _isDragging = true;
                    ILegendItem li = e.ItemBox.Item;
                    while (li != null && li as ILayer == null)
                    {
                        li = li.GetParentItem();
                    }
                    ILayer lyr = li as ILayer;
                    if (lyr != null)
                    {
                        _dragItem = BoxFromItem(lyr);
                    }
                    else
                    {
                        _isDragging = false;
                    }
                }
            }
            else
            {
                // Check for textbox clicking
                if (e.ItemBox.Textbox.Contains(loc))
                {
                    if (ModifierKeys != Keys.Shift)
                    {
                        ClearSelection();
                    }
                    e.ItemBox.Item.IsSelected = true;

                    //_selection.Add(e.ItemBox);
                    //IsInitialized = false;
                    //Invalidate();
                    //return;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
        /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
        /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
        /// place to place.
        /// </summary>
        /// <param name="item">the legend item to test</param>
        /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
        public override bool CanReceiveItem(ILegendItem item)
        {
            if (item.GetParentItem() != this)
            {
                return(false);
            }
            ILayer lyr = item as ILayer;

            if (lyr != null)
            {
                return(false);
            }
            IFrame mf = item as IFrame;

            if (mf != null)
            {
                return(false);
            }
            IGroup gr = item as IGroup;

            if (gr != null)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// This method starts with this legend item and tests to see if it can contain
        /// the specified target.  As it moves up the
        /// </summary>
        /// <param name="startItem">This legend item</param>
        /// <param name="dropItem">The target legend item to test</param>
        /// <returns>An ILegendItem that is one of the parent items of this item, but that can receive the target.</returns>
        public static ILegendItem GetValidContainerFor(this ILegendItem startItem, ILegendItem dropItem)
        {
            if (startItem == null)
            {
                return(null);
            }
            if (dropItem == null)
            {
                return(null);
            }
            if (startItem.CanReceiveItem(dropItem))
            {
                return(startItem);
            }
            ILegendItem item = startItem;

            while ((item = item.GetParentItem()) != null)
            {
                if (item.CanReceiveItem(dropItem))
                {
                    return(item);
                }
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the index at which the positionBase is situated in the parent. This can be used to determine the index the item that gets moved should be inserted.
        /// </summary>
        /// <param name="parent">The legend item the moving item should be added to.</param>
        /// <param name="positionBase">The item that is used to determine the new position of the moving item.</param>
        /// <returns>The new position of the moving item.</returns>
        public static int InsertIndex(this ILegendItem parent, ILegendItem positionBase)
        {
            if (parent == null || positionBase == null)
            {
                return(-1);
            }

            ILegendItem item = positionBase;

            if (item == parent)
            {
                return(item.LegendItems.Count());
            }

            while (item != null)
            {
                var p = item.GetParentItem();

                if (p == parent)
                {
                    var items = p.LegendItems.ToList();
                    return(items.IndexOf(item));
                }

                item = p;
            }

            return(-1);
        }
Esempio n. 6
0
        /// <summary>
        /// Tests the specified legend item. If the item is another layer or a group or a map-frame, then this
        /// will return false. Furthermore, if the parent of the item is not also this object, then it will
        /// also return false. The idea is that layers can have sub-nodes move around, but not transport from
        /// place to place.
        /// </summary>
        /// <param name="item">the legend item to test.</param>
        /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
        public override bool CanReceiveItem(ILegendItem item)
        {
            if (item.GetParentItem() != this)
            {
                return(false);
            }

            return(item is not ILayer lyr);
        }
Esempio n. 7
0
        /// <summary>
        /// Tests the specified legend item. If the item is another layer or a group or a map-frame, then this
        /// will return false. Furthermore, if the parent of the item is not also this object, then it will
        /// also return false. The idea is that layers can have sub-nodes move around, but not transport from
        /// place to place.
        /// </summary>
        /// <param name="item">the legend item to test</param>
        /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
        public override bool CanReceiveItem(ILegendItem item)
        {
            if (item.GetParentItem() != this)
            {
                return(false);
            }

            var lyr = item as ILayer;

            return(lyr == null);
        }
Esempio n. 8
0
        /// <summary>
        /// This method starts with this legend item and searches through the
        /// parent groups until it finds a valid mapframe.
        /// </summary>
        /// <param name="self">The ILegendItem to start from</param>
        /// <returns>The IMapFrame that contains this item.</returns>
        public static IFrame ParentMapFrame(this ILegendItem self)
        {
            ILegendItem current = self;
            IFrame      frame   = current as IFrame;

            while (current != null)
            {
                if (frame != null)
                {
                    return(frame);
                }
                current = current.GetParentItem();
                frame   = current as IFrame;
            }
            return(null);
        }
Esempio n. 9
0
 /// <summary>
 /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
 /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
 /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
 /// place to place.
 /// </summary>
 /// <param name="item">the legend item to test</param>
 /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     if (item.GetParentItem() != this) return false;
     ILayer lyr = item as ILayer;
     if (lyr != null) return false;
     IFrame mf = item as IFrame;
     if (mf != null) return false;
     IGroup gr = item as IGroup;
     if (gr != null) return false;
     return true;
 }
Esempio n. 10
0
 /// <summary>
 /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
 /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
 /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
 /// place to place.
 /// </summary>
 /// <param name="item">the legend item to test</param>
 /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     if (item.GetParentItem() != this) return false;
     var lyr = item as ILayer;
     if (lyr != null) return false;
     return true;
 }