summaryrefslogtreecommitdiff
path: root/src/Notepad/Presentation/Presenters/Menu/File/ISaveAsPresenter.cs
blob: 509d21c87433f3ce22758d425b0b2bbae609ff3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Notepad.Infrastructure.Extensions;
using Notepad.Presentation.Core;
using Notepad.Presentation.Views.Menu.File;
using Notepad.Tasks;

namespace Notepad.Presentation.Presenters.Menu.File {
    public interface ISaveAsPresenter : IPresenter {
        void SaveToFileAt(string pathToSaveDocumentTo);
    }

    public class SaveAsPresenter : ISaveAsPresenter {
        private readonly ISaveAsView view;
        private readonly IDocumentTasks tasks;

        public SaveAsPresenter(ISaveAsView view, IDocumentTasks tasks) {
            this.view = view;
            this.tasks = tasks;
        }

        public void Initialize() {
            view.AttachTo(this);
        }

        public void SaveToFileAt(string pathToSaveDocumentTo) {
            tasks.SaveActiveDocumentTo(pathToSaveDocumentTo.AsAnAbsoluteFilePath());
        }
    }
}