Example #1
0
        public override void OnMouseMove(float x, float y)
        {
            if ((!IsPointSelected) && (!_isBeaconRadiusSelected))
            {
                foreach (var beacon in _beacons.Where(beacon => IsOverPoint(beacon, x, y)))
                {
                    IsPointSelected = true;
                    SelectedPoint   = beacon;
                    break;
                }

                foreach (var beacon in _beacons.Where(beacon => IsOverBeaconAccuracyRadius(beacon, x, y)))
                {
                    _isBeaconRadiusSelected = true;
                    SelectedPoint           = beacon;
                    break;
                }
            }
            else
            {
                if (Dragging)
                {
                    SelectedPoint.RefreshPosition(x - ShiftX, y - ShiftY, MetersToPixels);
                    NeedToRecalculate.Invoke(this, null);
                }
                else if (_changingAccuracy)
                {
                    var beacon = SelectedPoint as Beacon;
                    if (beacon != null)
                    {
                        beacon.RefreshAccuracy(x - ShiftX, y - ShiftY, MetersToPixels);
                    }
                    NeedToRecalculate.Invoke(this, null);
                }

                if (IsNotOverSelectedPoint(x, y))
                {
                    IsPointSelected = false;
                }

                if (IsNotOverSelectedBeaconAccuracyRadius(x, y))
                {
                    _isBeaconRadiusSelected = false;
                }
            }

            Draw();
        }
Example #2
0
        public override bool CheckIfTheObjectIsClicked(Point point)
        {
            const int delta = 20;

            if (point.X < StartPoint.X + delta && point.X > StartPoint.X - delta &&
                point.Y < StartPoint.Y + delta && point.Y > StartPoint.Y - delta)
            {
                selectPoint = SelectedPoint.StartPoint;
                return(true);
            }
            if (point.X < EndPoint.X + delta && point.X > EndPoint.X - delta &&
                point.Y < EndPoint.Y + delta && point.Y > EndPoint.Y - delta)
            {
                selectPoint = SelectedPoint.EndPoint;
                return(true);
            }
            return(false);
        }
Example #3
0
        public override void Visit(NBox component)
        {
            component.IsCloseEnough = false;

            for (int i = 0; i < component.ConnectPoints.Length; i++)
            {
                double d = NMathHelper.Distance(SelectedPoint, component.ConnectPoints[i]);
                if (d <= NConfig.CONNECT_DISTANCE)
                {
                    component.IsCloseEnough = true;
                    if (Connect)
                    {
                        if (Connector.Model.StartPoint == SelectedPoint)
                        {
                            Connector.StartBox            = component;
                            Connector.Model.StartBoxIndex = i;
                            Connector.Model.StartBoxID    = component.Model.ID;
                        }
                        else
                        {
                            Connector.EndBox            = component;
                            Connector.Model.EndBoxIndex = i;
                            Connector.Model.EndBoxID    = component.Model.ID;
                        }
                        SelectedPoint.Set(component.ConnectPoints[i]);


                        PathResolver.Connector  = Connector;
                        PathResolver.StartPoint = Connector.Model.StartPoint;
                        PathResolver.EndPoint   = Connector.Model.EndPoint;

                        PathResolver.RebuildGraph();
                        PathResolver.Resolve();

                        return;
                    }
                }
            }
        }