示例#1
0
        public override void Paint(MapItem item, ItemControls.ItemScrollBar scrollBar,
                                   ItemLinkPoint[] linkPoints)
        {
            if (item.PreviousItemSize == item.Size)
            {
                DrawWorkplaceFromBuffer(item);
            }
            else
            {
                item.PreviousItemSize = item.Size;
                CalculateWorkplaceRectangle(item);
                item.Buffer.Clear(Color.Transparent);

                DrawBody(item);
                DrawHeader(item);
                DrawWorkplace(item);
                DrawSelectionBodyFrame(item);
            }

            bool      scrollBarVisible          = scrollBar.Visible;
            Rectangle clippedWorkplaceRectangle = Rectangle.Inflate(
                item.WorkplaceRectangle, -1, -1);

            item.Buffer.SetClip(clippedWorkplaceRectangle);
            DrawItemElements(item, scrollBar);

            //Repaint if scroll bar visible was changed
            if (scrollBarVisible != scrollBar.Visible)
            {
                item.Buffer.SetClip(item.ClientRectangle);
                Paint(item, scrollBar, linkPoints);
                return;
            }

            //Correct scroll bar position
            if (scrollBar.Position > scrollBar.MaxValue)
            {
                item.Buffer.SetClip(item.ClientRectangle);
                scrollBar.Position = scrollBar.MaxValue;
                return;
            }

            DrawControls(item);
            DrawScrollBar(item, scrollBar);

            int       shift     = item.Selected ? 1 : 0;
            Rectangle rectangle = new Rectangle(
                item.ClientRectangle.Left + shift,
                item.ClientRectangle.Top,
                item.ClientRectangle.Width - shift * 2 - ShadowDistance,
                item.ClientRectangle.Height);

            item.Buffer.SetClip(rectangle);
            DrawLinkPoint(item, linkPoints);
            item.Buffer.SetClip(item.ClientRectangle);
        }
        public override void Paint(MapItem item, ItemControls.ItemScrollBar scrollBar,
                                   ItemLinkPoint[] linkPoints)
        {
            Rectangle rectangle = item.ClientRectangle;

            ItemPainterHelper.DrawRoundedRectangleShadow(item.Buffer,
                                                         ref rectangle, CornerRadius, ShadowDistance, ShadowColor);

            Pen pen = new Pen(Color.FromArgb(255, Color.Green), 5);

            rectangle.Inflate(-(int)pen.Width, -(int)pen.Width);
            item.ItemRegion = ItemPainterHelper.CalculateRoundedRectangleGraphicsPath(
                rectangle, CornerRadius);

            pen.EndCap = pen.StartCap = LineCap.Flat;
            item.Buffer.DrawPath(pen, item.ItemRegion);
        }
 public virtual void Paint(MapItem item, ItemControls.ItemScrollBar scrollBar,
                           ItemLinkPoint[] linkPoints)
 {
 }
示例#4
0
 private void DrawScrollBar(MapItem item, ItemControls.ItemScrollBar scrollBar)
 {
     scrollBar.Draw(item.Buffer, ScrollBodyColor, ScrollFrontColor,
                    ScrollMarksColor);
 }
示例#5
0
        private void DrawItemElements(MapItem item, ItemControls.ItemScrollBar scrollBar)
        {
            //Mark all visibled item control as destroyed
            foreach (IItemControl control in item.ControlsOnScreen.Values)
            {
                control.Destroyed = true;
            }

            //Get scroll bar padding and calculate control rectangle
            int       scrollBarPadding  = scrollBar.Visible ? ScrollBarPadding : 1;
            Rectangle controlsRectangle = new Rectangle(item.WorkplaceRectangle.Left,
                                                        item.WorkplaceRectangle.Top, item.WorkplaceRectangle.Width -
                                                        scrollBar.Width - scrollBarPadding, item.WorkplaceRectangle.Height);

            //Fix bad situation, when scroll position equal to max. value and
            //item has increase own vertical size
            int areaSizeDiff = controlsRectangle.Height - scrollBar.AreaSize;

            if (scrollBar.AreaSize > 0 && areaSizeDiff > 0 &&
                scrollBar.Position + areaSizeDiff >= scrollBar.MaxValue)
            {
                scrollBar.SetPositionSilent(Math.Max(scrollBar.MaxValue - areaSizeDiff, 0));
            }

            //Calculate current screen height (with positioning)
            int curHeight = -scrollBar.Position + GroupSpaceHeight;

            List <ItemGroup> groups = item.Groups.GetVisibleGroups();

            foreach (ItemGroup group in groups)
            {
                List <ItemGroupElement> elements = group.GetVisibleElements();

                // +1 - for the divider line
                bool gDrawing = curHeight + GroupAreaHeight + 1 >= 0 &&
                                curHeight <= controlsRectangle.Height;
                if (gDrawing)
                {
                    DrawGroup(item, group, elements.Count, controlsRectangle,
                              curHeight + controlsRectangle.Top);
                }

                curHeight += GroupAreaHeight + GroupSpaceHeight + 1;

                if (!group.Collapsed && elements.Count > 0)
                {
                    curHeight -= 1;
                    foreach (ItemGroupElement element in elements)
                    {
                        bool eDrawing = curHeight + GroupElementAreaHeight >= 0 &&
                                        curHeight <= controlsRectangle.Height;
                        if (eDrawing)
                        {
                            DrawGroupElement(item, element, controlsRectangle,
                                             curHeight + controlsRectangle.Top);
                        }
                        curHeight += GroupElementAreaHeight;
                    }
                }
                else
                {
                    curHeight -= GroupSpaceHeight + 1;
                }
            }

            curHeight += GroupElementSpaceHeight + 1;

            //Update scrollbar rectangle
            scrollBar.ClientRectangle = new Rectangle(Padding.Left + (item.Width -
                                                                      Padding.Left - Padding.Right) - scrollBar.Width - scrollBarPadding,
                                                      controlsRectangle.Top + ScrollBarPadding, scrollBar.Width,
                                                      controlsRectangle.Height - ScrollBarPadding * 2);

            //Set scrollbar area size and max value
            scrollBar.AreaSize = controlsRectangle.Height;
            scrollBar.MaxValue = Math.Max(curHeight + scrollBar.Position -
                                          controlsRectangle.Height, 0);

            //Remove hidden item controls
            RemoveHiddenItemControls(item);
        }