Esempio n. 1
0
        public void TestBoundingBoxBezierRectangle()
        {
            var curve = new BezierTestData {
                Matrix = new Matrix {
                    OffsetX = 50, OffsetY = offsetY
                }
            }
            .RoundedRectBezier;

            ReportPainter.PushPaint(c => {
                c.SetLineWidth(1);
                var bb = BezierExtensions.BezierBoundingBox(curve);
                c.SetColor(Colors.SpringGreen);
                c.Rectangle(bb);
                c.Stroke();

                c.SetColor(Colors.Blue);
                c.SetLineWidth(2);
                ContextPainterExtensions.DrawBezier(c, curve);
                c.Stroke();
            });

            WritePainter();

            offsetY += 200;
        }
Esempio n. 2
0
        public void TestBezierRectangleShapeResize()
        {
            var rect  = new Rectangle(10, 10, 200, 100);
            var shape = new BezierRectangleShape(rect);

            ReportPainter.PushPaint(c => {
                c.SetLineWidth(1);
                c.SetColor(Colors.Red);
                c.Rectangle(shape.Data);
                c.Stroke();

                c.SetColor(Colors.Blue);
                ContextPainterExtensions.DrawBezier(c, shape.BezierPoints);
                c.Stroke();

                c.SetColor(Colors.Yellow);
                c.Rectangle(shape.BoundsRect);
                c.Stroke();
            });

            Action <Point, Size> prove = (l, s) => {
                Assert.AreEqual(shape.BoundsRect.Location, shape.Location);
                Assert.AreEqual(shape.BoundsRect.Size, shape.Size);
                Assert.AreEqual(shape.DataSize, shape.Data.Size);
                Assert.AreEqual(l, shape.Location);
                Assert.AreEqual(s, shape.Size);
            };

            Assert.AreEqual(shape.DataSize, rect.Size);
            prove(shape.BoundsRect.Location, shape.BoundsRect.Size);

            Action <Rectangle> proveResize = (r) => {
                var reset       = shape.Data;
                var resetBounds = shape.BoundsRect;
                shape.Location = r.Location;
                prove(r.Location, shape.Size);

                shape.Size = r.Size;
                prove(r.Location, r.Size);

                shape.Data = reset;
                prove(resetBounds.Location, resetBounds.Size);

                shape.Location = r.Location;
                shape.Size     = r.Size;
                prove(r.Location, r.Size);
            };

            var resize = shape.BoundsRect.Inflate(3, 3);

            proveResize(resize);

            resize = shape.BoundsRect.Inflate(-7, -7);
            proveResize(resize);

            WritePainter();
        }
Esempio n. 3
0
        public void TestExpand()
        {
            var options = new AlignerOptions {
                AlignX     = Alignment.Start,
                AlignY     = Alignment.Center,
                Dimension  = Dimension.X,
                PointOrder = PointOrder.XY,
            };

            var worker = SceneWorkerWithTestData2(3, options);

            options.Distance = worker.Layout.Distance;

            var origins   = new IVisual [] { worker.Scene.Focused };
            var aligner   = new Aligner <IVisual, IVisualEdge> (worker.Scene, worker.Layout);
            var deep      = false;
            var graphView = worker.Scene.Graph as SubGraph <IVisual, IVisualEdge>;

            var affected = new SubGraphWorker <IVisual, IVisualEdge>
                               (graphView).Expand(origins, deep);

            var walk = graphView.Walk();

            origins.ForEach(origin => {
                var route = (deep ? walk.DeepWalk(origin, 1) : walk.ExpandWalk(origin, 1))
                            .Where(l => !(l.Node is IVisualEdge)).ToArray();
                var bounds         = new Rectangle(aligner.Locator.GetLocation(origin), aligner.Locator.GetSize(origin));
                options.Collisions = Collisions.None;
                var cols           = aligner.MeasureWalk(route, ref bounds, options);
                var removeCol      = cols.Dequeue();

                if (options.Dimension == Dimension.X)
                {
                    var adjust      = options.AlignY.Delta(bounds.Height, removeCol.Item2.Height);
                    bounds.Location = new Point(bounds.X + removeCol.Item2.Width + options.Distance.Width, bounds.Y - adjust);
                }
                else
                {
                    var adjust      = options.AlignX.Delta(bounds.Width, removeCol.Item2.Width);
                    bounds.Location = new Point(bounds.X + adjust, bounds.Y + removeCol.Item2.Height + options.Distance.Height);
                }
                options.Collisions = Collisions.NextFree | Collisions.PerColumn | Collisions.Toggle;
                aligner.LocateColumns(cols, bounds, options);
            });

            aligner.Commit();
            worker.Modeller.Perform();
            worker.Modeller.Finish();

            ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx));

            WritePainter();
        }
