diff --git a/Correlator/Dialog/AudioFileDialog.xaml b/Correlator/Dialog/AudioFileDialog.xaml
index 41f08ea..3ae1f15 100644
--- a/Correlator/Dialog/AudioFileDialog.xaml
+++ b/Correlator/Dialog/AudioFileDialog.xaml
@@ -3,6 +3,7 @@
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"
@@ -25,107 +26,130 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Correlator/Dialog/AudioFileDialog.xaml b/Correlator/Dialog/AudioFileDialog.xaml
index 41f08ea..3ae1f15 100644
--- a/Correlator/Dialog/AudioFileDialog.xaml
+++ b/Correlator/Dialog/AudioFileDialog.xaml
@@ -3,6 +3,7 @@
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"
@@ -25,107 +26,130 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs
index 7a0fd9f..fb32d28 100644
--- a/Correlator/Util/MethodExtensions.cs
+++ b/Correlator/Util/MethodExtensions.cs
@@ -502,16 +502,6 @@
}
///
- /// 根据列表返回总页码
- ///
- ///
- ///
- public static int GetPageSize(this int count)
- {
- return (count + RuntimeCache.PerPageItemCount - 1) / RuntimeCache.PerPageItemCount;
- }
-
- ///
/// 判断是否是数字
///
///
@@ -549,18 +539,18 @@
return bitmap;
}
-
+
///
/// List 转 ObservableCollection
///
- ///
+ ///
///
- public static ObservableCollection ToObservableCollection(this List imageFiles)
+ public static ObservableCollection ToObservableCollection(this List list)
{
- var collection = new ObservableCollection();
- foreach (var file in imageFiles)
+ var collection = new ObservableCollection();
+ foreach (var t in list)
{
- collection.Add(file);
+ collection.Add(t);
}
return collection;
diff --git a/Correlator/Dialog/AudioFileDialog.xaml b/Correlator/Dialog/AudioFileDialog.xaml
index 41f08ea..3ae1f15 100644
--- a/Correlator/Dialog/AudioFileDialog.xaml
+++ b/Correlator/Dialog/AudioFileDialog.xaml
@@ -3,6 +3,7 @@
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"
@@ -25,107 +26,130 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs
index 7a0fd9f..fb32d28 100644
--- a/Correlator/Util/MethodExtensions.cs
+++ b/Correlator/Util/MethodExtensions.cs
@@ -502,16 +502,6 @@
}
///
- /// 根据列表返回总页码
- ///
- ///
- ///
- public static int GetPageSize(this int count)
- {
- return (count + RuntimeCache.PerPageItemCount - 1) / RuntimeCache.PerPageItemCount;
- }
-
- ///
/// 判断是否是数字
///
///
@@ -549,18 +539,18 @@
return bitmap;
}
-
+
///
/// List 转 ObservableCollection
///
- ///
+ ///
///
- public static ObservableCollection ToObservableCollection(this List imageFiles)
+ public static ObservableCollection ToObservableCollection(this List list)
{
- var collection = new ObservableCollection();
- foreach (var file in imageFiles)
+ var collection = new ObservableCollection();
+ foreach (var t in list)
{
- collection.Add(file);
+ collection.Add(t);
}
return collection;
diff --git a/Correlator/Util/RuntimeCache.cs b/Correlator/Util/RuntimeCache.cs
index 4d78069..90d620d 100644
--- a/Correlator/Util/RuntimeCache.cs
+++ b/Correlator/Util/RuntimeCache.cs
@@ -68,11 +68,6 @@
public static readonly List SmallAudioFiles = new List();
///
- /// 列表每页条目数
- ///
- public const int PerPageItemCount = 8;
-
- ///
/// 工作模式,水听器和加速度计
///
public static int WorkMode = 1;
diff --git a/Correlator/Dialog/AudioFileDialog.xaml b/Correlator/Dialog/AudioFileDialog.xaml
index 41f08ea..3ae1f15 100644
--- a/Correlator/Dialog/AudioFileDialog.xaml
+++ b/Correlator/Dialog/AudioFileDialog.xaml
@@ -3,6 +3,7 @@
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"
@@ -25,107 +26,130 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs
index 7a0fd9f..fb32d28 100644
--- a/Correlator/Util/MethodExtensions.cs
+++ b/Correlator/Util/MethodExtensions.cs
@@ -502,16 +502,6 @@
}
///
- /// 根据列表返回总页码
- ///
- ///
- ///
- public static int GetPageSize(this int count)
- {
- return (count + RuntimeCache.PerPageItemCount - 1) / RuntimeCache.PerPageItemCount;
- }
-
- ///
/// 判断是否是数字
///
///
@@ -549,18 +539,18 @@
return bitmap;
}
-
+
///
/// List 转 ObservableCollection
///
- ///
+ ///
///
- public static ObservableCollection ToObservableCollection(this List imageFiles)
+ public static ObservableCollection ToObservableCollection(this List list)
{
- var collection = new ObservableCollection();
- foreach (var file in imageFiles)
+ var collection = new ObservableCollection();
+ foreach (var t in list)
{
- collection.Add(file);
+ collection.Add(t);
}
return collection;
diff --git a/Correlator/Util/RuntimeCache.cs b/Correlator/Util/RuntimeCache.cs
index 4d78069..90d620d 100644
--- a/Correlator/Util/RuntimeCache.cs
+++ b/Correlator/Util/RuntimeCache.cs
@@ -68,11 +68,6 @@
public static readonly List SmallAudioFiles = new List();
///
- /// 列表每页条目数
- ///
- public const int PerPageItemCount = 8;
-
- ///
/// 工作模式,水听器和加速度计
///
public static int WorkMode = 1;
diff --git a/Correlator/ViewModels/AudioFileDialogViewModel.cs b/Correlator/ViewModels/AudioFileDialogViewModel.cs
index b5efbd8..6de901e 100644
--- a/Correlator/ViewModels/AudioFileDialogViewModel.cs
+++ b/Correlator/ViewModels/AudioFileDialogViewModel.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows;
+using System.Windows.Media.Imaging;
using System.Windows.Threading;
using Correlator.DataService;
using Correlator.Model;
@@ -29,9 +31,21 @@
remove { }
}
- private List _audioFiles;
+ private BitmapImage _emptyBitmapImage;
- public List AudioFiles
+ public BitmapImage EmptyBitmapImage
+ {
+ get => _emptyBitmapImage;
+ set
+ {
+ _emptyBitmapImage = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private ObservableCollection _audioFiles;
+
+ public ObservableCollection AudioFiles
{
get => _audioFiles;
set
@@ -77,18 +91,6 @@
}
}
- private int _pageIndex = 1;
-
- public int PageIndex
- {
- get => _pageIndex;
- set
- {
- _pageIndex = value;
- RaisePropertyChanged();
- }
- }
-
private int _maxPage;
public int MaxPage
@@ -116,6 +118,11 @@
private AudioFile _selectedFile;
private AudioFileReader _audioFileReader;
+ ///
+ /// 列表每页条目数
+ ///
+ private const int PerPageItemCount = 8;
+
private readonly DispatcherTimer _audioTimer = new DispatcherTimer
{
Interval = new TimeSpan(0, 0, 0, 1)
@@ -206,9 +213,8 @@
//刷新数据
var totalFiles = GetTotalAudioFiles();
- MaxPage = totalFiles.Count.GetPageSize();
- PageIndex = 1;
- AudioFiles = totalFiles.Take(RuntimeCache.PerPageItemCount).ToList();
+ MaxPage = (totalFiles.Count + PerPageItemCount - 1) / PerPageItemCount;
+ AudioFiles = totalFiles.ToObservableCollection();
}
catch (IOException)
{
@@ -218,10 +224,11 @@
private void PageUpdated(FunctionEventArgs args)
{
- AudioFiles = GetTotalAudioFiles()
- .Skip((args.Info - 1) * RuntimeCache.PerPageItemCount)
- .Take(RuntimeCache.PerPageItemCount)
+ var audioFiles = GetTotalAudioFiles()
+ .Skip((args.Info - 1) * PerPageItemCount)
+ .Take(PerPageItemCount)
.ToList();
+ AudioFiles = audioFiles.ToObservableCollection();
}
private void DisposeResource(string message)
@@ -242,9 +249,10 @@
public void OnDialogOpened(IDialogParameters parameters)
{
+ EmptyBitmapImage = new BitmapImage(new Uri(@"..\..\Image\empty_image.png", UriKind.Relative));
var totalFiles = GetTotalAudioFiles();
- MaxPage = totalFiles.Count.GetPageSize();
- AudioFiles = totalFiles.Take(RuntimeCache.PerPageItemCount).ToList();
+ MaxPage = (totalFiles.Count + PerPageItemCount - 1) / PerPageItemCount;
+ AudioFiles = totalFiles.Take(PerPageItemCount).ToList().ToObservableCollection();
}
private static List GetTotalAudioFiles()