MainWindow.xaml.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using SourceChord.FluentWPF;
  17. namespace Phihong_EVSE_UI_Tool
  18. {
  19. /// <summary>
  20. /// MainWindow.xaml 的互動邏輯
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. private ListViewItem lastSelectedItem = null;
  25. private InitialIdleUC ucInitialIdle = new InitialIdleUC();
  26. private AuthenticationUC ucAuthentaction = new AuthenticationUC();
  27. private PlugChargingUC ucPlugCharging = new PlugChargingUC();
  28. private MaintenanceUC ucMaintenance = new MaintenanceUC();
  29. private BuildIco ucBuildIco = new BuildIco();
  30. private ModifyIco ucModifyIco = new ModifyIco();
  31. public MainWindow()
  32. {
  33. InitializeComponent();
  34. this.MaxHeight = SystemParameters.WorkArea.Height + 12.5;
  35. this.MinWidth = 1200;
  36. this.MinHeight = 800;
  37. uxInitListViewItem.IsSelected = true;
  38. uxInitListViewItem.Focus();
  39. }
  40. private void uxMenuListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
  41. {
  42. if (uxMenuListView.SelectedItem != null)
  43. {
  44. if (lastSelectedItem != null)
  45. {
  46. lastSelectedItem.Foreground = new SolidColorBrush(Colors.Black);
  47. lastSelectedItem.Background = null;
  48. }
  49. ListViewItem item = uxMenuListView.SelectedItem as ListViewItem;
  50. Binding myBinding = new Binding("ImmersiveSystemAccentBrush");
  51. myBinding.Source = new AccentColors();
  52. item.SetBinding(ListViewItem.ForegroundProperty, myBinding);
  53. item.Background = new SolidColorBrush(Color.FromArgb(45, 0, 0, 0));
  54. uxTitleTextBlock.Text = (item.Content as StackPanel).Children.OfType<TextBlock>().First().Text;
  55. uxContentGrid.Children.Clear();
  56. switch (item.Name)
  57. {
  58. case "uxInitListViewItem":
  59. uxContentGrid.Children.Add(ucInitialIdle);
  60. uxContentGrid.Children.OfType<InitialIdleUC>().First().uxContentScrollViewer.ScrollToTop();
  61. break;
  62. case "uxAuthListViewItem":
  63. uxContentGrid.Children.Add(ucAuthentaction);
  64. uxContentGrid.Children.OfType<AuthenticationUC>().First().uxContentScrollViewer.ScrollToTop();
  65. break;
  66. case "uxChargingListViewItem":
  67. uxContentGrid.Children.Add(ucPlugCharging);
  68. uxContentGrid.Children.OfType<PlugChargingUC>().First().uxContentScrollViewer.ScrollToTop();
  69. break;
  70. case "uxMaintainListViewItem":
  71. uxContentGrid.Children.Add(ucMaintenance);
  72. uxContentGrid.Children.OfType<MaintenanceUC>().First().uxContentScrollViewer.ScrollToTop();
  73. break;
  74. case "uxBuildListViewItem":
  75. uxContentGrid.Children.Add(ucBuildIco);
  76. uxContentGrid.Children.OfType<BuildIco>().First().uxContentScrollViewer.ScrollToTop();
  77. break;
  78. case "uxModifyListViewItem":
  79. uxContentGrid.Children.Add(ucModifyIco);
  80. uxContentGrid.Children.OfType<ModifyIco>().First().uxContentScrollViewer.ScrollToTop();
  81. break;
  82. default:
  83. break;
  84. }
  85. lastSelectedItem = item;
  86. }
  87. }
  88. }
  89. }