Esempio n. 1
0
        public void ExploreArea(Bitmap source, Bitmap newBitmap, int x, int y, CleanMode cleanMode)
        {
            var area = new List <(int, int, Color)>();

            area.Add((x, y, source.GetPixel(x, y)));
            processed[x, y] = 1;
            ExploreAround(source, area, x, y, cleanMode);

            area = area.OrderBy(z => z.Item1).ThenBy(z => z.Item2).ToList();

            var minX = area.Min(z => z.Item1);
            var maxX = area.Max(z => z.Item1);
            var minY = area.Min(z => z.Item2);
            var maxY = area.Max(z => z.Item2);

            var areaPixels  = (maxX - minX + 1) * (maxY - minY + 1);
            var colorPixels = area.Count;

            var isSquare = (colorPixels * 100 / areaPixels) > 80 &&
                           (maxX - minX) > 5 &&
                           (maxY - minY) > 5;

            foreach (var item in area)
            {
                newBitmap.SetPixel(item.Item1, item.Item2, isSquare ? Color.Black : item.Item3);
            }
        }
Esempio n. 2
0
        public Bitmap Clean(CleanMode cleanMode)
        {
            var newBitmap = new Bitmap(source.Width, source.Height);

            processed = new byte[source.Width, source.Height];

            for (var x = 0; x < source.Width; x++)
            {
                for (var y = 0; y < source.Height; y++)
                {
                    if (processed[x, y] == 1)
                    {
                        continue;
                    }

                    var p = source.GetPixel(x, y);

                    if (IsBlack(p))
                    {
                        newBitmap.SetPixel(x, y, Color.Black);
                        processed[x, y] = 1;
                        continue;
                    }

                    ExploreArea(source, newBitmap, x, y, cleanMode);
                }
            }

            return(newBitmap);
        }
Esempio n. 3
0
        /// <summary>
        /// CleanMode: Normal
        /// This command starts the default cleaning mode. This is the same as pressing Roomba’s Clean button, and will pause a cleaning cycle if one is already in progress.
        /// CleanMode: Max
        /// This command starts the Max cleaning mode, which will clean until the battery is dead. This command will pause a cleaning cycle if one is already in progress.
        /// CleanMode: Spot
        /// This command starts the Spot cleaning mode. This is the same as pressing Roomba’s Spot button, and will pause a cleaning cycle if one is already in progress.
        ///
        /// Available in modes: Passive, Safe, or Full
        /// Changes mode to: Passive
        /// </summary>
        public async Task Clean(CleanMode mode = CleanMode.Normal)
        {
            if (!await this.oiSensor.CheckIsStarted())
            {
                return;
            }

            switch (mode)
            {
            case CleanMode.Normal:
                await this.dispatcher.SendCommand(OpCode.Clean).ConfigureAwait(false);

                break;

            case CleanMode.Max:
                await this.dispatcher.SendCommand(OpCode.Max).ConfigureAwait(false);

                break;

            case CleanMode.Spot:
                await this.dispatcher.SendCommand(OpCode.Spot).ConfigureAwait(false);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }

            //TODO: Set mode to passive
        }
 /// <summary>
 /// Arguments for git-clean
 /// </summary>
 /// <param name="mode">The cleanup mode what to delete</param>
 /// <param name="dryRun">Only show what would be deleted</param>
 /// <param name="directories">Delete untracked directories too</param>
 /// <param name="paths">Limit to specific paths</param>
 public static ArgumentString CleanCmd(CleanMode mode, bool dryRun, bool directories, string paths = null)
 {
     return(new GitArgumentBuilder("clean")
     {
         mode,
         { directories, "-d" },
         { dryRun, "--dry-run", "-f" },
         paths
     });
 }
Esempio n. 5
0
        public void Clean(Solution solution, CleanMode mode)
        {
            if (mode == CleanMode.all || mode == CleanMode.packages)
            {
                var packagesFolder = solution.PackagesDirectory();
                _fileSystem.CleanWithTracing(packagesFolder);
            }

            if (mode == CleanMode.all || mode == CleanMode.projects)
            {
                solution.Projects.Each(p => p.Clean(_fileSystem));
            }
        }
Esempio n. 6
0
        public void Clean(Solution solution, CleanMode mode)
        {
            if (mode == CleanMode.all || mode == CleanMode.packages)
            {
                var packagesFolder = solution.PackagesDirectory();
                _fileSystem.CleanWithTracing(packagesFolder);
            }

            if (mode == CleanMode.all || mode == CleanMode.projects)
            {
                solution.Projects.Each(p => p.Clean(_fileSystem));
            }
        }
Esempio n. 7
0
        public void Clean(Solution solution, CleanMode mode)
        {
            if (mode == CleanMode.all || mode == CleanMode.packages)
            {
                var packagesFolder = solution.PackagesDirectory();
                RippleLog.Debug("Deleting " + packagesFolder);
                _fileSystem.CleanDirectory(packagesFolder);
            }

            if (mode == CleanMode.all || mode == CleanMode.projects)
            {
                solution.Projects.Each(p => p.Clean(_fileSystem));
            }
        }
Esempio n. 8
0
        public static string CleanString(this string pathContainingTokens, CleanMode cleanMode = CleanMode.InTextFile)
        {
            var cleanedString = pathContainingTokens.Replace("\\[", "[").Replace("\\]", "]");

            switch (cleanMode)
            {
            case CleanMode.InFile:
                // TODO: MaxLenth
                cleanedString = Regex.Replace(NoUtf(cleanedString), @"[^\w\d\.]", "_");


                break;

            case CleanMode.InPath:
                cleanedString = Regex.Replace(cleanedString, @"[^\w\d\\\/]", "");
                break;
            }

            return(cleanedString);
        }
        /// <summary>
        /// Adds the git argument syntax for members of the <see cref="CleanMode"/> enum.
        /// </summary>
        /// <param name="builder">The <see cref="ArgumentBuilder"/> to add arguments to.</param>
        /// <param name="mode">The enum member to add to the builder.</param>
        public static void Add(this ArgumentBuilder builder, CleanMode mode)
        {
            builder.Add(GetArgument());

            string GetArgument()
            {
                switch (mode)
                {
                case CleanMode.OnlyNonIgnored:
                    return("");

                case CleanMode.OnlyIgnored:
                    return("-X");

                case CleanMode.All:
                    return("-x");

                default:
                    throw new InvalidEnumArgumentException(nameof(mode), (int)mode, typeof(CleanMode));
                }
            }
        }
Esempio n. 10
0
 public void Clean(CleanMode mode)
 {
     Storage.Clean(this, mode);
 }
Esempio n. 11
0
 public void Clean(CleanMode mode)
 {
     Storage.Clean(this, mode);
 }
 public void CleanCmd(CleanMode mode, bool dryRun, bool directories, string paths, string expected)
 {
     Assert.AreEqual(expected, GitCommandHelpers.CleanCmd(mode, dryRun, directories, paths).Arguments);
 }
Esempio n. 13
0
		public void Clean(Solution solution, CleanMode mode)
		{
		}
Esempio n. 14
0
 public void Clean(Solution solution, CleanMode mode)
 {
 }
Esempio n. 15
0
        public void Clean(IFileSystem fileSystem, CleanMode mode)
        {
            if (mode == CleanMode.all || mode == CleanMode.packages)
            {
                var packagesFolder = PackagesFolder();
                Console.WriteLine("Deleting " + packagesFolder);
                fileSystem.DeleteDirectory(packagesFolder);
            }

            if (mode == CleanMode.all || mode == CleanMode.projects)
            {
                _projects.Each(p => p.Clean(fileSystem));
            }
        }