summaryrefslogtreecommitdiff
path: root/platform/winrt/gsview/TextLine.cs
blob: c37f604b15d8108328f31ec9979ddc31f782473b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace gsview
{
	public enum Intersection_t
	{
		NONE,
		PARTIAL,
		FULL
	};

	public class TextLine : INotifyPropertyChanged
	{
		public List<TextCharacter> TextCharacters;
		double height;
		double width;
		double x;
		double y;
		double scale;
		String color;
		int page_number;

		/* Determine intersection case of line with selection rectangle */
		public Intersection_t CheckIntersection(double rect_x, double rect_y, double rect_w, double rect_h)
		{
			if (rect_h == 0 || rect_y > y + height || rect_y + rect_h < y)
				return Intersection_t.NONE;
			
			if (rect_y <= y && y + height <= rect_y + rect_h)
				return Intersection_t.FULL;

			return Intersection_t.PARTIAL;
		}

		public double Height
		{
			get { return height; }
			set
			{
				height = value;
				OnPropertyChanged("Height");
			}
		}

		public double Width
		{
			get { return width; }
			set
			{
				width = value;
				OnPropertyChanged("Width");
			}
		}

		public double X
		{
			get { return x; }
			set
			{
				x = value;
				OnPropertyChanged("X");
			}
		}

		public double Y
		{
			get { return y; }
			set
			{
				y = value;
				OnPropertyChanged("Y");
			}
		}
		public double Scale
		{
			get { return scale; }
			set { scale = value;}
		}

		public int PageNumber
		{
			get { return page_number; }
			set { page_number = value;  }
		}

		public String Color
		{
			get { return color; }
			set
			{
				color = value;
				//OnPropertyChanged("Color");
			}
		}
		public event PropertyChangedEventHandler PropertyChanged;

		// Create the OnPropertyChanged method to raise the event 
		protected void OnPropertyChanged(string name)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(name));
			}
		}
	}

	public class LinesText : ObservableCollection<TextLine>
	{
		public LinesText()
			: base()
		{
		}
	}
}