Exemplo n.º 1
0
 void UCLayerManager_MouseUp(object sender, MouseEventArgs e)
 {
     try
     {
         Cursor = Cursors.Default;
         if (e.Button == MouseButtons.Right)
         {
             contextMenuStrip1.Show(this, e.Location);
             return;
         }
         LayerItem targetLayerItem = null;
         if (_isDraging && _dragLayerItem != null && Math.Abs(e.Location.Y - beginDrapPoint.Y) > 6)
         {
             FindActivedLayerItem(e.Location, _rootLayerItem);
             targetLayerItem = _activedLayerItem;
             if (targetLayerItem != null)
             {
                 if (targetLayerItem.Equals(_dragLayerItem) || !targetLayerItem.Parent.Equals(_dragLayerItem.Parent))
                 {
                     _isDraging = false;
                     return;
                 }
                 int       idx          = -1;
                 LayerItem desLayerItem = null;
                 idx          = targetLayerItem.Parent.IndexOf(targetLayerItem);
                 desLayerItem = targetLayerItem.Parent;
                 if (OnLayerItemOrderChanged != null)
                 {
                     OnLayerItemOrderChanged(_dragLayerItem, desLayerItem, idx);
                 }
             }
             return;
         }
         _dragLayerItem = null;
         if (targetLayerItem != null && !targetLayerItem.IsFixed)
         {
             if (OnMouseUpAtLayerItem != null)
             {
                 OnMouseUpAtLayerItem(targetLayerItem);
             }
         }
     }
     finally
     {
         beginDrapPoint = Point.Empty;
         _isDraging     = false;
     }
 }
Exemplo n.º 2
0
        private void DrawLayerItem(LayerItem it, Graphics g, ref int top, ref int left)
        {
            if (it == null)
            {
                return;
            }
            int offsetLeft = 0;

            if (it.ChildCount == 0)
            {
                if (it.Parent != null && !_rootLayerItem.Equals(it.Parent))
                {
                    offsetLeft = GetOffsetLeft(it);
                }
                it._bounds.X      = 0;
                it._bounds.Y      = top;
                it._bounds.Width  = Width;
                it._bounds.Height = cstLayerItemHeight;
                //if (_activedLayerItem != null && _activedLayerItem.Equals(it) || it.Equals(_currentLayerItem))
                //    g.FillRectangle(focusFillBrush, it._bounds);
                g.DrawRectangle(Pens.Gray, it._bounds);
                g.DrawImage(GetImage(it), offsetLeft + cstVisibleBarWidth + 4, top + cstRemainBank);
                it._visibleBounds.X      = 4;
                it._visibleBounds.Y      = top + cstRemainBank;
                it._visibleBounds.Width  = imageList1.Images[cstEyeIcoOpen].Width;
                it._visibleBounds.Height = imageList1.Images[cstEyeIcoOpen].Height;
                //
                it._editBounds = new Rectangle(it._visibleBounds.Right + 2, it._visibleBounds.Y, it._visibleBounds.Width, it._visibleBounds.Height);
                if (it.Enabled)
                {
                    g.DrawImage(imageList1.Images[cstEyeIcoOpen], it._visibleBounds.X, it._visibleBounds.Y);
                }
                else
                {
                    g.DrawImage(imageList1.Images[cstEyeIcoClose], it._visibleBounds.X, it._visibleBounds.Y);
                }
                if (_editLayerItem != null && it.Equals(_editLayerItem))
                {
                    g.DrawImage(imageList1.Images[cstEditIco], it._editBounds.X, it._editBounds.Y);
                }
                if (it.Equals(_currentLayerItem))
                {
                    g.DrawString(it.Name, Font, Brushes.Gray, offsetLeft + cstVisibleBarWidth + imageList1.ImageSize.Width + 8, top + cstRemainBank + 2);
                }
                else
                {
                    g.DrawString(it.Name, Font, Brushes.Black, offsetLeft + cstVisibleBarWidth + imageList1.ImageSize.Width + 8, top + cstRemainBank + 2);
                }
                top       += cstLayerItemHeight;
                offsetLeft = 0;
            }
            else//group
            {
                it._bounds        = new Rectangle(cstVisibleBarWidth, top, Width, cstGroupBarHeight);
                it._bounds.X      = 0;
                it._bounds.Y      = top;
                it._bounds.Width  = Width;
                it._bounds.Height = cstGroupBarHeight;
                g.FillRectangle(groupFillBrush, it._bounds);
                //if (_activedLayerItem != null && _activedLayerItem.Equals(it))
                //    g.FillRectangle(focusFillBrush, it._bounds);
                g.DrawRectangle(Pens.Gray, it._bounds);
                if (it.Parent != null && !_rootLayerItem.Equals(it.Parent))
                {
                    offsetLeft = GetOffsetLeft(it);
                }
                it._groupCollpaseBounds.X      = offsetLeft + cstVisibleBarWidth + 4;
                it._groupCollpaseBounds.Y      = top + cstGroupImageTopRemainBank;
                it._groupCollpaseBounds.Width  = imageList1.Images[2].Width;
                it._groupCollpaseBounds.Height = imageList1.Images[2].Height;
                if (it.IsCollpased)
                {
                    g.DrawImage(imageList1.Images[cstUpIco], it._groupCollpaseBounds.X, it._groupCollpaseBounds.Y);
                }
                else
                {
                    g.DrawImage(imageList1.Images[cstDownIco], it._groupCollpaseBounds.X, it._groupCollpaseBounds.Y);
                }
                g.DrawImage(_groupImage, offsetLeft + cstVisibleBarWidth + 22, top + cstGroupImageTopRemainBank);
                it._visibleBounds.X      = 4;
                it._visibleBounds.Y      = top + 6;
                it._visibleBounds.Width  = imageList1.Images[cstEyeIcoOpen].Width;
                it._visibleBounds.Height = imageList1.Images[cstEyeIcoOpen].Height;
                if (it.Enabled)
                {
                    g.DrawImage(imageList1.Images[cstEyeIcoOpen], it._visibleBounds.X, it._visibleBounds.Y);
                }
                else
                {
                    g.DrawImage(imageList1.Images[cstEyeIcoClose], it._visibleBounds.X, it._visibleBounds.Y);
                }
                if (it.Equals(_currentLayerItem))
                {
                    g.DrawString(it.Name, Font, Brushes.Gray, offsetLeft + cstVisibleBarWidth + 38, top + cstRemainBank);
                }
                else
                {
                    g.DrawString(it.Name, Font, Brushes.Black, offsetLeft + cstVisibleBarWidth + 38, top + cstRemainBank);
                }
                top += cstGroupBarHeight;
                //
                if (!it.IsCollpased)
                {
                    foreach (LayerItem child in it.Children)
                    {
                        DrawLayerItem(child, g, ref top, ref left);
                    }
                }
            }
        }