예제 #1
0
        private Image GetImage(LayerItem it)
        {
            if (it.Image != null)
            {
                return(it.Image);
            }
            switch (it.LayerType)
            {
            case LayerItem.enumLayerTypes.OrbitData:
                return(imageList1.Images[6]);

            case LayerItem.enumLayerTypes.BaseVector:
                return(imageList1.Images[7]);

            case LayerItem.enumLayerTypes.DigitalNumberMeasure:
                return(imageList1.Images[8]);

            case LayerItem.enumLayerTypes.RoutineObser:
                return(imageList1.Images[9]);

            case LayerItem.enumLayerTypes.Raster:
                return(imageList1.Images[10]);

            default:
                return(imageList1.Images[cstUnknowIco]);
            }
        }
예제 #2
0
        public bool IsContainsAll(LayerItem item)
        {
            bool isContains = false;

            IsContainsAll(this, item, ref isContains);
            return(isContains);
        }
예제 #3
0
 public void Remove(LayerItem child)
 {
     if (_children != null && _children.Contains(child))
     {
         _children.Remove(child);
         child.Parent = null;
     }
 }
예제 #4
0
 public bool IsContains(LayerItem item)
 {
     if (item == null || _children == null)
     {
         return(false);
     }
     return(_children.Contains(item));
 }
예제 #5
0
 public int IndexOf(LayerItem item)
 {
     if (_children == null)
     {
         return(-1);
     }
     return(_children.IndexOf(item));
 }
예제 #6
0
        private int GetOffsetLeft(LayerItem it)
        {
            int n = 0;

            while (it.Parent != null)
            {
                n++;
                it = it.Parent;
            }
            return((n - 1) * cstGroupLeftRemainBank);
        }
예제 #7
0
 public void Insert(LayerItem item, int index)
 {
     if (_children.Contains(item))
     {
         _children.Remove(item);
     }
     if (item.Parent != null)
     {
         item.Parent.Remove(item);
     }
     _children.Insert(index, item);
     item.Parent = this;
 }
예제 #8
0
 void UCLayerManager_Click(object sender, EventArgs e)
 {
     if (_activedLayerItem != null)
     {
         if (OnLayerItemClick != null)
         {
             OnLayerItemClick(_activedLayerItem);
             _currentLayerItem = _activedLayerItem;
             EnsureVisible(_currentLayerItem);
             return;
         }
     }
     _currentLayerItem = null;
 }
예제 #9
0
 private void FindActivedLayerItem(Point pt, LayerItem layerItem)
 {
     if (layerItem._bounds.Contains(pt))
     {
         _activedLayerItem = layerItem;
         return;
     }
     if (layerItem.Children != null && !layerItem.IsCollpased)
     {
         foreach (LayerItem it in layerItem.Children)
         {
             FindActivedLayerItem(pt, it);
         }
     }
 }
예제 #10
0
 void UCLayerManager_MouseDown(object sender, MouseEventArgs e)
 {
     _activedLayerItem = null;
     FindActivedLayerItem(e.Location, _rootLayerItem);
     if (_activedLayerItem != null)
     {
         if (_activedLayerItem._visibleBounds.Contains(e.Location))
         {
             _activedLayerItem.Enabled = !_activedLayerItem.Enabled;
             if (_activedLayerItem.ChildCount > 0)
             {
                 foreach (LayerItem it in _activedLayerItem.Children)
                 {
                     it.Enabled = _activedLayerItem.Enabled;
                 }
             }
             if (OnLayerItemEnabledChanged != null)
             {
                 OnLayerItemEnabledChanged(_activedLayerItem);
             }
         }
         else if (_activedLayerItem._editBounds.Contains(e.Location) && _activedLayerItem.Editable)
         {
             _editLayerItem = _activedLayerItem;
             Invalidate();
             return;
         }
         else
         {
             if (_activedLayerItem._groupCollpaseBounds.Contains(e.Location))
             {
                 _activedLayerItem.IsCollpased = !_activedLayerItem.IsCollpased;
             }
         }
         if (_allowDrag && _activedLayerItem != null && !_activedLayerItem.IsFixed)
         {
             _isDraging     = true;
             _dragLayerItem = _activedLayerItem;
             beginDrapPoint = e.Location;
         }
     }
     if (_textBox.Visible)
     {
         _textBox.Visible = false;
     }
     _currentLayerItem = _activedLayerItem;
     Invalidate();
 }
예제 #11
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;
     }
 }
예제 #12
0
 public void Add(LayerItem child)
 {
     if (child == null)
     {
         return;
     }
     if (_children == null)
     {
         _children = new List <LayerItem>(1);
     }
     if (!_children.Contains(child))
     {
         _children.Add(child);
         child.Parent = this;
     }
 }
예제 #13
0
 public void EnsureVisible(LayerItem layerItem)
 {
     if (Parent == null)
     {
         return;
     }
     using (Control c = new Control())
     {
         c.Location = layerItem._bounds.Location;
         c.Width    = Width;
         c.Height   = layerItem._bounds.Height;
         Parent.Controls.Add(c);
         (Parent as Panel).ScrollControlIntoView(c);
         (Parent as Panel).Controls.Remove(c);
     }
 }
예제 #14
0
 private void IsContainsAll(LayerItem parent, LayerItem item, ref bool isContains)
 {
     if (parent == null || item == null)
     {
         isContains = false;
     }
     if (parent.IsContains(item))
     {
         isContains = true;
         return;
     }
     if (parent.ChildCount > 0)
     {
         foreach (LayerItem subItem in parent.Children)
         {
             IsContainsAll(subItem, item, ref isContains);
         }
     }
 }
예제 #15
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);
                    }
                }
            }
        }