public string Generate(uint length, Charsets charsets)
        {
            var characters = new List <char>();

            if ((charsets & Charsets.Digits) == Charsets.Digits)
            {
                characters.AddRange(_digits.Value);
            }
            if ((charsets & Charsets.Letters) == Charsets.Letters)
            {
                characters.AddRange(_letters.Value);
            }
            if ((charsets & Charsets.SpecialCharacters) == Charsets.SpecialCharacters)
            {
                characters.AddRange(_special.Value);
            }

            var sb = new StringBuilder();

            for (int i = 1; i <= length; i++)
            {
                sb.Append(characters[_random.Next(0, characters.Count)]);
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private void ShowCalls(bool displayAllCalls)
        {
            _displayAllCalls = displayAllCalls;
            char[] chars = CallsTextBox.Text.ToCharArray();
            if (chars.Length == 0 && displayAllCalls)
            {
                chars = new Charsets().Chars["ASCII"];
            }
            var codes     = chars.Select(x => (uint)x).ToArray();
            var callItems = new List <CallItem>();
            var call      = GetCurrentCall();

            if (call != null)
            {
                Settings.Default.CallNameComboBox = call.CallName;
                //HelpTextBox.Text = call.CallName + ": " + call.CallDescription;
                for (uint i = 0; i < codes.Length; i++)
                {
                    CallItem c = call.Keys.ContainsKey(codes[i])
                                                ? call.Keys[codes[i]].Clone()
                                                : new CallItem()
                    {
                        Code = codes[i], Name = ((char)codes[i]).ToString()
                    };
                    c.Index = i + 1;
                    callItems.Add(c);
                }
            }
            CallsDataGridView.DataSource = callItems;
        }
Ejemplo n.º 3
0
        private void btnConvertSelection_Click(object sender, EventArgs e)
        {
            var resp = MetroMessageBox.Show(this, "This action can´t will generate an backup of selected files on the root selected folder! \n Do you want to continue with this action?", "Converting files character set", MessageBoxButtons.YesNo);

            if (resp != DialogResult.Yes)
            {
                return;
            }

            var dstCharset     = Charsets.GetEncoding(cboDestinationEncode.SelectedItem.ToString());
            var parentBasePath = new DirectoryInfo(txtBaseDirectory.Text).Parent;
            var zipFileName    = Path.Combine(parentBasePath.FullName, DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".zip");

            MetroMessageBox.Show(this, string.Format("Right!, Your backup file wil be saved on \"{0}\"", zipFileName), "Converting files character set", MessageBoxButtons.OK);

            var fz = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fz.CreateZip(zipFileName, txtBaseDirectory.Text, true, null);

            foreach (ListViewItem item in lstResults.SelectedItems)
            {
                var srcCharset = Charsets.GetEncoding(item.SubItems[0].Text);

                var srcFileName      = item.SubItems[1].Text;
                var srcDirectoryName = item.SubItems[2].Text;
                var srcFullName      = Path.Combine(srcDirectoryName, srcFileName);
                var dstFullName      = srcFullName;
                var srcContent       = File.ReadAllText(Path.Combine(srcDirectoryName, srcFileName), srcCharset);

                File.WriteAllText(dstFullName, srcContent, dstCharset);
            }

            MetroMessageBox.Show(this, "The selected files has ben converted!\n You have refresh view to see changes", "Right!");
        }
Ejemplo n.º 4
0
        public void loadFile(string fileName, string encodingName)
        {
            var encoding = Charsets.GetEncoding(encodingName);

            txtContent.Text = System.IO.File.ReadAllText(fileName, encoding);

            lnkFileName.Text = fileName;
        }
Ejemplo n.º 5
0
        public static string Generate(int minLength, int maxLength, int charRange = 62, Charsets Charset = Charsets.Any218)
        {
            Random random = SeededRandom();

            int length = random.Next(minLength, maxLength);
            StringBuilder result = new StringBuilder();

            for (int i = 0; i < length; i++)
                result.Append(Characters[(int)Charset][random.Next(0, charRange)]);

            return result.ToString();
        }
Ejemplo n.º 6
0
        public Image2Ascii()
        {
            activeChars = new string[] { " ·:+x#W@", " ░░▒▒▓▓█" }[0];

            mCanvasSize    = new Size(80, 25);
            mColorMode     = ColorModes.GrayScale;
            mScanMode      = ScanModes.Fast;
            mCharset       = Charsets.Standard;
            mGrayScaleMode = GrayscaleModes.Average;
            mBackColor     = Color.Black;
            mFont          = new Font("Consolas", 12, GraphicsUnit.Pixel);
            SetCharSize();
        }
Ejemplo n.º 7
0
        public string Generate(uint length, Charsets charsets)
        {
            List <char> chrs = new List <char>();

            if ((charsets & Charsets.Digits) == Charsets.Digits)
            {
                chrs.AddRange(SimplePasswordGenerator._digits.Value);
            }
            if ((charsets & Charsets.Letters) == Charsets.Letters)
            {
                chrs.AddRange(SimplePasswordGenerator._letters.Value);
            }
            if ((charsets & Charsets.SpecialCharacters) == Charsets.SpecialCharacters)
            {
                chrs.AddRange(SimplePasswordGenerator._special.Value);
            }
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 1; (long)i <= (long)length; i++)
            {
                stringBuilder.Append(chrs[SimplePasswordGenerator._random.Next(0, chrs.Count)]);
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 8
0
 public static string HtmlEntities(string _string, HtmlEntitiesFlags flags, Charsets encoding, bool doubleEncode)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public static void SetContentType(string ct, Charsets charset)
 {
 }
Ejemplo n.º 10
0
 protected LatinBaseValidator(Charsets charset)
 {
     _charset = charset;
 }
 protected LatinBaseValidator(Charsets charset)
     : base(
         $"Testo contenente caratteri non validi ({(charset == Charsets.BasicLatin ? "Unicode Basic Latin" : "Unicode Latin-1 Supplement")}). valori non accettati: {{NonLatinCode}}")
 {
     _charset = charset;
 }
Ejemplo n.º 12
0
 public static string iconv(Charsets in_charset, Charsets out_charset, string str)
 {
     //string iconv ( string $in_charset , string $out_charset , string $str )
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public static string htmlspecialchars(string _string, HtmlEntitiesFlags flags = HtmlEntitiesFlags.COMPAT | HtmlEntitiesFlags.HTML401, Charsets encoding = Charsets.UTF_8)
 {
     //  string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' [, bool $double_encode = true ]]] )
     return(HttpUtility.HtmlEncode(_string));
 }
Ejemplo n.º 14
0
 /// <summary></summary>
 static public string[] GetBlocksNames()
 {
     return(Charsets.GetBlocksNames());
 }
Ejemplo n.º 15
0
 public static void SetContentType(string ct, Charsets charset)
 {
 }
Ejemplo n.º 16
0
 public static string HtmlEntities(string _string, HtmlEntitiesFlags flags, Charsets encoding, bool doubleEncode)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
        public static long ToBase10(string value, int fromBase, Charsets Charset = Charsets.Any218)
        {
            long result = 0;

            for (int i = 0; i < value.Length; i++)
                result += Array.IndexOf(Characters[(int)Charset], value[i]) *
                    Convert.ToInt64(Math.Pow(fromBase, value.Length - (i + 1)));

            return result;
        }
Ejemplo n.º 18
0
 public LatinBaseValidator(Charsets charset)
     : base($"Testo contentente caratteri non validi ({(charset == Charsets.BasicLatin ? "Unicode Basic Latin" : "Unicode Latin-1 Supplement")})")
 {
     _charset = charset;
 }
Ejemplo n.º 19
0
        public static string FromBase10(long value, int toBase, Charsets Charset = Charsets.Any218)
        {
            StringBuilder builder = new StringBuilder();

            while (value >= 1)
            {
                builder.Insert(0, Characters[(int)Charset][(int)(value % toBase)]);
                value /= toBase;
            }

            return builder.ToString().PadLeft(1, Characters[(int)Charset][0]);
        }