WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f2da1e7

Browse files
committed
添加&优化搜索
1 parent 3afae32 commit f2da1e7

File tree

3 files changed

+89
-30
lines changed

3 files changed

+89
-30
lines changed

UotanToolbox/Features/Appmgr/AppmgrViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public AppmgrViewModel() : base(GetTranslation("Sidebar_Appmgr"), MaterialIconKi
4848
if (!string.IsNullOrEmpty(Search))
4949
{
5050
applicationInfos.Clear();
51-
applicationInfos.AddRange(allApplicationInfos.Where(app => app.DisplayName.Contains(Search) || app.Name.Contains(Search))
51+
applicationInfos.AddRange(allApplicationInfos.Where(app => app.DisplayName.Contains(Search, StringComparison.OrdinalIgnoreCase) || app.Name.Contains(Search, StringComparison.OrdinalIgnoreCase))
5252
.OrderByDescending(app => app.Size)
5353
.ThenBy(app => app.Name)
5454
.ToList());

UotanToolbox/Features/Modifypartition/ModifypartitionView.axaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,28 @@
1717
theme:WrapPanelExtensions.AnimatedScroll="True"
1818
Orientation="Horizontal">
1919
<suki:GlassCard Classes="Card" Margin="10 10" Height="635" Width="668">
20-
<suki:BusyArea Name="BusyPart"
21-
BusyText="载入中...">
22-
<DataGrid Name="PartList"
23-
Width="625"
24-
Height="565"
25-
FontSize="15"
26-
IsReadOnly="True"
27-
AutoGenerateColumns="True"
28-
CanUserResizeColumns="True">
29-
</DataGrid>
30-
</suki:BusyArea>
20+
<StackPanel Margin="0 -10 0 0">
21+
<StackPanel Margin="200 0 0 0" Orientation="Horizontal">
22+
<TextBox Name="SearchBox"
23+
Width="200"
24+
Height="30"
25+
FontSize="15"
26+
Watermark="搜索分区"/>
27+
<TextBlock Margin="90 14 0 0" Text="显示物理分区"/>
28+
<ToggleSwitch Name="ShowAllPart" IsEnabled="False" />
29+
</StackPanel>
30+
<suki:BusyArea Name="BusyPart"
31+
BusyText="载入中...">
32+
<DataGrid Name="PartList"
33+
Width="625"
34+
Height="565"
35+
FontSize="15"
36+
IsReadOnly="True"
37+
AutoGenerateColumns="True"
38+
CanUserResizeColumns="True">
39+
</DataGrid>
40+
</suki:BusyArea>
41+
</StackPanel>
3142
</suki:GlassCard>
3243
<StackPanel Orientation="Vertical">
3344
<suki:GlassCard Classes="Card" Margin="15 10 15 10" Width="265" Height="210">

UotanToolbox/Features/Modifypartition/ModifypartitionView.axaml.cs

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using Avalonia.Controls;
22
using Avalonia.Controls.Notifications;
33
using Avalonia.Interactivity;
4+
using ReactiveUI;
45
using SukiUI.Dialogs;
56
using SukiUI.Toasts;
67
using System;
8+
using System.Collections.ObjectModel;
79
using System.IO;
810
using System.Linq;
911
using System.Text.RegularExpressions;
@@ -20,10 +22,27 @@ private static string GetTranslation(string key)
2022
return FeaturesHelper.GetTranslation(key);
2123
}
2224

25+
public ObservableCollection<PartModel> Parts { get; set; } = new ObservableCollection<PartModel>();
26+
2327
public ModifypartitionView()
2428
{
2529
InitializeComponent();
2630
_ = LoadMassage();
31+
_ = this.WhenAnyValue(part => part.SearchBox.Text)
32+
.Subscribe(option =>
33+
{
34+
if (PartList.ItemsSource != null)
35+
{
36+
if (!string.IsNullOrEmpty(SearchBox.Text))
37+
{
38+
PartList.ItemsSource = Parts.Where(part => part.Name.Contains(SearchBox.Text, StringComparison.OrdinalIgnoreCase)).ToList();
39+
}
40+
else
41+
{
42+
PartList.ItemsSource = Parts.Where(info => info != null).ToList();
43+
}
44+
}
45+
});
2746
}
2847

2948
public async Task LoadMassage()
@@ -44,12 +63,14 @@ private async void SetFastboot(object sender, RoutedEventArgs args)
4463
NewPartitionFormat.IsEnabled = false;
4564
NewPartitionStartpoint.IsEnabled = false;
4665
NewPartitionEndpoint.IsEnabled = false;
66+
ShowAllPart.IsEnabled = true;
4767
}
4868
else
4969
{
5070
NewPartitionFormat.IsEnabled = true;
5171
NewPartitionStartpoint.IsEnabled = true;
5272
NewPartitionEndpoint.IsEnabled = true;
73+
ShowAllPart.IsEnabled = false;
5374
}
5475
}
5576