Esempio n. 4
0
        public void TestPaintDocumentNaviatator()
        {
            var engine = ReportPainter.Switch();

            var bounds = new Rectangle(10, 10, 500, 100);

            var iconeria = new AwesomeIconeria {
                Fill = true, FillColor = Colors.Black
            };

            var utils = Registry.Pooled <IDrawingUtils>();
            var style = Registry.Pooled <StyleSheets>().DefaultStyleSheet.ItemStyle.DefaultStyle.Clone() as IStyle;

            // points = pixels * 72 / g.DpiX;
            style.Font = Font.FromName(style.Font.Family).WithSize((bounds.Height - bounds.Height / 10) * 72 / utils.ScreenResolution().Width);

            var pageNr     = "XXXX";
            var pageNrSize = utils.GetTextDimension(pageNr, style);

            ReportPainter.PushPaint(ctx => {
                ctx.SetLineWidth(1);
                ctx.SetColor(Colors.Blue);

                ContextPainterExtensions.DrawRoundedRect(ctx, bounds, 45);
                ctx.ClosePath();
                ctx.Stroke();
                var iconSize = bounds.Height;

                iconeria.PaintIcon(ctx, iconSize, bounds.X + iconSize / 2, bounds.Y, c => {
                    c.Scale(-1, 1);
                    iconeria.FaPlay(c);
                });

                iconeria.PaintIcon(ctx, iconSize, bounds.Right - ((iconSize * .7)), bounds.Y, c => {
                    iconeria.FaPlay(c);
                });

                var textBounds      = new Rectangle(new Point(), pageNrSize);
                textBounds.Location = new Point(
                    bounds.Location.X + (bounds.Width - textBounds.Width) / 2,
                    bounds.Location.Y + (bounds.Height - textBounds.Height) / 2);

                ContextPainterExtensions.DrawText(ctx, textBounds, "123", style.Font, style.TextColor);

                ctx.SetColor(Colors.Aqua);
                ctx.Rectangle(textBounds);
                ctx.Stroke();
            });
            WritePainter();

            ReportPainter.Restore(engine);
        }
        private EmployeePlanningDay ProcessDayCell(XRControl cell)
        {
            EmployeePlanningDay result = null;

            EmployeePlanningWeek employeeWeek = GetCurrentRow();

            StoreDay storeDay = _planningContext.StoreDays[(DateTime)cell.Tag];

            if (employeeWeek != null && storeDay != null && employeeWeek.Days.ContainsKey(storeDay.Date))
            {
                result = employeeWeek.Days[storeDay.Date];
            }

            ReportPainter.ApplyEmployeePlanningDayStyle(cell, storeDay, result, CurrentWorldID);

            return(result);
        }
        private void PrintDataCell(XRTableCell cell)
        {
            XRPanel panel = ReportPainter.GetPanelControl(cell);

            panel.Dock = XRDockStyle.Fill;
            panel.Controls.Clear();

            EmployeePlanningDay planningDay = ProcessDayCell(cell);

            if (planningDay.HasLongAbsence)
            {
                string s = _planningContext.GetLongTimeAbbreviation(planningDay.LongAbsenceId);
                if (!String.IsNullOrEmpty(s))
                {
                    XRLabel label = ReportPainter.AddLabelLine(panel, s, Color.Black, 0, false);

                    label.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    int?color = _planningContext.GetLongTimeAbsenceColor(planningDay.LongAbsenceId);
                    if (color.HasValue)
                    {
                        label.BackColor = Color.FromArgb(color.Value);
                        cell.BackColor  = Color.FromArgb(color.Value);
                    }
                    //cell.Text = s;
                    //cell.ForeColor = Color.White;
                    //cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                }
                return;
            }
            else
            {
                cell.ForeColor = Color.Black;
            }

            int y = 0;

            foreach (__TimeRange range in GetDayTimes(planningDay))
            {
                XRLabel label = ReportPainter.AddLabelLine(panel, range.AsTimeString, String.IsNullOrEmpty(range.AbsenceCode) ? Color.Black : range.BeginColor, y, false);
                y = y + label.Height + 1;
            }
        }
        private void PrintPlannedDayCell(XRTableCell cell)
        {
            XRPanel panel = ReportPainter.GetPanelControl(cell);

            panel.Width = cell.Width;
            panel.Dock  = XRDockStyle.Fill;
            panel.Controls.Clear();

            EmployeeDay      employeeDay  = null;
            EmployeeWeekView employeeWeek = GetCurrentWeekView();
            StoreDay         storeDay     = _recordingContext.StoreDays[(DateTime)cell.Tag];

            if (employeeWeek != null && storeDay != null && employeeWeek.PlanningWeek != null)
            {
                employeeDay = employeeWeek.PlanningWeek.GetDay(storeDay.Date);
            }

            ReportPainter.ApplyEmployeeDayStyle(cell, storeDay, employeeDay, StoreToWorldID, _recordingContext);

            ReportPainter.PrintDayCellValues(panel, employeeDay, _recordingContext);
        }
Esempio n. 8
0
        private void PrintTimeCell(object sender, PrintEventArgs e)
        {
            XRTableCell          cell = (XRTableCell)sender;
            EmployeePlanningWeek employeePlanningWeek = GetCurrentEmployeeWeek();
            EmployeeDayView      dayView = DayViewList.GetByEmployeeId(employeePlanningWeek.EmployeeId);

            if (dayView == null)
            {
                return;
            }
            StoreDay storeDay = _planningContext.StoreDays[dayView.ViewDate];

            if (storeDay == null)
            {
                return;
            }

            foreach (XRControl child in cell.Controls)
            {
                XRLabel      shape    = child as XRLabel;
                TimeCellInfo cellInfo = child.Tag as TimeCellInfo;
                if (shape == null || cellInfo == null)
                {
                    continue;
                }

                short currentTime = Convert.ToInt16(cellInfo.DayTime.TotalMinutes);

                Color color = storeDay.IsOpeningTime(currentTime) ? Color.White : Color.LightGray;
                if (!cellInfo.ManualFill)
                {
                    Color workingTimeColor = dayView.GetColor(currentTime / 15);
                    if (workingTimeColor != Color.White)
                    {
                        color = workingTimeColor;
                    }
                }
                ReportPainter.AcceptShape(shape, cell, color);
            }
        }
Esempio n. 9
0
        private void PaintSegments(IList <Point> curve)
        {
            var segments = BezierExtensions.BezierSegments(curve);
            var cols     = new Color[] {
                Colors.Blue,
                Colors.Red,
                Colors.BlueViolet,
                Colors.OrangeRed,
                Colors.AliceBlue,
                Colors.Orange,
                Colors.Aquamarine,
                Colors.DodgerBlue
            };


            ReportPainter.PushPaint(c => {
                var iCol = 0;
                foreach (var seg in segments)
                {
                    c.SetLineWidth(1);
                    var bb = BezierExtensions.BezierBoundingBox(seg.Start, seg.Cp1, seg.Cp2, seg.End);
                    c.SetColor(Colors.SpringGreen);
                    c.Rectangle(bb);
                    c.Stroke();

                    c.SetColor(cols[iCol++]);
                    c.SetLineWidth(2);
                    ContextPainterExtensions.DrawBezier(c, seg);
                    c.Stroke();

                    var med = BezierExtensions.BezierPoint(seg.Start, seg.Cp1, seg.Cp2, seg.End, .5);
                    c.SetColor(Colors.DarkGray);
                    c.Arc(med.X, med.Y, 5, 0, 360);
                    c.Stroke();
                }
            });

            WritePainter();
        }
Esempio n. 10
0
        private void PrintPlannedCell(object sender, PrintEventArgs e)
        {
            XRTableCell cell = (XRTableCell)sender;

            if (_plannedDayView == null)
            {
                return;
            }
            StoreDay storeDay = _recordingContext.StoreDays[_recordingContext.ViewDate];

            if (storeDay == null)
            {
                return;
            }

            foreach (XRControl child in cell.Controls)
            {
                XRLabel      shape    = child as XRLabel;
                TimeCellInfo cellInfo = child.Tag as TimeCellInfo;
                if (shape == null || cellInfo == null)
                {
                    continue;
                }

                short currentTime = Convert.ToInt16(cellInfo.DayTime.TotalMinutes);

                Color color = storeDay.IsOpeningTime(currentTime) ? Color.White : Color.LightGray;
                if (!cellInfo.ManualFill)
                {
                    Color workingTimeColor = _plannedDayView.GetColorByTime(currentTime);
                    if (workingTimeColor != Color.White)
                    {
                        color = workingTimeColor;
                    }
                }

                ReportPainter.AcceptShape(shape, cell, color);
            }
        }
Esempio n. 11
0
        public void Init(WorldsTimeRecordingPrintoutContext recordingContext, DateTime viewDate, bool printPlannedValues, bool hideSums)
        {
            _recordingContext   = recordingContext;
            _printPlannedValues = printPlannedValues;
            _hideSums           = hideSums;

            // Hide SUM colums if needed
            if (_hideSums)
            {
                //tbl_DailyCaption.DeleteColumn(lbCell_ContractWorkingHours);
                tbl_DailyCaption.DeleteColumn(lbCell_AllreadyPlannedWorkingHours);
                //tbl_DailyCaption.DeleteColumn(lbCell_SummOfAdditionalCharges);
                //tbl_DailyCaption.DeleteColumn(lbCell_PlusMinusHours);
                //tbl_DailyCaption.DeleteColumn(lbCell_EmployeeBalanceHours);

                //tbl_DailyData.DeleteColumn(fieldCell_ContractWorkingHoursPlanned);
                tbl_DailyData.DeleteColumn(fieldCell_PlannedWorkingHoursPlanned);
                //tbl_DailyData.DeleteColumn(fieldCell_SumAdditionalHoursPlanned);
                //tbl_DailyData.DeleteColumn(fieldCell_PlusMinusHoursPlanned);
                //tbl_DailyData.DeleteColumn(fieldCell_BalanceHoursPlanned);

                //tbl_DailyData.DeleteColumn(fieldCell_ContractWorkingHours);
                tbl_DailyData.DeleteColumn(fieldCell_PlannedHours);
                //tbl_DailyData.DeleteColumn(fieldCell_PlusMinusHours);
                //tbl_DailyData.DeleteColumn(fieldCell_PlusMinusHours);
                //tbl_DailyData.DeleteColumn(fieldCell_BalanceHours);
            }

            //
            // Generate columnss
            //
            int segmentWidth = Convert.ToInt32(lbCell_0000.Width / 24);

            lbCell_Employee.Width = fieldCell_EmployeeName.Width = fieldCell_Employee1.Width = lbCell_0000.Right - (segmentWidth * 24);
            TimeSpan dayTime  = TimeSpan.Zero;
            TimeSpan timeStep = TimeSpan.FromMinutes(60);

            XRTableCell baseLabelCell   = lbCell_0000;
            XRTableCell basePlannedCell = fieldCell_0000Planned;
            XRTableCell baseDataCell    = fieldCell_0000;

            while (dayTime.TotalHours < 23)
            {
                DateTime columnTime = viewDate.Add(dayTime);

                // Caption
                ReportPainter.ApplyCaptionCellFormat(baseLabelCell, columnTime);
                tbl_DailyCaption.InsertColumnToRight(baseLabelCell);
                baseLabelCell.Width = segmentWidth;

                baseLabelCell = baseLabelCell.NextCell;

                // Planned values
                tbl_DailyData.InsertColumnToRight(basePlannedCell);

                basePlannedCell.Tag          = columnTime;
                basePlannedCell.BeforePrint += PrintPlannedCell;
                //basePlannedCell.SizeChanged += CellSizeChanged;
                basePlannedCell.Width = segmentWidth;
                ReportPainter.Insert15MinuteShapes(basePlannedCell, columnTime, false);

                basePlannedCell = basePlannedCell.NextCell;

                // Data
                baseDataCell.Tag          = columnTime;
                baseDataCell.BeforePrint += PrintTimeCell;
                baseDataCell.Width        = segmentWidth;
                //baseDataCell.SizeChanged += CellSizeChanged;
                ReportPainter.Insert15MinuteShapes(baseDataCell, columnTime, false);

                baseDataCell = baseDataCell.NextCell;

                dayTime = dayTime.Add(timeStep);
            }

            DateTime lastColumnTime = viewDate.Add(dayTime);

            ReportPainter.ApplyCaptionCellFormat(baseLabelCell, lastColumnTime);

            basePlannedCell.Tag          = baseDataCell.Tag = lastColumnTime;
            basePlannedCell.BeforePrint += PrintPlannedCell;
            baseDataCell.BeforePrint    += PrintTimeCell;
            ReportPainter.Insert15MinuteShapes(basePlannedCell, lastColumnTime, false);
            ReportPainter.Insert15MinuteShapes(baseDataCell, lastColumnTime, false);

            if (!_printPlannedValues)
            {
                tbl_DailyData.Rows.RemoveAt(0);
                Detail.Height = tbl_DailyData.Height;
            }
        }
Esempio n. 12
0
        public void BlockAlgin()
        {
            var options = new AlignerOptions {
                AlignX     = Alignment.Start,
                AlignY     = Alignment.Start,
                Dimension  = Dimension.X,
                PointOrder = PointOrder.XY,
                Collisions = Collisions.None,
            };

            var scene = SceneWithTestData(3, 1);

            var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> ();

            worker.Compose(scene, new VisualsRenderer());
            worker.StyleSheet.BackColor = Colors.WhiteSmoke;
            worker.Layout.SetOptions(options);

            worker.Folder.AddRaw(scene.Graph.RootSource()?.Source);
            worker.Modeller.Perform();
            worker.Modeller.Finish();

            var origins = scene.Graph.FindRoots(null);

            scene.Focused = origins.First();

            options.Distance = worker.Layout.Distance;
            var visualComparer = new VisualComparer();
            var aligner        = new Aligner <IVisual, IVisualEdge> (worker.Scene, worker.Layout);

            var graphView = worker.Scene.Graph as SubGraph <IVisual, IVisualEdge>;

            graphView.Edges().ForEach(e => e.Data = "");

            // var roots = new IVisual [] { worker.Scene.Focused };

            var walk = new Walker1 <IVisual, IVisualEdge> (graphView);

            //walk.Trace = true;
            walk.Comparer = visualComparer;

            var startPoint = (Point)worker.Layout.Border;

            foreach (var origin in origins)
            {
                ReportDetail($"-> {origin}\t{startPoint}");
                var bounds = AlignByPath(walk.DeepWalk(origin, 1, null, false), options, aligner, startPoint);
                startPoint.Y += bounds.Height + options.Distance.Height;
            }

            aligner.Commit();
            worker.Modeller.Perform();
            worker.Modeller.Finish();

            ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx));
            foreach (var r in TrackBounds.Where(r => !r.IsEmpty))
            {
                ReportPainter.PushPaint(ctx => {
                    var translate = worker.Painter.Viewport.ClipOrigin;
                    ctx.Save();
                    ctx.Translate(-translate.X, -translate.Y);

                    ctx.SetColor(Colors.Red);
                    ctx.SetLineWidth(0.5);
                    ctx.SetLineDash(0, 2, 5);
                    ctx.Rectangle(r);
                    ctx.ClosePath();
                    ctx.Stroke();
                    ctx.Restore();
                });
            }
            WritePainter();
        }
