public MainWindowViewModel(IOpenFileDialog openFileDialog)
        {
            var fileConverter    = new FileConverter();
            var projectConverter = new ProjectConverter();

            Settings = new SettingsViewModel();
            File     = new ConvertFileViewModel(fileConverter, Settings);
            Project  = new ConvertProjectViewModel(fileConverter, projectConverter, openFileDialog, File, Settings, this);
        }
Пример #2
0
        public ConvertProjectViewModel(FileConverter fileConverter, ProjectConverter projectConverter, IOpenFileDialog openFileDialog, ConvertFileViewModel convertFileVm, SettingsViewModel settings, MainWindowViewModel mainWindow)
        {
            _convertFileVm    = convertFileVm;
            _fileConverter    = fileConverter;
            _projectConverter = projectConverter;
            _settings         = settings;
            _mainWindow       = mainWindow;

            CopyToBak = true;

            LoadCsproj = ReactiveCommand.CreateFromObservable(() => openFileDialog.BrowseFile());
            LoadCsproj.SelectMany(projectFile => LoadProjectFile(projectFile).ToObservable())
            .Subscribe();

            PreviewPage = ReactiveCommand.Create((PageViewModel page) => {
                var originalFileName = File.Exists(page.FilePath)
                                       ? page.FilePath
                                       : File.Exists(page.FilePath + ".bak")
                                         ? page.FilePath + ".bak"
                                         : null;

                if (originalFileName != null)
                {
                    convertFileVm.Xaml = File.ReadAllText(originalFileName);
                }
                else
                {
                    convertFileVm.Xaml = "File doesn't exist on disk anymore";
                }

                UpdatePageFilenames();

                convertFileVm.Ammy = page.Ammy;

                _mainWindow.IsConvertFileSelected = true;
            });

            Convert = ReactiveCommand.Create(ConvertProject);
        }