コード例 #1
0
        //making export from database to csv file
        private async void ExportToCSVFile(object sender, RoutedEventArgs e)
        {
            string dictionary = StringOperation.LanguagesToTable(ChosenDictionary.Text);
            string path       = Path.Combine(ChosenPathText.Text, dictionary + ".csv");

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Word, Translation");

            DatabaseConnection dbCon = new DatabaseConnection();
            List <string>      words = dbCon.GettingRows(dictionary);

            foreach (string word in words)
            {
                sb.AppendLine(word.Replace(" ➤", ","));
            }

            try
            {
                await folder.GetFileAsync(dictionary + ".csv");
            }
            catch
            {
                await folder.CreateFileAsync(dictionary + ".csv");
            }

            StorageFile csvFile = await folder.GetFileAsync(dictionary + ".csv");

            await FileIO.WriteTextAsync(csvFile, sb.ToString(), Windows.Storage.Streams.UnicodeEncoding.Utf8);
        }
コード例 #2
0
        public void SettingRows()
        {
            DatabaseConnection conDB = new DatabaseConnection();
            List <string>      rows  = conDB.GettingRows(StringOperation.LanguagesToTable(Tables.SelectedItem.ToString()));

            foreach (string item in rows)
            {
                CreatingListItems(Words, item);
            }
        }
コード例 #3
0
        //setting words from database with counts
        public void SettingRows()
        {
            Words.Items.Clear();
            Translation.Items.Clear();

            DatabaseConnection conDB = new DatabaseConnection();
            List <string>      rows  = conDB.SearchningWordsWithHighestCount(StringOperation.LanguagesToTable(DictionariesButton.Content.ToString()));

            short iterator = 2;

            foreach (string item in rows)
            {
                if (iterator % 2 == 0)
                {
                    CreatingListItems(Words, iterator / 2 + ". " + item);
                }
                else
                {
                    CreatingListItems(Translation, item);
                }
                iterator++;
            }
        }