示例#1
0
        private void SaveFile(object sender, ExecutedRoutedEventArgs e)
        {
            SpecialPaths.VerifyDirectory(SpecialPaths.DataBases);

            //Начало сохранения данных
            this.BusyIndicator.BusyContent = "Сохранение данных...";
            this.BusyIndicator.IsBusy      = true;

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                this.dataStorage.Save();
            };

            worker.RunWorkerCompleted += delegate
            {
                //Сохранение завершено
                this.BusyIndicator.IsBusy = false;

                MessageBox.Show("Данные сохранены", "Успех", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            };

            worker.RunWorkerAsync();
        }
示例#2
0
        private void SaveFileAs(object sender, ExecutedRoutedEventArgs e)
        {
            SpecialPaths.VerifyDirectory(SpecialPaths.DataBases);
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "SQLite file|*.sqlite";
            saveFileDialog.InitialDirectory = SpecialPaths.DataBases;

            if (saveFileDialog.ShowDialog(this) == true)
            {
                //Начало сохранения данных
                this.BusyIndicator.BusyContent = "Сохранение данных...";
                this.BusyIndicator.IsBusy      = true;

                BackgroundWorker worker = new BackgroundWorker();

                worker.DoWork += delegate
                {
                    this.dataStorage.SaveAs(saveFileDialog.FileName);
                };

                worker.RunWorkerCompleted += delegate
                {
                    //Сохранение завершено
                    this.BusyIndicator.IsBusy = false;

                    MessageBox.Show("Данные сохранены", "Успех", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                };

                worker.RunWorkerAsync();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("\n***** Loading languages list... *****");
                Language.LoadLanguages();
                _sampleWords = LoadWordsSampleList();
                Console.WriteLine("***** Completed! *****");

                for (int i = 0; i < Language.AllLanguages.Count; i++)
                {
                    var lang = Language.AllLanguages[i];
                    Console.WriteLine("\n***** {0} language: \"{1}\" *****", i + 1, lang.Code.ToUpper());
                    string dataString = GenerateDataString(lang);
                    Uri    fileUri    = SpecialPaths.GetWordsUploadFileUri(lang.Code);
                    SendFileToServer(dataString, fileUri);
                }

                UpVersion();

                Console.WriteLine("\nTotal words detected: {0}", _sampleWords.Count());
                Console.WriteLine("\n---------------------------------------------------");
                Console.WriteLine("-------   Translation has been completed   --------");
                Console.WriteLine("---------------------------------------------------");

                Console.WriteLine("\nPress any key to restart...");
                Console.ReadLine();
            }
        }
示例#4
0
        public static async Task LoadWords()
        {
            string lang =
                ApplicationLanguages.Languages.Select(x => x.Substring(0, 2))
                .First(x => ApplicationLanguages.ManifestLanguages.Contains(x));

            bool isSuccess = false;

            try
            {
                int serverVersion = await GetServerWordsVersion();

                if (serverVersion > GlobalSettings.GetLocalWordsVersion(lang)) // Если на сервере новее
                {
                    string words = await new HttpClient().GetStringAsync(SpecialPaths.GetWordsFilePath(lang));
                    LoadWordsFromText(words);
                    await SaveWordsToFile(lang, words);

                    GlobalSettings.SetLocalWordsVersion(lang, serverVersion);
                    isSuccess = true;
                }
            }
            catch
            {
            }

            if (!isSuccess)
            {
                string words = await GetLocalWords(lang);

                LoadWordsFromText(words);
            }
        }
示例#5
0
        private void OpenFile(object sender, ExecutedRoutedEventArgs e)
        {
            SpecialPaths.VerifyDirectory(SpecialPaths.DataBases);

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "sqlite files|*.sqlite|all files|*.*";
            openFileDialog.InitialDirectory = SpecialPaths.DataBases;

            if (openFileDialog.ShowDialog() == true)
            {
                //Начало загрузки данных
                this.BusyIndicator.IsBusy      = true;
                this.BusyIndicator.BusyContent = "Загрузка данных...";

                BackgroundWorker worker = new BackgroundWorker();

                worker.DoWork += delegate
                {
                    try
                    {
                        Dispatcher.Invoke((Action)(() =>
                        {
                            this.dataStorage = new DataStorage(openFileDialog.FileName, true);
                            this.ShowEntities();
                        }));
                    }
                    catch (Exception ex)
                    {
                        this.dataStorage = null;
                        MessageBox.Show("Не удалось считать данные!\n\nException:\n" + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                };

                worker.RunWorkerCompleted += delegate
                {
                    //Загрузка завершена
                    this.BusyIndicator.IsBusy = false;
                };

                worker.RunWorkerAsync();
            }
        }
示例#6
0
        private void LoadInternal(string fileName)
        {
            _iniFile = new INIFile(fileName);

            foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(this))
            {
                if (item.IsBrowsable)
                {
                    switch (item.Name)
                    {
                    case "Format":
                        Format.LoadSection("Format", _iniFile);
                        break;

                    case "Details":
                        Details.LoadSection("Details", _iniFile);
                        break;

                    case "License":
                        License.LoadSection("License", _iniFile);
                        break;

                    case "Version":
                        Version.LoadSection("Version", _iniFile);
                        break;

                    case "SpecialPaths":
                        SpecialPaths.LoadSection("SpecialPaths", _iniFile);
                        break;

                    case "Dependencies":
                        Dependencies.LoadSection("Dependencies", _iniFile);
                        break;

                    case "Control":
                        Control.LoadSection("Control", _iniFile);
                        break;
                    }
                }
            }
        }
示例#7
0
        public void Save()
        {
            foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(this))
            {
                if (item.IsBrowsable)
                {
                    switch (item.Name)
                    {
                    case "Format":
                        Format.SaveSection("Format", _iniFile);
                        break;

                    case "Details":
                        Details.SaveSection("Details", _iniFile);
                        break;

                    case "License":
                        License.SaveSection("License", _iniFile);
                        break;

                    case "Version":
                        Version.SaveSection("Version", _iniFile);
                        break;

                    case "SpecialPaths":
                        SpecialPaths.SaveSection("SpecialPaths", _iniFile);
                        break;

                    case "Dependencies":
                        Dependencies.SaveSection("Dependencies", _iniFile);
                        break;

                    case "Control":
                        Control.SaveSection("Control", _iniFile);
                        break;
                    }
                }
            }
        }
示例#8
0
        public TreeNode BuildTreeUI()
        {
            TreeNode rootNode = new TreeNode();

            foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(this))
            {
                if (item.IsBrowsable)
                {
                    switch (item.Name)
                    {
                    case "Format":
                    {
                        var topNode = Format.BuildTreeUI("Format", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "Details":
                    {
                        var topNode = Details.BuildTreeUI("Details", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "License":
                    {
                        var topNode = License.BuildTreeUI("License", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "Version":
                    {
                        var topNode = Version.BuildTreeUI("Version", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "SpecialPaths":
                    {
                        var topNode = SpecialPaths.BuildTreeUI("SpecialPaths", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "Dependencies":
                    {
                        var topNode = Dependencies.BuildTreeUI("Dependencies", rootNode);
                        topNode.Expand();
                    }
                    break;

                    case "Control":
                    {
                        var topNode = Control.BuildTreeUI("Control", rootNode);
                        topNode.Expand();
                    }
                    break;
                    }
                }
            }

            return(rootNode);
        }