Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>Whether any SRs suitable for heartbeating were found.</returns>
        internal bool ScanForHeartbeatSRs()
        {
            System.Diagnostics.Trace.Assert(pool != null);

            // Start action and show progress with a dialog
            GetHeartbeatSRsAction action = new GetHeartbeatSRsAction(pool);

            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }
            if (action.Cancelled || action.Cancelling || !action.IsCompleted)
            {
                return(false);
            }

            if (!action.Succeeded || action.SRs.Count == 0)
            {
                dataGridViewExSRs.Enabled = false;
                return(true);
            }

            dataGridViewExSRs.Enabled = true;

            List <SRWrapper> srs = action.SRs;

            srs.Sort((a, b) => a.enabled != b.enabled
                                   ? b.enabled.CompareTo(a.enabled)
                                   : (a.sr.NameWithoutHost.CompareTo(b.sr.NameWithoutHost)));

            dataGridViewExSRs.Rows.Clear();

            foreach (SRWrapper srWrapper in srs)
            {
                var row = new StorageRow(srWrapper);
                dataGridViewExSRs.Rows.Add(row);
                row.Enabled = srWrapper.enabled;

                // coming forward to this page after having already been through it once
                if (selectedHeartbeatSR != null && srWrapper.sr.opaque_ref == selectedHeartbeatSR.opaque_ref)
                {
                    if (srWrapper.enabled)
                    {
                        row.Selected = true;
                    }
                    else
                    {
                        selectedHeartbeatSR = null;
                        OnPageUpdated();
                    }
                }
            }

            return(true);
        }
        public static bool TryFindIntersectingNodeLink(this Map map, StorageRow storageRow, [NotNullWhen(true)] out NodeLink?nodeLink, out LineSegment2D lineFromStorageRowToIntersection)
        {
            map        = map.MustNotBeNull(nameof(map));
            storageRow = storageRow.MustNotBeNull(nameof(storageRow));

            nodeLink = null;
            lineFromStorageRowToIntersection = default;
            if (map.NodeLinks.Count == 0)
            {
                return(false);
            }

            var perpendicularRay = storageRow.GetPerpendicularRay();
            var shortestDistance = default(double?);

            foreach (var link in map.NodeLinks)
            {
                if (!link.TryGetLineSegment(out var linkLineSegment))
                {
                    continue;
                }

                var intersection = perpendicularRay.LineEquation.CalculateIntersection(linkLineSegment.LineEquation);
                if (intersection == null || !perpendicularRay.IsPointOnRay(intersection.Value) || !linkLineSegment.IsPointOnLineSegment(intersection.Value))
                {
                    continue;
                }

                var distance = perpendicularRay.ReferencePoint.CalculateMagnitude(intersection.Value);
                if (shortestDistance != null && shortestDistance.Value < distance)
                {
                    continue;
                }

                shortestDistance = distance;
                nodeLink         = link;
                lineFromStorageRowToIntersection = new LineSegment2D(perpendicularRay.ReferencePoint, intersection.Value);
            }

            return(nodeLink != null);
        }
Esempio n. 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns>Whether any SRs suitable for heartbeating were found.</returns>
        internal bool ScanForHeartbeatSRs()
        {
            System.Diagnostics.Trace.Assert(pool != null);

            // Start action and show progress with a dialog
            GetHeartbeatSRsAction action = new GetHeartbeatSRsAction(pool);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);
            if (dialog.action.Cancelled || dialog.action.Cancelling || !dialog.action.IsCompleted)
                return false;

            if (!action.Succeeded || action.SRs.Count == 0)
            {
                dataGridViewExSRs.Enabled = false;
                return true;
            }

            dataGridViewExSRs.Enabled = true;

            List<SRWrapper> srs = action.SRs;
            srs.Sort((a, b) => a.enabled != b.enabled
                                   ? b.enabled.CompareTo(a.enabled)
                                   : (a.sr.NameWithoutHost.CompareTo(b.sr.NameWithoutHost)));

            dataGridViewExSRs.Rows.Clear();

            foreach (SRWrapper srWrapper in srs)
            {
                var row = new StorageRow(srWrapper);
                dataGridViewExSRs.Rows.Add(row);
                row.Enabled = srWrapper.enabled;

                // coming forward to this page after having already been through it once
                if (selectedHeartbeatSR != null && srWrapper.sr.opaque_ref == selectedHeartbeatSR.opaque_ref)
                {

                    if (srWrapper.enabled)
                        row.Selected = true;
                    else
                    {
                        selectedHeartbeatSR = null;
                        OnPageUpdated();
                    }
                }
            }

            return true;
        }