Browse Source

Merge pull request #8718 from workgroupengineering/fixes/Samples/IntegrationTestApp

fix IntergrationTestApp Null Annotation
pull/8724/head
Max Katz 4 years ago
committed by GitHub
parent
commit
03295901fd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      samples/IntegrationTestApp/MainWindow.axaml.cs

36
samples/IntegrationTestApp/MainWindow.axaml.cs

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia; using Avalonia;
@ -31,20 +30,23 @@ namespace IntegrationTestApp
private void InitializeViewMenu() private void InitializeViewMenu()
{ {
var mainTabs = this.FindControl<TabControl>("MainTabs"); var mainTabs = this.Get<TabControl>("MainTabs");
var viewMenu = (NativeMenuItem)NativeMenu.GetMenu(this).Items[1]; var viewMenu = (NativeMenuItem)NativeMenu.GetMenu(this).Items[1];
foreach (TabItem tabItem in mainTabs.Items) if (mainTabs.Items is not null)
{ {
var menuItem = new NativeMenuItem foreach (TabItem tabItem in mainTabs.Items)
{ {
Header = (string)tabItem.Header!, var menuItem = new NativeMenuItem
IsChecked = tabItem.IsSelected, {
ToggleType = NativeMenuItemToggleType.Radio, Header = (string)tabItem.Header!,
}; IsChecked = tabItem.IsSelected,
ToggleType = NativeMenuItemToggleType.Radio,
menuItem.Click += (s, e) => tabItem.IsSelected = true; };
viewMenu.Menu.Items.Add(menuItem);
menuItem.Click += (s, e) => tabItem.IsSelected = true;
viewMenu?.Menu?.Items.Add(menuItem);
}
} }
} }
@ -107,8 +109,8 @@ namespace IntegrationTestApp
private void MenuClicked(object? sender, RoutedEventArgs e) private void MenuClicked(object? sender, RoutedEventArgs e)
{ {
var clickedMenuItemTextBlock = this.FindControl<TextBlock>("ClickedMenuItem"); var clickedMenuItemTextBlock = this.Get<TextBlock>("ClickedMenuItem");
clickedMenuItemTextBlock.Text = ((MenuItem)sender!).Header.ToString(); clickedMenuItemTextBlock.Text = (sender as MenuItem)?.Header?.ToString();
} }
private void OnButtonClick(object? sender, RoutedEventArgs e) private void OnButtonClick(object? sender, RoutedEventArgs e)
@ -116,13 +118,13 @@ namespace IntegrationTestApp
var source = e.Source as Button; var source = e.Source as Button;
if (source?.Name == "ComboBoxSelectionClear") if (source?.Name == "ComboBoxSelectionClear")
this.FindControl<ComboBox>("BasicComboBox").SelectedIndex = -1; this.Get<ComboBox>("BasicComboBox").SelectedIndex = -1;
if (source?.Name == "ComboBoxSelectFirst") if (source?.Name == "ComboBoxSelectFirst")
this.FindControl<ComboBox>("BasicComboBox").SelectedIndex = 0; this.Get<ComboBox>("BasicComboBox").SelectedIndex = 0;
if (source?.Name == "ListBoxSelectionClear") if (source?.Name == "ListBoxSelectionClear")
this.FindControl<ListBox>("BasicListBox").SelectedIndex = -1; this.Get<ListBox>("BasicListBox").SelectedIndex = -1;
if (source?.Name == "MenuClickedMenuItemReset") if (source?.Name == "MenuClickedMenuItemReset")
this.FindControl<TextBlock>("ClickedMenuItem").Text = "None"; this.Get<TextBlock>("ClickedMenuItem").Text = "None";
if (source?.Name == "ShowWindow") if (source?.Name == "ShowWindow")
ShowWindow(); ShowWindow();
if (source?.Name == "SendToBack") if (source?.Name == "SendToBack")

Loading…
Cancel
Save