Beispiel #1
0
 void _HeaderItemHitEvent(ScLayerLayoutViewerHeaderItem headerItem, ScMouseEventArgs e)
 {
     if (HeaderItemHitEvent != null)
     {
         HeaderItemHitEvent(headerItem.ItemDataName);
     }
 }
        void HorSizeChanged(ScLayerLayoutViewerHeaderItem headerItem)
        {
            if (HeaderSizeMode == ScLayerLayoutViewerHeaderSizeMode.ADAPTIVE)
            {
                if (Width == 0)
                {
                    return;
                }

                SuspendLayout();
                AdaptiveAdjustItems2(false, headerItem);
                ResumeLayout(true);
            }
            else
            {
                SuspendLayout();
                Width = AdjustItemsLocation(0);
                ResumeLayout(true);
            }

            if (SizeChanegedEvent != null)
            {
                SizeChanegedEvent(this, controls);
            }
        }
        public void CreateHeaderItemFormDataInfo(
            ScLayerLayoutViewerColumnInfo[] columnInfos, float controlerSize,
            ScLayerLayoutViewerHeaderItem.HeaderItemHitEventHandler headerItemHitEventHandler)
        {
            this.columnInfos = columnInfos;
            itemCreateCount  = columnInfos.Count();

            ControlerSize = controlerSize;

            for (int i = 0; i < itemCreateCount; i++)
            {
                ScLayerLayoutViewerHeaderItem headerItem = new ScLayerLayoutViewerHeaderItem(ScMgr);

                headerItem.HeaderOrientation                 = HeaderOrientation;
                headerItem.ItemMinSize                       = ItemMinSize;
                headerItem.ControlerSize                     = ControlerSize;
                headerItem.ItemDataName                      = columnInfos[itemCreateCount - i - 1].dataName;
                headerItem.ColumnInfo                        = columnInfos[itemCreateCount - i - 1];
                headerItem.HeaderItemHitEvent               += headerItemHitEventHandler;
                headerItem.HeaderItemSizeChangedEvent       += HeaderItem_HeaderItemSizeChangedEvent;
                headerItem.HeaderItemValueChangedEvent      += HeaderItem_HeaderItemValueChangedEvent;
                headerItem.ComputeHeaderItemWidthLimitEvent += HeaderItem_ComputeHeaderItemWidthLimitEvent;
                headerItem.Idx = i;
                Add(headerItem);

                if (CreateHeaderItemDataLayerEvent != null)
                {
                    CreateHeaderItemDataLayerEvent(headerItem.ContentLayer, headerItem.ItemDataName);

                    if (headerItem.ContentLayer.controls.Count > 0)
                    {
                        ScLayer userLayer = headerItem.ContentLayer.controls[0];
                        headerItem.Controler.MouseMove += userLayer.SelfMouseEnter;
                    }
                }
            }

            switch (HeaderOrientation)
            {
            case ScLayerLayoutViewerHeaderOrientation.HORIZONTAL:
                for (int i = 0; i < itemCreateCount; i++)
                {
                    controls[i].Width = columnInfos[itemCreateCount - i - 1].length;
                }
                break;

            case ScLayerLayoutViewerHeaderOrientation.VERTICAL:
                for (int i = 0; i < itemCreateCount; i++)
                {
                    controls[i].Height = columnInfos[itemCreateCount - i - 1].length;
                }
                break;
            }

            if (HeaderSizeMode == ScLayerLayoutViewerHeaderSizeMode.ADAPTIVE)
            {
                ScLayerLayoutViewerHeaderItem headerItem = (ScLayerLayoutViewerHeaderItem)controls[0];
                headerItem.IsUseControler = false;
            }
        }
        private float HeaderItem_ComputeHeaderItemWidthLimitEvent(ScLayerLayoutViewerHeaderItem adjustItem, float adjustWidth)
        {
            float frontWidth = 0;
            int   startIdx   = 0;
            float limitWidth = adjustWidth;

            for (int i = controls.Count - 1; i >= 0; i--)
            {
                if (controls[i] == adjustItem)
                {
                    frontWidth += adjustWidth;
                    startIdx    = i - 1;
                    break;
                }

                frontWidth += controls[i].Width - ControlerSize;
            }

            if (frontWidth > Width)
            {
                limitWidth = adjustWidth - (frontWidth - Width) - 0.1f;
            }

            return(limitWidth);
        }
        private void HeaderItem_HeaderItemSizeChangedEvent(ScLayerLayoutViewerHeaderItem headerItem)
        {
            switch (HeaderOrientation)
            {
            case ScLayerLayoutViewerHeaderOrientation.HORIZONTAL:
                HorSizeChanged(headerItem);
                break;

            case ScLayerLayoutViewerHeaderOrientation.VERTICAL:
                VerSizeChanged(headerItem);
                break;
            }
        }
        void AdaptiveAdjustItems2(bool isTriggerItemSizeChangedEvent, ScLayerLayoutViewerHeaderItem headerItem)
        {
            float n;
            float layerWidth;
            float frontWidth   = 0;
            float orgBackWidth = 0;
            int   startIdx     = 0;
            ScLayerLayoutViewerHeaderItem item;

            SuspendLayout();

            for (int i = controls.Count - 1; i >= 0; i--)
            {
                item        = (ScLayerLayoutViewerHeaderItem)controls[i];
                frontWidth += item.Width - ControlerSize;

                if (item == headerItem)
                {
                    startIdx = i - 1;
                    break;
                }
            }

            for (int i = startIdx; i >= 0; i--)
            {
                orgBackWidth += controls[i].Width - ControlerSize;
            }

            orgBackWidth += ControlerSize;
            float backWidth = Width - frontWidth;


            for (int i = startIdx; i >= 0; i--)
            {
                item = (ScLayerLayoutViewerHeaderItem)controls[i];
                item.IsTriggerItemSizeChangedEvent = isTriggerItemSizeChangedEvent;

                layerWidth = item.Width - ControlerSize;

                n          = layerWidth / (orgBackWidth - ControlerSize);
                item.Width = (backWidth - ControlerSize) * n + ControlerSize;
            }

            AdjustItemsLocation(Width);
            ResumeLayout(true);
        }
        void VerSizeChanged(ScLayerLayoutViewerHeaderItem headerItem)
        {
            ScLayerLayoutViewerHeaderItem item;
            float totalHeight = ControlerSize;

            foreach (ScLayer layer in controls)
            {
                totalHeight += layer.Height - ControlerSize;
            }


            float pos = totalHeight - ControlerSize;

            for (int i = 0; i < controls.Count(); i++)
            {
                item          = (ScLayerLayoutViewerHeaderItem)controls[i];
                pos          += ControlerSize - item.Height;
                item.Location = new PointF(0, pos);
            }


            Height = totalHeight;
        }
Beispiel #8
0
        public int GetItemIdx(ScLayer item)
        {
            ScLayerLayoutViewerHeaderItem header = (ScLayerLayoutViewerHeaderItem)item.Parent.Parent;

            return(header.Idx);
        }