예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateRectangle(IColorMap aColorMap)
        {
            iFillRectangle = new System.Drawing.RectangleF(
                (iLowerLeft.X * iScale.X),
                (iLowerLeft.Y * iScale.Y),
                (iWidth * iScale.X),
                iHeight * iScale.Y);

            if (aColorMap.GetColors().GetLength(0) < iId)
            {
                iId = 0;
            }

            iBrush = new System.Drawing.Drawing2D.LinearGradientBrush(
                iFillRectangle,
                aColorMap.GetColor(iId), Color.Black,
                System.Drawing.Drawing2D.LinearGradientMode.Vertical);
            iGrayBrush = new System.Drawing.Drawing2D.LinearGradientBrush(
                iFillRectangle,
                Color.Gray, Color.Black,
                System.Drawing.Drawing2D.LinearGradientMode.Vertical);


            iBorderRectangle = new System.Drawing.Rectangle(
                (int)Math.Ceiling(iLowerLeft.X * iScale.X),
                (int)Math.Ceiling(iLowerLeft.Y * iScale.Y),
                (int)Math.Ceiling(iWidth * iScale.X),
                (int)Math.Ceiling(iHeight * iScale.Y));
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aGraphics"></param>
        /// <param name="aColorMap"></param>
        private void DrawChild(Graphics aGraphics, IColorMap aColorMap, List <int> aSelectedIds, IndexVisibilityHandler aVisibility)
        {
            float height = iHeight * iScale.Y;

            if (height <= 1)
            {
                return;
            }

            UpdateRectangle(aColorMap);

            // Last level: Draw Label and Fill Rectangle
            if (iChildRectangles.Count == 0)
            {
                int amount = aColorMap.GetColors().GetLength(0);
                if (amount < iId)
                {
                    iId = 0;
                }

                // *** If selected ***
                if (aSelectedIds != null && aSelectedIds.Contains(iId) && (aVisibility != null && aVisibility.GetVisibility(iId)))
                {
                    System.Drawing.Drawing2D.LinearGradientBrush brush = new
                                                                         System.Drawing.Drawing2D.LinearGradientBrush(
                        iFillRectangle,
                        aColorMap.GetColor(iId), Color.White,
                        System.Drawing.Drawing2D.LinearGradientMode.Vertical);

                    aGraphics.FillRectangle(brush, iFillRectangle);
                    DrawLabel(aGraphics, iSelectedGroupLabelPen);
                    Pen selectedPen  = new Pen(Color.Cyan, 3);
                    Pen selectedPen2 = new Pen(Color.Blue, 3);

                    aGraphics.DrawRectangle(selectedPen, iBorderRectangle.X + 3, iBorderRectangle.Y + 3, iBorderRectangle.Width - 7, iBorderRectangle.Height - 7);
                    aGraphics.DrawRectangle(selectedPen2, iBorderRectangle.X + 6, iBorderRectangle.Y + 6, iBorderRectangle.Width - 12, iBorderRectangle.Height - 12);
                }
                else
                {
                    if (aVisibility != null && aVisibility.GetVisibility(iId))
                    {
                        aGraphics.FillRectangle(iBrush, iFillRectangle);
                    }
                    else
                    {
                        aGraphics.FillRectangle(iGrayBrush, iFillRectangle);
                    }

                    DrawLabel(aGraphics);
                }
            }
            else
            {
                // Call children recursively
                foreach (TreeRectangle rectangle in iChildRectangles)
                {
                    rectangle.DrawChild(aGraphics, aColorMap, aSelectedIds, aVisibility);
                }

                // Draw the The Group Rectangle (as a border)
                aGraphics.DrawRectangle(iPen, iBorderRectangle);

                // Draw the Group Label
                DrawGroupLabel(iFillRectangle, aGraphics, iBorderPen);
            }
        }