Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2511 - 1
using System.ComponentModel;
2
using System.Globalization;
3
using System.Resources;
4
using System.Windows.Data;
5
 
6
namespace MKLiveView
7
{
8
    public class TranslationSource : INotifyPropertyChanged
9
    {
10
        private static readonly TranslationSource instance = new TranslationSource();
11
 
12
        public static TranslationSource Instance
13
        {
14
            get { return instance; }
15
        }
16
 
17
        private readonly ResourceManager resManager = Properties.Resources.ResourceManager;
18
        private CultureInfo currentCulture = null;
19
 
20
        public string this[string key]
21
        {
22
            get { return this.resManager.GetString(key, this.currentCulture); }
23
        }
24
 
25
        public CultureInfo CurrentCulture
26
        {
27
            get { return this.currentCulture; }
28
            set
29
            {
30
                if (this.currentCulture != value)
31
                {
32
                    this.currentCulture = value;
33
                    var @event = this.PropertyChanged;
34
                    if (@event != null)
35
                    {
36
                        @event.Invoke(this, new PropertyChangedEventArgs(string.Empty));
37
                    }
38
                }
39
            }
40
        }
41
 
42
        public event PropertyChangedEventHandler PropertyChanged;
43
    }
44
 
45
    public class LocExtension
46
        : Binding
47
    {
48
        public LocExtension(string name)
49
            : base("[" + name + "]")
50
        {
51
            this.Mode = BindingMode.OneWay;
52
            this.Source = TranslationSource.Instance;
53
        }
54
    }
55
}