Exemple #1
0
        public bool IsExitable(Bitmap b)
        {
            var darkPixels  = new Point[] { new Point(3788, 1998), new Point(3789, 2008), new Point(3776, 2013), new Point(3790, 2023), new Point(3787, 2034), new Point(3857, 1996), new Point(3850, 2013) };
            var lightPixles = new Point[] { new Point(3790, 2002), new Point(3781, 2013), new Point(3789, 2015), new Point(3782, 2029), new Point(3815, 2016), new Point(3857, 2003) };

            if (darkPixels.Any(p =>
            {
                var pixel = b.GetPixel(p.X, p.Y);
                if (pixel.R > 100 || pixel.G > 100 || pixel.G > 100)
                {
                    return(true);
                }
                return(false);
            }))
            {
                return(false);
            }
            if (lightPixles.Any(p =>
            {
                var pixel = b.GetPixel(p.X, p.Y);
                if (pixel.R < 180 || pixel.G < 180 || pixel.G < 180)
                {
                    return(true);
                }
                return(false);
            }))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
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;
        }
        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);
            }
        }
Exemple #4
0
        public bool IsChatOpen(Bitmap screen)
        {
            var lightPixels = new Point[] { new Point(147, 617), new Point(154, 617), new Point(170, 612), new Point(175, 629), new Point(153, 634) };
            var darkPixels  = new Point[] { new Point(151, 608), new Point(154, 630), new Point(170, 630), new Point(172, 608), new Point(162, 609) };

            return(!lightPixels.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value <= 0.5f) &&
                   !darkPixels.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value >= 0.5f));
        }
        public bool IsPromptOpen(Bitmap screen)
        {
            var lightPixels = new Point[] { new Point(2021, 1231), new Point(2031, 1218), new Point(2042, 1230), new Point(2031, 1245), new Point(2053, 1217), new Point(2057, 1231), new Point(2053, 1245), new Point(2069, 1217), new Point(2070, 1245) };
            var darkPixels  = new Point[] { new Point(2031, 1231), new Point(2060, 1218), new Point(2071, 1230), new Point(2060, 1243), new Point(2045, 1218), new Point(2045, 1245) };

            return(!lightPixels.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value <= 0.5f) &&
                   !darkPixels.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value >= 0.5f));
        }
