forked from JeremieCHN/MetaDataStringEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditorListItem.cs
47 lines (37 loc) · 1.37 KB
/
EditorListItem.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MetaDataStringEditor {
public class EditorListItem : ListViewItem {
public bool IsEdit { private set; get; }
public byte[] OriginStrBytes { private set; get; }
public byte[] NewStrBytes { private set; get; }
public EditorListItem(byte[] OriginStrBytes) {
this.OriginStrBytes = OriginStrBytes;
IsEdit = false;
Text = Encoding.UTF8.GetString(OriginStrBytes);
SubItems.Add("");
SubItems.Add("");
}
public void SetNewStr(string newString) {
NewStrBytes = Encoding.UTF8.GetBytes(newString);
IsEdit = !Equals(OriginStrBytes, NewStrBytes);
SubItems[1].Text = IsEdit ? newString : "";
SubItems[2].Text = IsEdit ? "*" : "";
}
public void Discard() {
NewStrBytes = null;
IsEdit = false;
SubItems[1].Text = "";
SubItems[2].Text = "";
}
public bool MatchKeyWord(string keyWord) {
return Text.ToLower().Contains(keyWord.ToLower()) ||
SubItems[0].Text.ToLower().Contains(keyWord.ToLower()) ||
SubItems[1].Text.ToLower().Contains(keyWord.ToLower());
}
}
}