public void Enqueue(Point[] points)
        {
            if (!points.Any())
            {
                return;
            }

            if (_timer == null)
            {
                //TODO: Fire!
                //OnSendBusinessEvent(this, new SendBusinessEventArgs(null, "The engine that sends data to the database is not enabled. Probably becuse the FlushSecondsInterval has not been configured.", points.Length, OutputLevel.Error));
                return;
            }

            if (!_timer.Enabled)
            {
                _timer.Start();
            }

            //Prepare metadata information about the queue and add that to the points to be sent.
            if (_metadata)
            {
                var metaPoints = _dataSenders.Select(x => MetaDataBusiness.GetQueueCountPoints("Enqueue", x.TargetServer, x.TargetDatabase, x.QueueCount, points.Length + _dataSenders.Count, new SendResponse(null, null))).ToArray();
                points = points.Union(metaPoints).ToArray();
            }

            foreach (var dataSender in _dataSenders)
            {
                dataSender.Enqueue(points);
            }
        }
Example #2
0
        public void Enqueue(Point[] points)
        {
            if (!points.Any())
            {
                return;
            }

            if (!_timer.Enabled)
            {
                _timer.Start();
            }

            lock (_syncRoot)
            {
                _queue.Enqueue(points);
            }
        }
Example #3
0
    private string[] TestPaths(Point from, Point to, int distance, Point[] rocks)
    {
        Console.Error.WriteLine("TestPaths for " + from + " from " + from.Position);

        if (rocks.Any(rock => rock.X == from.X && rock.Y == from.Y))
        {
            Console.Error.WriteLine("Indy would be hit by a rock at " + from);
            return null;
        }

        if (from.X == to.X && from.Y == to.Y)
            return new string[0];

        var thisRoomType = RoomTypeAt(from);
        var exitDirection = nextStepOf(thisRoomType, from.Position);
        Console.Error.WriteLine("\tExiting to " + exitDirection);
        var nextRoom = from + exitDirection;
        if (!IsInsideMap(nextRoom))
            return null;

        string[] path = null;
        var testedDirections = new List<Direction>();

        //No rotation
        path = PathWithRotation(nextRoom, 0, to, distance + 1, testedDirections, rocks);
        if (path != null)
            return path;

        var isNextRoomLocked = nextRoom == to || IsRoomLockedAt(nextRoom);
        if (!isNextRoomLocked)
        {
            //Rotate left
            path = PathWithRotation(nextRoom, 1, to, distance, testedDirections, rocks);
            if (path != null)
                return new[] { nextRoom + " LEFT" }.Concat(path).ToArray();

            //Rotate right
            path = PathWithRotation(nextRoom, 3, to, distance, testedDirections, rocks);
            if (path != null)
                return new[] { nextRoom + " RIGHT" }.Concat(path).ToArray();

            if (distance > 1)
            {
                //Rotate 180
                path = PathWithRotation(nextRoom, 2, to, distance, testedDirections, rocks);
                if (path != null)
                    return new[] { nextRoom + " LEFT", nextRoom + " LEFT" }.Concat(path).ToArray();
            }
        }

        Console.Error.WriteLine("This path has no solution");
        return null;
    }
Example #4
0
        /// <summary>
        /// Returns the initial System.Drawing.Point of the
        /// given DepartmentInfo
        /// </summary>
        private Point CalculateInitialPoint(Point[] coords)
        {
            int minX = WIDTH;
            int minY = HEIGHT;
            int maxX = 0;
            int maxY = 0;

            foreach (Point item in coords)
            {
                minX = Math.Min(minX, item.X);
                minY = Math.Min(minY, item.Y);
                maxX = Math.Max(maxX, item.X);
                maxY = Math.Max(maxY, item.Y);
            }

            int avgX = (maxX + minX) / 2;
            int avgY = (maxY + minY) / 2;

            Point initialPoint = new Point(avgX, avgY);

            /* If the average point is not in the area
             * of the department, the first - hand
             * gathered - coordinate will be chosen.
             * This is most times near the center.
             */
            if (!coords.Any(p => p.Equals(initialPoint)))
                initialPoint = coords[0];
            return initialPoint;
        }
Example #5
0
        public void CellPosition(CellClass c)
        {
            var b = c.Bounds2D;

            b.Offset(-ScreenArea.Left, -ScreenArea.Top);

            var pointsToCheck = new Point[] {
                new Point(b.Left, b.Top),
                new Point(b.Left, b.Bottom),
                new Point(b.Right, b.Top),
                new Point(b.Right, b.Bottom),
            };

            if (pointsToCheck.Any(p => ScreenBounds.Contains(p))) {
                var tl = c.TileDimensions;
                c.TacticalPosition = new CellStruct(b.Left - tl.Left, b.Top - tl.Top);
                c.VisibleInTactical = true;
                return;
            }

            c.TacticalPosition = new CellStruct();
            c.VisibleInTactical = false;
            return;
        }
        //Allow the user to import an array of points to be used to draw a signature in the view, with new
        //lines indicated by a PointF.Empty in the array.
        public void LoadPoints(Point [] loadedPoints)
        {
            if (!loadedPoints.Any())
            {
                return;
            }

            //Clear any existing paths or points.
            points = new List<List<Point>>();

            foreach (Point pt in loadedPoints)
            {
                this.inkPresenter.Children.Add(
                  new Line()
                  {
                      X1 = previousPosition.X,
                      Y1 = previousPosition.Y,
                      X2 = pt.X,
                      Y2 = pt.Y,
                      Stroke = this.Stroke,
                      StrokeThickness = this.StrokeWidth
                  }
                );
                previousPosition = pt;
            }

            points.Last().AddRange(loadedPoints);
            ////Obtain the image for the imported signature and display it in the image view.
            //image.Source = GetImage (false);
            ////Display the clear button.
            clearText.Visibility = Visibility.Visible;

            UpdateBitmapBuffer(); //Update the BitmapBuffer
        }
Example #7
0
        public static Display ByPointsColors(Point[] points, Color[] colors)
        {
            if(points == null)
            {
                throw new ArgumentNullException("points");
            }

            if (!points.Any())
            {
                throw new ArgumentException(Resources.NoVertexExceptionMessage, "points");
            }

            if (points.Count() %3 != 0)
            {
                throw new ArgumentException(Resources.VerticesDivisibleByThreeExceptionMessage);
            }

            if(colors == null)
            {
                throw new ArgumentNullException("colors");
            }

            if (!colors.Any())
            {
                throw new ArgumentException(Resources.NoColorsExceptionMessage, "colors");
            }

            if (colors.Count() != points.Count())
            {
                throw new ArgumentException(Resources.VertexColorCountMismatchExceptionMessage, "colors");
            }

            return new Display(points, colors);
        }