Exemple #1
0
        private void BuildLayout()
        {
            if (m_Words == null)
            {
                return;
            }

            using (CanvasDrawingSession ds = _DrawingCanvas.CreateDrawingSession())
            {
                IGraphicEngine graphicEngine = new GdiGraphicEngine(ds, FontStyle, FontFamily, m_Palette, MinFontSize, MaxFontSize, m_MinWordWeight, m_MaxWordWeight);

                m_Layout = LayoutFactory.CrateLayout(m_LayoutType, new Size(this.ActualWidth, this.ActualHeight));
                m_Layout.Arrange(m_Words, graphicEngine);
            }
        }
Exemple #2
0
        private void Paint(IEnumerable <IWord> wordsToDraw, string saveImageLocation)
        {
            var layout = new LayoutFactory().CreateLayout(Size, LayoutType);
            var toDraw = wordsToDraw as IList <IWord> ?? wordsToDraw.ToList();
            var minMax = CaclulateMinMaxWordWeights(toDraw);
            var bitmap = new Bitmap(Size.Width, Size.Height);

            bitmap.SetResolution(Convert.ToInt32(Size.Width / 6), Convert.ToInt32(Size.Height / 6));
            var graphics = Graphics.FromImage(bitmap);

            graphics.Clear(GetRandomBackgroundColor());
            var graphicEngine = new GdiGraphicEngine(graphics, FontFamily, FontStyle,
                                                     ColorPalette, MinFontSize, MaxFontSize, minMax.Min, minMax.Max);

            layout.Arrange(toDraw, graphicEngine);
            SaveFile(bitmap, saveImageLocation);
        }
Exemple #3
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();
        }