forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslationItemWithCategory.cs
80 lines (70 loc) · 2.27 KB
/
TranslationItemWithCategory.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.ComponentModel;
using System.Diagnostics;
using ResourceManager.Xliff;
namespace TranslationApp
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class TranslationItemWithCategory : INotifyPropertyChanged, ICloneable
{
public TranslationItemWithCategory()
{
_item = new TranslationItem();
}
public TranslationItemWithCategory(string category, TranslationItem item)
{
Category = category;
_item = item;
}
public string Category { get; set; }
private TranslationItem _item;
public TranslationItem GetTranslationItem()
{
return _item;
}
public string Name { get { return _item.Name; } set { _item.Name = value; } }
public string Property { get { return _item.Property; } set { _item.Property = value; } }
public string NeutralValue { get { return _item.Source; } set { _item.Source = value; } }
public string TranslatedValue
{
get { return _item.Value; }
set
{
var pc = PropertyChanged;
if (pc != null)
{
pc(this, new PropertyChangedEventArgs("TranslatedValue"));
}
if (value != _item.Value)
{
_item.Value = value;
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
public bool IsSourceEqual(string value)
{
if (NeutralValue == null)
return true;
bool equal = (value == NeutralValue);
if (!equal && value.Contains("\n"))
return value.Replace(Environment.NewLine, "\n") == NeutralValue.Replace(Environment.NewLine, "\n");
return equal;
}
private string DebuggerDisplay
{
get
{
return string.Format("\"{0}\" - \"{1}\"", Category, NeutralValue);
}
}
object ICloneable.Clone()
{
return Clone();
}
public TranslationItemWithCategory Clone()
{
return new TranslationItemWithCategory(Category, _item.Clone());
}
}
}