From 1e88ea36b5400aecbf9e6ba6de87141de8892ce4 Mon Sep 17 00:00:00 2001 From: HelloWorld Date: Sun, 27 Dec 2020 13:30:57 +0800 Subject: [PATCH] Update to .Net 5 --- Loopback/Loopback.csproj | 2 +- Loopback/MainWindow.xaml.cs | 210 ++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Loopback/Loopback.csproj b/Loopback/Loopback.csproj index e3e8a80..510d810 100644 --- a/Loopback/Loopback.csproj +++ b/Loopback/Loopback.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp3.1 + net5.0-windows true Loopback Application.ico diff --git a/Loopback/MainWindow.xaml.cs b/Loopback/MainWindow.xaml.cs index b695528..8f88ee2 100644 --- a/Loopback/MainWindow.xaml.cs +++ b/Loopback/MainWindow.xaml.cs @@ -16,122 +16,122 @@ namespace Loopback { - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - private LoopUtil _loop; - private List appFiltered = new List(); - private bool isDirty = false; + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private LoopUtil _loop; + private List appFiltered = new List(); + private bool isDirty = false; - public MainWindow() - { - InitializeComponent(); - _loop = new LoopUtil(); - dgLoopback.ItemsSource = appFiltered; - Filter(String.Empty, false, null); - ICollectionView cvApps = CollectionViewSource.GetDefaultView(dgLoopback.ItemsSource); - } + public MainWindow() + { + InitializeComponent(); + _loop = new LoopUtil(); + dgLoopback.ItemsSource = appFiltered; + Filter(String.Empty, false, null); + ICollectionView cvApps = CollectionViewSource.GetDefaultView(dgLoopback.ItemsSource); + } - private void btnSave_Click(object sender, RoutedEventArgs e) - { - if (!isDirty) - { - Log("nothing to save"); - return; - } + private void btnRefresh_Click(object sender, RoutedEventArgs e) + { + _loop.LoadApps(); + Filter(String.Empty, false, null); + txtFilter.Text = ""; + Loopback_Enabled.IsChecked = false; + Loopback_Disabled.IsChecked = false; + isDirty = false; + Log("refreshed"); + } - isDirty = false; - if (_loop.SaveLoopbackState()) - { - Log(" saved loopback excemptions"); - } - else - { - Log(" ERROR SAVING"); - } - } + private void btnSave_Click(object sender, RoutedEventArgs e) + { + if (!isDirty) + { + Log("nothing to save"); + return; + } - private void btnRefresh_Click(object sender, RoutedEventArgs e) - { - _loop.LoadApps(); - Filter(String.Empty, false, null); - txtFilter.Text = ""; - Loopback_Enabled.IsChecked = false; - Loopback_Disabled.IsChecked = false; - isDirty = false; - Log("refreshed"); - } + isDirty = false; + if (_loop.SaveLoopbackState()) + { + Log(" saved loopback excemptions"); + } + else + { + Log(" ERROR SAVING"); + } + } - private void Window_Closing(object sender, CancelEventArgs e) - { - if (isDirty) - { - MessageBoxResult resp = System.Windows.MessageBox.Show("You have not saved your changes. Are you sure you want to exit ?", "Loopback Manager", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (resp == MessageBoxResult.No) - { - e.Cancel = true; - return; - } - } - //To Do - _loop.FreeResources(); - } + private void dgcbLoop_Click(object sender, RoutedEventArgs e) + { + isDirty = true; + } - private void txtFilter_KeyUp(object sender, KeyEventArgs e) - { - bool isEnabledChecked = (bool)Loopback_Enabled.IsChecked; - if (isEnabledChecked) - { - Filter(txtFilter.Text, (bool)Loopback_Enabled.IsChecked, isEnabledChecked); - } - else - { - Filter(txtFilter.Text, (bool)Loopback_Disabled.IsChecked, isEnabledChecked); - } - } + private void Filter(string filter, bool Ischecked, bool? IsEnabled) + { + string appsInFilter = filter.ToUpper(); + appFiltered.Clear(); - private void Loopback_Click_Enabled(object sender, RoutedEventArgs e) - { - Filter(txtFilter.Text, (bool)Loopback_Enabled.IsChecked, true); - Loopback_Disabled.IsChecked = false; - } + foreach (LoopUtil.AppContainer app in _loop.Apps) + { + string appName = app.DisplayName.ToUpper(); - private void Loopback_Click_Disabled(object sender, RoutedEventArgs e) - { - Filter(txtFilter.Text, (bool)Loopback_Disabled.IsChecked, false); - Loopback_Enabled.IsChecked = false; - } + if (string.IsNullOrEmpty(filter) || appName.Contains(appsInFilter)) + { + if (Ischecked == false || app.LoopUtil == IsEnabled) + { + appFiltered.Add(app); + } + } + } + dgLoopback.Items.Refresh(); + } - private void Filter(string filter, bool Ischecked, bool? IsEnabled) - { - string appsInFilter = filter.ToUpper(); - appFiltered.Clear(); + private void Log(String logtxt) + { + txtStatus.Text = DateTime.Now.ToString("hh:mm:ss.fff ") + logtxt; + } - foreach (LoopUtil.AppContainer app in _loop.Apps) - { - string appName = app.DisplayName.ToUpper(); + private void Loopback_Click_Disabled(object sender, RoutedEventArgs e) + { + Filter(txtFilter.Text, (bool)Loopback_Disabled.IsChecked, false); + Loopback_Enabled.IsChecked = false; + } - if (string.IsNullOrEmpty(filter) || appName.Contains(appsInFilter)) - { - if (Ischecked == false || app.LoopUtil == IsEnabled) - { - appFiltered.Add(app); - } - } - } - dgLoopback.Items.Refresh(); - } + private void Loopback_Click_Enabled(object sender, RoutedEventArgs e) + { + Filter(txtFilter.Text, (bool)Loopback_Enabled.IsChecked, true); + Loopback_Disabled.IsChecked = false; + } - private void dgcbLoop_Click(object sender, RoutedEventArgs e) - { - isDirty = true; - } + private void txtFilter_KeyUp(object sender, KeyEventArgs e) + { + bool isEnabledChecked = (bool)Loopback_Enabled.IsChecked; + if (isEnabledChecked) + { + Filter(txtFilter.Text, (bool)Loopback_Enabled.IsChecked, isEnabledChecked); + } + else + { + Filter(txtFilter.Text, (bool)Loopback_Disabled.IsChecked, isEnabledChecked); + } + } - private void Log(String logtxt) - { - txtStatus.Text = DateTime.Now.ToString("hh:mm:ss.fff ") + logtxt; - } - } + private void Window_Closing(object sender, CancelEventArgs e) + { + if (isDirty) + { + MessageBoxResult resp = System.Windows.MessageBox.Show("You have not saved your changes. Are you sure you want to exit ?", "Loopback Manager", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (resp == MessageBoxResult.No) + { + e.Cancel = true; + return; + } + } + //To Do + _loop.FreeResources(); + } + } } \ No newline at end of file