Esempio n. 13
0
        protected override void OnBeforePrint(PrintEventArgs e)
        {
            base.OnBeforePrint(e);

            // Hide SUM colums if needed
            if (_hideSums)
            {
                //tbl_DailyCaption.DeleteColumn(lbCell_ContractWorkingHours);
                tbl_DailyCaption.DeleteColumn(lbCell_AllreadyPlannedWorkingHours);
                //tbl_DailyCaption.DeleteColumn(lbCell_SummOfAdditionalCharges);
                //tbl_DailyCaption.DeleteColumn(lbCell_PlusMinusHours);
                //tbl_DailyCaption.DeleteColumn(lbCell_EmployeeBalanceHours);

                //tbl_DailyData.DeleteColumn(fieldCell_ContractWorkingHours);
                tbl_DailyData.DeleteColumn(fieldCell_PlannedWorkingHours);
                //tbl_DailyData.DeleteColumn(fieldCell_SumAdditionalHours);
                //tbl_DailyData.DeleteColumn(fieldCell_PlusMinusHours);
                //tbl_DailyData.DeleteColumn(fieldCell_BalanceHours);
            }
            //
            // Generate columnss
            //
            int segmentWidth = Convert.ToInt32(lbCell_0000.Width / 24);

            lbCell_Employee.Width = fieldCell_EmployeeName.Width = lbCell_0000.Right - (segmentWidth * 24);
            TimeSpan dayTime  = TimeSpan.Zero;
            TimeSpan timeStep = TimeSpan.FromMinutes(60);

            XRTableCell baseLabelCell = lbCell_0000;
            XRTableCell baseDataCell  = fieldCell_0000;

            while (dayTime.TotalHours < 23)
            {
                DateTime columnTime = _viewDate.Add(dayTime);

                // Caption
                ReportPainter.ApplyCaptionCellFormat(baseLabelCell, columnTime);
                tbl_DailyCaption.InsertColumnToRight(baseLabelCell);
                baseLabelCell.Width = segmentWidth;

                baseLabelCell = baseLabelCell.NextCell;

                // Data
                baseDataCell.Tag = columnTime;
                tbl_DailyData.InsertColumnToRight(baseDataCell);
                baseDataCell.BeforePrint += PrintTimeCell;
                baseDataCell.Width        = segmentWidth;
                ReportPainter.Insert15MinuteShapes(baseDataCell, columnTime, ManualFillOnly);

                baseDataCell = baseDataCell.NextCell;

                dayTime = dayTime.Add(timeStep);
            }

            DateTime lastColumnTime = _viewDate.Add(dayTime);

            ReportPainter.ApplyCaptionCellFormat(baseLabelCell, lastColumnTime);
            baseDataCell.Tag          = lastColumnTime;
            baseDataCell.BeforePrint += PrintTimeCell;
            ReportPainter.Insert15MinuteShapes(baseDataCell, lastColumnTime, ManualFillOnly);
            //
            // If manuall fill, add new row
            if (ManualFill && !ManualFillOnly)
            {
                XRTableRow dataRow = tbl_DailyData.Rows.FirstRow;
                tbl_DailyData.InsertRowBelow(dataRow);
                XRTableRow manualFillRow = tbl_DailyData.Rows[1];
                for (int idx = 1; idx < dataRow.Cells.Count; idx++)
                {
                    if (dataRow.Cells[idx].Tag.GetType() == typeof(DateTime))
                    {
                        DateTime columnTime = (DateTime)dataRow.Cells[idx].Tag;
                        manualFillRow.Cells[idx].Tag = columnTime;
                        ReportPainter.Insert15MinuteShapes(manualFillRow.Cells[idx], columnTime, true);
                        manualFillRow.Cells[idx].BeforePrint += PrintTimeCell;
                    }
                }
            }
        }
