Esempio n. 1
0
 private void Draw(Cairo.Context context, bool needClip)
 {
     if (needClip)
     {
         context.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
         context.Clip();
     }
     foreach (var entry in this.entries)
     {
         if (entry.horizontalStretchFactor != 0 || entry.verticalStretchFactor != 0)
         {
             context.FillRectangle(entry.rect, CairoEx.ColorLightBlue);
             context.StrokeRectangle(entry.rect, CairoEx.ColorBlack);
         }
         else
         {
             context.FillRectangle(entry.rect, CairoEx.ColorPink);
             context.StrokeRectangle(entry.rect, CairoEx.ColorBlack);
         }
         var innerGroup = entry as Group;
         if (innerGroup != null)
         {
             innerGroup.Draw(context, needClip);
         }
     }
     if (needClip)
     {
         context.ResetClip();
     }
 }
Esempio n. 2
0
        private static void Draw(Cairo.Context context, Visual visual)
        {
            var node    = (Node)visual;
            var isGroup = node.IsGroup;

            if (!isGroup)
            {
                if (node.RuleSet.HorizontallyStretched || node.RuleSet.VerticallyStretched)
                {
                    context.FillRectangle(node.Rect, CairoEx.ColorLightBlue);
                }
                else if (node.RuleSet.IsFixedWidth || node.RuleSet.IsFixedHeight)
                {
                    context.FillRectangle(node.Rect, CairoEx.ColorOrange);
                }
                else
                {
                    context.FillRectangle(node.Rect, CairoEx.ColorGreen);
                }
            }

            context.StrokeRectangle(node.Rect, CairoEx.ColorBlack);

            if (!isGroup)
            {
                return;
            }

            context.Save();
            node.Foreach(v =>
            {
                Draw(context, v);
                return(true);
            });
            context.Restore();
        }