Esempio n. 1
0
        public void ExecuteExport(Transcription data, string destfile = null)
        {
            if (destfile == null)
            {
                SaveFileDialog sf = new SaveFileDialog();

                sf.CheckPathExists = true;
                sf.Filter          = _mask;

                if (sf.ShowDialog() == true)
                {
                    destfile = sf.FileName;
                }
            }

            try
            {
                if (Isassembly)
                {
                    _exportDelegate.Invoke(data, File.Create(destfile));
                }
                else
                {
                    string tempFolder = FilePaths.TempDirectory;
                    string inputfile  = System.IO.Path.Combine(tempFolder, System.IO.Path.GetRandomFileName()) + ".trsx";
                    string tempFile   = destfile;

                    data.Serialize(inputfile, true);

                    ProcessStartInfo psi = new ProcessStartInfo();

                    psi.FileName  = Path.Combine(FilePaths.GetReadPath(FilePaths.PluginsPath), _fileName);
                    psi.Arguments = string.Format(_parameters, "\"" + inputfile + "\"", "\"" + tempFile + "\"", "\"" + tempFolder + "\"");

                    Process p = new Process();
                    p.StartInfo = psi;

                    p.Start();
                    p.WaitForExit();
                    File.Delete(inputfile);
                }
            }
            catch
            {
                MessageBox.Show(Properties.Strings.MessageBoxExportError, Properties.Strings.MessageBoxErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        private void GetDictionaryFromZip(Stream s)
        {
            ZipFile zf    = ZipFile.Read(s);
            var     entry = zf.Entries.Where(en => en.FileName.EndsWith(".aff")).ToArray();

            if (entry.Length > 0)
            {
                var aff = entry[0];
                var dic = zf.Entries.Where(en => en.FileName == System.IO.Path.GetFileNameWithoutExtension(aff.FileName) + ".dic").FirstOrDefault();

                if (dic != null)
                {
                    if (MessageBox.Show(this, string.Format(Properties.Strings.MessageBoxDictionaryConfirmLoad, System.IO.Path.GetFileNameWithoutExtension(aff.FileName)), Properties.Strings.MessageBoxQuestionCaption, MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                    {
                        var readme = zf.Entries.Where(en => en.FileName.ToLower().Contains("readme")).FirstOrDefault();
                        if (readme != null)
                        {
                            string ss = new StreamReader(readme.OpenReader()).ReadToEnd();

                            if (TextWallWindow.ShowWall(true, Properties.Strings.OODictionaryLicenceTitle, ss))
                            {
                                if (SpellChecker.SpellEngine != null)
                                {
                                    SpellChecker.SpellEngine.Dispose();
                                    SpellChecker.SpellEngine = null;
                                }


                                File.WriteAllText(FilePaths.GetWritePath("data\\readme_slovniky.txt"), ss);
                                string p = FilePaths.GetWritePath("data\\cs_CZ.aff");

                                using (Stream fs = File.Create(p))
                                    aff.Extract(fs);
                                p = FilePaths.GetWritePath("data\\cs_CZ.dic");

                                using (Stream fs = File.Create(p))
                                    dic.Extract(fs);

                                SpellChecker.LoadVocabulary();
                                MessageBox.Show(this, Properties.Strings.MessageBoxDictinaryInstalled, Properties.Strings.MessageBoxInfoCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public WPFTranscription ExecuteImport(string sourcefile = null)
        {
            if (sourcefile == null)
            {
                OpenFileDialog opf = new OpenFileDialog();
                opf.CheckFileExists = true;
                opf.CheckPathExists = true;
                opf.Filter          = _mask;

                if (opf.ShowDialog() == true)
                {
                    sourcefile = opf.FileName;
                }
            }

            if (File.Exists(sourcefile))
            {
                try
                {
                    if (Isassembly)
                    {
                        using (var f = File.OpenRead(sourcefile))
                        {
                            var imp = new WPFTranscription();
                            if (!_importDelegate.Invoke(f, imp))
                            {
                                throw new Exception();
                            }

                            imp.FileName = sourcefile;

                            return(imp);
                        }
                    }
                    else
                    {
                        string inputfile  = sourcefile;
                        string tempFolder = FilePaths.TempDirectory;
                        string tempFile   = System.IO.Path.Combine(tempFolder, System.IO.Path.GetRandomFileName()) + ".trsx";


                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName  = Path.Combine(FilePaths.GetReadPath(FilePaths.PluginsPath), _fileName);
                        psi.Arguments = string.Format(_parameters, "\"" + inputfile + "\"", "\"" + tempFile + "\"", "\"" + tempFolder + "\"");

                        Process p = new Process();
                        p.StartInfo = psi;

                        p.Start();
                        p.WaitForExit();

                        var data = WPFTranscription.Deserialize(tempFile);
                        return(data);
                    }
                }
                catch
                {
                    MessageBox.Show(Properties.Strings.MessageBoxImportError, Properties.Strings.MessageBoxErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            return(null);
        }