개정판 8898253f
issue #1133: TextControl LineSize, TextSize 수정 시 이벤트 누락.
Change-Id: I1bfd83d31b3f8e3dbc5be2bc6b2fa1cf46af2f3c
MarkupToPDF/Controls/Text/TextControl.cs | ||
---|---|---|
14 | 14 |
using System.Windows.Shapes; |
15 | 15 |
|
16 | 16 |
namespace MarkupToPDF.Controls.Text |
17 |
{ |
|
18 |
[TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))] |
|
19 |
[TemplatePart(Name = "PART_TextBlock", Type = typeof(TextBlock))] |
|
20 |
[TemplatePart(Name = "PART_TextPath", Type = typeof(Path))] |
|
21 |
[TemplatePart(Name = "PART_Border", Type = typeof(Border))] |
|
22 |
[TemplatePart(Name = "PART_Grid", Type = typeof(Grid))] |
|
23 |
public class TextControl : CommentUserInfo, INotifyPropertyChanged, IMarkupControlData, IPath |
|
17 |
{ |
|
18 |
public class TextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData |
|
24 | 19 |
{ |
25 | 20 |
public event PropertyChangedEventHandler PropertyChanged; |
26 | 21 |
|
... | ... | |
96 | 91 |
this.Base_TextBox.ApplyTemplate(); |
97 | 92 |
MoveCustomCaret(); |
98 | 93 |
|
99 |
this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
|
94 |
this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
|
95 |
this.Base_TextBox.TextChanged += new TextChangedEventHandler(Base_TextBox_TextChanged); |
|
96 |
this.Base_TextBlock.SizeChanged += new SizeChangedEventHandler(Base_TextBlock_SizeChanged); |
|
100 | 97 |
this.Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus); |
101 | 98 |
this.Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus); |
102 | 99 |
this.Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret(); |
103 | 100 |
|
104 |
DrawingCloud(); |
|
101 |
|
|
105 | 102 |
SetText(); |
103 |
DrawingCloud(); |
|
104 |
|
|
106 | 105 |
|
107 |
|
|
108 |
|
|
109 | 106 |
|
110 | 107 |
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
111 | 113 |
/// <summary> |
112 | 114 |
/// Moves the custom caret on the canvas. |
113 | 115 |
/// </summary> |
... | ... | |
130 | 132 |
public override void ApplyOverViewData() |
131 | 133 |
{ |
132 | 134 |
this.OverViewPathData = this.PathData; |
133 |
this.OverViewText = this.Text; |
|
135 |
if (Text == "") |
|
136 |
this.Text = this.OverViewText; |
|
137 |
else |
|
138 |
this.OverViewText = this.Text; |
|
139 |
|
|
134 | 140 |
this.OverViewPaint = this.Paint; |
135 | 141 |
|
136 | 142 |
} |
137 | 143 |
|
138 | 144 |
void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e) |
139 |
{ |
|
140 |
if(IsEditingMode) |
|
145 |
{ |
|
146 |
BoxWidth = e.NewSize.Width; |
|
147 |
BoxHeight = e.NewSize.Height; |
|
148 |
|
|
149 |
DrawingCloud(); |
|
150 |
} |
|
151 |
private void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e) |
|
152 |
{ |
|
153 |
BoxWidth = e.NewSize.Width; |
|
154 |
BoxHeight = e.NewSize.Height; |
|
155 |
|
|
156 |
DrawingCloud(); |
|
157 |
} |
|
158 |
private void Base_TextBox_TextChanged(object sender, TextChangedEventArgs e) |
|
159 |
{ |
|
160 |
if (IsEditingMode) |
|
141 | 161 |
{ |
142 | 162 |
if (Base_TextBox.Text.Contains("|OR||DZ|")) |
143 | 163 |
{ |
... | ... | |
145 | 165 |
} |
146 | 166 |
|
147 | 167 |
this.Text = Base_TextBox.Text; |
148 |
BoxWidth = e.NewSize.Width; |
|
149 |
BoxHeight = e.NewSize.Height; |
|
150 |
DrawingCloud(); |
|
168 |
|
|
151 | 169 |
} |
170 |
DrawingCloud(); |
|
152 | 171 |
} |
153 |
|
|
154 | 172 |
void Base_TextBox_GotFocus(object sender, RoutedEventArgs e) |
155 | 173 |
{ |
156 | 174 |
this.BaseTextbox_Caret.Visibility = Visibility.Visible; |
... | ... | |
236 | 254 |
{ |
237 | 255 |
Base_TextPath.StrokeThickness = LineSize.Left; |
238 | 256 |
} |
257 |
|
|
239 | 258 |
} |
240 | 259 |
|
241 | 260 |
public void DrawingCloud() |
242 | 261 |
{ |
262 |
|
|
243 | 263 |
List<Point> pCloud = new List<Point> |
244 | 264 |
{ |
245 | 265 |
new Point(0, 0), |
246 | 266 |
new Point(0, 0 + BoxHeight + 0), |
247 | 267 |
new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0), |
248 |
new Point(0 + BoxWidth + 2 ,0),
|
|
268 |
new Point(0 + BoxWidth + 2 ,0) |
|
249 | 269 |
}; |
250 | 270 |
//this.Base_TextBox.Select(Base_TextBox.Text.Length, 0); |
251 | 271 |
if (Base_TextPath != null) |
... | ... | |
266 | 286 |
new Point(0, 0), |
267 | 287 |
new Point(0, 0 + BoxHeight + 0), |
268 | 288 |
new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0), |
269 |
new Point(0 + BoxWidth + 10 ,0),
|
|
289 |
new Point(0 + BoxWidth + 10 ,0) |
|
270 | 290 |
}; |
271 | 291 |
PathDataInner = (GenerateInner(pCloud)); |
272 | 292 |
} |
... | ... | |
420 | 440 |
"Text", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
421 | 441 |
|
422 | 442 |
public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register( |
423 |
"OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
|
443 |
"OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
|
|
424 | 444 |
|
425 | 445 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
426 | 446 |
"UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
... | ... | |
1033 | 1053 |
|
1034 | 1054 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1035 | 1055 |
{ |
1036 |
var instance = (TextControl)sender; |
|
1056 |
//var instance = (TextControl)sender;
|
|
1037 | 1057 |
|
1038 |
if (e.OldValue != e.NewValue && instance.Base_Border != null) |
|
1039 |
{ |
|
1040 |
instance.SetValue(e.Property, e.NewValue); |
|
1058 |
//if (e.OldValue != e.NewValue && instance.Base_Border != null)
|
|
1059 |
//{
|
|
1060 |
// instance.SetValue(e.Property, e.NewValue);
|
|
1041 | 1061 |
|
1042 |
if (instance.IsSelected) |
|
1043 |
{ |
|
1044 |
instance.StrokeColor = new SolidColorBrush(Colors.Blue); |
|
1045 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue); |
|
1046 |
} |
|
1047 |
else |
|
1048 |
{ |
|
1049 |
instance.StrokeColor = new SolidColorBrush(Colors.Red); |
|
1050 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red); |
|
1051 |
//instance.FontColor = new SolidColorBrush(Colors.Transparent); |
|
1052 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent); |
|
1053 |
} |
|
1062 |
// if (instance.IsSelected)
|
|
1063 |
// {
|
|
1064 |
// instance.StrokeColor = new SolidColorBrush(Colors.Blue);
|
|
1065 |
// //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue);
|
|
1066 |
// }
|
|
1067 |
// else
|
|
1068 |
// {
|
|
1069 |
// instance.StrokeColor = new SolidColorBrush(Colors.Red);
|
|
1070 |
// //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red);
|
|
1071 |
// //instance.FontColor = new SolidColorBrush(Colors.Transparent);
|
|
1072 |
// //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent);
|
|
1073 |
// }
|
|
1054 | 1074 |
|
1055 |
} |
|
1075 |
//}
|
|
1056 | 1076 |
} |
1057 | 1077 |
|
1058 | 1078 |
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
... | ... | |
1086 | 1106 |
} |
1087 | 1107 |
} |
1088 | 1108 |
} |
1109 |
public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
1110 |
{ |
|
1111 |
var instance = (TextControl)sender; |
|
1112 |
|
|
1113 |
if (e.OldValue != e.NewValue) |
|
1114 |
{ |
|
1115 |
instance.SetValue(e.Property, e.NewValue); |
|
1116 |
} |
|
1117 |
} |
|
1089 | 1118 |
|
1090 | 1119 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1091 | 1120 |
{ |
... | ... | |
1111 | 1140 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1112 | 1141 |
{ |
1113 | 1142 |
var instance = (TextControl)sender; |
1114 |
if (e.OldValue != e.NewValue && instance != null) |
|
1115 |
{ |
|
1116 |
instance.SetValue(e.Property, e.NewValue); |
|
1117 |
//instance.DrawingCloud(); |
|
1143 |
|
|
1144 |
if (e.OldValue != e.NewValue && instance.Base_TextBox != null) |
|
1145 |
{ |
|
1146 |
instance.SetText(); |
|
1147 |
instance.DrawingCloud(); |
|
1118 | 1148 |
} |
1149 |
|
|
1119 | 1150 |
} |
1120 | 1151 |
|
1121 | 1152 |
#endregion CallBack Method |
내보내기 Unified diff