개정판 baacbc36
issue #000 Page 숫자를 입력하는 TextBox tlcurrentPage에 이벤트 PreviewTextInput,TextChanged 추가
TextChanged 되기전 PreviewTextInput 이벤트에서 숫자 입력만 받게 하고 텍스트를 복사한 경우 TextChanged 이벤트에서 텍스트를 Validation함
Change-Id: Id25ef59ab6a19d660c5982b2d509ba596a9d076d
KCOM/Events/Implementation/TopMenuEvent.cs | ||
---|---|---|
1230 | 1230 |
{ |
1231 | 1231 |
try |
1232 | 1232 |
{ |
1233 |
|
|
1233 | 1234 |
var instanceMain = this.ParentOfType<MainWindow>(); |
1234 |
instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text)); |
|
1235 |
var max = instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Max(f => f.PageNumber); |
|
1236 |
if (string.IsNullOrEmpty(tlcurrentPage.Text)) |
|
1237 |
{ |
|
1238 |
RadWindow.Alert(new DialogParameters |
|
1239 |
{ |
|
1240 |
Owner = Application.Current.MainWindow, |
|
1241 |
Theme = new VisualStudio2013Theme(), |
|
1242 |
Header = "안내", |
|
1243 |
Content = "페이지 번호를 정확하게 입력해 주세요", |
|
1244 |
}); |
|
1245 |
} |
|
1246 |
else |
|
1247 |
{ |
|
1248 |
if (Convert.ToInt32(tlcurrentPage.Text) > max || Convert.ToInt32(tlcurrentPage.Text) == 0) |
|
1249 |
{ |
|
1250 |
RadWindow.Alert(new DialogParameters |
|
1251 |
{ |
|
1252 |
Owner = Application.Current.MainWindow, |
|
1253 |
Theme = new VisualStudio2013Theme(), |
|
1254 |
Header = "안내", |
|
1255 |
Content = "페이지 번호를 정확하게 입력해 주세요", |
|
1256 |
}); |
|
1257 |
} |
|
1258 |
else |
|
1259 |
{ |
|
1260 |
instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text)); |
|
1261 |
} |
|
1262 |
} |
|
1263 |
|
|
1235 | 1264 |
} |
1236 | 1265 |
catch (Exception) |
1237 | 1266 |
{ |
... | ... | |
1246 | 1275 |
|
1247 | 1276 |
} |
1248 | 1277 |
} |
1278 |
private string previousText; |
|
1279 |
private void TlcurrentPage_PreviewTextInput(object sender, TextCompositionEventArgs e) |
|
1280 |
{ |
|
1281 |
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[^0-9]+"); |
|
1282 |
e.Handled = regex.IsMatch(e.Text); |
|
1283 |
} |
|
1284 |
private void TlcurrentPage_TextChanged(object sender, TextChangedEventArgs e) |
|
1285 |
{ |
|
1286 |
double num = 0; |
|
1287 |
bool success = double.TryParse(((TextBox)sender).Text, out num); |
|
1288 |
if (success & num >= 0) |
|
1289 |
previousText = ((TextBox)sender).Text; |
|
1290 |
else |
|
1291 |
{ |
|
1292 |
if (string.IsNullOrEmpty(((TextBox)sender).Text)) |
|
1293 |
{ |
|
1294 |
((TextBox)sender).Text = ""; |
|
1295 |
} |
|
1296 |
else |
|
1297 |
{ |
|
1298 |
|
|
1299 |
((TextBox)sender).Text = previousText; |
|
1300 |
} |
|
1301 |
} |
|
1302 |
} |
|
1303 |
|
|
1249 | 1304 |
|
1250 | 1305 |
private void tlcurrentPage_readonly_KeyDown(object sender, KeyEventArgs e) |
1251 | 1306 |
{ |
KCOM/Views/TopMenu.xaml | ||
---|---|---|
799 | 799 |
<RowDefinition/> |
800 | 800 |
</Grid.RowDefinitions> |
801 | 801 |
|
802 |
<TextBox Text="1" Width="30" Padding="0" Grid.Row="0" Grid.Column="0" BorderThickness="3" VerticalAlignment="Center" HorizontalContentAlignment="Center" Margin="5,0" x:Name="tlcurrentPage" KeyDown="tlcurrentPage_KeyDown"/> |
|
802 |
<TextBox Text="1" Width="30" Padding="0" Grid.Row="0" Grid.Column="0" BorderThickness="3" VerticalAlignment="Center" HorizontalContentAlignment="Center" Margin="5,0" x:Name="tlcurrentPage" |
|
803 |
KeyDown="tlcurrentPage_KeyDown" PreviewTextInput="TlcurrentPage_PreviewTextInput" TextChanged="TlcurrentPage_TextChanged"/> |
|
803 | 804 |
<TextBlock Grid.Row="0" Grid.Column="1" Margin="0,7,5,0"> |
804 | 805 |
<TextBlock Text="/" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/> |
805 | 806 |
<TextBlock Text="{Binding Document_Info.Count, Source={x:Static common:ViewerDataModel.Instance}}" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="tlPageCount"/> |
내보내기 Unified diff