コード例 #1
1
ファイル: ProgramLogic.cs プロジェクト: Trovarius/simple
        private void EnsureNetFxPath()
        {
            var dotnetPath = GetNetFxPath();

            var paths = new Paths(Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine));
            var userPaths = new Paths(Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User));

            if (!paths.Contains(dotnetPath) && !userPaths.Contains(dotnetPath))
            {
                userPaths.Add(dotnetPath);
                Environment.SetEnvironmentVariable("PATH",
                    userPaths.ToString(), EnvironmentVariableTarget.User);
                Environment.SetEnvironmentVariable("PATH",
                    userPaths.ToString(), EnvironmentVariableTarget.Process);
            }
        }
コード例 #2
0
ファイル: Diagnostics.xaml.cs プロジェクト: kknet/OCTGN
        private void RefreshTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            var p = Process.GetCurrentProcess();

            this.PrivateMemory  = Readable(p.PrivateMemorySize64);
            this.WorkingMemory  = Readable(p.WorkingSet64);
            this.VirtualMemory  = Readable(p.VirtualMemorySize64);
            this.PagedMemory    = Readable(p.PagedMemorySize64);
            this.ProcessPercent = pcounter.NextValue() + "%";
            this.ProcessTime    = p.TotalProcessorTime.ToString();
            this.FPS            = lastFrameRate.ToString(CultureInfo.InvariantCulture);
            LatestVersion       = UpdateManager.Instance.LatestVersion.Version;

            var pathList = Library.Config.Instance.Paths
                           .GetType()
                           .GetProperties()
                           .Where(x => x.PropertyType == typeof(string))
                           .Select(x => new Tuple <string, string>(x.Name, x.GetValue(Config.Instance.Paths, null) as string))
                           .ToArray();

            Dispatcher.Invoke(new Action(() =>
            {
                Paths.Clear();
                foreach (var path in pathList)
                {
                    Paths.Add(path);
                }
            }));
            //Process.GetCurrentProcess().UserProcessorTime
        }
コード例 #3
0
        public void StepTrace(int currStep, int prev, MapCordinate point, List <MappedCordinate> trace)
        {
            try
            {
                int value = this.Map[point.y][point.x];
                currStep++;

                if (value < prev)
                {
                    trace.Add(new MappedCordinate(currStep, prev, value, point.y, point.x));

                    this.StepTrace(currStep, value, new MapCordinate(point.y - 1, point.x), new List <MappedCordinate>(trace));
                    this.StepTrace(currStep, value, new MapCordinate(point.y, point.x + 1), new List <MappedCordinate>(trace));
                    this.StepTrace(currStep, value, new MapCordinate(point.y + 1, point.x), new List <MappedCordinate>(trace));
                    this.StepTrace(currStep, value, new MapCordinate(point.y, point.x - 1), new List <MappedCordinate>(trace));
                }
                else if (trace.Count >= _lastLength)
                {
                    _lastLength = trace.Count;

                    if (!Paths.Any(x => x.SequenceEqual(trace)))
                    {
                        Paths.Add(trace.ToArray());
                    }
                }
            }
            catch // Out of Bounds
            {
                // Trace End
            }
        }
コード例 #4
0
ファイル: RandoMQ.cs プロジェクト: mzxrules/MasterOcarina
            private void InitPaths(BinaryReader br)
            {
                int loop = 0;

                do
                {
                    sbyte nodes = br.ReadSByte();
                    br.BaseStream.Position += 3;
                    SegmentAddress address = br.ReadBigInt32();

                    if (nodes > 0 &&
                        loop < 20 &&
                        (address.Offset < 0x2F_FFFF) && //assuming an address range of 0200 0000 to 022F FFFF, quite larger than expected
                        address.Segment == 0x02)
                    {
                        var         seekback = br.BaseStream.Position;
                        Path_MQJson path     = new Path_MQJson();
                        br.BaseStream.Position = address.Offset;
                        for (int i = 0; i < nodes; i++)
                        {
                            var point = new short[] { br.ReadBigInt16(), br.ReadBigInt16(), br.ReadBigInt16() };
                            path.Points.Add(point);
                        }
                        Paths.Add(path);
                        br.BaseStream.Position = seekback;

                        loop++;
                    }
                    else
                    {
                        break;
                    }
                }while (true);
            }
