Ejemplo n.º 1
0
 public void Draw(LayoutItem layoutItem)
 {
     Font font = GetFont(layoutItem.Word.Occurrences);
     Color color = GetPresudoRandomColorFromPalette(layoutItem);
     //m_Graphics.DrawString(layoutItem.Word, font, brush, layoutItem.Rectangle);
     Point point = new Point((int)layoutItem.Rectangle.X, (int)layoutItem.Rectangle.Y);
     TextRenderer.DrawText(m_Graphics, layoutItem.Word.Text, font, point, color);
 }
Ejemplo n.º 2
0
 public void DrawEmphasized(LayoutItem layoutItem)
 {
     Font font = GetFont(layoutItem.Word.Occurrences);
     Color color = GetPresudoRandomColorFromPalette(layoutItem);
     //m_Graphics.DrawString(layoutItem.Word, font, brush, layoutItem.Rectangle);
     Point point = new Point((int)layoutItem.Rectangle.X, (int)layoutItem.Rectangle.Y);
     TextRenderer.DrawText(m_Graphics, layoutItem.Word.Text, font, point, Color.LightGray);
     int offset = (int)(5 *font.Size / MaxFontSize)+1;
     point.Offset(-offset, -offset);
     TextRenderer.DrawText(m_Graphics, layoutItem.Word.Text, font, point, color);
 }
Ejemplo n.º 3
0
        public void Arrange(IEnumerable<IWord> words, IGraphicEngine graphicEngine)
        {
            if (words == null)
            {
                throw new ArgumentNullException("words");
            }

            foreach (IWord word in words)
            {
                SizeF size = graphicEngine.Measure(word.Text, word.Occurrences);
                RectangleF freeRectangle;
                if (!TryFindFreeRectangle(size, out freeRectangle))
                {
                    return;
                }
                LayoutItem item = new LayoutItem(freeRectangle, word);
                QuadTree.Insert(item);
            }
        }
Ejemplo n.º 4
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     LayoutItem nextItemUnderMouse;
     Point mousePositionRelativeToControl = this.PointToClient(new Point(MousePosition.X, MousePosition.Y));
     this.TryGetItemAtLocation(mousePositionRelativeToControl, out nextItemUnderMouse);
     if (nextItemUnderMouse != m_ItemUderMouse)
     {
         if (nextItemUnderMouse != null)
         {
             Rectangle newRectangleToInvalidate = RectangleGrow(nextItemUnderMouse.Rectangle, 6);
             this.Invalidate(newRectangleToInvalidate);
         }
         if (m_ItemUderMouse != null)
         {
             Rectangle prevRectangleToInvalidate = RectangleGrow(m_ItemUderMouse.Rectangle, 6);
             this.Invalidate(prevRectangleToInvalidate);
         }
         m_ItemUderMouse = nextItemUnderMouse;
     }
     base.OnMouseMove(e);
 }
Ejemplo n.º 5
0
 public bool TryGetItemAtLocation(Point location, out LayoutItem foundItem)
 {
     foundItem = null;
     IEnumerable<LayoutItem> itemsInArea = GetItemsInArea(new RectangleF(location, new SizeF(0, 0)));
     foreach (LayoutItem item in itemsInArea)
     {
         foundItem = item;
         return true;
     }
     return false;
 }
Ejemplo n.º 6
0
 private Color GetPresudoRandomColorFromPalette(LayoutItem layoutItem)
 {
     Color color = Palette[layoutItem.Word.Occurrences * layoutItem.Word.Text.Length % Palette.Length];
     return color;
 }