12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using SourceChord.FluentWPF;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Media;
- namespace Phihong_EVSE_UI_Tool
- {
- /// <summary>
- /// MainWindow.xaml 的互動邏輯
- /// </summary>
- public partial class MainWindow : Window
- {
- private ListViewItem lastSelectedItem = null;
- private InitialIdleUC ucInitialIdle = new InitialIdleUC();
- private AuthenticationUC ucAuthentaction = new AuthenticationUC();
- private PlugChargingUC ucPlugCharging = new PlugChargingUC();
- private MaintenanceUC ucMaintenance = new MaintenanceUC();
- private BuildIco ucBuildIco = new BuildIco();
- private ModifyIco ucModifyIco = new ModifyIco();
- public MainWindow()
- {
- InitializeComponent();
- this.MaxHeight = SystemParameters.WorkArea.Height + 12.5;
- this.MinWidth = 1200;
- this.MinHeight = 800;
- uxInitListViewItem.IsSelected = true;
- uxInitListViewItem.Focus();
- }
- private void uxMenuListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (uxMenuListView.SelectedItem != null)
- {
- if (lastSelectedItem != null)
- {
- lastSelectedItem.Foreground = new SolidColorBrush(Colors.Black);
- lastSelectedItem.Background = null;
- }
- ListViewItem item = uxMenuListView.SelectedItem as ListViewItem;
- Binding myBinding = new Binding("ImmersiveSystemAccentBrush");
- myBinding.Source = new AccentColors();
- item.SetBinding(ListViewItem.ForegroundProperty, myBinding);
- item.Background = new SolidColorBrush(Color.FromArgb(45, 0, 0, 0));
- uxTitleTextBlock.Text = (item.Content as StackPanel).Children.OfType<TextBlock>().First().Text;
- uxContentGrid.Children.Clear();
- switch (item.Name)
- {
- case "uxInitListViewItem":
- uxContentGrid.Children.Add(ucInitialIdle);
- uxContentGrid.Children.OfType<InitialIdleUC>().First().uxContentScrollViewer.ScrollToTop();
- break;
- case "uxAuthListViewItem":
- uxContentGrid.Children.Add(ucAuthentaction);
- uxContentGrid.Children.OfType<AuthenticationUC>().First().uxContentScrollViewer.ScrollToTop();
- break;
- case "uxChargingListViewItem":
- uxContentGrid.Children.Add(ucPlugCharging);
- uxContentGrid.Children.OfType<PlugChargingUC>().First().uxContentScrollViewer.ScrollToTop();
- break;
- case "uxMaintainListViewItem":
- uxContentGrid.Children.Add(ucMaintenance);
- uxContentGrid.Children.OfType<MaintenanceUC>().First().uxContentScrollViewer.ScrollToTop();
- break;
- case "uxBuildListViewItem":
- uxContentGrid.Children.Add(ucBuildIco);
- uxContentGrid.Children.OfType<BuildIco>().First().uxContentScrollViewer.ScrollToTop();
- break;
- case "uxModifyListViewItem":
- uxContentGrid.Children.Add(ucModifyIco);
- uxContentGrid.Children.OfType<ModifyIco>().First().uxContentScrollViewer.ScrollToTop();
- break;
- default:
- break;
- }
- lastSelectedItem = item;
- }
- }
- }
- }
|