コード例 #5
0
 public void AddPath(FileInfo file)
 {
     if (!Paths.Contains(file.FullName))
     {
         Paths.Add(file.FullName);
     }
 }
コード例 #6
0
ファイル: MarkGeometriesWrapper.cs プロジェクト: AdilGM/2DCAD
        public MarkGeometriesWrapper(IMarkGeometry[] geometries)
        {
            foreach (var geometry in geometries)
            {
                if (geometry is MarkGeometryPoint point)
                {
                    Points.Add(point);
                }
                else if (geometry is MarkGeometryLine line)
                {
                    Lines.Add(line);
                }
                else if (geometry is MarkGeometryPath path)
                {
                    Paths.Add(path);
                }
                else if (geometry is MarkGeometryArc arc)
                {
                    Arcs.Add(arc);
                }
                else if (geometry is MarkGeometryCircle circle)
                {
                    Circles.Add(circle);
                }
            }

            Update();
        }
コード例 #7
0
        public virtual void MoveFile(string src, string destination)
        {
            src         = NormalizePath(src);
            destination = NormalizePath(destination);

            Paths.Add(destination, Paths[src]);
            Paths.Remove(src);
        }
コード例 #8
0
        private static void SortStates()
        {
            for (int i = Ciphers.Count - 1; i >= 0; i--)
            {
                if (DKAEndNodes.Contains(Ciphers[i]))
                {
                    Ciphers.Remove(Ciphers[i]);
                    Paths.Remove(Paths[i]);
                }
            }

            string        tempCipher;
            List <string> tempPath;

            for (int i = 0; i < Ciphers.Count; i++)
            {
                for (int j = i + 1; j < Ciphers.Count; j++)
                {
                    if (Convert.ToInt32(Ciphers[i].Split(',')[0]) > Convert.ToInt32(Ciphers[j].Split(',')[0]))
                    {
                        tempCipher = Ciphers[i];
                        Ciphers[i] = Ciphers[j];
                        Ciphers[j] = tempCipher;

                        tempPath = Paths[i];
                        Paths[i] = Paths[j];
                        Paths[j] = tempPath;
                    }
                }
            }

            for (int i = 0; i < DKAEndNodes.Count; i++)
            {
                for (int j = i + 1; j < DKAEndNodes.Count; j++)
                {
                    if (Convert.ToInt32(DKAEndNodes[i]) > Convert.ToInt32(DKAEndNodes[j]))
                    {
                        string tempNode = DKAEndNodes[i];
                        DKAEndNodes[i] = DKAEndNodes[j];
                        DKAEndNodes[j] = tempNode;
                    }
                }
            }

            DKAEndNodes.Add(DKAEndNodes[0]);
            DKAEndNodes.RemoveAt(0);

            Ciphers.AddRange(DKAEndNodes);
            for (int i = 0; i < DKAEndNodes.Count; i++)
            {
                Paths.Add(new List <string>());

                for (int k = 0; k < Labels.Length; k++)
                {
                    Paths[Paths.Count - 1].Add("$");
                }
            }
        }
