diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/Model/ChildFolderModel.cs b/Correlator/Model/ChildFolderModel.cs new file mode 100644 index 0000000..60f1113 --- /dev/null +++ b/Correlator/Model/ChildFolderModel.cs @@ -0,0 +1,11 @@ +namespace Correlator.Model +{ + public class ChildFolderModel + { + public string FolderType { set; get; } + public string FolderName { set; get; } + public string FullPath { set; get; } + public string CreationTime { set; get; } + public string ChildFileCount { set; get; } + } +} \ No newline at end of file diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/Model/ChildFolderModel.cs b/Correlator/Model/ChildFolderModel.cs new file mode 100644 index 0000000..60f1113 --- /dev/null +++ b/Correlator/Model/ChildFolderModel.cs @@ -0,0 +1,11 @@ +namespace Correlator.Model +{ + public class ChildFolderModel + { + public string FolderType { set; get; } + public string FolderName { set; get; } + public string FullPath { set; get; } + public string CreationTime { set; get; } + public string ChildFileCount { set; get; } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/AudioFileDialogViewModel.cs b/Correlator/ViewModels/AudioFileDialogViewModel.cs index 5bc3cc6..87c2cfe 100644 --- a/Correlator/ViewModels/AudioFileDialogViewModel.cs +++ b/Correlator/ViewModels/AudioFileDialogViewModel.cs @@ -102,7 +102,7 @@ }, delegate { }); } - private async void PageUpdated(FunctionEventArgs args) + private void PageUpdated(FunctionEventArgs args) { var audioFiles = _totalFiles .Skip((args.Info - 1) * PerPageItemCount) diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/Model/ChildFolderModel.cs b/Correlator/Model/ChildFolderModel.cs new file mode 100644 index 0000000..60f1113 --- /dev/null +++ b/Correlator/Model/ChildFolderModel.cs @@ -0,0 +1,11 @@ +namespace Correlator.Model +{ + public class ChildFolderModel + { + public string FolderType { set; get; } + public string FolderName { set; get; } + public string FullPath { set; get; } + public string CreationTime { set; get; } + public string ChildFileCount { set; get; } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/AudioFileDialogViewModel.cs b/Correlator/ViewModels/AudioFileDialogViewModel.cs index 5bc3cc6..87c2cfe 100644 --- a/Correlator/ViewModels/AudioFileDialogViewModel.cs +++ b/Correlator/ViewModels/AudioFileDialogViewModel.cs @@ -102,7 +102,7 @@ }, delegate { }); } - private async void PageUpdated(FunctionEventArgs args) + private void PageUpdated(FunctionEventArgs args) { var audioFiles = _totalFiles .Skip((args.Info - 1) * PerPageItemCount) diff --git a/Correlator/ViewModels/ImageChildFolderViewModel.cs b/Correlator/ViewModels/ImageChildFolderViewModel.cs new file mode 100644 index 0000000..4a823eb --- /dev/null +++ b/Correlator/ViewModels/ImageChildFolderViewModel.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Correlator.Model; +using Correlator.Util; +using HandyControl.Data; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Services.Dialogs; + +namespace Correlator.ViewModels +{ + public class ImageChildFolderViewModel : BindableBase, IDialogAware + { + #region 属性绑定 + + public string Title => "快照文件夹列表"; + + public event Action RequestClose + { + add { } + remove { } + } + + private ObservableCollection _childFolders; + + public ObservableCollection ChildFolders + { + get => _childFolders; + set + { + _childFolders = value; + RaisePropertyChanged(); + } + } + + private ChildFolderModel _selectedFolder; + + public ChildFolderModel SelectedFolder + { + get => _selectedFolder; + set + { + _selectedFolder = value; + RaisePropertyChanged(); + } + } + + private int _maxPage; + + public int MaxPage + { + get => _maxPage; + set + { + _maxPage = value; + RaisePropertyChanged(); + } + } + + private bool _taskHasCompleted; + + public bool TaskHasCompleted + { + get => _taskHasCompleted; + set + { + _taskHasCompleted = value; + RaisePropertyChanged(); + } + } + + #endregion + + #region DelegateCommand + + public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand MouseDoubleClickCommand { get; set; } + public DelegateCommand> PageUpdatedCmd { get; set; } + + #endregion + + private readonly IDialogService _dialogService; + private List _totalFolders; + + /// + /// 截屏文件夹九宫格每页条目数 + /// + private const int PerGridItemCount = 55; + + public ImageChildFolderViewModel(IDialogService dialogService) + { + _dialogService = dialogService; + + ItemSelectedCommand = new DelegateCommand(ItemSelected); + MouseDoubleClickCommand = new DelegateCommand(ShowChildFolderPicture); + PageUpdatedCmd = new DelegateCommand>(PageUpdated); + } + + private void ItemSelected(ChildFolderModel selectedItem) + { + SelectedFolder = selectedItem; + } + + private void ShowChildFolderPicture(ChildFolderModel childFolder) + { + if (childFolder == null) + { + MessageBox.Show("文件夹路径错误,无法查看", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Stop); + return; + } + + _dialogService.ShowDialog("ScreenImageFileDialog", new DialogParameters + { + { "ChildFolderFullPath", childFolder.FullPath } + }, delegate { }); + } + + private void PageUpdated(FunctionEventArgs args) + { + var childFolders = _totalFolders + .Skip((args.Info - 1) * PerGridItemCount) + .Take(PerGridItemCount) + .ToList(); + ChildFolders = childFolders.ToObservableCollection(); + } + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + } + + public async void OnDialogOpened(IDialogParameters parameters) + { + _totalFolders = await GetTotalChildFoldersAsync(); + MaxPage = (_totalFolders.Count + PerGridItemCount - 1) / PerGridItemCount; + ChildFolders = _totalFolders.Take(PerGridItemCount).ToList().ToObservableCollection(); + } + + /// + /// 异步遍历文件夹,防止卡主线程 + /// + /// + private async Task> GetTotalChildFoldersAsync() + { + var childFolders = new List(); + + await Task.Run(() => TraverseFolder(DirectoryManager.GetPictureDir(), childFolders)); + TaskHasCompleted = true; + return childFolders.OrderBy(folder => folder.CreationTime).Reverse().ToList(); + } + + /// + /// 遍历文件夹并生成相应的数据类型集合 + /// + /// + /// + private static void TraverseFolder(string folderPath, List childFolders) + { + var directories = new DirectoryInfo(folderPath).GetDirectories(); + foreach (var dic in directories) + { + var childFolderFullPath = dic.FullName; + var childFolder = new ChildFolderModel + { + FolderType = "Image", + FolderName = dic.Name, + FullPath = childFolderFullPath, + CreationTime = dic.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"), + ChildFileCount = new DirectoryInfo(childFolderFullPath).GetFiles().Length.ToString() + }; + + childFolders.Add(childFolder); + } + } + } +} \ No newline at end of file diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/Model/ChildFolderModel.cs b/Correlator/Model/ChildFolderModel.cs new file mode 100644 index 0000000..60f1113 --- /dev/null +++ b/Correlator/Model/ChildFolderModel.cs @@ -0,0 +1,11 @@ +namespace Correlator.Model +{ + public class ChildFolderModel + { + public string FolderType { set; get; } + public string FolderName { set; get; } + public string FullPath { set; get; } + public string CreationTime { set; get; } + public string ChildFileCount { set; get; } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/AudioFileDialogViewModel.cs b/Correlator/ViewModels/AudioFileDialogViewModel.cs index 5bc3cc6..87c2cfe 100644 --- a/Correlator/ViewModels/AudioFileDialogViewModel.cs +++ b/Correlator/ViewModels/AudioFileDialogViewModel.cs @@ -102,7 +102,7 @@ }, delegate { }); } - private async void PageUpdated(FunctionEventArgs args) + private void PageUpdated(FunctionEventArgs args) { var audioFiles = _totalFiles .Skip((args.Info - 1) * PerPageItemCount) diff --git a/Correlator/ViewModels/ImageChildFolderViewModel.cs b/Correlator/ViewModels/ImageChildFolderViewModel.cs new file mode 100644 index 0000000..4a823eb --- /dev/null +++ b/Correlator/ViewModels/ImageChildFolderViewModel.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Correlator.Model; +using Correlator.Util; +using HandyControl.Data; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Services.Dialogs; + +namespace Correlator.ViewModels +{ + public class ImageChildFolderViewModel : BindableBase, IDialogAware + { + #region 属性绑定 + + public string Title => "快照文件夹列表"; + + public event Action RequestClose + { + add { } + remove { } + } + + private ObservableCollection _childFolders; + + public ObservableCollection ChildFolders + { + get => _childFolders; + set + { + _childFolders = value; + RaisePropertyChanged(); + } + } + + private ChildFolderModel _selectedFolder; + + public ChildFolderModel SelectedFolder + { + get => _selectedFolder; + set + { + _selectedFolder = value; + RaisePropertyChanged(); + } + } + + private int _maxPage; + + public int MaxPage + { + get => _maxPage; + set + { + _maxPage = value; + RaisePropertyChanged(); + } + } + + private bool _taskHasCompleted; + + public bool TaskHasCompleted + { + get => _taskHasCompleted; + set + { + _taskHasCompleted = value; + RaisePropertyChanged(); + } + } + + #endregion + + #region DelegateCommand + + public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand MouseDoubleClickCommand { get; set; } + public DelegateCommand> PageUpdatedCmd { get; set; } + + #endregion + + private readonly IDialogService _dialogService; + private List _totalFolders; + + /// + /// 截屏文件夹九宫格每页条目数 + /// + private const int PerGridItemCount = 55; + + public ImageChildFolderViewModel(IDialogService dialogService) + { + _dialogService = dialogService; + + ItemSelectedCommand = new DelegateCommand(ItemSelected); + MouseDoubleClickCommand = new DelegateCommand(ShowChildFolderPicture); + PageUpdatedCmd = new DelegateCommand>(PageUpdated); + } + + private void ItemSelected(ChildFolderModel selectedItem) + { + SelectedFolder = selectedItem; + } + + private void ShowChildFolderPicture(ChildFolderModel childFolder) + { + if (childFolder == null) + { + MessageBox.Show("文件夹路径错误,无法查看", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Stop); + return; + } + + _dialogService.ShowDialog("ScreenImageFileDialog", new DialogParameters + { + { "ChildFolderFullPath", childFolder.FullPath } + }, delegate { }); + } + + private void PageUpdated(FunctionEventArgs args) + { + var childFolders = _totalFolders + .Skip((args.Info - 1) * PerGridItemCount) + .Take(PerGridItemCount) + .ToList(); + ChildFolders = childFolders.ToObservableCollection(); + } + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + } + + public async void OnDialogOpened(IDialogParameters parameters) + { + _totalFolders = await GetTotalChildFoldersAsync(); + MaxPage = (_totalFolders.Count + PerGridItemCount - 1) / PerGridItemCount; + ChildFolders = _totalFolders.Take(PerGridItemCount).ToList().ToObservableCollection(); + } + + /// + /// 异步遍历文件夹,防止卡主线程 + /// + /// + private async Task> GetTotalChildFoldersAsync() + { + var childFolders = new List(); + + await Task.Run(() => TraverseFolder(DirectoryManager.GetPictureDir(), childFolders)); + TaskHasCompleted = true; + return childFolders.OrderBy(folder => folder.CreationTime).Reverse().ToList(); + } + + /// + /// 遍历文件夹并生成相应的数据类型集合 + /// + /// + /// + private static void TraverseFolder(string folderPath, List childFolders) + { + var directories = new DirectoryInfo(folderPath).GetDirectories(); + foreach (var dic in directories) + { + var childFolderFullPath = dic.FullName; + var childFolder = new ChildFolderModel + { + FolderType = "Image", + FolderName = dic.Name, + FullPath = childFolderFullPath, + CreationTime = dic.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"), + ChildFileCount = new DirectoryInfo(childFolderFullPath).GetFiles().Length.ToString() + }; + + childFolders.Add(childFolder); + } + } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index 50f7a55..6e24ef1 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -637,7 +637,7 @@ private void OpenImageFile(Popup popup) { - _dialogService.Show("ScreenImageFileDialog", null, delegate { }); + _dialogService.Show("ImageChildFolderDialog", null, delegate { }); popup.IsOpen = false; } @@ -736,8 +736,7 @@ { try { - var file = new DirectoryInfo(DirectoryManager.LogDirPath) - .GetFiles("*.log", SearchOption.AllDirectories) + var file = new DirectoryInfo(DirectoryManager.LogDirPath).GetFiles() .OrderBy(f => f.LastWriteTime) .Reverse() .First(); @@ -844,7 +843,13 @@ private void SnapShot() { - var filePath = $"{DirectoryManager.GetPictureDir()}\\快照_{DateTime.Now:yyyyMMddHHmmss}.png"; + var childFolder = $"{DirectoryManager.GetPictureDir()}\\{DateTime.Now.Date:yyyy-MM-dd}"; + if (!Directory.Exists(childFolder)) + { + Directory.CreateDirectory(childFolder); + } + + var filePath = $"{childFolder}\\快照_{DateTime.Now:yyyyMMddHHmmss}.png"; filePath.SnapShot(); } diff --git a/Correlator/App.xaml.cs b/Correlator/App.xaml.cs index 66b62a8..f998df3 100644 --- a/Correlator/App.xaml.cs +++ b/Correlator/App.xaml.cs @@ -101,6 +101,7 @@ containerRegistry.RegisterSingleton(); //Dialog or Window + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/Correlator/Converter/ChildFolderImageConverter.cs b/Correlator/Converter/ChildFolderImageConverter.cs new file mode 100644 index 0000000..d120692 --- /dev/null +++ b/Correlator/Converter/ChildFolderImageConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Correlator.Converter +{ + public class ChildFolderImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Debug.Assert(value != null, nameof(value) + " != null"); + if (value.Equals("Image")) + { + return new BitmapImage(new Uri(@"..\..\Image\image_folder.png", UriKind.Relative)); + } + + return new BitmapImage(new Uri(@"..\..\Image\audio_folder.png", UriKind.Relative)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 5673d97..0543852 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -189,22 +189,23 @@ Designer - - + + + - + - + - + - + @@ -222,6 +223,9 @@ CheckResponseDialog.xaml + + ImageChildFolderDialog.xaml + DetectNoiseDialog.xaml @@ -237,22 +241,24 @@ LoadingDialog.xaml - - ScreenImageFileDialog.xaml + + ScreenImageFileDialog.xaml SoundSampleRateDialog.xaml - - + + + - + - - - + + + + NoiseWaveView.xaml @@ -299,13 +305,13 @@ - + - + @@ -318,23 +324,24 @@ - + Designer MSBuild:Compile + - + Designer MSBuild:Compile - - - + + + Designer MSBuild:Compile @@ -464,8 +471,12 @@ false - - + + + + + + diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml b/Correlator/Dialog/ImageChildFolderDialog.xaml new file mode 100644 index 0000000..13f71c1 --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Dialog/ImageChildFolderDialog.xaml.cs b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs new file mode 100644 index 0000000..a6a4f6f --- /dev/null +++ b/Correlator/Dialog/ImageChildFolderDialog.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace Correlator.Dialog +{ + public partial class ImageChildFolderDialog : UserControl + { + public ImageChildFolderDialog() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Correlator/Dialog/ScreenImageFileDialog.xaml b/Correlator/Dialog/ScreenImageFileDialog.xaml index 2a8f133..3ecbd7e 100644 --- a/Correlator/Dialog/ScreenImageFileDialog.xaml +++ b/Correlator/Dialog/ScreenImageFileDialog.xaml @@ -3,7 +3,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" - xmlns:cvt="clr-namespace:Correlator.Converter" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -24,150 +23,106 @@ - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Grid.Column="1" + VerticalAlignment="Center" + FontSize="16" + Text="{Binding SelectedImageFile.FileSize, StringFormat={}文件大小:{0}}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/Correlator/Image/audio_folder.png b/Correlator/Image/audio_folder.png new file mode 100644 index 0000000..e238213 --- /dev/null +++ b/Correlator/Image/audio_folder.png Binary files differ diff --git a/Correlator/Image/image_folder.png b/Correlator/Image/image_folder.png new file mode 100644 index 0000000..7f22657 --- /dev/null +++ b/Correlator/Image/image_folder.png Binary files differ diff --git a/Correlator/Model/ChildFolderModel.cs b/Correlator/Model/ChildFolderModel.cs new file mode 100644 index 0000000..60f1113 --- /dev/null +++ b/Correlator/Model/ChildFolderModel.cs @@ -0,0 +1,11 @@ +namespace Correlator.Model +{ + public class ChildFolderModel + { + public string FolderType { set; get; } + public string FolderName { set; get; } + public string FullPath { set; get; } + public string CreationTime { set; get; } + public string ChildFileCount { set; get; } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/AudioFileDialogViewModel.cs b/Correlator/ViewModels/AudioFileDialogViewModel.cs index 5bc3cc6..87c2cfe 100644 --- a/Correlator/ViewModels/AudioFileDialogViewModel.cs +++ b/Correlator/ViewModels/AudioFileDialogViewModel.cs @@ -102,7 +102,7 @@ }, delegate { }); } - private async void PageUpdated(FunctionEventArgs args) + private void PageUpdated(FunctionEventArgs args) { var audioFiles = _totalFiles .Skip((args.Info - 1) * PerPageItemCount) diff --git a/Correlator/ViewModels/ImageChildFolderViewModel.cs b/Correlator/ViewModels/ImageChildFolderViewModel.cs new file mode 100644 index 0000000..4a823eb --- /dev/null +++ b/Correlator/ViewModels/ImageChildFolderViewModel.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Correlator.Model; +using Correlator.Util; +using HandyControl.Data; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Services.Dialogs; + +namespace Correlator.ViewModels +{ + public class ImageChildFolderViewModel : BindableBase, IDialogAware + { + #region 属性绑定 + + public string Title => "快照文件夹列表"; + + public event Action RequestClose + { + add { } + remove { } + } + + private ObservableCollection _childFolders; + + public ObservableCollection ChildFolders + { + get => _childFolders; + set + { + _childFolders = value; + RaisePropertyChanged(); + } + } + + private ChildFolderModel _selectedFolder; + + public ChildFolderModel SelectedFolder + { + get => _selectedFolder; + set + { + _selectedFolder = value; + RaisePropertyChanged(); + } + } + + private int _maxPage; + + public int MaxPage + { + get => _maxPage; + set + { + _maxPage = value; + RaisePropertyChanged(); + } + } + + private bool _taskHasCompleted; + + public bool TaskHasCompleted + { + get => _taskHasCompleted; + set + { + _taskHasCompleted = value; + RaisePropertyChanged(); + } + } + + #endregion + + #region DelegateCommand + + public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand MouseDoubleClickCommand { get; set; } + public DelegateCommand> PageUpdatedCmd { get; set; } + + #endregion + + private readonly IDialogService _dialogService; + private List _totalFolders; + + /// + /// 截屏文件夹九宫格每页条目数 + /// + private const int PerGridItemCount = 55; + + public ImageChildFolderViewModel(IDialogService dialogService) + { + _dialogService = dialogService; + + ItemSelectedCommand = new DelegateCommand(ItemSelected); + MouseDoubleClickCommand = new DelegateCommand(ShowChildFolderPicture); + PageUpdatedCmd = new DelegateCommand>(PageUpdated); + } + + private void ItemSelected(ChildFolderModel selectedItem) + { + SelectedFolder = selectedItem; + } + + private void ShowChildFolderPicture(ChildFolderModel childFolder) + { + if (childFolder == null) + { + MessageBox.Show("文件夹路径错误,无法查看", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Stop); + return; + } + + _dialogService.ShowDialog("ScreenImageFileDialog", new DialogParameters + { + { "ChildFolderFullPath", childFolder.FullPath } + }, delegate { }); + } + + private void PageUpdated(FunctionEventArgs args) + { + var childFolders = _totalFolders + .Skip((args.Info - 1) * PerGridItemCount) + .Take(PerGridItemCount) + .ToList(); + ChildFolders = childFolders.ToObservableCollection(); + } + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + } + + public async void OnDialogOpened(IDialogParameters parameters) + { + _totalFolders = await GetTotalChildFoldersAsync(); + MaxPage = (_totalFolders.Count + PerGridItemCount - 1) / PerGridItemCount; + ChildFolders = _totalFolders.Take(PerGridItemCount).ToList().ToObservableCollection(); + } + + /// + /// 异步遍历文件夹,防止卡主线程 + /// + /// + private async Task> GetTotalChildFoldersAsync() + { + var childFolders = new List(); + + await Task.Run(() => TraverseFolder(DirectoryManager.GetPictureDir(), childFolders)); + TaskHasCompleted = true; + return childFolders.OrderBy(folder => folder.CreationTime).Reverse().ToList(); + } + + /// + /// 遍历文件夹并生成相应的数据类型集合 + /// + /// + /// + private static void TraverseFolder(string folderPath, List childFolders) + { + var directories = new DirectoryInfo(folderPath).GetDirectories(); + foreach (var dic in directories) + { + var childFolderFullPath = dic.FullName; + var childFolder = new ChildFolderModel + { + FolderType = "Image", + FolderName = dic.Name, + FullPath = childFolderFullPath, + CreationTime = dic.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"), + ChildFileCount = new DirectoryInfo(childFolderFullPath).GetFiles().Length.ToString() + }; + + childFolders.Add(childFolder); + } + } + } +} \ No newline at end of file diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index 50f7a55..6e24ef1 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -637,7 +637,7 @@ private void OpenImageFile(Popup popup) { - _dialogService.Show("ScreenImageFileDialog", null, delegate { }); + _dialogService.Show("ImageChildFolderDialog", null, delegate { }); popup.IsOpen = false; } @@ -736,8 +736,7 @@ { try { - var file = new DirectoryInfo(DirectoryManager.LogDirPath) - .GetFiles("*.log", SearchOption.AllDirectories) + var file = new DirectoryInfo(DirectoryManager.LogDirPath).GetFiles() .OrderBy(f => f.LastWriteTime) .Reverse() .First(); @@ -844,7 +843,13 @@ private void SnapShot() { - var filePath = $"{DirectoryManager.GetPictureDir()}\\快照_{DateTime.Now:yyyyMMddHHmmss}.png"; + var childFolder = $"{DirectoryManager.GetPictureDir()}\\{DateTime.Now.Date:yyyy-MM-dd}"; + if (!Directory.Exists(childFolder)) + { + Directory.CreateDirectory(childFolder); + } + + var filePath = $"{childFolder}\\快照_{DateTime.Now:yyyyMMddHHmmss}.png"; filePath.SnapShot(); } diff --git a/Correlator/ViewModels/ScreenImageFileDialogViewModel.cs b/Correlator/ViewModels/ScreenImageFileDialogViewModel.cs index 1337bbd..39fece3 100644 --- a/Correlator/ViewModels/ScreenImageFileDialogViewModel.cs +++ b/Correlator/ViewModels/ScreenImageFileDialogViewModel.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Threading.Tasks; using System.Windows; using Correlator.Model; using Correlator.Util; @@ -19,7 +18,7 @@ { #region 属性绑定 - public string Title => "图片文件列表"; + public string Title => "快照文件列表"; public event Action RequestClose { @@ -63,18 +62,6 @@ } } - private bool _taskHasCompleted; - - public bool TaskHasCompleted - { - get => _taskHasCompleted; - set - { - _taskHasCompleted = value; - RaisePropertyChanged(); - } - } - #endregion #region DelegateCommand @@ -121,7 +108,7 @@ }, delegate { }); } - private async void PageUpdated(FunctionEventArgs args) + private void PageUpdated(FunctionEventArgs args) { var imageFiles = _totalFiles .Skip((args.Info - 1) * PerGridItemCount) @@ -139,37 +126,24 @@ { } - public async void OnDialogOpened(IDialogParameters parameters) + public void OnDialogOpened(IDialogParameters parameters) { - _totalFiles = await GetTotalPictureFilesAsync(); + _totalFiles = GetTotalPictureFiles(parameters.GetValue("ChildFolderFullPath")); MaxPage = (_totalFiles.Count + PerGridItemCount - 1) / PerGridItemCount; PictureFiles = _totalFiles.Take(PerGridItemCount).ToList().ToObservableCollection(); } /// - /// 异步遍历文件夹,防止卡主线程 - /// - /// - private async Task> GetTotalPictureFilesAsync() - { - var imageFiles = new List(); - - await Task.Run(() => TraverseFolder(DirectoryManager.GetPictureDir(), imageFiles)); - TaskHasCompleted = true; - return imageFiles.OrderBy(file => file.CreationTime).Reverse().ToList(); - } - - /// /// 遍历文件夹并生成相应的数据类型集合 /// /// - /// - private static void TraverseFolder(string folderPath, List imageFiles) + private List GetTotalPictureFiles(string folderPath) { + var imageFiles = new List(); var files = new DirectoryInfo(folderPath).GetFiles(); foreach (var file in files) { - var filePath = DirectoryManager.GetPictureDir() + "\\" + file.Name; + var filePath = folderPath + "\\" + file.Name; var imageFile = new ImageFile { FileName = file.Name, @@ -181,6 +155,8 @@ imageFiles.Add(imageFile); } + + return imageFiles.OrderBy(file => file.CreationTime).Reverse().ToList(); } } } \ No newline at end of file