Beispiel #1
0
        //合并路径矩阵
        public static Paths PathsMatrixMergeByRandom(List <Paths> pgss, float m_dis_threshold, Paths addPgs)
        {
            Paths        finaloutPathsList = new Paths(); //输出合并后的路径
            Paths        mtempPaths        = new Paths(); //用作内部零食
            Paths        AfterorderPaths   = new Paths(); //顺序合并后路径集合
            List <Paths> pgssAfter         = new List <Paths>();

            if ((pgss.Count % 2) == 1)
            {
                pgssAfter = new List <Paths> (PathsRowToCol(pgss));
            }
            else
            {
                pgssAfter = new List <Paths> (pgss);
            }
            foreach (Paths pgs in pgssAfter)
            {
                mtempPaths = PathsMergeByOrder(pgs, m_dis_threshold);
                AfterorderPaths.AddRange(mtempPaths);
            }

            AfterorderPaths.AddRange(new Paths(addPgs));                              //加入附加的路径
            finaloutPathsList = PathsMergeByRandom(AfterorderPaths, m_dis_threshold); //最终合并结果
            return(finaloutPathsList);
        }
Beispiel #2
0
        public Paths PathsFrom(BoardLocation location, int forPlayer)
        {
            var paths = new Paths();

            paths.AddRange(new RookPathGenerator().PathsFrom(location, forPlayer));
            paths.AddRange(new BishopPathGenerator().PathsFrom(location, forPlayer));

            return(paths);
        }
Beispiel #3
0
        private static Paths ToPaths(List <XPolygon> polygons, double scaleBy = 1)
        {
            Paths paths = new Paths();

            polygons.ForEach(p => paths.AddRange(ToPaths(p, scaleBy)));
            return(paths);
        }
 public void Filter()
 {
     Paths.Clear();
     Paths.AddRange(originalPaths);
     if (IsDirect)
     {
         for (int i = 0; i < Paths.Count; i++)
         {
             if (Paths[i].Change > 0)
             {
                 Paths.RemoveAt(i);
                 i--;
             }
         }
     }
     if (!IsExpress)
     {
         for (int i = 0; i < Paths.Count; i++)
         {
             foreach (var con in Paths[i].Connections)
             {
                 if (con.Train.Type == "Ekspres")
                 {
                     Paths.RemoveAt(i);
                     i--;
                     break;
                 }
             }
         }
     }
 }
        public RelativeValueStoragePath(params string[] paths)
        {
            if (paths is null)
            {
                throw new ArgumentNullException(nameof(paths));
            }

            Paths.AddRange(paths);
        }
Beispiel #6
0
 public Form1()
 {
     InitializeComponent();
     for (int i = 0; i < 9; i++)
     {
         Paths.Add(i + ".bmp");
     }
     Paths.AddRange(new List <string>()
     {
         "c.bmp", "d.bmp", "f.bmp", "g.bmp", "qq.bmp"
     });
     Train();
 }
Beispiel #7
0
        private async Task RunRefresh()
        {
            CanRefresh = false;
            Paths.Clear();
            Files.Clear();
            var callback = new Progress <Tuple <string, int> >(UpdateProgress);
            var result   = await analyzerService.AnalyzeAsync(callback);

            Files.AddRange(result.Files);
            Paths.AddRange(result.UsedAnalyzers);
            Statistics = string.Format("{0} files found ({1})", result.Files.Count,
                                       StringUtilities.GetBytesReadable(result.TotalSize));
            currentResult = result;
            CanRefresh    = true;
        }
        // Open folder dialog
        public void OpenFolderDialog()
        {
            using (var folder = new FolderBrowserDialog())
            {
                // Show dialog
                DialogResult result = folder.ShowDialog();

                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(folder.SelectedPath))
                {
                    Paths.Clear();
                    SelectedPath = folder.SelectedPath;
                    string[] files  = Directory.GetFiles(folder.SelectedPath, "*.png");
                    string[] files2 = Directory.GetFiles(folder.SelectedPath, "*.jpg");

                    this.Paths.AddRange(files);
                    Paths.AddRange(files2);
                }
            }
        }
