コード例 #1
0
ファイル: PassGen.xaml.cs プロジェクト: puffchumpy/codesafe
        private void LoadCurrentState()
        {
            var password = _entry.Password;

            if (string.IsNullOrEmpty(password))
            {
                /* Default password:
                 * - Length = 20
                 * - Upper-case
                 * - Lower-case
                 * - Digits
                 */

                password = "******";
            }

            sldLength.Value = Math.Max(MIN_LENGTH,
                                       Math.Min(sldLength.Maximum, password.Length));

            _checks = CharacterSets
                      .GetAll()
                      .Select(x => new CharacterSetCheckBox(x))
                      .ToArray();

            foreach (var check in _checks)
            {
                check.LoadState(password);
                pnlSets.Children.Add(check);
            }
        }
コード例 #2
0
 /// <summary>
 /// Copies all of the properties from the source writing system to this writing system.
 /// </summary>
 /// <param name="source">The source writing system.</param>
 public void Copy(CoreWritingSystemDefinition source)
 {
     Language = source.Language;
     Script   = source.Script;
     Region   = source.Region;
     Variants.ReplaceAll(source.Variants);
     Abbreviation      = source.Abbreviation;
     RightToLeftScript = source.RightToLeftScript;
     Fonts.ReplaceAll(source.Fonts.CloneItems());
     DefaultFont        = source.DefaultFont == null ? null : Fonts[source.Fonts.IndexOf(source.DefaultFont)];
     Keyboard           = source.Keyboard;
     VersionNumber      = source.VersionNumber;
     VersionDescription = source.VersionDescription;
     SpellCheckDictionaries.ReplaceAll(source.SpellCheckDictionaries.CloneItems());
     SpellCheckingId = source.SpellCheckingId;
     DateModified    = source.DateModified;
     LocalKeyboard   = source.LocalKeyboard;
     WindowsLcid     = source.WindowsLcid;
     DefaultRegion   = source.DefaultRegion;
     KnownKeyboards.ReplaceAll(source.KnownKeyboards);
     MatchedPairs.Clear();
     MatchedPairs.UnionWith(source.MatchedPairs);
     PunctuationPatterns.Clear();
     PunctuationPatterns.UnionWith(source.PunctuationPatterns);
     QuotationMarks.ReplaceAll(source.QuotationMarks);
     QuotationParagraphContinueType = source.QuotationParagraphContinueType;
     Collations.ReplaceAll(source.Collations.CloneItems());
     DefaultCollation = source.DefaultCollation == null ? null : Collations[source.Collations.IndexOf(source.DefaultCollation)];
     CharacterSets.ReplaceAll(source.CharacterSets.CloneItems());
     LegacyMapping     = source.LegacyMapping;
     IsGraphiteEnabled = source.IsGraphiteEnabled;
 }
コード例 #3
0
        public void TestTryConvertByteArrayToString()
        {
            string result;

            result = CharacterSets.ConvertByteArrayToString(nullbuffer);
            Assert.AreEqual("", result);

            result = CharacterSets.ConvertByteArrayToString(empty);
            Assert.AreEqual("", result);

            result = CharacterSets.ConvertByteArrayToString(simple);
            Assert.AreEqual("abc", result, "simple will convert to abc");

            result = CharacterSets.ConvertByteArrayToString(bit8);
            Assert.AreEqual("a¢c", result, "8bit converts--is three chars long!");

            result = CharacterSets.ConvertByteArrayToString(bit83);
            Assert.AreEqual("a¢£¤c", result, "83bit converts--is three chars long!");

            result = CharacterSets.ConvertByteArrayToString(embeddednull);
            Assert.AreEqual("a\0\0c", result, "embedded null will convert");

            result = CharacterSets.ConvertByteArrayToString(embeddedc080);
            //NOTE:
            // The C080 sequence is an over-long NUL. Normally NUL (8 bits, all zero)
            // will be encoded in UTF8 as \0, NUL. But in Modified-UTF8 (MUTF-8),
            // NUL is encoded in an over-long sequence C080 so that the resuting
            // string doesn't have any NUL chars, ever.
            // All MUTF-8 readers can also read CESU-8
            // For now, pin a somewhat unhappy behavior: the overlong sequence
            // is best-effort converted and the overlong NUL is treated as two
            // bogus characters and silently replaced.
            //Assert.AreEqual("a\0c", result, "embedded c080 will convert to...");
            Assert.AreEqual("a��c", result, "embedded c080 will convert to...");
        }
コード例 #4
0
 internal void Clear()
 {
     Symbols.Clear();
     CharacterSets.Clear();
     Productions.Clear();
     FAStates.Clear();
     LRActionLists.Clear();
     Groups.Clear();
 }