コード例 #9
0
ファイル: PathsMerge.cs プロジェクト: ydcwd1995/pathplanning
        //行进行先后合并
        public static Paths PathsMergeByOrder(Paths pgs, float m_dis_threshold)
        {
            Paths outPathsList  = new Paths(); //输出合并结果
            Paths tempMergePath = new Paths(); //存储每次hebing输出结果
            Path  eachPath      = new Path();  //存储每一条独立路径

            bool unistate = false;             //合并状态

            for (int i = 0; i < pgs.Count; i++)
            {
                if (pgs[i].Count == 0)         //融合是碰到pg(i)为空
                {
                    if (eachPath.Count > 0)    //如果eachPath内有数据,此条合并结束,重置eachPath
                    {
                        outPathsList.Add(eachPath); eachPath = new Path();
                    }
                }
                else if (eachPath.Count == 0)        //eachPath为空,需要为eachPath赋值一条数据,并退出此次循环
                {
                    eachPath = pgs[i];
                    continue;
                }
                else                                    //均非空,则考虑合并
                {
                    tempMergePath = PathMergeAlong(eachPath, pgs[i], m_dis_threshold, out unistate);
                    if (unistate)
                    {
                        //eachPath.AddRange(tempMergePath[0]);                     //如果可以合并肯定就一条路径
                        eachPath = tempMergePath[0];
                    }
                    else                                              //如果不能合并,切断融合,开始下一条融合
                    {
                        outPathsList.Add(eachPath);
                        eachPath = new Path();
                        eachPath.AddRange(pgs[i]);                 //插入下一条进行初始化
                    }
                }
            }
            if (eachPath.Count > 0)                //跳出循环后如果eachPath非空则插入
            {
                outPathsList.Add(eachPath);
            }

            return(outPathsList);
        }
コード例 #10
0
        /// <summary>
        /// Adds the specified relative path.
        /// </summary>
        /// <param name="relativePath">The relative path.</param>
        /// <param name="file">The file.</param>
        protected virtual void Add(string relativePath, FileInfo file)
        {
            ApacheRuleSet rule = new ApacheRuleSet(relativePath, file);

            Paths.Add(relativePath, rule);

            // start monitoring the rule set
            AddRuleSetMonitoring(relativePath, file.FullName);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: leoggehrer/DevelopTools
        static Program()
        {
            HomePath = (Environment.OSVersion.Platform == PlatformID.Unix ||
                        Environment.OSVersion.Platform == PlatformID.MacOSX)
                       ? Environment.GetEnvironmentVariable("HOME")
                       : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");

            Paths.Add(Path.Combine(HomePath, "Google Drive", "Schule", "CSharp"));
        }
コード例 #12
0
    public void Init()
    {
        if (Load())
        {
            return;
        }

        Paths.Add("Assets");
    }
コード例 #13
0
ファイル: ShxCommandProcessor.cs プロジェクト: ixmilia/shx
        public void ProcessArc(ShxGlyphCommandFractionalArc a)
        {
            var arc = FromArcCommand(a, ref _lastPoint);

            if (_isDrawing)
            {
                Paths.Add(arc);
            }
        }
コード例 #14
0
 void InitializePaths(List <Landmark> landmarks, int nmbrOfLandmarks)
 {
     for (int i = 0; i < this.NmbrOfPaths; i++)
     {
         Path tmp = new Path(nmbrOfLandmarks, landmarks);
         tmp.InitializePath();
         Paths.Add(tmp);
     }
 }
コード例 #15
0
        /// <inheritdoc />
        public Task AddPathAsync(string path)
        {
            if (!Paths.Contains(path))
            {
                Paths.Add(path);
            }

            return(Task.CompletedTask);
        }
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            string      selectedPath = FilesManager.OpenFolderDialog();
            PathElement newPath      = new PathElement {
                FullPath = selectedPath
            };

            Paths.Add(newPath);
        }
