Exemplo n.º 1
0
        public ExtRectF GetImageRect()
        {
            ExtRectF result = ExtRectF.Create(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue);

            foreach (Node node in fNodes)
            {
                var lx = node.x;
                var ly = node.y;
                var rx = node.x + node.width;
                var ry = node.y + node.height;

                if (result.Left > lx)
                {
                    result.Left = lx;
                }
                if (result.Top > ly)
                {
                    result.Top = ly;
                }
                if (result.Right < rx)
                {
                    result.Right = rx;
                }
                if (result.Bottom < ry)
                {
                    result.Bottom = ry;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 public SvgGraphics(TextWriter tw, ExtRectF viewBox)
 {
     _viewBox             = viewBox;
     _tw                  = tw;
     IncludeXmlAndDoctype = true;
     //SetColor(Color.Black);
     _states.Push(_state);
 }
Exemplo n.º 3
0
 public SvgGraphics(TextWriter tw, ExtRectF viewBox)
 {
     fFmt     = CultureInfo.InvariantCulture;
     fState   = new State();
     fStates  = new Stack <State>();
     fViewBox = viewBox;
     fWriter  = tw;
 }
Exemplo n.º 4
0
        public CircleChartModel()
        {
            fCircleBrushes = new IBrush[CircleChartOptions.MAX_BRUSHES];
            fDarkBrushes   = new IBrush[CircleChartOptions.MAX_BRUSHES];

            fBounds             = new ExtRectF();
            fGenWidth           = CircleChartModel.DEFAULT_GEN_WIDTH;
            fSegments           = new List <CircleSegment>();
            fSelected           = null;
            fVisibleGenerations = MAX_GENERATIONS;
        }
Exemplo n.º 5
0
        public CircleChartModel()
        {
            fCircleBrushes = new IBrush[AncestorsCircleOptions.MAX_BRUSHES];
            fDarkBrushes   = new IBrush[AncestorsCircleOptions.MAX_BRUSHES];

            fBounds         = new ExtRectF();
            fGenWidth       = CircleChartModel.DEFAULT_GEN_WIDTH;
            fMaxGenerations = 8;
            fSegments       = new List <CircleSegment>();
            fSelected       = null;
        }
Exemplo n.º 6
0
        public void Test_SvgGraphics()
        {
            using (MemoryStream stm = new MemoryStream()) {
                var svg = new SvgGraphics(stm, ExtRectF.CreateBounds(0, 0, 100, 100));

                svg.BeginDrawing();
                svg.Clear(UIHelper.ConvertColor(Color.Yellow));

                svg.BeginEntity(null);
                svg.DrawLine(10, 10, 50, 10, 1);
                svg.DrawArc(60, 60, 20, 15, 25, 1);
                svg.DrawEllipse(10, 10, 30, 30, null, null);
                svg.DrawRect(50, 50, 20, 20, 2);
                svg.DrawRoundedRect(80, 80, 10, 10, 3, 1);
                svg.EndEntity();

                svg.FillArc(60, 60, 20, 15, 25);
                svg.DrawEllipse(10, 10, 30, 30, null, null);
                svg.FillRect(50, 50, 20, 20);

                svg.SetColor(UIHelper.ConvertColor(Color.Red));
                svg.FillRoundedRect(80, 80, 10, 10, 3);

                svg.DrawCircleSegment(0, 0, 10, 20, 0, 17, null, null);
                svg.DrawImage(null, 0, 0, 100, 100);
                svg.DrawPolygon(new ExtPointF[] {}, null, null);
                svg.DrawString("x", 10, 10);

                svg.ResetState();
                svg.SaveState();
                svg.RestoreState();

                svg.Rotate(75);
                svg.Translate(10, 10);
                svg.Scale(0.5f, 0.5f);
                svg.SetClippingRect(0.0f, 0.0f, 10f, 10f);

                svg.SetFont(null);
                Assert.Throws(typeof(ArgumentNullException), () => { svg.SetColor(null); });

                svg.BeginLines(false);
                svg.EndLines();

                svg.EndDrawing();
            }
        }
Exemplo n.º 7
0
        public void Test_ExtRectF()
        {
            ExtRectF rt = ExtRectF.Create(0, 0, 9, 9);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            rt = ExtRectF.CreateBounds(0, 0, 10, 10);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            Assert.AreEqual("{X=0,Y=0,Width=10,Height=10}", rt.ToString());

            Assert.IsTrue(rt.Contains(5, 5));

            rt.Inflate(3, -2);
            Assert.AreEqual("{X=3,Y=-2,Width=4,Height=14}", rt.ToString());

            rt.Offset(2, 5);
            Assert.AreEqual("{X=5,Y=3,Width=4,Height=14}", rt.ToString());

            rt = rt.GetOffset(10, 10);
            Assert.AreEqual("{X=15,Y=13,Width=4,Height=14}", rt.ToString());

            Assert.IsTrue(rt.IntersectsWith(ExtRect.Create(16, 14, 20, 20)));

            rt = ExtRectF.CreateEmpty();
            Assert.IsTrue(rt.IsEmpty());

            Assert.IsFalse(rt.Contains(5, 5));

            // implicit
            ExtRectF rtf = ExtRect.CreateBounds(11, 11, 20, 20);

            Assert.AreEqual("{X=11,Y=11,Width=20,Height=20}", rtf.ToString());
        }
Exemplo n.º 8
0
        public void AdjustBounds()
        {
            /* Update scrolling area. */
            fBounds.Left   = 0.0f;
            fBounds.Top    = 0.0f;
            fBounds.Right  = 0.0f;
            fBounds.Bottom = 0.0f;
            foreach (var segment in fSegments)
            {
                ExtRectF bound = segment.Path.GetBounds();
                fBounds.Left   = Math.Min(fBounds.Left, bound.Left);
                fBounds.Top    = Math.Min(fBounds.Top, bound.Top);
                fBounds.Right  = Math.Max(fBounds.Right, bound.Right);
                fBounds.Bottom = Math.Max(fBounds.Bottom, bound.Bottom);
            }

            /* Add double width of the pen -- adjust both sides. */
            fImageHeight = (int)(fBounds.GetHeight() + fPen.Width * 2);
            fImageWidth  = (int)(fBounds.GetWidth() + fPen.Width * 2);
        }
Exemplo n.º 9
0
        public override void SetSVGMode(bool active, string svgFileName, int width, int height)
        {
            if (active)
            {
                fSVGWriter = new StreamWriter(new FileStream(svgFileName, FileMode.Create), Encoding.UTF8);
                fSVGGfx    = new SvgGraphics(fSVGWriter, ExtRectF.CreateBounds(0, 0, width, height));
                fSVGGfx.BeginDrawing();
            }
            else
            {
                if (fSVGWriter != null)
                {
                    fSVGGfx.EndDrawing();
                    fSVGGfx = null;

                    fSVGWriter.Flush();
                    fSVGWriter.Close();
                    fSVGWriter = null;
                }
            }
        }
Exemplo n.º 10
0
 public override ExtRectF GetPageSize()
 {
     return(ExtRectF.Create(fDocument.Left, fDocument.Bottom, fDocument.Right, fDocument.Top));
 }
Exemplo n.º 11
0
        protected override void InternalGenerate()
        {
            try {
                #if !NETSTANDARD
                IColor clrBlack = AppHost.GfxProvider.CreateColor(0x000000);
                IColor clrBlue  = AppHost.GfxProvider.CreateColor(0x0000FF);

                fLinkFont = fWriter.CreateFont("", 8f, false, true, clrBlue);
                fTextFont = fWriter.CreateFont("", 8f, false, false, clrBlack);

                fWriter.EnablePageNumbers();

                fRenderer = fWriter.GetPageRenderer();
                if (fRenderer == null)
                {
                    // TODO: warning
                    return;
                }

                IFont titleFont = fWriter.CreateFont("", 30f, true, false, clrBlack);
                fPageSize = fWriter.GetPageSize();
                float pageHeight = fPageSize.GetHeight();
                float pageWidth  = fPageSize.GetWidth();
                float halfpage   = (pageHeight - (((PDFWriter.FontHandler)titleFont).GetTextHeight())) / 2f;
                fWriter.NewLine(0.0f, halfpage);
                fWriter.AddParagraph(fTitle, titleFont, TextAlignment.taCenter);

                var chartOptions = new TreeChartOptions();
                chartOptions.Assign(GlobalOptions.Instance.TreeChartOptions);
                chartOptions.DefaultPortraits   = false;
                chartOptions.HideUnknownSpouses = true;
                chartOptions.InvertedTree       = false;
                chartOptions.Kinship            = false;
                chartOptions.ShowPlaces         = false;

                var treeBox = AppHost.Container.Resolve <ITreeChart>();
                treeBox.SetRenderer(fRenderer);
                treeBox.Base    = fBase;
                treeBox.Options = chartOptions;
                treeBox.Height  = (int)pageHeight;
                treeBox.Width   = (int)pageWidth;

                fPatList = PatriarchsMan.GetPatriarchsList(fBase.Context, 2, false);
                fPatList.QuickSort(PatriarchsCompare);

                int num = fPatList.Count;
                for (int i = 0; i < num; i++)
                {
                    var patriarch = fPatList[i].IRec;

                    fIndiQueue.Clear();
                    fIndiQueue.Add(new IndiObj(patriarch, TreeChartKind.ckDescendants));

                    for (int q = 0; q < fIndiQueue.Count; q++)
                    {
                        fWriter.NewPage();
                        TryRenderTreeSlice(treeBox, q, patriarch);
                    }
                }
                #endif
            } catch (Exception ex) {
                Logger.WriteError("TreesAlbumExporter.InternalGenerate()", ex);
                throw;
            }
        }
Exemplo n.º 12
0
        public ExtRectF GetBounds()
        {
            RectangleF rect = Handle.Bounds;

            return(ExtRectF.CreateBounds(rect.Left, rect.Top, rect.Width, rect.Height));
        }
Exemplo n.º 13
0
 public static RectangleF Rt2Rt(ExtRectF ert)
 {
     return(new RectangleF(ert.Left, ert.Top, ert.GetWidth(), ert.GetHeight()));
 }
Exemplo n.º 14
0
 public override void BeginDrawing()
 {
     fWriter = new StreamWriter(new FileStream(fFileName, FileMode.Create, FileAccess.Write), Encoding.UTF8);
     fGfx    = new SvgGraphics(fWriter, ExtRectF.CreateBounds(0, 0, fWidth, fHeight));
     fGfx.BeginDrawing();
 }
Exemplo n.º 15
0
 public void SetClippingRect(float x, float y, float width, float height)
 {
     fState.ClippingRect = ExtRectF.CreateBounds(x, y, width, height);
 }
Exemplo n.º 16
0
 public SvgGraphics(Stream s, ExtRectF viewBox)
     : this(new StreamWriter(s, System.Text.Encoding.UTF8), viewBox)
 {
 }
Exemplo n.º 17
0
 public static ExtRectF Rt2Rt(RectangleF ert)
 {
     return(ExtRectF.CreateBounds(ert.Left, ert.Top, ert.Width, ert.Height));
 }
Exemplo n.º 18
0
 public virtual ExtRectF GetPageSize()
 {
     return(ExtRectF.CreateEmpty());
 }