コード例 #5
0
        private void CharacterSetsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            CharacterSetDefinition mainCharSet;

            MainCharacterSet = CharacterSets.TryGet("main", out mainCharSet) ? mainCharSet : null;
            m_wordFormingOverrides.Clear();
            if (MainCharacterSet != null)
            {
                AddWordFormingOverrides(MainCharacterSet.Characters);
            }
        }
コード例 #6
0
 /// <summary>
 /// Locks the instance and (possible) all dependent objects.
 /// </summary>
 /// <param name="recursive"><see langword="True"/> if all dependent objects should be locked too.</param>
 public override void Lock(bool recursive)
 {
     Tables.Lock(recursive);
     Views.Lock(recursive);
     Assertions.Lock(recursive);
     CharacterSets.Lock(recursive);
     Collations.Lock(recursive);
     Translations.Lock(recursive);
     Domains.Lock(recursive);
     Sequences.Lock(recursive);
 }
コード例 #7
0
        /// <summary>
        /// Localizes the name of the character set.
        /// </summary>
        /// <param name="characterSets">An enumeration of the character set of which to give a new name.</param>
        /// <param name="name">A new name (hopefully localized) for the character set.</param>
        public void LocalizeCharacterSetName(CharacterSets characterSets, string name)
        {
            if (name.Trim() == string.Empty)
            {
                return;
            }
            int idx = InternalEnumDescriptionPairs.FindIndex(f => f.Key == characterSets);

            if (idx != -1)
            {
                InternalEnumDescriptionPairs[idx] = new KeyValuePair <CharacterSets, string>(characterSets, name);
            }
        }
コード例 #8
0
 private void ReadBytes(Bytes bytes)
 {
     byte[] byteArray = bytes.ByteArray;
     _height = BitConverter.ToUInt16(byteArray, 0);
     SetOptionsValue(bytes.Get(2, 2));
     _colorIndex   = BitConverter.ToUInt16(byteArray, 4);
     _weight       = FontWeightConverter.Convert(BitConverter.ToUInt16(byteArray, 6));
     _escapement   = (EscapementTypes)BitConverter.ToUInt16(byteArray, 8);
     _underline    = (UnderlineTypes)byteArray[10];
     _fontFamily   = (FontFamilies)byteArray[11];
     _characterSet = (CharacterSets)byteArray[12];
     //skip byte index 13
     _fontName = UnicodeBytes.Read(bytes.Get(14, bytes.Length - 14), 8);
 }
コード例 #9
0
        private void SetDefaults()
        {
            _height       = 200;
            _italic       = false;
            _underlined   = false;
            _struckOut    = false;
            _colorIndex   = 32767;
            _weight       = FontWeight.Normal;
            _escapement   = EscapementTypes.Default;
            _underline    = UnderlineTypes.Default;
            _fontFamily   = FontFamilies.Default;
            _characterSet = CharacterSets.Default;
            _notUsed      = 0;
            _fontName     = "Arial";

            OnChange();
        }