コード例 #17
0
        public RelativeValueStoragePath(string path)
        {
            if (path is null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            Paths.Add(path);
        }
コード例 #18
0
        public void AppendPath(params string[] paths)
        {
            if (paths == null || paths.Length == 0)
            {
                return;
            }
            var domainAssemblies    = Domain.GetAssemblies();
            var basePath            = Domain.BaseDirectory;
            var localAssembliesInfo = new ConcurrentBag <AssemblyInfo>();

            foreach (var path in paths)
            {
                lock (_lock)
                {
                    if (Paths.Contains(path, StringComparer.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    Paths.Add(path);
                }
                var localPath     = Path.Combine(basePath, path?.Trim());
                var localExeFiles = Directory.EnumerateFiles(localPath, "*.exe", SearchOption.AllDirectories);
                var localDllFiles = Directory.EnumerateFiles(localPath, "*.dll", SearchOption.AllDirectories);
                var localFiles    = localExeFiles.Concat(localDllFiles);
                Parallel.ForEach(localFiles, file =>
                {
                    var fileName = Path.GetFileName(file);
                    lock (_lock)
                        if (!_ignoreFileNames.Add(fileName))
                        {
                            return;
                        }
                    try
                    {
                        var name = AssemblyName.GetAssemblyName(file);
                        if (IsExcludedAssembly(name.Name))
                        {
                            return;
                        }
                        if (domainAssemblies.All((l, fullName) => l.FullName != fullName, name.FullName) && !Assemblies.Contains(name.FullName))
                        {
                            localAssembliesInfo.Add(new AssemblyInfo(file, name));
                        }
                    }
                    catch (BadImageFormatException)
                    {
                        //
                    }
                    catch (Exception ex)
                    {
                        Core.Log.Write(ex);
                    }
                });
            }
            Assemblies.AddRange(localAssembliesInfo);
            Parallel.ForEach(Assemblies, asm => asm.Preload());
        }
コード例 #19
0
        public void RegisterPath(IPath path)
        {
            if (!PathIsAlreadyRegistered(path))
            {
                LOGGER.Info($"Adding path '{path.Fullname}'");

                Paths.Add(path);
            }
        }
コード例 #20
0
        public void AddPath(string path)
        {
            if (Paths.Contains(path))
            {
                return;
            }

            Paths.Add(path);
        }
コード例 #21
0
        internal static Paths Copy(Paths src)
        {
            var dst = new Paths(src.Capacity);

            foreach (var path in src)
            {
                dst.Add(new Path(path));
            }
            return(dst);
        }
コード例 #22
0
ファイル: Region.cs プロジェクト: migueldeicaza/DrawingSkia
        // An infinite region would cover the entire device region which is the same as
        // not having a clipping region. Note that this is not the same as having an
        // empty region, which when clipping to it has the effect of excluding the entire
        // device region.
        public Region()
        {
            // We set the default region to a very large
            regionObject = infinite;

            var path = RectangleToPath(infinite);

            solution.Add(path);

            regionList.Add(new RegionEntry(RegionType.Infinity, infinite, path));

            regionPath = new CGPath();
            regionPath.MoveToPoint(infinite.Left, infinite.Top);
            regionPath.AddLineToPoint(infinite.Right, infinite.Top);
            regionPath.AddLineToPoint(infinite.Right, infinite.Bottom);
            regionPath.AddLineToPoint(infinite.Left, infinite.Bottom);

            regionBounds = infinite;
        }
コード例 #23
0
        /// <summary>
        /// Adds the value to the <see cref="Paths"/> collection property and
        /// returns this <see cref="ForgetCommand"/> instance.
        /// </summary>
        /// <param name="value">
        /// The value to add to the <see cref="Paths"/> collection property.
        /// </param>
        /// <returns>
        /// This <see cref="ForgetCommand"/> instance.
        /// </returns>
        /// <remarks>
        /// This method is part of the fluent interface.
        /// </remarks>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="value"/> is <c>null</c> or empty.</para>
        /// </exception>
        public CommitCommand WithPath(string value)
        {
            if (StringEx.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentNullException("value");
            }

            Paths.Add(value.Trim());
            return(this);
        }
コード例 #24
0
ファイル: B002MMTPCFileSystem.cs プロジェクト: Stok/EDMSuite
        public B002MMTPCFileSystem()
        {
            Paths.Add("settingsPath", "C:\\Users\\Equipe\\Documents\\EDMSuiteData\\Settings");
            Paths.Add("scanMasterDataPath", "C:\\Users\\Equipe\\Documents\\EDMSuiteData\\Data");
            Paths.Add("fakeData", "C:\\Users\\Equipe\\Documents\\EDMSuiteData\\Fakedata");

            DataSearchPaths.Add(Paths["scanMasterDataPath"]);

            SortDataByDate = true;
        }
コード例 #25
0
        public PHRHENDRIC02FileSystem()
        {
            Paths.Add("settingsPath", "d:\\scanmaster\\settings\\");
            Paths.Add("scanMasterDataPath", "d:\\data\\");
            Paths.Add("fakeData", "d:\\scanmaster\\examples\\");

            DataSearchPaths.Add(Paths["scanMasterDataPath"]);

            SortDataByDate = false;
        }
コード例 #26
0
        //------------------------------------------------------------------------------

        private void AddPolygon(Point pt1, Point pt2, Point pt3)
        {
            Path p = new Path();

            p.Capacity = 3;
            p.Add(pt3);
            p.Add(pt2);
            p.Add(pt1);
            triangles.Add(p);
        }
コード例 #27
0
        public static Paths ClipperPaths(this Polygon this_, float scale)
        {
            Paths paths = new Paths();

            this_.EnumeratePolygons((Polygon eachPolygon) =>
            {
                paths.Add(eachPolygon.ClipperPath(scale));
            });
            return(paths);
        }
コード例 #28
0
        private void PictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Buttons != MouseButtons.Primary || control.Image == null)
            {
                return;
            }

            isDrawing = true;
            Paths.Add(new Path(Pen.Clone(), control.ZoomFactor));
        }
コード例 #29
0
ファイル: PathsFixture.cs プロジェクト: juanplopes/simple
        public void AddingNonNormalizedPathWillNormalizeAndAddItToList()
        {
            var pathStr = @"c:\whatever;d:\omg";

            var path = new Paths(pathStr);

            path.Add("E:/Wtf").Should().Be(@"e:\wtf\");

            path.Should().Have.SameSequenceAs(
                @"c:\whatever", @"d:\omg", @"e:\wtf\");
        }
コード例 #30
0
        public RagnarokFileSystem()
        {
            //Paths.Add("mathPath", "c:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\mathkernel.exe");
            Paths.Add("settingsPath", "d:\\Data\\Settings\\");
            Paths.Add("scanMasterDataPath", "d:\\Data\\CH");
            Paths.Add("fakeData", "d:\\Data\\Examples\\");

            DataSearchPaths.Add(Paths["scanMasterDataPath"]);

            SortDataByDate = false;
        }
コード例 #31
0
        /// <summary>
        /// 将list<>list xyz 转化为 intpoint list<>list
        /// </summary>
        public static Paths Paths_xyzToPaths(Paths_xyz _Paths_xyz)
        {
            Paths _Paths = new Paths();

            foreach (Path_xyz _Path_xyz in _Paths_xyz)
            {
                Path _Path = Path_xyzToPath(_Path_xyz);
                _Paths.Add(_Path);
            }
            return(_Paths);
        }
コード例 #32
0
        public CarmeliteFileSystem()
        {
            Paths.Add("settingsPath", "c:\\experiment control\\");
            Paths.Add("scanMasterDataPath", "c:\\data\\");
            Paths.Add("mathPath", "c:/program files/wolfram research/mathematica/5.1/mathkernel.exe");
            Paths.Add("fakeData", "c:\\data\\examples\\");

            DataSearchPaths.Add(Paths["scanMasterDataPath"]);

            SortDataByDate = false;
        }
コード例 #33
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      internal static Paths Minkowki(Path poly, Path path, bool IsSum, bool IsClosed)
      {
        int delta = (IsClosed ? 1 : 0);
        int polyCnt = poly.Count;
        int pathCnt = path.Count;
        Paths result = new Paths(pathCnt);
        if (IsSum)
          for (int i = 0; i < pathCnt; i++)
          {
            Path p = new Path(polyCnt);
            foreach (IntPoint ip in poly)
              p.Add(new IntPoint(path[i].X + ip.X, path[i].Y + ip.Y));
            result.Add(p);
          }
        else
          for (int i = 0; i < pathCnt; i++)
          {
            Path p = new Path(polyCnt);
            foreach (IntPoint ip in poly)
              p.Add(new IntPoint(path[i].X - ip.X, path[i].Y - ip.Y));
            result.Add(p);
          }

        Paths quads = new Paths((pathCnt + delta) * (polyCnt + 1));
        for (int i = 0; i <= pathCnt - 2 + delta; i++)
          for (int j = 0; j <= polyCnt - 1; j++)
          {
            Path quad = new Path(4);
            quad.Add(result[i % pathCnt][j % polyCnt]);
            quad.Add(result[(i + 1) % pathCnt][j % polyCnt]);
            quad.Add(result[(i + 1) % pathCnt][(j + 1) % polyCnt]);
            quad.Add(result[i % pathCnt][(j + 1) % polyCnt]);
            if (!Orientation(quad)) quad.Reverse();
            quads.Add(quad);
          }

        Clipper c = new Clipper();
        c.AddPaths(quads, PolyType.ptSubject, true);
        c.Execute(ClipType.ctUnion, result, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
        return result;
      }
コード例 #34
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      private void BuildResult(Paths polyg)
      {
          polyg.Clear();
          polyg.Capacity = m_PolyOuts.Count;
          for (int i = 0; i < m_PolyOuts.Count; i++)
          {
              OutRec outRec = m_PolyOuts[i];
              if (outRec.Pts == null) continue;
              OutPt p = outRec.Pts;
              int cnt = PointCount(p);
              if (cnt < 2) continue;
              Path pg = new Path(cnt);
              for (int j = 0; j < cnt; j++)
              {
                  pg.Add(p.Pt);
                  p = p.Prev;
              }
              polyg.Add(pg);
          }
      }
コード例 #35
0
        void calculateRegionPath(ClipType clipType)
        {
            Clipper c = new Clipper();

            var subjects = solution;
            //subjects.Add (solution);

            var clips = new Paths ();

            foreach (var path in regionList [regionList.Count - 1].regionPath)
                clips.Add (path);

            c.AddPolygons(subjects, PolyType.ptSubject);
            c.AddPolygons(clips, PolyType.ptClip);

            solution.Clear();

            bool succeeded = c.Execute(clipType, solution, SUBJ_FILL_TYPE, CLIP_FILL_TYPE);

            if (succeeded)
            {
                PathsToInternalPath (solution);

                // Not sure what this is returning
            //				var bounds = c.GetBounds ();
            //				regionBounds.X = bounds.left / scale;
            //				regionBounds.Y = bounds.top / scale;
            //				regionBounds.Width = (bounds.right - bounds.left) / scale;
            //				regionBounds.Height = (bounds.bottom - bounds.top) / scale;

                if (regionPath.IsEmpty)
                    regionBounds = RectangleF.Empty;
                else
                    regionBounds = regionPath.BoundingBox;

            }
        }
コード例 #36
0
ファイル: Program.cs プロジェクト: vuhoangminh/smartd
        ////////////////////////////////////////////////

        static bool LoadFromFile(string filename, Paths ppg, int dec_places, int xOffset = 0, int yOffset = 0)
        {
            double scaling;
            scaling = Math.Pow(10, dec_places);

            ppg.Clear();
            if (!File.Exists(filename)) return false;
            StreamReader sr = new StreamReader(filename);
            if (sr == null) return false;
            string line;
            if ((line = sr.ReadLine()) == null) return false;
            int polyCnt, vertCnt;
            if (!Int32.TryParse(line, out polyCnt) || polyCnt < 0) return false;
            ppg.Capacity = polyCnt;
            for (int i = 0; i < polyCnt; i++)
            {
                if ((line = sr.ReadLine()) == null) return false;
                if (!Int32.TryParse(line, out vertCnt) || vertCnt < 0) return false;
                Path pg = new Path(vertCnt);
                ppg.Add(pg);
                if (scaling > 0.999 & scaling < 1.001)
                    for (int j = 0; j < vertCnt; j++)
                    {
                        Int64 x, y;
                        if ((line = sr.ReadLine()) == null) return false;
                        char[] delimiters = new char[] { ',', ' ' };
                        string[] vals = line.Split(delimiters);
                        if (vals.Length < 2) return false;
                        if (!Int64.TryParse(vals[0], out x)) return false;
                        if (!Int64.TryParse(vals[1], out y))
                            if (vals.Length < 2 || !Int64.TryParse(vals[2], out y)) return false;
                        x = x + xOffset;
                        y = y + yOffset;
                        pg.Add(new IntPoint(x, y));
                    }
                else
                    for (int j = 0; j < vertCnt; j++)
                    {
                        double x, y;
                        if ((line = sr.ReadLine()) == null) return false;
                        char[] delimiters = new char[] { ',', ' ' };
                        string[] vals = line.Split(delimiters);
                        if (vals.Length < 2) return false;
                        if (!double.TryParse(vals[0], out x)) return false;
                        if (!double.TryParse(vals[1], out y))
                            if (vals.Length < 2 || !double.TryParse(vals[2], out y)) return false;
                        x = x * scaling + xOffset;
                        y = y * scaling + yOffset;
                        pg.Add(new IntPoint((Int64)Math.Round(x), (Int64)Math.Round(y)));
                    }
            }
            return true;
        }
コード例 #37
0
        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);

            }
        }
コード例 #38
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      public static Paths OffsetPaths(Paths polys, double delta,
          JoinType jointype, EndType endtype, double MiterLimit)
      {
        Paths out_polys = new Paths(polys.Count);
        IntPoint botPt = new IntPoint();
        IntPoint pt;
        int botIdx = -1;
        for (int i = 0; i < polys.Count; ++i)
        {
          out_polys.Add(new Path());
          if (StripDupsAndGetBotPt(polys[i], out_polys[i], endtype == EndType.etClosed, out pt))
            if (botIdx < 0 || pt.Y > botPt.Y || (pt.Y == botPt.Y && pt.X < botPt.X))
            {
              botPt = pt;
              botIdx = i;
            }
        }
        if (endtype == EndType.etClosed && botIdx >= 0 && !Orientation(out_polys[botIdx]))
          ReversePaths(out_polys);

        Paths result;
        new PolyOffsetBuilder(out_polys, out result, delta, jointype, endtype, MiterLimit);
        return result;
      }
コード例 #39
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      internal static void AddPolyNodeToPaths(PolyNode polynode, NodeType nt, Paths paths)
      {
        bool match = true;
        switch (nt)
        {
          case NodeType.ntOpen: return;
          case NodeType.ntClosed: match = !polynode.IsOpen; break;
          default: break;
        }

        if (polynode.Contour.Count > 0 && match) 
          paths.Add(polynode.Contour);
        foreach (PolyNode pn in polynode.Childs)
          AddPolyNodeToPaths(pn, nt, paths);
      }
コード例 #40
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      public static Paths OpenPathsFromPolyTree(PolyTree polytree)
      {
        Paths result = new Paths();
        result.Capacity = polytree.ChildCount;
        for (int i = 0; i < polytree.ChildCount; i++)
          if (polytree.Childs[i].IsOpen)
            result.Add(polytree.Childs[i].Contour);
        return result;
      }
コード例 #41
0
ファイル: PathsFixture.cs プロジェクト: juanplopes/simple
        public void CanGetPathStringFromPathList()
        {
            var path = new Paths("");
            path.Add(@"c:\a");
            path.Add(@"d:\b");
            path.Add(@"e:/C");

            path.ToString().Should().Be(@"c:\a\;d:\b\;e:\c\");
        }
コード例 #42
0
ファイル: clipper.cs プロジェクト: CharlesTaylor95/clipper
      //------------------------------------------------------------------------------

      public static Paths CleanPolygons(Paths polys,
          double distance = 1.415)
      {
          Paths result = new Paths(polys.Count);
          for (int i = 0; i < polys.Count; i++)
              result.Add(CleanPolygon(polys[i], distance));
          return result;
      }