Beispiel #9
0
        protected override void OnStart(string[] args)
        {
//            Thread.Sleep(TimeSpan.FromSeconds(10));
            LogFile = System.Configuration.ConfigurationManager.AppSettings["LogFolder"] + @"\" + DateTime.Now.ToString("yyyyMMdd-hhmmss") + ".txt";
            Paths.AddRange(System.Configuration.ConfigurationManager.AppSettings["Paths"].Split(';'));
            var interval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Interval"]);

            LogMessage("Service started");
            LogMessage($"Interval: {interval}");
            LogMessage("Paths: ");
            foreach (var p in Paths)
            {
                LogMessage(p);
            }
            WritePings();

            _timer          = new Timer(interval);
            _timer.Elapsed += (sender, eventArgs) => WritePings();
            _timer.Start();
        }
        public bool ValidateMove(BoardMove move, IReadOnlyBoardState <TEntity> roBoardState)
        {
            var piece = roBoardState.GetItem(move.From);

            if (piece == null)
            {
                return(false);
            }

            var owner = piece.Item.Owner;

            var enemyPaths = new Paths();
            var enemyItems = roBoardState.GetItems().Where(i => i.Item.Owner != owner);

            enemyPaths.AddRange(enemyItems.SelectMany(li => li.Paths));

            var attackMoveTypes = new [] { (int)DefaultActions.MoveOrTake, (int)DefaultActions.TakeOnly, (int)ChessMoveTypes.KingMove };

            return(!enemyPaths.ContainsMoveTypeTo(move.To, attackMoveTypes));
        }
        private void FilterNestedPaths(Paths paths)
        {
            var filtered = new List <Path>(paths);

            for (var i = 0; i < paths.Count; ++i)
            {
                var path = paths[i];

                if (!filtered.Contains(path))
                {
                    continue;
                }

                for (var j = i + 1; j < paths.Count; ++j)
                {
                    if (!filtered.Contains(path))
                    {
                        continue;
                    }

                    var other = paths[j];

                    if (IsPathContainedInOtherPath(path, other))
                    {
                        filtered.Remove(path);
                        break;
                    }
                    else if (IsPathContainedInOtherPath(other, path))
                    {
                        filtered.Remove(other);
                    }
                }
            }

            paths.Clear();
            paths.AddRange(filtered);
        }
Beispiel #12
0
        private PathEntry TryGetDebugPath(string system, string type)
        {
            if (Paths.Any(p => p.IsSystem(system)))
            {
                // we have the system, but not the type.  don't attempt to add an unknown type
                return(null);
            }

            // we don't have anything for the system in question.  add a set of stock paths
            var systemPath = $"{system.RemoveInvalidFileSystemChars()}_INTERIM";
            var systemDisp = $"{system} (INTERIM)";

            Paths.AddRange(new[]
            {
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "Base", Path = Path.Combine(".", systemPath), Ordinal = 0
                },
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "ROM", Path = ".", Ordinal = 1
                },
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2
                },
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3
                },
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4
                },
                new PathEntry {
                    System = system, SystemDisplayName = systemDisp, Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5
                }
            });

            return(this[system, type]);
        }
        static void WidenPath(GraphicsPath path, Pen pen, out List<PointF> widePoints, out List<byte> wideTypes)
        {
            widePoints = new List<PointF> ();
            wideTypes = new List<byte> ();

            var pathData = path.PathData;

            var iterator = new GraphicsPathIterator(path);
            var subPaths = iterator.SubpathCount;

            int startIndex = 0;
            int endIndex = 0;
            bool isClosed = false;

            var flattenedSubpath = new Paths();
            var offsetPaths = new Paths();

            var width = (pen.Width / 2) * scale;
            var miterLimit = pen.MiterLimit * scale;

            var joinType = JoinType.jtMiter;
            switch (pen.LineJoin)
            {
            case LineJoin.Round:
                joinType = JoinType.jtRound;
                break;
            case LineJoin.Bevel:
                joinType = JoinType.jtSquare;
                break;
            }

            for (int sp = 0; sp < subPaths; sp++)
            {

                var numOfPoints = iterator.NextSubpath(out startIndex, out endIndex, out isClosed);
                //Console.WriteLine("subPath {0} - from {1} to {2} closed {3}", sp+1, startIndex, endIndex, isClosed);

                var subPoints = pathData.Points.Skip(startIndex).Take(numOfPoints).ToArray();

                //for (int pp = startIndex; pp <= endIndex; pp++)
                //{
                //    Console.WriteLine("         {0} - {1}", pathData.Points[pp], (PathPointType)pathData.Types[pp]);
                //}

                // Load our Figure Subpath
                flattenedSubpath.Clear();
                flattenedSubpath.Add(Region.PointFArrayToIntArray(subPoints, scale));

                // Calculate the outter offset region
                var outerOffsets = Clipper.OffsetPaths(flattenedSubpath, width, joinType, EndType.etClosed, miterLimit);
                // Calculate the inner offset region
                var innerOffsets = Clipper.OffsetPaths(flattenedSubpath, -width, joinType, EndType.etClosed, miterLimit);

                // Add the offsets to our paths
                offsetPaths.AddRange(outerOffsets);

                // revers our innerOffsets so that they create a hole when filling
                Clipper.ReversePaths (innerOffsets);
                offsetPaths.AddRange(innerOffsets);

            }

            foreach (var offPath in offsetPaths)
            {
                if (offPath.Count < 1)
                    continue;

                var pointArray = Region.PathToPointFArray(offPath, scale);

                var type = (byte)PathPointType.Start;
                widePoints.Add (pointArray [0]);
                wideTypes.Add (type);

                type = (byte)PathPointType.Line;
                for (int i = 1; i < offPath.Count; i++)
                {
                    widePoints.Add (pointArray [i]);
                    wideTypes.Add (type);

                }

                if (widePoints.Count > 0)
                    wideTypes [wideTypes.Count-1] = (byte) (wideTypes [wideTypes.Count-1] | (byte) PathPointType.CloseSubpath);

            }
        }