@@ -91,13 +112,14 @@ public void AddPartList()
91112
{
92113
string size = string.Format("{0}", StringHelper.DiskSize(choice));
93114
PartSize.Text = size;
94-
PartModel[] part = new PartModel[parts.Length - 5];
115+
PartModel[] part = new PartModel[parts.Length - 6];
95116
for (int i = 6; i < parts.Length; i++)
96117
{
97118
string[] items = StringHelper.Items(parts[i].ToCharArray());
98119
part[i - 6] = new PartModel(items[0], items[1], items[2], items[3], items[4], items[5], items[6]);
99120
}
100-
PartList.ItemsSource = part;
121+
Parts = new ObservableCollection<PartModel>(part);
122+
PartList.ItemsSource = Parts;
101123
}
102124
else
103125
{
@@ -173,6 +195,7 @@ private async void ReadPart(object sender, RoutedEventArgs args)
173195
{
174196
BusyPart.IsBusy = true;
175197
ReadPartBut.IsEnabled = false;
198+
PartList.ItemsSource = null;
176199
Global.checkdevice = false;
177200
string allinfo = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} getvar all");
178201
string[] parts = new string[1000];
@@ -192,7 +215,8 @@ private async void ReadPart(object sender, RoutedEventArgs args)
192215
string size = StringHelper.byte2AUnit((ulong)Convert.ToInt64(partinfos[3].Replace("0x", ""), 16));
193216
part[i] = new PartModel(i.ToString(), null, null, size, null, partinfos[2], null);
194217
}
195-
PartList.ItemsSource = part;
218+
Parts = new ObservableCollection<PartModel>(part);
219+
PartList.ItemsSource = Parts;
196220
BusyPart.IsBusy = false;
197221
ReadPartBut.IsEnabled = true;
198222
Global.checkdevice = true;
@@ -201,36 +225,60 @@ private async void ReadPart(object sender, RoutedEventArgs args)
201225
{
202226
BusyPart.IsBusy = true;
203227
ReadPartBut.IsEnabled = false;
228+
PartList.ItemsSource = null;
204229
Global.checkdevice = false;
205230
string allinfo = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} getvar all");
206-
string[] vparts = new string[1000];
231+
string[] parts = new string[1000];
207232
string[] allinfos = allinfo.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
208-
for (int i = 0; i < allinfos.Length; i++)
233+
if ((bool)ShowAllPart.IsChecked)
209234
{
210-
if (allinfos[i].Contains("is-logical") && allinfos[i].Contains("yes"))
235+
for (int i = 0; i < allinfos.Length; i++)
236+
{
237+
if (allinfos[i].Contains("partition-size"))
238+
{
239+
parts[i] = allinfos[i];
240+
}
241+
}
242+
parts = parts.Where(s => !string.IsNullOrEmpty(s)).ToArray();
243+
PartModel[] part = new PartModel[parts.Length];
244+
for (int i = 0; i < parts.Length; i++)
211245
{
212-
string[] vpartinfos = allinfos[i].Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
213-
vparts[i] = vpartinfos[2];
246+
string[] partinfos = parts[i].Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
247+
string size = StringHelper.byte2AUnit((ulong)Convert.ToInt64(partinfos[3].Replace("0x", ""), 16));
248+
part[i] = new PartModel(i.ToString(), null, null, size, null, partinfos[2], null);
214249
}
250+
Parts = new ObservableCollection<PartModel>(part);
215251
}
216-
vparts = vparts.Where(s => !string.IsNullOrEmpty(s)).ToArray();
217-
PartModel[] part = new PartModel[vparts.Length];
218-
for (int i = 0; i < vparts.Length; i++)
252+
else
219253
{
220-
for (int j = 0; j < allinfos.Length; j++)
254+
for (int i = 0; i < allinfos.Length; i++)
255+
{
256+
if (allinfos[i].Contains("is-logical") && allinfos[i].Contains("yes"))
257+
{
258+
string[] vpartinfos = allinfos[i].Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
259+
parts[i] = vpartinfos[2];
260+
}
261+
}
262+
parts = parts.Where(s => !string.IsNullOrEmpty(s)).ToArray();
263+
PartModel[] vpart = new PartModel[parts.Length];
264+
for (int i = 0; i < parts.Length; i++)
221265
{
222-
if (allinfos[j].Contains("partition-size"))
266+
for (int j = 0; j < allinfos.Length; j++)
223267
{
224-
string[] partinfos = allinfos[j].Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
225-
if (partinfos[2] == vparts[i])
268+
if (allinfos[j].Contains("partition-size"))
226269
{
227-
string size = StringHelper.byte2AUnit((ulong)Convert.ToInt64(partinfos[3].Replace("0x", ""), 16));
228-
part[i] = new PartModel(i.ToString(), null, null, size, null, partinfos[2], null);
270+
string[] partinfos = allinfos[j].Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
271+
if (partinfos[2] == parts[i])
272+
{
273+
string size = StringHelper.byte2AUnit((ulong)Convert.ToInt64(partinfos[3].Replace("0x", ""), 16));
274+
vpart[i] = new PartModel(i.ToString(), null, null, size, null, partinfos[2], null);
275+
}
229276
}
230277
}
231278
}
279+
Parts = new ObservableCollection<PartModel>(vpart);
232280
}
233-
PartList.ItemsSource = part;
281+
PartList.ItemsSource = Parts;
234282
BusyPart.IsBusy = false;
235283
ReadPartBut.IsEnabled = true;
236284
Global.checkdevice = true;

0 commit comments

Comments
 (0)