Exemple #1
0
        public static double DrawColumn(DrawingContext Context, string Caption, Pen LinePencil, Rect AvailableArea,
                                        IEnumerable <IRecognizableElement> Items)
        {
            double UsedHeight         = 0;
            double MaxPicWidth        = Display.ICOSIZE_LIT * 3;
            double SubItemsIdentation = 0;

            var ItemsFormat    = new TextFormat("Arial", 9, Brushes.Black);
            var SubitemsFormat = new TextFormat("Arial", 8, Brushes.Black);
            var CaptionFormat  = new TextFormat("Arial", 9, Brushes.Black, true, false, false, TextAlignment.Center);
            var ItemsArea      = new Rect(AvailableArea.X + 2, AvailableArea.Y + 2,
                                          AvailableArea.Width - 4, AvailableArea.Height - 4);

            if (ItemsArea.Width < MaxPicWidth)
            {
                return(0);
            }

            UsedHeight += 14; if (ItemsArea.Top + UsedHeight > ItemsArea.Bottom)
            {
                return(0);
            }
            Context.DrawGeometry(Brushes.White, LinePencil, new LineGeometry(new Point(AvailableArea.Left, ItemsArea.Top + UsedHeight),
                                                                             new Point(AvailableArea.Right, ItemsArea.Top + UsedHeight)));
            Context.DrawText(CaptionFormat.GenerateFormattedText(Caption, ItemsArea.Width, 14), ItemsArea.TopLeft);

            foreach (var Item in Items)
            {
                var DisplayArea   = ItemsArea;
                var DisplayFormat = ItemsFormat;

                if (Item is SimplePresentationElement)    // Denotes "subitem" like Relationship's Link-Role Variants
                {
                    DisplayArea = new Rect(ItemsArea.X + SubItemsIdentation, ItemsArea.Y,
                                           ItemsArea.Width - SubItemsIdentation, ItemsArea.Height);
                    DisplayFormat = SubitemsFormat;
                }

                UsedHeight += 2;
                if (UsedHeight + Display.ICOSIZE_LIT > DisplayArea.Height)
                {
                    break;
                }

                if (Item.Pictogram != null)
                {
                    Context.DrawImage(Item.Pictogram, new Rect(((DisplayArea.X + MaxPicWidth / 2.0) - Item.Pictogram.GetWidth() / 2.0).EnforceMinimum(DisplayArea.X),
                                                               DisplayArea.Y + UsedHeight,
                                                               Item.Pictogram.GetWidth().EnforceMaximum(MaxPicWidth),
                                                               Item.Pictogram.GetHeight().EnforceMaximum(Display.ICOSIZE_LIT)));
                }

                Context.DrawText(DisplayFormat.GenerateFormattedText(Item.Name /* Too long: + " -- " + Item.Summary */,
                                                                     DisplayArea.Width - (MaxPicWidth + 2), Display.ICOSIZE_LIT),
                                 new Point(DisplayArea.X + MaxPicWidth + 2, DisplayArea.Y + UsedHeight));

                UsedHeight += Display.ICOSIZE_LIT + 2;
            }

            return(UsedHeight);
        }