aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItem.cs
blob: d7fbd8e92a69967cf88b93c19d50acb7aa619f11 (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
57
58
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using Tango.Core;
using Tango.SharedUI.Helpers;

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

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

        public string Name { get; set; }
        public ObservableCollection<IProjectItem> Items { get; set; }
        public ObservableCollection<ISolutionItemCommand> Commands { get ; set; }

        public ProjectItem():base()
        {
            Items = new ObservableCollection<IProjectItem>();
        }

        public abstract BitmapSource Image { get; }

        public abstract FrameworkElement OnGetView();

        private FrameworkElement GetView()
        {
            return OnGetView();
        }

        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 abstract bool CanOpen { get; }
        public FrameworkElement View => GetView();
    }
}
inkTimer.Start(); } } void StopBlinkAnimation() { caretBlinkTimer.Stop(); } internal Brush CaretBrush; protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (isVisible && blink) { Brush caretBrush = this.CaretBrush; if (caretBrush == null) caretBrush = (Brush)textView.GetValue(TextBlock.ForegroundProperty); Rect r = new Rect(caretRectangle.X - textView.HorizontalOffset, caretRectangle.Y - textView.VerticalOffset, caretRectangle.Width, caretRectangle.Height); drawingContext.DrawRectangle(caretBrush, null, PixelSnapHelpers.Round(r, PixelSnapHelpers.GetPixelSize(this))); } } } }