Example #1
0
        public PreviewViewModel(IDataExchangeViewModel dataExchangeViewModel)
        {
            if (dataExchangeViewModel.ContainsKey(EnumExchangeViewmodel.Preview))
            {
            }


            using (var t = File.OpenRead(Path.GetTempPath() + @"\temp.html"))
            {
                _documentAdv = HTMLImporting.ConvertToDocumentAdv(t);
            }

            RaisePropertyChanged(DocumentAdvPropertyName);
        }
        //metoda wyszukująca hasło w słowniku
        private void Search(string text)
        {
            foreach (var elements in _dictionary)
            {
                if (elements[0].Word.Trim().ToLower() == text.Trim().ToLower())
                {
                    ExecuteExportToHtml(elements);
                    var filename = Path.GetTempPath() + @"\temp.html";

                    using (var t = File.OpenRead(filename))
                    {
                        _documentAdv = HTMLImporting.ConvertToDocumentAdv(t);
                        RaisePropertyChanged(DocumentPropertyName);
                    }
                }
            }
        }
        //wczytanie pliku z tekstem
        private void ExecuteOpenCommand()
        {
            try
            {
                var openFileDialog = new OpenFileDialog
                {
                    Filter =
                        "Plain text (*.txt)|*.txt|" +
                        "JSON (*.json)|*.json|" +
                        "html (*.html)|*.html",
                    Multiselect = false
                };

                var result = openFileDialog.ShowDialog();

                if (result != true)
                {
                    return;
                }
                switch (openFileDialog.FilterIndex)
                {
                case 1:
                    _textToRecognize = _textImporting.ConvertToDocumentAdv(File.Open(openFileDialog.FileName, FileMode.Open));
                    break;

                case 2:
                    _textToRecognize = _textImporting.ConvertToDocumentAdv(JsonConvert.DeserializeObject <string>(File.ReadAllText(openFileDialog.FileName)));
                    break;

                default:
                    _textToRecognize =
                        HTMLImporting.ConvertToDocumentAdv(File.OpenRead(openFileDialog.FileName));
                    break;
                }
                _enableAfterOpen = true;
                RaisePropertyChanged(EnableAfterOpenPropertyName);

                RaisePropertyChanged(TextToRecognizePropertyName);
            }
            catch (Exception)
            {
                MessageBox.Show(Resources.ErrorLoadDictionary, Resources.ErrorLoad, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }