コード例 #1
0
        /// <summary>
        ///     Loads the user dictionary file
        /// </summary>
        private void LoadUserFile()
        {
            // load user words
            UserWords.Clear();

            // quit if user file is disabled
            if (!EnableUserFile)
            {
                return;
            }

            string userPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "NetSpell");
            string filePath = Path.Combine(userPath, UserFile);

            if (File.Exists(filePath))
            {
                TraceWriter.TraceInfo("Loading User Dictionary:{0}", filePath);

                FileStream fs = null;
                try
                {
                    fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    using (var sr = new StreamReader(fs, Encoding.UTF8))
                    {
                        fs = null;

                        // read line by line
                        while (sr.Peek() >= 0)
                        {
                            string tempLine = sr.ReadLine().Trim();
                            if (tempLine.Length > 0)
                            {
                                UserWords.Add(tempLine, tempLine);
                            }
                        }
                    }
                }
                finally
                {
                    fs?.Dispose();
                }

                TraceWriter.TraceInfo("Loaded User Dictionary; Words:{0}", UserWords.Count);
            }
        }
コード例 #2
0
        public Boolean InitWordGrid(int size, string input, string key)
        {
            _wordlist   = new List <string>();
            UserWords   = _wordlist;
            RowCol      = size;
            GridSize    = size * size;
            GridContent = new char[GridSize];
            string[] conversion = input.Split(' ');
            int      getCount   = 0;

            Trace.WriteLine("Before Checking items");
            foreach (var items in conversion)
            {
                UserWords.Add(items);
                getCount = items.Length;
                if (items.Length > RowCol || getCount > GridSize)
                {
                    Trace.WriteLine("Return False" + items.Length);
                    return(false);
                }
            }
            Trace.WriteLine("After Checking item list");

            SessionKey = key;
            directions = GenerateTries();
            rand       = new Random();
            Trace.WriteLine("Before GenerateTable");
            if (GenerateTable())
            {
                Trace.WriteLine("In GenerateTable");
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 /// <summary>
 ///     Adds a word to the user list
 /// </summary>
 /// <param name="word" type="string">
 ///     <para>
 ///         The word to add
 ///     </para>
 /// </param>
 /// <remarks>
 ///     This method is only affects the user word list
 /// </remarks>
 public void Add(string word)
 {
     UserWords.Add(word, word);
     SaveUserFile();
 }