Exemple #6
0
        private bool IsLoginScreen(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(2885, 1324), new Point(2913, 1347), new Point(2928, 1325), new Point(2960, 1339), new Point(3005, 1346) };
            var darkPixels  = new Point[] { new Point(2878, 1336), new Point(2894, 1335), new Point(2921, 1335), new Point(2951, 1328), new Point(2994, 1346) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #7
0
        private bool IsDailyRewardScreenItem(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(2706, 1875), new Point(2743, 1897), new Point(2776, 1897), new Point(2830, 1873), new Point(2956, 1885) };
            var darkPixels  = new Point[] { new Point(2766, 1894), new Point(2868, 1875), new Point(2963, 1879), new Point(3038, 1889), new Point(3162, 1885) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #8
0
        private bool IsGlyphScreen(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(1953, 118), new Point(1983, 175), new Point(2045, 147), new Point(2118, 135), new Point(2185, 170) };
            var darkPixels  = new Point[] { new Point(1928, 142), new Point(1989, 163), new Point(2045, 119), new Point(2099, 133), new Point(2162, 159) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #9
0
        private bool IsMainMenu(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(554, 959), new Point(650, 975), new Point(680, 933), new Point(778, 950), new Point(810, 977) };
            var darkPixels  = new Point[] { new Point(568, 942), new Point(626, 972), new Point(700, 948), new Point(771, 939), new Point(902, 956) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #10
0
        private bool IsProfileMenu(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(569, 929), new Point(585, 956), new Point(659, 980), new Point(673, 926), new Point(760, 951) };
            var darkPixels  = new Point[] { new Point(571, 957), new Point(647, 953), new Point(694, 932), new Point(749, 940), new Point(810, 932) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #11
0
        private bool IsWarframeControl(Bitmap bitmap)
        {
            var miniProfileIconPoints  = new Point[] { new Point(198, 172), new Point(208, 171), new Point(218, 170), new Point(228, 173), new Point(238, 174), new Point(248, 170) };
            var largeProfileIconPoints = new Point[] { new Point(196, 194), new Point(206, 199), new Point(216, 195), new Point(226, 196), new Point(236, 197), new Point(246, 198) };

            return(!miniProfileIconPoints.Any(p => { var pixel = bitmap.GetPixel(p.X, p.Y); return pixel.R >= 178 && pixel.R <= 198 && pixel.G >= 155 && pixel.G <= 175 && pixel.B >= 91 && pixel.B <= 111; }) &&
                   !largeProfileIconPoints.Any(p => { var pixel = bitmap.GetPixel(p.X, p.Y); return pixel.R >= 178 && pixel.R <= 198 && pixel.G >= 155 && pixel.G <= 175 && pixel.B >= 91 && pixel.B <= 111; }));
        }
Exemple #12
0
        private bool IsDailyRewardScreenPlat(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(3265, 1939), new Point(3291, 1964), new Point(3325, 1958), new Point(3347, 1963), new Point(3383, 1942) };
            var darkPixels  = new Point[] { new Point(3271, 1951), new Point(3300, 1950), new Point(3325, 1964), new Point(3373, 1941), new Point(3381, 1964) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value < 0.65f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value > 0.4f));
        }
Exemple #13
0
        public bool GlyphFiltersPresent(Bitmap bitmap)
        {
            var lightPixels = new Point[] { new Point(367, 256), new Point(401, 275), new Point(427, 257), new Point(440, 272), new Point(456, 255) };
            var darkPixels  = new Point[] { new Point(369, 261), new Point(395, 271), new Point(419, 264), new Point(447, 251), new Point(460, 265) };

            return(!lightPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value <= 0.5f) &&
                   !darkPixels.Any(p => bitmap.GetPixel(p.X, p.Y).ToHsv().Value >= 0.5f));
        }
Exemple #14
0
        private bool IsLoadingScreen(Bitmap bitmap)
        {
            var warframeLogoPoints    = new Point[] { new Point(1885, 1964), new Point(1956, 1973), new Point(2003, 2000), new Point(2022, 1985), new Point(2080, 1970), new Point(2116, 2003), new Point(2122, 1977), new Point(2209, 2003) };
            var notWarframeLogoPoints = new Point[] { new Point(1900, 1969), new Point(1927, 1968), new Point(1956, 1999), new Point(1994, 1977), new Point(2037, 1996), new Point(2069, 1977), new Point(2100, 1996) };
            var warframePointsPresent = !warframeLogoPoints.Any(p => bitmap.GetPixel(p.X, p.Y).GetBrightness() < 0.95);
            var notWarframePointsDark = notWarframeLogoPoints.Select(p => bitmap.GetPixel(p.X, p.Y).GetBrightness()).Average() < 0.9;

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

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

            lock (_syncRoot)
            {
                _queue.Enqueue(points);
            }
        }
Exemple #16
0
        public static Point[] GenerateRandomPoints(int n, int?pointRadius = null)
        {
            Random random = new Random();

            Point[] points = new Point[n];

            int index = 0;

            while (true)
            {
                if (index == n)
                {
                    break;
                }

                int    k      = random.Next(1, n + 1);
                int    m      = random.Next(1, n + 1);
                double radius = (double)k / n;
                double angle  = (double)2 * Math.PI * m / n;

                if (!points.Any(p => p?.Angle == angle && p?.Radius == radius))
                {
                    Point point = new Point
                    {
                        Radius  = radius,
                        Angle   = angle,
                        Ellipse = new Ellipse()
                    };

                    if (pointRadius != null)
                    {
                        point.Ellipse.Width  = (double)pointRadius;
                        point.Ellipse.Height = (double)pointRadius;
                        point.Ellipse.Fill   = Brushes.Red;
                    }

                    points[index] = point;
                    index++;
                }
            }

            return(points);
        }
        public bool IsExitable(Bitmap b)
        {
            var exitDarkPixels  = new Point[] { new Point(3788, 1998), new Point(3789, 2008), new Point(3776, 2013), new Point(3790, 2023), new Point(3787, 2034), new Point(3857, 1996), new Point(3850, 2013) };
            var exitLightPixels = new Point[] { new Point(3790, 2002), new Point(3781, 2013), new Point(3789, 2015), new Point(3782, 2029), new Point(3815, 2016), new Point(3857, 2003) };
            var isExitButton    = !exitDarkPixels.Any(p => b.GetPixel(p.X, p.Y).ToHsv().Value >= 0.4) &&
                                  !exitLightPixels.Any(p => b.GetPixel(p.X, p.Y).ToHsv().Value <= 0.6);

            if (isExitButton)
            {
                return(true);
            }

            var closeDarkPixels  = new Point[] { new Point(3744, 2014), new Point(3773, 2015), new Point(3799, 2016), new Point(3829, 2009), new Point(3828, 2023), new Point(3860, 2008), new Point(3860, 2023) };
            var closeLightPixels = new Point[] { new Point(3735, 2015), new Point(3765, 2003), new Point(3764, 2029), new Point(3777, 2029), new Point(3792, 2006), new Point(3836, 2027), new Point(3858, 2015) };
            var isCloseButton    = !closeDarkPixels.Any(p => b.GetPixel(p.X, p.Y).ToHsv().Value >= 0.6) && //Noisy background may be pretty bright
                                   !closeLightPixels.Any(p => b.GetPixel(p.X, p.Y).ToHsv().Value <= 0.85); //Be stricter on white/light pixels to account for background

            return(isExitButton || isCloseButton);
        }
Exemple #18
0
        public bool IsChatCollapsed(Bitmap screen)
        {
            //Already moved down pixels
            var lightPixelsLower    = new Point[] { new Point(151, 2115), new Point(158, 2136), new Point(166, 2115), new Point(173, 2124), new Point(171, 2136) };
            var darkPixelsLower     = new Point[] { new Point(156, 2120), new Point(168, 2131), new Point(172, 2110), new Point(146, 2118), new Point(176, 2133) };
            var isLowerAndCollapsed = !lightPixelsLower.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value <= 0.3f) &&
                                      !darkPixelsLower.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value >= 0.15f);

            if (isLowerAndCollapsed)
            {
                return(true);
            }

            //Not yet moved down pixels
            var lightPixelsHigher    = lightPixelsLower.Select(p => new Point(p.X, p.Y - 27));
            var darkPixelsHigher     = darkPixelsLower.Select(p => new Point(p.X, p.Y - 27));
            var isHigherAndCollapsed = !lightPixelsHigher.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value <= 0.3f) &&
                                       !darkPixelsHigher.Any(p => screen.GetPixel(p.X, p.Y).ToHsv().Value >= 0.15f);

            return(isLowerAndCollapsed || isHigherAndCollapsed);
        }
        private void RestoreSavedPosition()
        {
            if (SettingsManager.Current.DisplaySettings.LastPosition != default)
            {
                var savedBounds = SettingsManager.Current.DisplaySettings.LastPosition;
                var tlCorner    = SettingsManager.Current.DisplaySettings.LastPosition.Location;
                var trCorner    = new Point(savedBounds.Right, savedBounds.Top);
                var blCorner    = new Point(savedBounds.Left, savedBounds.Bottom);
                var brCorner    = new Point(savedBounds.Right, savedBounds.Bottom);
                var corners     = new Point[] { tlCorner, trCorner, blCorner, brCorner };

                var screen = Screen.FromPoint(tlCorner);

                if (screen != null && corners.Any(x => screen.Bounds.Contains(x)))
                {
                    Bounds = savedBounds;
                    if (SettingsManager.Current.DisplaySettings.IsMaximized)
                    {
                        WindowState = FormWindowState.Maximized;
                    }
                }
            }
        }
