コード例 #1
0
        public PrimaryOptionsControl([NotNull] Lifetime lifetime, OptionsSettingsSmartContext settings)
        {
            _settings = settings;

            InitializeComponent();

            groupBoxUserDictionary.Text = ResourceAccessor.GetString("UI_UserDictionaryListTitle")
                                          ?? "User Dictionary";
            groupBoxIgnoredWords.Text = ResourceAccessor.GetString("UI_IgnoredWordListTitle")
                                        ?? "Ignored Words";

            // Extract the string keys from the settings and apply them to the UI list boxes.
            UserWords.Initialize(
                settings.EnumEntryIndices <SpellCheckSettings, string, byte>(x => x.UserEntries)
                .ToArray()
                );

            IgnoreWords.Initialize(
                settings.EnumEntryIndices <SpellCheckSettings, string, byte>(x => x.IgnoreEntries)
                .ToArray()
                );

            // Monitor the changed properties on the UI list boxes and when changed apply the modifications to the settings collection to be saved.

            var userWordsProperty = WinFormsProperty.Create(lifetime, UserWords, x => x.CurrentItems, true);

            userWordsProperty.Change.Advise_NoAcknowledgement(lifetime, x => ApplyChanges(settings, UserWords, p => p.UserEntries));

            var ignoreWordsProperty = WinFormsProperty.Create(lifetime, IgnoreWords, x => x.CurrentItems, true);

            ignoreWordsProperty.Change.Advise_NoAcknowledgement(lifetime, x => ApplyChanges(settings, IgnoreWords, p => p.IgnoreEntries));

            ResetDictionariesGrid(settings);
        }
コード例 #2
0
        /// <summary>
        /// Delete word from database
        /// </summary>
        /// <param name="ew">Selected word</param>
        private void DeleteWord(UserWords ew)
        {
            ew.SlowkoID = int.Parse(selectedWordID);

            SqlConnection connection = new SqlConnection(connstring);

            string sql = "Delete FROM Slowka WHERE SlowkoID=@slowkoID";

            //Sql command
            SqlCommand command = new SqlCommand(sql, connection);

            command.Parameters.AddWithValue("@SlowkoID", ew.SlowkoID);
            //Open connection
            connection.Open();
            int counter = command.ExecuteNonQuery();

            if (counter > 0)
            {
                MessageBox.Show("Słówko zostało usunięte!");
            }
            else
            {
                MessageBox.Show("Wystąpił błąd!");
            }
            connection.Close();
        }
コード例 #3
0
        /// <summary>
        /// Update database with changed word
        /// </summary>
        /// <param name="ew">Word object with changed values</param>
        public void saveChangedWord(UserWords ew)
        {
            SqlConnection connection = new SqlConnection(connstring);

            //Update database
            string sql = "UPDATE Slowka SET Slowko=@Slowko, Tlumaczenie=@Tlumaczenie, Kategoria=@Kategoria, Nauczone=@Nauczone WHERE SlowkoID=@slowkoID";

            //SQL command
            SqlCommand command = new SqlCommand(sql, connection);

            //Parameters
            command.Parameters.AddWithValue("@Slowko", ew.Slowko);
            command.Parameters.AddWithValue("@Tlumaczenie", ew.Tlumaczenie);
            command.Parameters.AddWithValue("@Kategoria", ew.Kategoria);
            command.Parameters.AddWithValue("SlowkoID", ew.SlowkoID);
            command.Parameters.AddWithValue("@Nauczone", ew.Nauczone);


            //Open database connection
            connection.Open();
            int counter = command.ExecuteNonQuery();

            //if query is success
            if (counter > 0)
            {
                MessageBox.Show("Słówko zostało zmienione!");
            }
            else
            {
                MessageBox.Show("Wystąpił błąd!");
            }
            connection.Close();
        }
コード例 #4
0
        /// <summary>
        /// Save word into database
        /// </summary>
        /// <param name="ewx">Object with assigned values</param>
        /// <param name="connstring">Connectionstring</param>
        /// <returns></returns>
        public bool SaveWord(UserWords ewx, string connstring)
        {
            SqlConnection connection = new SqlConnection(connstring);



            string sql = "INSERT INTO Slowka (Slowko, Tlumaczenie, Kategoria, Jezyk, Nauczone, Bledne, Poprawne) VALUES(@Slowko, @Tlumaczenie, @Kategoria, @Jezyk, 'Nie', 0, 0)";

            SqlCommand command = new SqlCommand(sql, connection);

            command.Parameters.AddWithValue("@Slowko", ewx.Slowko);
            command.Parameters.AddWithValue("@Tlumaczenie", ewx.Tlumaczenie);
            command.Parameters.AddWithValue("@Kategoria", ewx.Kategoria);
            command.Parameters.AddWithValue("@Jezyk", ewx.Jezyk);

            connection.Open();

            int count = command.ExecuteNonQuery();

            if (count > 0)
            {
                MessageBox.Show("Dodano słówko!");
                return(true);
            }
            else
            {
                MessageBox.Show("Wystąpił błąd, spróbuj ponownie!");
                return(false);
            }
        }
