コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (m_Words == null || !m_Words.Any())
            {
                return;
            }
            if (m_Layout == null)
            {
                return;
            }

            IEnumerable <LayoutItem> wordsToRedraw = m_Layout.GetWordsInArea(e.ClipRectangle);

            using (IGraphicEngine graphicEngine =
                       NewGraphicEngine(e.Graphics, this.Font.FontFamily, FontStyle.Regular, m_Palette, MinFontSize, MaxFontSize, m_MinWordWeight, m_MaxWordWeight))
            {
                foreach (LayoutItem currentItem in wordsToRedraw)
                {
                    if (m_ItemUnderMouse == currentItem)
                    {
                        graphicEngine.DrawEmphasized(currentItem);
                    }
                    else
                    {
                        graphicEngine.Draw(currentItem);
                    }
                }
            }
        }
コード例 #2
0
        private T Process <T>(
            Func <IGraphicEngine <TBitmap>, IEnumerable <LayoutItem>, T> handler)
        {
            // Arrange word cloud.
            var size = new SizeD(wordCloud.Width, wordCloud.Height);

            layout.Arrange(wordCloud.Entries, engine);

            // Process results.
            var area = new RectangleD(new PointD(0, 0), size);

            return(handler(engine, layout.GetWordsInArea(area)));
        }
コード例 #3
0
ファイル: CloudControl.cs プロジェクト: zhifu10001/YAGP
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (m_Words == null)
            {
                return;
            }
            if (m_Layout == null)
            {
                return;
            }

            IEnumerable <LayoutItem> wordsToRedraw = m_Layout.GetWordsInArea(e.ClipRectangle);

            using (Graphics graphics = e.Graphics)
                using (GdiGraphicEngine graphicEngine =
                           new GdiGraphicEngine(graphics, m_Palette, m_MinWordWeight, m_MaxWordWeight))
                {
                    graphicEngine.FontFamily  = Font.FontFamily;
                    graphicEngine.FontStyle   = FontStyle.Regular;
                    graphicEngine.MinFontSize = MinFontSize;
                    graphicEngine.MaxFontSize = MaxFontSize;

                    foreach (LayoutItem currentItem in wordsToRedraw)
                    {
                        if (m_ItemUderMouse == currentItem)
                        {
                            graphicEngine.DrawEmphasized(currentItem);
                        }
                        else
                        {
                            graphicEngine.Draw(currentItem);
                        }
                    }
                }
        }
コード例 #4
0
        protected void PaintWords()
        {
            if (m_Words == null)
            {
                return;
            }
            if (m_Layout == null)
            {
                return;
            }

            IEnumerable <LayoutItem> wordsToRedraw = m_Layout.GetWordsInArea(new Rect(0, 0, this.ActualWidth, this.ActualHeight));

            using (CanvasDrawingSession ds = _DrawingCanvas.CreateDrawingSession())
            {
                ds.Clear(m_BackColor);

                using (IGraphicEngine graphicEngine = new GdiGraphicEngine(ds, FontStyle, FontFamily, m_Palette, MinFontSize, MaxFontSize, m_MinWordWeight, m_MaxWordWeight))
                {
                    foreach (LayoutItem currentItem in wordsToRedraw)
                    {
                        String hummaa = currentItem.Word.Text;

                        if (m_ItemUderMouse == currentItem)
                        {
                            graphicEngine.DrawEmphasized(currentItem);
                        }
                        else
                        {
                            graphicEngine.Draw(currentItem);
                        }
                    }
                }
            }

            Win2DCanvas.Invalidate();
        }
コード例 #5
0
        public Size CalculateMinimumRequiredTotalSize(out ILayout layout, out IEnumerable <LayoutItem> wordsToDraw)
        {
            Size requiredSize = Size.Empty;

            using (Graphics graphics = this.CreateGraphics())
            {
                var engine = NewGraphicEngine(graphics,
                                              this.Font.FontFamily,
                                              FontStyle.Regular,
                                              m_Palette,
                                              m_MinFontSize,
                                              m_MaxFontSize,
                                              m_MinWordWeight,
                                              m_MaxWordWeight);

                int numAllWords = m_Words.Count();
                wordsToDraw = null;

                var   trySize = new SizeF(640, 480);
                float xInc = (trySize.Width / 4), yInc = (trySize.Height / 4);

                do
                {
                    layout = CreateLayout(m_LayoutType, trySize);

                    if (layout.Arrange(m_Words, engine) == numAllWords)
                    {
                        wordsToDraw  = layout.GetWordsInArea(new RectangleF(new PointF(0, 0), trySize));
                        requiredSize = Size.Ceiling(trySize);
                    }
                    else
                    {
                        trySize = new SizeF(trySize.Width + xInc, trySize.Height + yInc);
                    }
                }while (requiredSize.IsEmpty);
            }

            return(requiredSize);
        }