-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditorProvider.cs
57 lines (51 loc) · 1.61 KB
/
EditorProvider.cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Caliburn.Micro;
using Gemini.Framework;
using Gemini.Framework.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TessBoxHelper.Modules.ViewModels;
namespace TessBoxHelper
{
[Export(typeof(IEditorProvider))]
public class EditorProvider : IEditorProvider
{
private List<EditorFileType> _FileTypes = new List<EditorFileType> {
new EditorFileType("PNG", ".png")
,new EditorFileType("JPEG", ".jpeg")
,new EditorFileType("jpg", ".jpg")
,new EditorFileType("bmp", ".bmp")
,new EditorFileType("tiff", ".tiff")
,new EditorFileType("tif", ".tif")
};
public IEnumerable<EditorFileType> FileTypes
{
get
{
return _FileTypes;
}
}
public bool Handles(string path)
{
var extension = Path.GetExtension(path);
bool result = extension != null && _FileTypes.First(x => x.FileExtension == extension) != null;//extension == ".txt";
return result;
}
public IDocument Create()
{
return IoC.Get<BoxMakerViewModel>();
}
public async Task New(IDocument document, string name)
{
await ((BoxMakerViewModel)document).New(name);
}
public async Task Open(IDocument document, string path)
{
await ((BoxMakerViewModel)document).Load(path);
}
}
}