コード例 #5
0
        public Boolean ValidWord(string userEntry)
        {
            char[] reversedEntry = userEntry.ToCharArray();
            Array.Reverse(reversedEntry);
            string reversed = new string(reversedEntry);

            return(UserWords.Contains(userEntry) || UserWords.Contains(reversed));
        }
コード例 #6
0
 //Kelime  Silme
 public int DeleteWord(int id, User _user)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         UserWords delete = db.DbuserWords.Where(x => x.WordsId == id && x.UserId == _user.Id).FirstOrDefault();
         db.DbuserWords.Remove(delete);
         int result = db.SaveChanges();
         return(result);
     }
 }
コード例 #7
0
        public JsonResult AddWord(int groupId, string word, string wordTr)
        {
            Words     words;
            UserWords userWord;
            int       userId = Convert.ToInt32(Session[Sys.userId]);

            try
            {
                using (entities = new wwbEntities())
                {
                    /* If group not exist then insert then just take id below */
                    words = entities.Words
                            .Where(w => w.word == word && w.word_translate == wordTr)
                            .FirstOrDefault();

                    if (words == null)
                    {
                        words                = new Words();
                        words.group_id       = groupId;
                        words.word           = word;
                        words.word_translate = wordTr;

                        entities.Words.Add(words);
                        entities.SaveChanges();
                    }
                }

                using (entities = new wwbEntities())
                {
                    /* Already exists */
                    userWord = entities.UserWords
                               .Where(uw => (uw.user_id == userId && uw.word_id == words.word_id))
                               .FirstOrDefault();

                    if (userWord != null)
                    {
                        return(Json(WordAddingStatus.AlreadyExist, JsonRequestBehavior.AllowGet));
                    }

                    userWord         = new UserWords();
                    userWord.word_id = words.word_id;
                    userWord.user_id = userId;

                    entities.UserWords.Add(userWord);
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                return(Json(WordAddingStatus.Fail, JsonRequestBehavior.AllowGet));
            }


            return(Json(WordAddingStatus.Success, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
 //Soruların bilinme durumunu değiştirme
 public void changeAnsweredWord(Words _word, User _user)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         UserWords word = new UserWords();
         word            = db.DbuserWords.Where(x => x.WordsId == _word.Id && x.UserId == _user.Id).FirstOrDefault();
         word.IsAnswered = true;
         db.DbuserWords.Update(word);
         db.SaveChanges();
     }
 }
コード例 #9
0
ファイル: Tests.cs プロジェクト: PHPHitman/Slowka
        public void SaveWord_WordIsSaved_ReturnTrue()
        {
            string    connstr = "Data Source=DESKTOP-0FF2I00;Initial Catalog=Slowka;Integrated Security=True";
            AddWords  addw    = new AddWords();
            UserWords word    = new UserWords()
            {
                Slowko      = "Plane",
                Tlumaczenie = "Samolot",
                Kategoria   = "Przedmioty",
                Jezyk       = "Angielski"
            };
            bool x = addw.SaveWord(word, connstr);

            Assert.IsTrue(x);
        }
コード例 #10
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);
            }
        }
コード例 #11
0
        //Başarılı Kullanıcı kaydı
        public int AddUser(string _userName, string _password, string _Name)
        {
            using (DatabaseContext db = new DatabaseContext())
            {
                int deg = 0;

                //Kullanıcı kaydı
                List <Words> wordList = db.DbWords.ToList();
                User         user     = new User()
                {
                    UserName = _userName,
                    Password = _password,
                    Name     = _Name
                };
                db.DbUsers.Add(user);
                db.SaveChanges();

                // Ortak tablo Id Kaydı
                foreach (Words item in wordList)
                {
                    UserWords userWords = new UserWords();
                    userWords.UserId  = user.Id;
                    userWords.WordsId = item.Id;
                    db.DbuserWords.Add(userWords);
                    db.SaveChanges();
                }

                //Score tablosu id ve değer kaydı
                Score score = new Score()
                {
                    ScorePoint  = 0,
                    WrongCount  = 0,
                    CorrectCout = 0,
                    UserId      = user.Id
                };
                db.DbScores.Add(score);

                deg = db.SaveChanges();



                return(deg);
            }
        }
