Пример #1
0
        public async Task <RdbNets> RotateAround(
            RdbNets nets,
            Point pivot,
            float angle,
            BackgroundWorker bgw)
        {
            BackgroundWorker = bgw;
            NumberOfEntries  = nets.Nets.SelectMany(net => net.pins).Count();
            Index            = 0;
            int oldPercent = 0;
            int newPercent = 0;

            foreach (var net in nets.Nets)
            {
                var newPins = new List <Pin>();
                foreach (var pin in net.pins)
                {
                    var point = new Point
                    {
                        X = pin.x,
                        Y = pin.y
                    };
                    if (pin.name != "_")
                    {
                        point =
                            _movePoint.RotateAround(point, pivot, angle);
                    }

                    newPins.Add(new Pin
                    {
                        name = pin.name,
                        x    = point.X,
                        y    = point.Y
                    });
                    Index++;

                    oldPercent = newPercent;
                    newPercent = (Index * 100) / NumberOfEntries;
                    BackgroundWorker.ReportProgress(newPercent, (int)1);
                    if (newPercent > oldPercent)
                    {
                        Thread.Sleep(5);
                    }
                }
                net.pins = newPins;
            }

            BackgroundWorker.ReportProgress(newPercent);
            if (newPercent > oldPercent)
            {
                Thread.Sleep(1);
            }

            nets.UpdateCentroid();

            BackgroundWorker.ReportProgress(100);
            Thread.Sleep(1);

            return(nets);
        }
Пример #2
0
        public RdbNets Get(string fileName)
        {
            var nets    = _readRdb.Read(fileName);
            var rdbNets = new RdbNets
            {
                fileName = fileName,
                Nets     = nets
            };

            rdbNets.UpdateCentroid();

            return(rdbNets);
        }