//视图-接口 private void ResetStatusText() { StatusRadicalCountText.Text = Radical2Chars.Keys.Count.ToString(); StatusCharCountText.SetBinding(TextBlock.TextProperty, new Binding { ElementName = "DataView", Path = new PropertyPath("Items.Count") }); }
private void DisplayRadicalsByNumberOfReferencesMenuItemClick(object sender, RoutedEventArgs e) { if (Char2Radicals == null || Radical2Chars == null) { return; } ResetStatusText(); RefreshDataViewWithRadicalsOrderByCharCount(Radical2Chars, () => StatusCharCountText.SetResourceReference(TextBlock.TextProperty, "StatusBar.Unavailable")); }
private void ApplicationCommandsFind(object sender, ExecutedRoutedEventArgs e) { if (DataView.Items.Count == 0) { return; } var box = new SearchBox { Owner = this }; box.ShowDialog(); if (box.Action == SearchBox.SearchBoxAction.None || string.IsNullOrEmpty(box.SearchKeyString) || string.IsNullOrWhiteSpace(box.SearchKeyString)) { return; } if (Char2Radicals == null || Radical2Chars == null) { return; } ResetStatusText(); void UpdateInterfaceWhenHasResult() => StatusRadicalCountText.SetResourceReference(TextBlock.TextProperty, "StatusBar.Unavailable"); void UpdateInterfaceWhenNoResult() { var NoResultTextBlock = new TextBlock(); NoResultTextBlock.SetResourceReference(TextBlock.TextProperty, "DataView.NoResult"); RefreshDataView(null, new List <ListViewItem> { new ListViewItem { Content = NoResultTextBlock, HorizontalAlignment = HorizontalAlignment.Center } }, () => { StatusRadicalCountText.SetResourceReference(TextBlock.TextProperty, "StatusBar.Unavailable"); StatusCharCountText.SetResourceReference(TextBlock.TextProperty, "StatusBar.Unavailable"); }); } switch (box.Action) { case SearchBox.SearchBoxAction.SearchByWord: SearchByWord(box.SearchKeyString[0], UpdateInterfaceWhenHasResult, UpdateInterfaceWhenNoResult); break; case SearchBox.SearchBoxAction.SearchByRadical: SearchByRadical(box.SearchKeyString[0], UpdateInterfaceWhenHasResult, UpdateInterfaceWhenNoResult); break; case SearchBox.SearchBoxAction.SearchByMultipleRadical: SearchByMultipleRadical(box.SearchKeyString, UpdateInterfaceWhenHasResult, UpdateInterfaceWhenNoResult); break; } }