コード例 #12
0
        //Kelime Ekle
        public int AddWord(string _wordTurkish, string _wordEnglish, User user)
        {
            using (DatabaseContext db = new DatabaseContext())
            {
                //Kelime Ekle
                Words newWord = new Words();
                newWord.Turkish = _wordTurkish;
                newWord.English = _wordEnglish;
                db.DbWords.Add(newWord);
                db.SaveChanges();

                //Ortak tablo id ekle
                UserWords uw = new UserWords();
                uw.UserId  = user.Id;
                uw.WordsId = newWord.Id;
                db.DbuserWords.Add(uw);

                return(db.SaveChanges());
            }
        }
コード例 #13
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);
            }
        }
コード例 #14
0
 public ActionResult Update([FromBody] UserWords uWord)
 {
     _wordService.SaveDb(uWord, CreateReason.Update);
     return(Ok(uWord));
 }
コード例 #15
0
 /// <summary>
 ///     Removes a word from the user list
 /// </summary>
 /// <param name="word" type="string">
 ///     <para>
 ///         The word to remove
 ///     </para>
 /// </param>
 /// <remarks>
 ///     This method is only affects the user word list
 /// </remarks>
 public void Remove(string word)
 {
     UserWords.Remove(word);
     SaveUserFile();
 }
コード例 #16
0
        /// <summary>
        ///     Searches all contained word lists for word
        /// </summary>
        /// <param name="word" type="string">
        ///     <para>
        ///         The word to search for
        ///     </para>
        /// </param>
        /// <returns>
        ///     Returns true if word is found
        /// </returns>
        public bool Contains(string word)
        {
            // clean up possible base word list
            PossibleBaseWords.Clear();

            // Step 1 Search UserWords
            if (UserWords.ContainsKey(word))
            {
                TraceWriter.TraceVerbose("Word Found in User Dictionary: {0}", word);
                return(true);  // word found
            }

            // Step 2 Search BaseWords
            if (BaseWords.ContainsKey(word))
            {
                TraceWriter.TraceVerbose("Word Found in Base Words: {0}", word);
                return(true); // word found
            }

            // Step 3 Remove suffix, Search BaseWords

            // save suffixed words for use when removing prefix
            List <string> suffixWords = new List <string>();

            // Add word to suffix word list
            suffixWords.Add(word);

            foreach (AffixRule rule in SuffixRules.Values)
            {
                foreach (AffixEntry entry in rule.AffixEntries)
                {
                    string tempWord = AffixUtility.RemoveSuffix(word, entry);
                    if (tempWord != word)
                    {
                        if (BaseWords.ContainsKey(tempWord))
                        {
                            if (VerifyAffixKey(tempWord, rule.Name[0]))
                            {
                                TraceWriter.TraceVerbose("Word Found With Base Words: {0}; Suffix Key: {1}", tempWord, rule.Name[0]);
                                return(true); // word found
                            }
                        }

                        if (rule.AllowCombine)
                        {
                            // saving word to check if it is a word after prefix is removed
                            suffixWords.Add(tempWord);
                        }
                        else
                        {
                            // saving possible base words for use in generating suggestions
                            PossibleBaseWords.Add(tempWord);
                        }
                    }
                }
            }
            // saving possible base words for use in generating suggestions
            PossibleBaseWords.AddRange(suffixWords);

            // Step 4 Remove Prefix, Search BaseWords
            foreach (AffixRule rule in PrefixRules.Values)
            {
                foreach (AffixEntry entry in rule.AffixEntries)
                {
                    foreach (string suffixWord in suffixWords)
                    {
                        string tempWord = AffixUtility.RemovePrefix(suffixWord, entry);
                        if (tempWord != suffixWord)
                        {
                            if (BaseWords.ContainsKey(tempWord))
                            {
                                if (VerifyAffixKey(tempWord, rule.Name[0]))
                                {
                                    TraceWriter.TraceVerbose("Word Found With Base Words: {0}; Prefix Key: {1}", tempWord, rule.Name[0]);
                                    return(true); // word found
                                }
                            }

                            // saving possible base words for use in generating suggestions
                            PossibleBaseWords.Add(tempWord);
                        }
                    } // suffix word
                }     // prefix rule entry
            }         // prefix rule
            // word not found
            TraceWriter.TraceVerbose("Possible Base Words: {0}", PossibleBaseWords.Count);
            return(false);
        }
コード例 #17
0
 /// <summary>
 ///     Clears the user list of words
 /// </summary>
 /// <remarks>
 ///     This method is only affects the user word list
 /// </remarks>
 public void Clear()
 {
     UserWords.Clear();
     SaveUserFile();
 }
コード例 #18
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();
 }
コード例 #19
0
ファイル: WordManager.cs プロジェクト: mervbayrak/WordLibrary
 ///UserWords
 public void SaveDb(UserWords a, Core.DataAccess.CreateReason reason)
 {
     _userWordsDal.SaveDb(a, reason);
 }