Exemple #20
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;
    }
Exemple #21
0
    public static void Main(string[] args)
    {
        bool inError = false;

        string[] xs = args[0].Replace("\"", string.Empty).Split(',');
        string[] ys = args[1].Replace("\"", string.Empty).Split(',');

        error |= (xs.Length != ys.Length);
        error |= (xs.Length < 3);

        // Checking data
        Point[] points = new Point[xs.Length];
        for (int i = 0; i < points.Length && !error; i++)
        {
            int x = 0, y = 0;

            error |= !(int.TryParse(xs[i], out x));
            error |= !(int.TryParse(ys[i], out y));

            points[i] = new Point {
                X = x, Y = y
            };
        }

        if (error)
        {
            ErrorAndExit();
        }

        List <Point> convexHull = new List <Point>();

        // Algorithm start (Jarvis' Algorithm)
        int   minX     = points.Min(pt => pt.X);
        Point leftmost = points.First(pt => pt.X == minX);         // I don't care if there are more than one

        convexHull.Add(leftmost);

        // Jarvis' Algorithm states that to determine the next point in the convex hull you need
        // to find the rightmost point, compared to the last one identified.
        // i.e. given P the last point and Q the one in exam, there is no point R in the remaining
        // set that creates a clockwise triangle PQR
        Point p          = leftmost;
        Point nextInHull = null;

        while (true)
        {
            nextInHull = null;
            foreach (Point q in points)
            {
                if (q == p)
                {
                    continue;
                }

                // if I find at least one point clockwise, then it's not the rightmost one
                if (points.Any(r =>
                {
                    if (r == q || r == p)
                    {
                        return(false);
                    }
                    return(IsClockwise(p, q, r));
                }))
                {
                    continue;
                }

                nextInHull = q;
                break;                 // I found the right one, just stop here
            }

            if (nextInHull != leftmost)
            {
                convexHull.Add(nextInHull);
                p = nextInHull;
            }
            else
            {
                break;
            }
        }

        Console.WriteLine("Convex Hull:");
        foreach (Point pt in convexHull)
        {
            Console.WriteLine("({0}, {1})", pt.X, pt.Y);
        }

        Console.ReadKey();
    }
Exemple #22
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);
        }
        //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
        }
Exemple #24
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;
        }
Exemple #25
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;
        }
Exemple #26
0
        private bool IsRiven(Bitmap bitmap)
        {
            var purplePixelAnchors = new Point[] { new Point(1831, 1160), new Point(2262, 1160), new Point(2262, 459), new Point(2337, 1061), new Point(1815, 432), new Point(2338, 896) };

            return(!purplePixelAnchors.Any(p => !IsPurple(bitmap.GetPixel(p.X, p.Y))));
        }