Beispiel #14
0
 public void Add(IEnumerable <string> paths)
 => Paths.AddRange(paths);
Beispiel #15
0
 public MultiPathFileSystemPoller(params string[] paths)
 {
     Paths.AddRange(paths);
 }
Beispiel #16
0
        public int BuildStuff(Bitmap aMask, Settings TheSettings)
        {
            DirectBitmap Mask = new DirectBitmap(aMask.Width, aMask.Height);
            Graphics     mg   = Graphics.FromImage(Mask.Bitmap);

            mg.DrawImage(aMask, 0, 0);


            int i = Math.Max(Mask.Width, Mask.Height);
            int R = 1;

            while (R < i)
            {
                R *= 2;
            }
            ArtTree = null;
            float ThresholdLevel = TheSettings.Threshold * 0.01f;

            switch (TheSettings.Mode)
            {
            case Settings.ArtMode.QuadTree:
            {
                DateTime rR = DateTime.Now;

                ArtTree = new QuadTreeNode()
                {
                    xstart = -1000, ystart = -1000, xend = R, yend = R
                };
                float hoek = (float)((6.283 * TheSettings.DegreesOff) / 360.0);
                for (int x = 0; x < Mask.Width; x++)
                {
                    for (int y = 0; y < Mask.Height; y++)
                    {
                        var  C    = Mask.GetPixelFast(x, y);
                        bool doit = false;
                        if (TheSettings.InvertSource)
                        {
                            doit = C.GetBrightness() > ThresholdLevel;
                        }
                        else
                        {
                            doit = C.GetBrightness() < ThresholdLevel;
                        }
                        if (doit)
                        {
                            double cx = Math.Cos(hoek) * x + Math.Sin(hoek) * y;
                            double cy = Math.Sin(hoek) * -x + Math.Cos(hoek) * y;
                            ArtTree.Insert((int)cx, (int)cy, new SolidQuadTreeItem()
                                {
                                    x = (int)cx, y = (int)cy
                                }, TheSettings.MaxSubDiv);
                        }
                    }
                }
                var Elapsed = DateTime.Now - rR;
                return((int)Elapsed.TotalMilliseconds);
            }

            case Settings.ArtMode.Delaunay:
            {
                DateTime rR = DateTime.Now;
                ArtTree = new QuadTreeNode()
                {
                    xstart = -1000, ystart = -1000, xend = R, yend = R
                };
                float hoek = (float)((6.283 * TheSettings.DegreesOff) / 360.0);
                for (int x = 0; x < Mask.Width; x++)
                {
                    for (int y = 0; y < Mask.Height; y++)
                    {
                        var  C    = Mask.GetPixelFast(x, y);
                        bool doit = false;
                        if (TheSettings.InvertSource)
                        {
                            doit = C.GetBrightness() > ThresholdLevel;
                        }
                        else
                        {
                            doit = C.GetBrightness() < ThresholdLevel;
                        }
                        if (doit)
                        {
                            double cx = Math.Cos(hoek) * x + Math.Sin(hoek) * y;
                            double cy = Math.Sin(hoek) * -x + Math.Cos(hoek) * y;
                            ArtTree.Insert((int)cx, (int)cy, new SolidQuadTreeItem()
                                {
                                    x = (int)cx, y = (int)cy
                                }, TheSettings.MaxSubDiv);
                        }
                    }
                }

                Delaunay.Build(ArtTree, TheSettings.DegreesOff);

                var Elapsed = DateTime.Now - rR;
                return((int)Elapsed.TotalMilliseconds);
            };

            case Settings.ArtMode.Tiling:
            {
                TD.Create(TheSettings.TileType);
                var P  = TD.CreateBaseTriangle(TheSettings.BaseTile, 1000);
                var P2 = TD.CreateBaseTriangle(TheSettings.BaseTile, 1000);
                P.Rotate(TheSettings.DegreesOff);
                P.AlterToFit(Mask.Width, Mask.Height);
                P2.Rotate(TheSettings.DegreesOff);
                P2.AlterToFit(Mask.Width, Mask.Height);

                if (TheSettings.Symmetry)
                {
                    P.ShiftToEdge(Mask.Width / 2, Mask.Height / 2);
                    P2.ShiftToEdge(Mask.Width / 2, Mask.Height / 2);
                    P2.Flip(Mask.Width / 2, Mask.Height / 2);
                    if (TheSettings.SuperSymmetry)
                    {
                        P2.MirrorAround(Mask.Width / 2, Mask.Height / 2);
                    }
                }

                DateTime rR = DateTime.Now;
                SubDivPoly = TD.SubdivideAdaptive(P, TheSettings.MaxSubDiv, MaskTree, TheSettings.alwayssubdivide);

                if (TheSettings.Symmetry)
                {
                    SubDivPoly.AddRange(TD.SubdivideAdaptive(P2, TheSettings.MaxSubDiv, MaskTree, TheSettings.alwayssubdivide));
                }

                if (TheSettings.xscalesmallerlevel != 0)
                {
                    float midx  = Mask.Width / 2.0f;
                    float width = Mask.Width;
                    float offs  = TheSettings.xscalecenter * 0.01f * width;
                    foreach (var A in SubDivPoly)
                    {
                        var   M      = A.Mid();
                        float scaler = 1.0f - ((float)(M.x - offs) / width) * TheSettings.xscalesmallerlevel * 0.01f;
                        //scaler = Math.Max(0, Math.Min(1.0f, scaler));
                        A.ScaleDown(TheSettings.scalingMode, scaler);
                    }
                }
                if (TheSettings.scalesmallerfactor != 1.0f)
                {
                    foreach (var A in SubDivPoly)
                    {
                        A.ScaleDown(Settings.TriangleScaleMode.Balanced, TheSettings.scalesmallerfactor);
                    }
                }

                if (TheSettings.scalesmaller != 0)
                {
                    float scaler = Math.Abs(TheSettings.scalesmaller);
                    if (TheSettings.scalesmaller > 0)
                    {
                        scaler = scaler / 10.0f;
                    }
                    else
                    {
                        scaler = -scaler / 10.0f;
                    }
                    foreach (var A in SubDivPoly)
                    {
                        if (A.depth - TheSettings.scalesmallerlevel <= 1)
                        {
                        }
                        else
                        {
                            A.ScaleDown(TheSettings.scalingMode, (1 + scaler * (1.0f / (A.depth - TheSettings.scalesmallerlevel))));
                        }
                    }
                }
                if (TheSettings.distanceToMaskScale != 0)
                {
                    float scaler = Math.Abs(TheSettings.distanceToMaskScale);
                    if (TheSettings.distanceToMaskScale > 0)
                    {
                        scaler = scaler / 10.0f;
                    }
                    else
                    {
                        scaler = -scaler / 10.0f;
                    }


                    float aThresholdLevel = TheSettings.Threshold * 0.01f;

                    foreach (var A in SubDivPoly)
                    {
                        var   m   = A.Mid();
                        float sum = GetPixelSum(m, Mask, TheSettings.distanceToMaskRange, aThresholdLevel, TheSettings.InvertSource);
                        //if (sum > 1) sum = 1;
                        A.ScaleDown(TheSettings.scalingMode, (scaler * sum));
                    }
                }


                if (TheSettings.MarcelPlating)
                {
                    List <Tiling.Polygon> MarcelShapes = new List <Tiling.Polygon>();
                    foreach (var A in SubDivPoly)
                    {
                        MarcelShape MS  = new MarcelShape();
                        MarcelShape MS2 = new MarcelShape();

                        foreach (var v in A.Vertices)
                        {
                            MS2.Vertices.Add(new ClipperLib.IntPoint((long)((v.x + 1000) * 1000), (long)((v.y + 1000) * 1000)));
                        }

                        MS.ShrinkFromShape(MS2.Vertices, TheSettings.Gap / 2 + TheSettings.Rounding / 2);
                        Paths Ps = new Paths();

                        Ps.AddRange(MS.BuildOutlines(TheSettings.Rounding / 2.0f));
                        if (TheSettings.BallRadius > 0)
                        {
                            Ps.AddRange(MS.BuildHoles(TheSettings.BallRadius));
                        }

                        foreach (var p in Ps)
                        {
                            Tiling.Polygon Poly = new Tiling.Polygon();
                            Poly.Vertices.AddRange(from a in p select new vec2((a.X) * 0.001f - 1000, (a.Y) * 0.001f - 1000));
                            MarcelShapes.Add(Poly);
                        }
                    }
                    SubDivPoly.Clear();
                    SubDivPoly = MarcelShapes;
                }

                var Elapsed = DateTime.Now - rR;
                return((int)Elapsed.TotalMilliseconds);
            }
            }
            ;
            return(0);
        }
Beispiel #17
0
 public void Add(params string[] paths)
 => Paths.AddRange(paths);
Beispiel #18
0
 public void AddRange(IEnumerable <MarkGeometryPath> paths)
 {
     Paths.AddRange(paths);
     Update();
 }