public void AddBezier()
        {
            var builder = new PathBuilder();

            builder.AddBezier(new Vector2(10, 10), new Vector2(20, 20), new Vector2(20, 30), new Vector2(10, 40));

            Assert.IsType <Path>(builder.Build());
        }
Beispiel #2
0
        public void DrawLinesOpenFigure()
        {
            PathBuilder builder = new PathBuilder();

            builder.AddLine(10, 10, 10, 90);
            builder.AddLine(10, 90, 50, 50);
            Path shape = Assert.IsType <Path>(builder.Build());
        }
Beispiel #3
0
        public static string?Route(this IHandler handler, IRequest request, string?route, bool relative = true)
        {
            if (route != null)
            {
                if (route.StartsWith("http") || route.StartsWith('/'))
                {
                    return(route);
                }

                if (route.StartsWith("."))
                {
                    if (!relative)
                    {
                        var routePath = new PathBuilder(route).Build();

                        return(request.Target.Path.Combine(routePath)
                               .ToString());
                    }

                    return(route);
                }

                var root = request.Server.Handler;

                var parts = route.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length > 0)
                {
                    var target = parts[0];

                    foreach (var resolver in handler.FindParents <IHandlerResolver>(root))
                    {
                        var responsible = resolver.Find(target);

                        if (responsible != null)
                        {
                            var targetParts = new List <string>(responsible.GetRoot(request, false).Parts);

                            for (int i = 1; i < parts.Length; i++)
                            {
                                targetParts.Add(parts[i]);
                            }

                            var targetPath = new WebPath(targetParts, route.EndsWith('/'));

                            if (relative)
                            {
                                return(request.Target.Path.RelativeTo(targetPath));
                            }

                            return(targetPath.ToString());
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #4
0
        public void ReadPathWithTrailingDirSeparator()
        {
            PathBuilder b = new PathBuilder(@"dir1\dir2\file.txt\");

            Assert.AreEqual(3, b.PathDepth);
            Assert.IsTrue(b.IsRelative);
            Assert.AreEqual(string.Empty, b.PathRoot);
            Assert.AreEqual(@"dir1\dir2\file.txt", b.ToString());
        }
Beispiel #5
0
        public void ReadPathWithSlashes()
        {
            PathBuilder b = new PathBuilder(@"dir1/dir2/file.txt");

            Assert.AreEqual(3, b.PathDepth);
            Assert.IsTrue(b.IsRelative);
            Assert.AreEqual(string.Empty, b.PathRoot);
            Assert.AreEqual(@"dir1\dir2\file.txt", b.ToString());
        }
 public IEnumerable <string> ExportWorkingCopyDiff(string workingCopyPath)
 {
     return(InvokeClient(workingCopyPath, (client, path) =>
     {
         var workingCopyDiffPath = PathBuilder.Combine(ResolveDiffDirectory(), Files.DiffPatch());
         client.ExportWorkingCopyDiff(path, workingCopyDiffPath);
         return workingCopyDiffPath;
     }));
 }
        public void Test2()
        {
            var pbuilder = new PathBuilder();
            var path     = pbuilder.RebuildNextPath(@"D:\clding\trunk\projects\ClDing\Tests\ClDing.Utility.Tests\bin\Debug\cldinglog\error\2014\141109.log");
            var path2    = pbuilder.RebuildNextPathByFileSize(@"D:\clding\trunk\projects\ClDing\Tests\ClDing.Utility.Tests\bin\Debug\cldinglog\error\2014\141109.log", "1MB");

            Assert.IsNotNullOrEmpty(path);
            Assert.IsNotNullOrEmpty(path2);
        }
        public void Test()
        {
            var pbuilder = new PathBuilder();

            pbuilder.SetVariant("%test%", x => "123");
            var path = pbuilder.BuildWithVariant("%appdir%\\sprlog\\%year%_%month%\\%day%log.log");

            Assert.IsNotNullOrEmpty(path);
        }
Beispiel #9
0
        /// <summary>
        /// Flood fills the image in the shape of the provided polygon with the specified brush.
        /// </summary>
        /// <typeparam name="TPixel">The type of the color.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="options">The graphics options.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="path">The shape.</param>
        /// <returns>The <see cref="Image{TPixel}"/>.</returns>
        public static IImageProcessingContext <TPixel> Fill <TPixel>(this IImageProcessingContext <TPixel> source, GraphicsOptions options, IBrush <TPixel> brush, Action <PathBuilder> path)
            where TPixel : struct, IPixel <TPixel>
        {
            var pb = new PathBuilder();

            path(pb);

            return(source.Fill(options, brush, pb.Build()));
        }
Beispiel #10
0
 public HierarchyCollection(
     DatabaseCollectionOptions options,
     EntityResolver resolver,
     PathBuilder pathBuilder)
     : base("hierarchy", options)
 {
     _pathBuilder = pathBuilder;
     _resolver    = resolver;
 }
Beispiel #11
0
    private void Start()
    {
        instance = this;
        m_cart   = GameObject.FindGameObjectWithTag("Cart");
        m_cm     = m_cart.GetComponent <CartMovement>();
        m_pb     = GameObject.FindGameObjectWithTag("Game").GetComponent <PathBuilder>();

        RestartGame();
    }
Beispiel #12
0
        public void ReadAbsolutePathWithDisk()
        {
            PathBuilder b = new PathBuilder(@"D:\dir1\dir2\file.txt");

            Assert.AreEqual(3, b.PathDepth);
            Assert.IsFalse(b.IsRelative);
            Assert.AreEqual(@"D:\", b.PathRoot);
            Assert.AreEqual(@"D:\dir1\dir2\file.txt", b.ToString());
        }
Beispiel #13
0
 private PathBuilder GetByLineStyle(LineStyle style, SubShape subShape)
 {
     if (style == null) return null;
     if (subShape.Lines.ContainsKey(style)) return subShape.Lines[style];
     var b = new PathBuilder(false, style.NoClose);
     b.Tag = style;
     subShape.Lines.Add(style, b);
     return b;
 }
Beispiel #14
0
        public void Construct()
        {
            // Execute
            var result = new PathBuilder(@"\some\odd\path");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(@"\some\odd\path", result.ToString());
        }
Beispiel #15
0
        public void RelativeWithDifferentDelimeters()
        {
            // Setup
            var path  = PathBuilder.Create(@"\some\odd");
            var child = PathBuilder.Create(@":some:odd:path:or:other", ":");

            // Execute
            PathBuilder.Relative(child, path);
        }
Beispiel #16
0
        public override IPath GetPath()
        {
            var         points = PolygonRegular.CalculateVertices(Vertices, Radius, Angle, Center);
            PathBuilder pb     = new PathBuilder();

            pb.AddLines(points);
            pb.CloseFigure();
            return(pb.Build());
        }
Beispiel #17
0
        /// <summary>
        /// Flood fills the image in the shape of the provided polygon with the specified brush..
        /// </summary>
        /// <typeparam name="TPixel">The type of the color.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="path">The shape.</param>
        /// <param name="options">The graphics options.</param>
        /// <returns>The <see cref="Image{TPixel}"/>.</returns>
        public static Image <TPixel> Fill <TPixel>(this Image <TPixel> source, IBrush <TPixel> brush, Action <PathBuilder> path, GraphicsOptions options)
            where TPixel : struct, IPixel <TPixel>
        {
            var pb = new PathBuilder();

            path(pb);

            return(source.Fill(brush, pb.Build(), options));
        }
Beispiel #18
0
        public void BuildPath_Adds_Cursor_Parameter()
        {
            var cursor = "abcdefg";
            var path   = PathBuilder.BuildPath("some/path", new RequestOptions {
                Cursor = cursor
            });

            path.Should().Be("some/path/?cursor=abcdefg");
        }
        public void PathBuilderShouldDoNothingWhenNoSegmentsAreAdded()
        {
            const string PathString = "test";
            var          builder    = new PathBuilder(PathString);

            builder.AddSegments();

            builder.Build().Should().Be(PathString);
        }
Beispiel #20
0
        public void BuildPath_Adds_Limit_Parameter_Above_Zero()
        {
            var limit = 10;
            var path  = PathBuilder.BuildPath("some/path", new RequestOptions {
                Limit = limit
            });

            path.Should().Be("some/path/?limit=10");
        }
Beispiel #21
0
 public void Dispose()
 {
     if (_monitor != null)
     {
         _monitor.End();
         _monitor = null;
         _builder = null;
     }
 }
Beispiel #22
0
 private PathBuilder GetByFillStyle(FillStyle style, SubShape subShape)
 {
     if (style == null) return null;
     if (subShape.Fills.ContainsKey(style)) return subShape.Fills[style];
     var b = new PathBuilder(true, false);
     b.Tag = style;
     subShape.Fills.Add(style, b);
     return b;
 }
Beispiel #23
0
        public void BuildPath_Does_Not_Add_Limit_Parameter_Zero()
        {
            var limit = 0;
            var path  = PathBuilder.BuildPath("some/path", new RequestOptions {
                Limit = limit
            });

            path.Should().Be("some/path/");
        }
        public static void RunRandomly(Random rnd, int width, int height, int numOfNodes, int iterations, ApproximationType approximation, bool oneChanges,
                                       string resultDir)
        {
            var vectorLength = width * height;
            var resultPath   =
                PathBuilder.Create(resultDir, "AMS_F2")
                .AddProperty("Dataset", "Random")
                .AddProperty("OneChanges", oneChanges.ToString())
                .AddProperty("Nodes", numOfNodes.ToString())
                .AddProperty("VectorLength", vectorLength.ToString())
                .AddProperty("Width", width.ToString())
                .AddProperty("Height", height.ToString())
                .AddProperty("Iterations", iterations.ToString())
                .AddProperty("Approximation", approximation.AsString())
                .ToPath("csv");
            var secondMomentFunction = new SecondMoment(width, height);

            using (var resultCsvFile = AutoFlushedTextFile.Create(resultPath, AccumaltedResult.Header(numOfNodes)))
            {
                var initVectors = ArrayUtils.Init(numOfNodes, _ => ArrayUtils.Init(vectorLength, __ => (double)rnd.Next(-4, 5)).ToVector());

                var multiRunner = MultiRunner.InitAll(initVectors, numOfNodes, vectorLength, approximation, secondMomentFunction.MonitoredFunction);
                // multiRunner.OnlySchemes(new MonitoringScheme.Value(), new MonitoringScheme.FunctionMonitoring(), new MonitoringScheme.Oracle());
                const int OracleFullSyncs = 2;

                Func <int, Vector> ChangeGenerator() => nodeIndex =>
                {
                    if (oneChanges)
                    {
                        if (nodeIndex != 0)
                        {
                            return(new Vector());
                        }
                        return(ArrayUtils.Init(vectorLength, _ => (rnd.NextDouble() - 0.5) * numOfNodes / 5).ToVector());
                    }
                    else
                    {
                        return(ArrayUtils.Init(vectorLength, _ => (rnd.NextDouble() - 0.5) / 5).ToVector());
                    }
                };

                for (int i = 0; i < iterations; i++)
                {
                    var changes = ArrayUtils.Init(numOfNodes, ChangeGenerator());

                    var stop = new StrongBox <bool>(false);
                    multiRunner.Run(changes, rnd, false)
                    .SideEffect(r => stop.Value = stop.Value || (r.MonitoringScheme.Equals(new MonitoringScheme.Oracle()) && r.NumberOfFullSyncs > OracleFullSyncs))
                    .Select(r => r.AsCsvString())
                    .ForEach(resultCsvFile.WriteLine);
                    if (stop.Value)
                    {
                        break;
                    }
                }
            }
        }
Beispiel #25
0
        public void ConstructWithEndingDelimiter()
        {
            // Execute
            var result = new PathBuilder(@":some:odd:path:", ":");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(@":some:odd:path:", result.ToString());
        }
Beispiel #26
0
        protected override void ProcessRecord()
        {
            if (!ShouldProcess(FileImage.FileInfo.ToString(), "Inset Image"))
            {
                return;
            }
            Image image       = FileImage.Image;
            int   insetLeft   = 0;
            int   insetRight  = 0;
            int   insetTop    = 0;
            int   insetBottom = 0;

            if (All != null && All.Length > 0)
            {
                insetLeft = insetRight = insetTop = insetBottom = All[0];
            }
            if (LeftRight.HasValue)
            {
                insetLeft = insetRight = LeftRight.Value;
            }
            insetLeft  = Left ?? insetLeft;
            insetRight = Right ?? insetRight;
            if (TopBottom.HasValue)
            {
                insetTop = insetBottom = TopBottom.Value;
            }
            insetTop    = Top ?? insetTop;
            insetBottom = Bottom ?? insetBottom;
            int           width       = image.Width + insetLeft + insetRight;
            int           height      = image.Height + insetTop + insetBottom;
            Rgba32        insetColor  = this.ParseColor(Color);
            PathBuilder   pathBuilder = new PathBuilder();
            List <PointF> outerPoints = new List <PointF>();

            outerPoints.Add(new PointF(0, 0));
            outerPoints.Add(new PointF(image.Width, 0));
            outerPoints.Add(new PointF(image.Width, image.Height));
            outerPoints.Add(new PointF(0, image.Height));
            outerPoints.Add(new PointF(0, 0));
            List <PointF> innerPoints = new List <PointF>();

            innerPoints.Add(new PointF(insetLeft, insetTop));
            innerPoints.Add(new PointF(image.Width - insetRight, insetTop));
            innerPoints.Add(new PointF(image.Width - insetRight, image.Height - insetBottom));
            innerPoints.Add(new PointF(insetLeft, image.Height - insetBottom));
            innerPoints.Add(new PointF(insetLeft, insetTop));
            pathBuilder.StartFigure();
            pathBuilder.AddLines(outerPoints);
            pathBuilder.StartFigure();
            pathBuilder.AddLines(innerPoints);
            pathBuilder.CloseAllFigures();
            IBrush brush = this.GetBrush(Brush, Color, Background);

            FileImage.Image.Mutate(im => im.Fill(brush, pathBuilder.Build()));
            WriteObject(FileImage);
        }
        private void FixStep(List <TickWorkerState> tiks, int position)
        {
            if (position == tiks.Count - 1)
            {
                return;
            }
            // find path from tiks[position] -> tiks[position+1]
            // rotate to valid direction

            var path = PathBuilder.Build(state.Map, tiks[position].Position, tiks[position + 1].Position);

            var segment = new List <TickWorkerState>();

            foreach (var p in path)
            {
                segment.Add(
                    new TickWorkerState()
                {
                    Position  = p,
                    Direction = tiks[position].Direction
                });
            }

            var d1 = tiks[position].Direction;
            var d2 = tiks[position + 1].Direction;

            if (d1 == d2)
            {
            }
            else if (d1.Rotate(1) == d2 || d1.Rotate(-1) == d2)
            {
                segment.Add(
                    new TickWorkerState()
                {
                    Position  = tiks[position + 1].Position,
                    Direction = (segment.LastOrDefault() ?? tiks[position]).Direction
                });
            }
            else
            {
                segment.Add(
                    new TickWorkerState()
                {
                    Position  = tiks[position + 1].Position,
                    Direction = (segment.LastOrDefault() ?? tiks[position]).Direction
                });
                segment.Add(
                    new TickWorkerState()
                {
                    Position  = tiks[position + 1].Position,
                    Direction = (segment.LastOrDefault() ?? tiks[position]).Direction.Rotate(1)
                });
            }

            tiks.InsertRange(position + 1, segment);
        }
Beispiel #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlyphBuilder"/> class.
        /// </summary>
        public BaseGlyphBuilder()
        {
            // glyphs are renderd relative to bottom left so invert the Y axis to allow it to render on top left origin surface
            Matrix4 mat = new Matrix4();

            mat.Scale(1.0f, -1.0f, 0.0f);

            //this.builder = new PathBuilder((Matrix3x2)mat);
            this.builder = new PathBuilder();
        }
    public void LoadBackground(string AssetBundlePath, string AssetFilePath)
    {
        var bundleLoad = AssetBundle.LoadFromFile(PathBuilder.BuildPath(PathBuilder.GetDataFolder(), AssetBundlePath));

        RuntimeAnimatorController Instance = bundleLoad.LoadAsset <RuntimeAnimatorController> (AssetFilePath);

        bundleLoad.Unload(false);
        Debug.Log("Animation = " + Instance.name);
        this._LoadingBackground.GetComponent <Animator> ().runtimeAnimatorController = Instance;
    }
        public void DrawLinesClosedFigure()
        {
            var builder = new PathBuilder();

            builder.AddLine(10, 10, 10, 90);
            builder.AddLine(10, 90, 50, 50);
            builder.CloseFigure();

            Assert.IsType <Polygon>(builder.Build());
        }
Beispiel #31
0
        /// <summary>
        /// Creates a new wrapper around the webdev.webserver.exe.
        /// </summary>
        /// <param name="webRootDirectory">The local web root path</param>
        /// <param name="webDevServerPath">The full path to the webdev.webserver.exe</param>
        public WebDevWebServer(string webRootDirectory, string webDevServerPath)
        {
            Guard.AgainstNullOrEmpty(() => webRootDirectory);
            Guard.AgainstNullOrEmpty(() => webDevServerPath);

            var pathBuilder = new PathBuilder();

            _webRootDirectory = pathBuilder.Normalize(webRootDirectory);
            WebDevServerPath  = pathBuilder.Normalize(webDevServerPath);
        }
Beispiel #32
0
        public void BuildPath_Adds_Query_Fields_Cursor_And_Limit_Parameters()
        {
            var query  = "search query";
            var fields = new[] { "field1", "field2(f1,f2,f3)" };
            var cursor = "abcdefg";
            var limit  = 10;
            var path   = PathBuilder.BuildPath("some/path", new RequestOptions(query, fields, cursor, limit));

            path.Should().Be("some/path/?query=search query&fields=field1,field2(f1,f2,f3)&cursor=abcdefg&limit=10");
        }
Beispiel #33
0
        public PackageMaster Zip(string zipFileNameFormat, params object[] args)
        {
            lastZipFileName = string.Format(
                CultureInfo.InvariantCulture,
                zipFileNameFormat,
                args);

            lastZipFileName = new PathBuilder(packagingDir).Add(lastZipFileName);

            FastZip zip = new FastZip();
            zip.CreateZip(lastZipFileName, packagingDirTemp, true, null, null);

            return this;
        }
Beispiel #34
0
 internal static ModelPath Build(ModelType rootType, Expression expression)
 {
     var builder = new PathBuilder() { expression = expression, path = new ModelPath() { RootType = rootType } };
     builder.Build();
     return builder.path;
 }
Beispiel #35
0
        private string cacheCtxToPath(CharpCtx ctx)
        {
            PathBuilder path = new PathBuilder ();

            if (ctx.cacheIsPrivate)
                path.Append ("u:").AppendNode (ctx.reqData["login"]);
            else
                path.AppendNode ("public");

            path.AppendNode (ctx.reqData["res"])
                .AppendNode (ctx.reqData["params"]);

            return path.ToString ();
        }
        public virtual Path createGenericPath()
        {
            PathBuilder pathBuilder = new PathBuilder();
            //UPGRADE_TODO: Interface 'java.awt.geom.PathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
            //UPGRADE_TODO: Method 'java.awt.Shape.getPathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtShapegetPathIterator_javaawtgeomAffineTransform_3"'
            System.Drawing.Drawing2D.GraphicsPathIterator itr = new System.Drawing.Drawing2D.GraphicsPathIterator(shape);
            double[] point = new double[6];

            //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.isDone' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorisDone_3"'
            while (!itr.isDone())
            {
                //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.currentSegment' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorcurrentSegment_double[]_3"'
                int type = itr.currentSegment(point);

                //UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.next' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratornext_3"'
                itr.next();
                //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_MOVETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_MOVETO_f_3"'
                if (type == PathIterator.SEG_MOVETO)
                {
                    pathBuilder.moveTo(point[0], point[1]);
                }
                else
                {
                    //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_LINETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_LINETO_f_3"'
                    if (type == PathIterator.SEG_LINETO)
                    {
                        pathBuilder.lineTo(point[0], point[1]);
                    }
                    else
                    {
                        //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_QUADTO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_QUADTO_f_3"'
                        if (type == PathIterator.SEG_QUADTO)
                        {
                            System.Drawing.PointF p1 = new System.Drawing.PointF((float) point[0], (float) point[1]);
                            System.Drawing.PointF p2 = new System.Drawing.PointF((float) point[2], (float) point[3]);
                            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                            pathBuilder.curveTo(ref p1, ref p2);
                        }
                        else
                        {
                            //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_CUBICTO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_CUBICTO_f_3"'
                            if (type == PathIterator.SEG_CUBICTO)
                            {
                                System.Drawing.PointF p1 = new System.Drawing.PointF((float) point[0], (float) point[1]);
                                System.Drawing.PointF p2 = new System.Drawing.PointF((float) point[2], (float) point[3]);
                                System.Drawing.PointF p3 = new System.Drawing.PointF((float) point[4], (float) point[5]);
                                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                                pathBuilder.curveTo(ref p1, ref p2, ref p3);
                            }
                            else
                            {
                                //UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_CLOSE' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_CLOSE_f_3"'
                                if (type == PathIterator.SEG_CLOSE)
                                {
                                    pathBuilder.close();
                                }
                            }
                        }
                    }
                }
            }

            return pathBuilder.createPath();
        }