コード例 #10
0
        /// <summary>
        /// Generates a cryptographically secure random string key
        /// </summary>
        /// <param name="length">The length of the key to generate</param>
        /// <param name="characterSet">The character set to use for key generation</param>
        public static string NewKey(int length, CharacterSets characterSet)
        {
            var fullSet = string.Empty;

            foreach (var set in characterSet.GetFlags())
            {
                fullSet += set switch
                {
                    CharacterSets.Numeric => "0123456789",
                    CharacterSets.Lowercase => "abcdefghijklmnopqrstuvwxyz",
                    CharacterSets.Uppercase => "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                    CharacterSets.Punctuation => "`~!@#$%^&*()_-=+[]{}|;:,.<>?",
                    _ => string.Empty
                }
            }
            ;

            return(NewKey(length, fullSet.ToCharArray()));
        }
コード例 #11
0
        /// <summary>
        /// Gets a collection the <see cref="Encoding"/> class instances corresponding to the given character set enumeration.
        /// </summary>
        /// <param name="characterSets">An enumeration value indicating which character set's encodings to get.</param>
        /// <returns>A collection of <see cref="Encoding"/> class instances for the given character set enumeration.</returns>
        public IEnumerable <Encoding> this[CharacterSets characterSets]
        {
            get
            {
                var result = new List <Encoding>();
                int idx    = internalList.FindIndex(f => f.Value == characterSets);
                if (idx != -1)
                {
                    foreach (int encodingNum in internalList[idx].Key)
                    {
                        try
                        {
                            var encoding = Encoding.GetEncoding(encodingNum);
                            result.Add(encoding);
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogAction?.Invoke(ex);
                            try
                            {
                                var encoding = CodePagesEncodingProvider.Instance.GetEncoding(encodingNum);

                                if (encoding != null)
                                {
                                    result.Add(encoding);
                                }
                            }
                            catch (Exception exInner)
                            {
                                ExceptionLogAction?.Invoke(exInner);
                            }
                        }
                    }
                }

                return(result);
            }
        }
コード例 #12
0
ファイル: Font.cs プロジェクト: shi5588/shi5588
        private void SetDefaults()
        {
            _height = 200;
            _italic = false;
            _underlined = false;
            _struckOut = false;
            _color = new Color(32767);
            _weight = FontWeight.Normal;
            _escapement = EscapementTypes.Default;
            _underline = UnderlineTypes.Default;
            _fontFamily = FontFamilies.Default;
            _characterSet = CharacterSets.Default;
            _notUsed = 0;
            _fontName = "Arial";

            OnChange();
        }
コード例 #13
0
ファイル: Font.cs プロジェクト: shi5588/shi5588
 private void ReadBytes(Bytes bytes)
 {
     byte[] byteArray = bytes.ByteArray;
     _height = BitConverter.ToUInt16(byteArray, 0);
     SetOptionsValue(bytes.Get(2, 2));
     _color = _doc.Workbook.Palette.GetColor(BitConverter.ToUInt16(byteArray, 4));
     _weight = FontWeightConverter.Convert(BitConverter.ToUInt16(byteArray, 6));
     _escapement = (EscapementTypes) BitConverter.ToUInt16(byteArray, 8);
     _underline = (UnderlineTypes) byteArray[10];
     _fontFamily = (FontFamilies) byteArray[11];
     _characterSet = (CharacterSets) byteArray[12];
     //skip byte index 13
     _fontName = UnicodeBytes.Read(bytes.Get(14, bytes.Length - 14), 8);
 }
コード例 #14
0
ファイル: Driver.cs プロジェクト: idsyn/mysql-connector-net
        public virtual void Configure(MySqlConnection connection)
        {
            bool firstConfigure = false;

            // if we have not already configured our server variables
            // then do so now
            if (serverProps == null)
            {
                firstConfigure = true;

                // if we are in a pool and the user has said it's ok to cache the
                // properties, then grab it from the pool
                try
                {
                    if (Pool != null && Settings.CacheServerProperties)
                    {
                        if (Pool.ServerProperties == null)
                        {
                            Pool.ServerProperties = LoadServerProperties(connection);
                        }
                        serverProps = Pool.ServerProperties;
                    }
                    else
                    {
                        serverProps = LoadServerProperties(connection);
                    }

                    LoadCharacterSets(connection);
                }
                catch (MySqlException ex)
                {
                    // expired password capability
                    if (ex.Number == 1820)
                    {
                        IsPasswordExpired = true;
                        return;
                    }
                    throw;
                }
            }

            // if the user has indicated that we are not to reset
            // the connection and this is not our first time through,
            // then we are done.
            if (!Settings.ConnectionReset && !firstConfigure)
            {
                return;
            }

            string charSet = ConnectionString.CharacterSet;

            if (string.IsNullOrEmpty(charSet))
            {
                if (ConnectionCharSetIndex >= 0 && CharacterSets.ContainsKey(ConnectionCharSetIndex))
                {
                    charSet = CharacterSets[ConnectionCharSetIndex];
                }
                else
                {
                    charSet = serverCharSet;
                }
            }

            if (serverProps.ContainsKey("max_allowed_packet"))
            {
                MaxPacketSize = Convert.ToInt64(serverProps["max_allowed_packet"]);
            }

            // now tell the server which character set we will send queries in and which charset we
            // want results in
            MySqlCommand charSetCmd = new MySqlCommand("SET character_set_results=NULL",
                                                       connection)
            {
                InternallyCreated = true
            };

            string clientCharSet;

            serverProps.TryGetValue("character_set_client", out clientCharSet);
            string connCharSet;

            serverProps.TryGetValue("character_set_connection", out connCharSet);
            if ((clientCharSet != null && clientCharSet.ToString() != charSet) ||
                (connCharSet != null && connCharSet.ToString() != charSet))
            {
                MySqlCommand setNamesCmd = new MySqlCommand("SET NAMES " + charSet, connection);
                setNamesCmd.InternallyCreated = true;
                setNamesCmd.ExecuteNonQuery();
            }
            // sets character_set_results to null to return values in their original character set
            charSetCmd.ExecuteNonQuery();

            Encoding = CharSetMap.GetEncoding(Version, charSet ?? "utf-8");

            handler.Configure();
        }
コード例 #15
0
        /// <summary>
        /// Gets the name of the character set.
        /// </summary>
        /// <param name="characterSets">The CharacterSets enumeration value.</param>
        /// <returns>A name for a given CharacterSets enumeration.</returns>
        public string GetCharacterSetName(CharacterSets characterSets)
        {
            int idx = InternalEnumDescriptionPairs.FindIndex(f => f.Key == characterSets);

            return(idx != -1 ? InternalEnumDescriptionPairs[idx].Value : string.Empty);
        }
コード例 #16
0
ファイル: QualityProgressBar.cs プロジェクト: jessenic/7Pass
 public QualityProgressBar()
 {
     _sets = CharacterSets.GetAll();
 }