public static IFileEditor GetFileEditor(string path)
        {
            IFileEditor editor = null;

            string[] array     = path.Split('.');
            string   extention = array[array.Length - 1];

            switch (extention)
            {
            case "txt":
                editor = new TxtEditor(path);
                break;

            case "xml":
                editor = new XMLEditor(path);
                break;

            case "csv":
                editor = new CSVEditor(path);
                break;

            default:
                throw new Exception("Nie znany typ edytora");
            }
            return(editor);
        }
Esempio n. 2
0
 public MainWindowViewModel()
 {
     _fileEditor = new FileEditor();
     _selectFileCommand = new RelayCommand(SelectFile);
     _openFileCommand = new RelayCommand(OpenFile, () => !_fileEditor.IsFileOpened);
     _closeFileCommand = new RelayCommand(CloseFile, () => _fileEditor.IsFileOpened);
 }
Esempio n. 3
0
        /// <summary>
        /// Редактирование файла из хранилища
        /// </summary>
        /// <param name="filename">Название файла</param>
        public void EditFile(string filename)
        {
            IFileEditor editor = null;

            vaultConnection.Connect();
            vaultConnection.DownloadToEdit(filename);
            switch (Path.GetExtension(filename))
            {
            case "pdf":
                editor = pdfFileEditor;
                break;

            case "bmp":
                editor = imageFileEditor;
                break;

            default:
                editor = textFileEditor;
                break;
            }

            editor.Open(filename);
            vaultConnection.UploadEditedFile(filename);
            vaultConnection.Disconnect();
        }
Esempio n. 4
0
 public MainWindowViewModel()
 {
     _fileEditor = new Model.FileEditor();
     _selectFileCommand = new RelayCommand(SelectFile);
     _openFileCommand = new RelayCommand(() => OpenFileAsync(), () => !_fileEditor.IsFileOpened);
     _closeFileCommand = new RelayCommand(() => CloseFileAsync(), () => _fileEditor.IsFileOpened);
     StatusColor = Brushes.CornflowerBlue;
 }
        private static void factory()
        {
            Console.WriteLine("Fabryka abstrackji");
            IFileEditor editor = AbstractFactory.GetFileEditor("D:/test.csv");

            editor.ClearAllText();
            editor.Add("Roman");
            Console.Read();
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="editor"></param>
        /// <returns></returns>
        public FileItem New(string path, IFileEditor editor)
        {
            if (editor == null)
            {
                throw new ArgumentNullException(nameof(editor));
            }

            return(new FileItem(this)
            {
                Path = path,
                Editor = editor
            });
        }
Esempio n. 7
0
 public Versioner(ISourceResolver resolver, IFileEditor editor)
 {
     this.resolver = resolver;
     this.editor   = editor;
 }
Esempio n. 8
0
 public static void ClearCache() => CachedEditor = null;