Esempio n. 14
0
        public void TestCollisions0()
        {
            var options = new AlignerOptions {
                AlignX     = Alignment.Start,
                AlignY     = Alignment.Center,
                Dimension  = Dimension.X,
                PointOrder = PointOrder.XY
            };

            var worker = SceneWorkerWithTestData2(0, options);

            options.Distance = worker.Layout.Distance;

            var scene = worker.Scene;

            ILocator <IVisual> locator = new GraphSceneItemShapeLocator <IVisual, IVisualEdge> {
                GraphScene = scene
            };


            Action <IEnumerable <IVisual> >         reportElems  = elms => ReportElems(scene, elms, locator, options);
            Func <IEnumerable <IVisual>, Rectangle> reportExtent = elms => ReportExtent(elms, locator, options);

            var visibleItems  = new HashSet <IVisual> (scene.Elements.Where(e => !(e is IVisualEdge)));
            var visibleBounds = locator.Bounds(visibleItems);

            reportElems(visibleItems);
            reportExtent(visibleItems);


            IEnumerable <IVisual> itemsToPlace = ((scene.Graph as SubGraph <IVisual, IVisualEdge>).Source).Walk()
                                                 .DeepWalk(scene.Focused, 0)
                                                 .Select(l => l.Node)
                                                 .ToArray();

            scene.Focused.Location = Point.Zero + worker.Layout.Distance;
            itemsToPlace.ForEach(e => scene.Graph.Add(e));

            itemsToPlace = itemsToPlace.Where(e => !(e is IVisualEdge));
            var aligner = new Aligner <IVisual, IVisualEdge> (scene, worker.Layout);

            aligner.Columns(scene.Focused, itemsToPlace, options);
            locator = aligner.Locator;
            reportElems(itemsToPlace);
            var bounds = reportExtent(itemsToPlace);
            var free   = aligner.NextFreeSpace(bounds.Location, bounds.Size, itemsToPlace, options.Dimension, options.Distance);

            ReportDetail("Next free space {0}", free);
            var free2 = aligner.NearestNextFreeSpace(bounds.Location, bounds.Size, itemsToPlace, false, options.Dimension, options.Distance);

            ReportDetail("Nearest Next free space {0}", free);

            var dist = new Size(bounds.Location.X - free2.Location.X, bounds.Location.Y - free2.Location.Y);

            itemsToPlace.ForEach(e => aligner.Locator.SetLocation(e, aligner.Locator.GetLocation(e) - dist));

            aligner.Commit();
            worker.Modeller.Perform();
            worker.Modeller.Finish();

            ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx));

            ReportPainter.PushPaint(ctx => {
                var translate = worker.Painter.Viewport.ClipOrigin;
                ctx.Save();
                ctx.Translate(-translate.X, -translate.Y);
                ctx.SetLineWidth(.5);
                ctx.SetColor(Colors.Black);
                ctx.Rectangle(visibleBounds);
                ctx.Stroke();
                ctx.SetColor(Colors.Red);
                ctx.Rectangle(bounds);
                ctx.Stroke();

                ctx.SetColor(Colors.Green);
                ctx.Rectangle(free);
                ctx.Stroke();

                ctx.SetColor(Colors.LawnGreen);
                ctx.Rectangle(free2);
                ctx.Stroke();
                ctx.Restore();
                ctx.SetColor(Colors.White);
            });

            WritePainter();
        }
