Ejemplo n.º 1
0
 internal void CustomDrawing(wTreeNodeDrawingArgs args)
 {
     if (E_TreeNodeDrawing != null)
     {
         E_TreeNodeDrawing(args);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 노드를 그리기 위한 버퍼. 노드 자체적으로 가지는 버퍼를 그린다.
        /// </summary>
        internal void DrawBuffer()
        {
            Size drawSize             = new Size(0, 0);
            wTreeNodeDrawingArgs args = null;
            bool isUserDrawn          = false;

            if (DrawHandler.UseCustomDrawing)
            {
                args = new wTreeNodeDrawingArgs(this, 0, 0);
                DrawHandler.CustomDrawing(args);
                if (args.UserDrawn)
                {
                    _drawnByUser   = true;
                    _imgToDrawNode = args.DrawnBuffer;
                    drawSize       = args.DrawnSize;
                    isUserDrawn    = true;
                    _lineHeight.Clear();
                    _lineHeight[0] = _imgToDrawNode.Height;
                }
            }
            if (isUserDrawn)
            {
                //drawItemsInBuffer();
                return;//이미 그렸으므로 지나감.
            }

            _drawnByUser = false;
            Graphics g = Graphics.FromImage(DrawHandler.ImageTempBufferToDrawForTree);
            //단순히 크기 가져오는 것이므로 버퍼는 그냥 전체버퍼를 사용.
            int wid = 0;
            //int wid = 0;
            int moveY = 0;

            int  maxHeight = 0;
            int  maxWid    = 0;
            Size itemSize;

            _lineHeight = new Dictionary <int, int>(); //첫 줄의 높이.
            int lineNum = 0;                           //줄바꿈이 있을 경우,줄의 번호..0부터 시작.

            foreach (wTreeNodeItem item in this.Items)
            {
                itemSize = item.GetItemSize();

                if (item.ItemType == wTreeNodeItemTypes.WhiteSpace)
                {
                    if ((WhiteSpaceTypes)item.Value == WhiteSpaceTypes.Return)
                    //if (itemSize.Width < 0)//다음줄로 넘어감..whiteSpace가 Return일 때..
                    {
                        moveY    += maxHeight;
                        maxHeight = 0;
                        wid       = 0;
                        lineNum++;
                    }
                    else
                    {
                        wid += itemSize.Width;//Space크기..
                    }
                }
                else
                {
                    wid                 += itemSize.Width;                     //item왼쪽의 margin
                    maxHeight            = getMax(maxHeight, itemSize.Height); //item 위쪽의 margin이다.
                    _lineHeight[lineNum] = maxHeight + ItemYMargin;            //각 줄의 높이를 구한다.//최대에서 ItemYMargin만큼 키운다.
                }
                maxWid = getMax(maxWid, wid);                                  //줄이바뀌어도 maxWid는 가장 큰 wid를 유지해야 함..
            }

            int totalHeight = 0;

            foreach (int lineHeight in _lineHeight.Values)
            {
                totalHeight += lineHeight;
            }


            Size buffSize = new Size(maxWid + moveX, totalHeight);// maxHeight + moveY);//버퍼크기를 정하고..(x margin은 2, ymargin은 4)

            if (ImageBufferToDraw == null || ImageBufferToDraw.Width != buffSize.Width || ImageBufferToDraw.Height != buffSize.Height)
            {//크기가 다르거나버퍼 없을 경우 다시 버퍼를 만들어줌..
                _imgToDrawNode = new Bitmap(buffSize.Width, buffSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            }



            drawItemsInBuffer();
        }