aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Project.cs
blob: 5a950d2c7ab89f3f64786a4053b85231c1eb4f82 (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
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Tango.SharedUI.Helpers;

namespace Tango.Scripting.IDE
{
    public abstract class Project : IProject
    {
        private static Dictionary<String, BitmapSource> _imageCache;

        static Project()
        {
            _imageCache = new Dictionary<string, BitmapSource>();
        }

        public string FilePath { get; set; }

        public string WorkingFolder => Path.GetDirectoryName(FilePath);

        public string Name => Path.GetFileNameWithoutExtension(FilePath);

        public abstract BitmapSource Image { get; }

        public ObservableCollection<IProjectItem> Items { get; set; }

        public Project()
        {
            Items = new ObservableCollection<IProjectItem>();
        }

        public abstract Task Build();
        public abstract Task Run();

        protected static BitmapSource GetImage(String name)
        {
            if (_imageCache.ContainsKey(name))
            {
                return _imageCache[name];
            }
            else
            {
                var image = ResourceHelper.GetImageFromResources(name);
                _imageCache.Add(name, image);
                return image;
            }
        }

        public bool CanOpen => false;
    }
}