Esempio n. 15
0
        public void TestShowAllData()
        {
            var options = new AlignerOptions {
                AlignX     = Alignment.Center,
                AlignY     = Alignment.Start,
                Dimension  = Dimension.X,
                PointOrder = PointOrder.XY,
                //Collisions = Collisions.NextFree
            };

            var scene     = SceneWithTestData(0);
            var graphView = scene.Graph as SubGraph <IVisual, IVisualEdge>;
            var graph     = graphView.Source;

            for (int i = 1; i < 6; i++)
            {
                (SceneWithTestData(i).Graph as SubGraph <IVisual, IVisualEdge>)
                .Source.ForEach(item => graph.Add(item));
            }

            var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> ();

            worker.Compose(scene, new VisualsRenderer());
            worker.StyleSheet.BackColor = Colors.WhiteSmoke;
            worker.Layout.SetOptions(options);
            options.Distance = worker.Layout.Distance;

            Action allData = () => {
                var roots = new Queue <IVisual> (graph.FindRoots(null));

                var walk = graph.Walk();

                roots.ForEach(root => walk.DeepWalk(root, 0).ForEach(item => graphView.Sink.Add(item.Node)));

                walk = graphView.Walk();

                var aligner = new Aligner <IVisual, IVisualEdge> (scene, worker.Layout);
                //var bounds = new Rectangle(worker.Layout.Border.Width, worker.Layout.Border.Height, 0, 0);
                var pos = new Point(worker.Layout.Border.Width, worker.Layout.Border.Height);
                roots.ForEach(root => {
                    var steps  = walk.DeepWalk(root, 1).Where(l => !(l.Node is IVisualEdge)).ToArray();
                    var bounds = new Rectangle(pos, Size.Zero);
                    var cols   = aligner.MeasureWalk(steps, ref bounds, options);
                    //bounds = aligner.NextFreeSpace(bounds.Location, bounds.Size, walk.Select(t => t.Node), Dimension.Y, options.Distance);
                    pos = new Point(pos.X, pos.Y + bounds.Size.Height + options.Distance.Height);
                    aligner.LocateColumns(cols, bounds, options);
                    //bounds.Top = bounds.Bottom + options.Distance.Height;
                });

                aligner.Commit();
                worker.Modeller.Perform();
                worker.Modeller.Finish();
            };

            allData();
            allData();

            ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx));

            WritePainter();
        }