提交记录修改Core/Servicers/Instances/AppData.cs+0 −1看文件
修改UI/Controls/Base/View.cs+8 −1看文件
修改UI/Controls/Input/InputBox.cs+1 −0看文件
修改UI/Models/CategoryAppList/ChooseAppModel.cs+2 −0看文件
修改UI/Models/CategoryAppListPageModel.cs+3 −0看文件
修改UI/ViewModels/CategoryAppListPageVM.cs+93 −4看文件
修改UI/Views/CategoryAppListPage.xaml+90 −64看文件
| @@ -133,7 +133,6 @@ namespace Core.Servicers.Instances | ||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | db.SaveChanges(); |
| 136 | 删除: _updateTempApps.Clear(); | |
| 137 | 136 | } |
| 138 | 137 | } |
| 139 | 138 | } |
| @@ -90,7 +90,14 @@ namespace UI.Controls.Base | ||
| 90 | 90 | else |
| 91 | 91 | { |
| 92 | 92 | var data = Value as IEnumerable<object>; |
| 93 | 删除: isShow = data.Count() == 0; | |
| 93 | 新增: if (data != null) | |
| 94 | 新增: { | |
| 95 | 新增: isShow = data.Count() == 0; | |
| 96 | 新增: } | |
| 97 | 新增: else | |
| 98 | 新增: { | |
| 99 | 新增: isShow = string.IsNullOrEmpty(Value.ToString()); | |
| 100 | 新增: } | |
| 94 | 101 | } |
| 95 | 102 | } |
| 96 | 103 | else |
| @@ -44,6 +44,7 @@ namespace UI.Controls.Input | ||
| 44 | 44 | |
| 45 | 45 | public void HideError() |
| 46 | 46 | { |
| 47 | 新增: | |
| 47 | 48 | IsShowError = false; |
| 48 | 49 | } |
| 49 | 50 | } |
| @@ -4,6 +4,7 @@ using System.Collections.Generic; | ||
| 4 | 4 | using System.Linq; |
| 5 | 5 | using System.Text; |
| 6 | 6 | using System.Threading.Tasks; |
| 7 | 新增:using System.Windows; | |
| 7 | 8 | using UI.Controls.Select; |
| 8 | 9 | |
| 9 | 10 | namespace UI.Models.CategoryAppList |
| @@ -13,5 +14,6 @@ namespace UI.Models.CategoryAppList | ||
| 13 | 14 | public bool IsChoosed { get; set; } |
| 14 | 15 | public AppModel App { get; set; } |
| 15 | 16 | public SelectItemModel Value { get; set; } = new SelectItemModel(); |
| 17 | 新增: public Visibility Visibility { get; set; } = Visibility.Visible; | |
| 16 | 18 | } |
| 17 | 19 | } |
| @@ -28,5 +28,8 @@ namespace UI.Models | ||
| 28 | 28 | |
| 29 | 29 | private AppModel SelectedItem_; |
| 30 | 30 | public AppModel SelectedItem { get { return SelectedItem_; } set { SelectedItem_ = value; OnPropertyChanged(); } } |
| 31 | 新增: | |
| 32 | 新增: private string SearchInput_; | |
| 33 | 新增: public string SearchInput { get { return SearchInput_; } set { SearchInput_ = value; OnPropertyChanged(); } } | |
| 31 | 34 | } |
| 32 | 35 | } |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | using Core.Servicers.Interfaces; |
| 3 | 3 | using System; |
| 4 | 4 | using System.Collections.Generic; |
| 5 | 新增:using System.Diagnostics; | |
| 5 | 6 | using System.Linq; |
| 6 | 7 | using System.Text; |
| 7 | 8 | using System.Threading.Tasks; |
| @@ -17,22 +18,73 @@ namespace UI.ViewModels | ||
| 17 | 18 | { |
| 18 | 19 | private readonly IAppData appData; |
| 19 | 20 | private readonly MainViewModel mainVM; |
| 20 | 删除: | |
| 21 | 新增: private List<ChooseAppModel> appList; | |
| 21 | 22 | public Command ShowChooseCommand { get; set; } |
| 22 | 23 | public Command ChoosedCommand { get; set; } |
| 23 | 24 | public Command GotoDetailCommand { get; set; } |
| 25 | 新增: public Command SearchCommand { get; set; } | |
| 26 | 新增: public Command ChooseCloseCommand { get; set; } | |
| 27 | 新增: public Command DelCommand { get; set; } | |
| 24 | 28 | public CategoryAppListPageVM(IAppData appData, MainViewModel mainVM) |
| 25 | 29 | { |
| 26 | 30 | this.appData = appData; |
| 27 | 31 | this.mainVM = mainVM; |
| 28 | 32 | |
| 33 | 新增: | |
| 29 | 34 | ShowChooseCommand = new Command(new Action<object>(OnShowChoose)); |
| 30 | 35 | ChoosedCommand = new Command(new Action<object>(OnChoosed)); |
| 31 | 36 | GotoDetailCommand = new Command(new Action<object>(OnGotoDetail)); |
| 37 | 新增: SearchCommand = new Command(new Action<object>(OnSearch)); | |
| 38 | 新增: ChooseCloseCommand = new Command(new Action<object>(OnChooseClose)); | |
| 39 | 新增: DelCommand = new Command(new Action<object>(OnDel)); | |
| 32 | 40 | |
| 33 | 41 | LoadData(); |
| 42 | 新增: | |
| 43 | 新增: } | |
| 44 | 新增: | |
| 45 | 新增: private void OnDel(object obj) | |
| 46 | 新增: { | |
| 47 | 新增: if (SelectedItem != null) | |
| 48 | 新增: { | |
| 49 | 新增: var list = Data.ToList(); | |
| 50 | 新增: | |
| 51 | 新增: list.Remove(SelectedItem); | |
| 52 | 新增: | |
| 53 | 新增: var app = appData.GetApp(SelectedItem.ID); | |
| 54 | 新增: if(app != null) | |
| 55 | 新增: { | |
| 56 | 新增: app.CategoryID = 0; | |
| 57 | 新增: app.Category = null; | |
| 58 | 新增: appData.UpdateApp(app); | |
| 59 | 新增: } | |
| 60 | 新增: | |
| 61 | 新增: Data = list; | |
| 62 | 新增: } | |
| 63 | 新增: } | |
| 64 | 新增: | |
| 65 | 新增: private void OnChooseClose(object obj) | |
| 66 | 新增: { | |
| 67 | 新增: ChooseVisibility = System.Windows.Visibility.Collapsed; | |
| 68 | 新增: SearchInput = ""; | |
| 69 | 新增: } | |
| 70 | 新增: | |
| 71 | 新增: private void OnSearch(object obj) | |
| 72 | 新增: { | |
| 73 | 新增: string keyword = obj.ToString(); | |
| 74 | 新增: | |
| 75 | 新增: if (keyword == "vscode") | |
| 76 | 新增: { | |
| 77 | 新增: keyword = "Visual Studio Code"; | |
| 78 | 新增: } | |
| 79 | 新增: else if (keyword == "ps") | |
| 80 | 新增: { | |
| 81 | 新增: keyword = "Photoshop"; | |
| 82 | 新增: } | |
| 83 | 新增: Search(keyword); | |
| 34 | 84 | } |
| 35 | 85 | |
| 86 | 新增: | |
| 87 | 新增: | |
| 36 | 88 | private void OnGotoDetail(object obj) |
| 37 | 89 | { |
| 38 | 90 | if (SelectedItem != null) |
| @@ -46,7 +98,10 @@ namespace UI.ViewModels | ||
| 46 | 98 | { |
| 47 | 99 | ChooseVisibility = System.Windows.Visibility.Collapsed; |
| 48 | 100 | |
| 101 | 新增: SearchInput = ""; | |
| 102 | 新增: | |
| 49 | 103 | var data = new List<AppModel>(); |
| 104 | 新增: | |
| 50 | 105 | foreach (var item in AppList) |
| 51 | 106 | { |
| 52 | 107 | |
| @@ -77,6 +132,7 @@ namespace UI.ViewModels | ||
| 77 | 132 | } |
| 78 | 133 | } |
| 79 | 134 | Data = data; |
| 135 | 新增: | |
| 80 | 136 | //LoadData(); |
| 81 | 137 | } |
| 82 | 138 | |
| @@ -117,25 +173,58 @@ namespace UI.ViewModels | ||
| 117 | 173 | { |
| 118 | 174 | Task.Run(() => |
| 119 | 175 | { |
| 120 | 删除: //Category = mainVM.Data as UI.Models.Category.CategoryModel; | |
| 176 | 新增: appList = new List<ChooseAppModel>(); | |
| 177 | 新增: | |
| 121 | 178 | if (Category == null) |
| 122 | 179 | { |
| 123 | 180 | return; |
| 124 | 181 | } |
| 125 | 删除: var appList = new List<ChooseAppModel>(); | |
| 126 | 182 | foreach (var item in appData.GetAllApps()) |
| 127 | 183 | { |
| 128 | 184 | var app = new ChooseAppModel(); |
| 129 | 185 | app.App = item; |
| 130 | 186 | app.IsChoosed = item.CategoryID == Category.Data.ID; |
| 131 | 删除: app.Value.Name = item.Name; | |
| 187 | 新增: app.Value.Name = String.IsNullOrEmpty(item.Description) ? item.Name : item.Description; | |
| 132 | 188 | app.Value.Img = item.IconFile; |
| 133 | 189 | |
| 134 | 190 | appList.Add(app); |
| 135 | 191 | } |
| 192 | 新增: appList = appList.OrderBy(m => m.App.Description).ToList(); | |
| 136 | 193 | |
| 137 | 194 | AppList = appList; |
| 138 | 195 | }); |
| 139 | 196 | } |
| 197 | 新增: | |
| 198 | 新增: private void Search(string keyword) | |
| 199 | 新增: { | |
| 200 | 新增: if (!string.IsNullOrEmpty(keyword)) | |
| 201 | 新增: { | |
| 202 | 新增: Debug.WriteLine(keyword); | |
| 203 | 新增: keyword = keyword.ToLower(); | |
| 204 | 新增: | |
| 205 | 新增: //var list = appList.Where(m => m.App.Description.ToLower().IndexOf(keyword) != -1 || m.App.Name.ToLower().IndexOf(keyword) != -1).ToList(); | |
| 206 | 新增: var list = AppList.ToList(); | |
| 207 | 新增: | |
| 208 | 新增: foreach (var item in list) | |
| 209 | 新增: { | |
| 210 | 新增: item.Visibility = item.App.Description.ToLower().IndexOf(keyword) != -1 || item.App.Name.ToLower().IndexOf(keyword) != -1 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; | |
| 211 | 新增: } | |
| 212 | 新增: | |
| 213 | 新增: AppList = list; | |
| 214 | 新增: | |
| 215 | 新增: } | |
| 216 | 新增: else | |
| 217 | 新增: { | |
| 218 | 新增: var list = AppList.ToList(); | |
| 219 | 新增: | |
| 220 | 新增: foreach (var item in list) | |
| 221 | 新增: { | |
| 222 | 新增: item.Visibility = System.Windows.Visibility.Visible; | |
| 223 | 新增: } | |
| 224 | 新增: | |
| 225 | 新增: AppList = list; | |
| 226 | 新增: | |
| 227 | 新增: } | |
| 228 | 新增: } | |
| 140 | 229 | } |
| 141 | 230 | } |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | 4 | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | 5 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | 删除: xmlns:local="clr-namespace:UI.Views" xmlns:base="clr-namespace:UI.Controls.Base" xmlns:select="clr-namespace:UI.Controls.Select" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" | |
| 6 | 新增: xmlns:local="clr-namespace:UI.Views" xmlns:base="clr-namespace:UI.Controls.Base" xmlns:select="clr-namespace:UI.Controls.Select" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:input="clr-namespace:UI.Controls.Input" | |
| 7 | 7 | mc:Ignorable="d" |
| 8 | 8 | d:DesignHeight="450" d:DesignWidth="800" |
| 9 | 9 | Title="CategoryAppListPage"> |
| @@ -13,67 +13,80 @@ | ||
| 13 | 13 | <Grid Visibility="{Binding ChooseVisibility}" Panel.ZIndex="2" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
| 14 | 14 | <Border Background="Black" Opacity=".7"/> |
| 15 | 15 | <Border Height="460" Background="White" CornerRadius="10" BorderBrush="#ccc" BorderThickness="1" Margin="50" VerticalAlignment="Top"> |
| 16 | 删除: <Grid> | |
| 17 | 删除: <Grid.RowDefinitions> | |
| 18 | 删除: <RowDefinition Height="40"/> | |
| 19 | 删除: <RowDefinition Height="*"/> | |
| 20 | 删除: <RowDefinition Height="80"/> | |
| 21 | 删除: | |
| 22 | 删除: </Grid.RowDefinitions> | |
| 23 | 删除: <TextBlock Text="选择应用" VerticalAlignment="Center" Margin="10,0,0,0"/> | |
| 24 | 删除: <ListView ItemsSource="{Binding AppList}" Margin="20" Grid.Row="1"> | |
| 25 | 删除: <ListBox.Resources> | |
| 26 | 删除: <Style TargetType="{x:Type ListView}"> | |
| 27 | 删除: <Setter Property="OverridesDefaultStyle" Value="True"/> | |
| 28 | 删除: | |
| 29 | 删除: <Setter Property="Template"> | |
| 30 | 删除: <Setter.Value> | |
| 31 | 删除: <ControlTemplate TargetType="{x:Type ListView}"> | |
| 32 | 删除: <ScrollViewer> | |
| 33 | 删除: <ItemsPresenter /> | |
| 34 | 删除: </ScrollViewer> | |
| 35 | 删除: </ControlTemplate> | |
| 36 | 删除: </Setter.Value> | |
| 37 | 删除: </Setter> | |
| 38 | 删除: </Style> | |
| 39 | 删除: <Style TargetType="{x:Type ListViewItem}"> | |
| 40 | 删除: <Setter Property="OverridesDefaultStyle" Value="True"/> | |
| 41 | 删除: <Setter Property="Template"> | |
| 42 | 删除: <Setter.Value> | |
| 43 | 删除: <ControlTemplate TargetType="{x:Type ListViewItem}"> | |
| 44 | 删除: <Border> | |
| 45 | 删除: <ContentPresenter/> | |
| 46 | 删除: </Border> | |
| 47 | 删除: | |
| 48 | 删除: </ControlTemplate> | |
| 49 | 删除: </Setter.Value> | |
| 50 | 删除: </Setter> | |
| 51 | 删除: | |
| 52 | 删除: </Style> | |
| 53 | 删除: </ListBox.Resources> | |
| 54 | 删除: <ListBox.ItemsPanel> | |
| 55 | 删除: <ItemsPanelTemplate> | |
| 16 | 新增: <Grid> | |
| 17 | 新增: <Grid.RowDefinitions> | |
| 18 | 新增: <RowDefinition Height="40"/> | |
| 19 | 新增: <RowDefinition Height="auto"/> | |
| 20 | 新增: <RowDefinition Height="*"/> | |
| 21 | 新增: <RowDefinition Height="80"/> | |
| 22 | 新增: | |
| 23 | 新增: </Grid.RowDefinitions> | |
| 24 | 新增: <Grid> | |
| 25 | 新增: <TextBlock Text="选择应用" VerticalAlignment="Center" Margin="10,0,0,0"/> | |
| 26 | 新增: <Button:IconButton Foreground="#ccc" Icon="ChromeClose" HorizontalAlignment="Right" FontSize="12" Margin="0,0,10,0" Command="{Binding ChooseCloseCommand}"/> | |
| 27 | 新增: </Grid> | |
| 28 | 新增: <Border Grid.Row="1"> | |
| 29 | 新增: <input:InputBox Placeholder="搜索应用" Margin="10" x:Name="SearchBox" Text="{Binding SearchInput,Mode=TwoWay}"> | |
| 30 | 新增: <i:Interaction.Triggers> | |
| 31 | 新增: <i:EventTrigger EventName="KeyUp"> | |
| 32 | 新增: <i:InvokeCommandAction Command="{Binding Path=SearchCommand}" CommandParameter="{Binding ElementName=SearchBox,Path=Text}"/> | |
| 33 | 新增: </i:EventTrigger> | |
| 34 | 新增: </i:Interaction.Triggers> | |
| 35 | 新增: </input:InputBox> | |
| 36 | 新增: </Border> | |
| 37 | 新增: <ListView ItemsSource="{Binding AppList}" Margin="20" Grid.Row="2"> | |
| 38 | 新增: <ListBox.Resources> | |
| 39 | 新增: <Style TargetType="{x:Type ListView}"> | |
| 40 | 新增: <Setter Property="OverridesDefaultStyle" Value="True"/> | |
| 41 | 新增: | |
| 42 | 新增: <Setter Property="Template"> | |
| 43 | 新增: <Setter.Value> | |
| 44 | 新增: <ControlTemplate TargetType="{x:Type ListView}"> | |
| 45 | 新增: <ScrollViewer> | |
| 46 | 新增: <ItemsPresenter /> | |
| 47 | 新增: </ScrollViewer> | |
| 48 | 新增: </ControlTemplate> | |
| 49 | 新增: </Setter.Value> | |
| 50 | 新增: </Setter> | |
| 51 | 新增: </Style> | |
| 52 | 新增: <Style TargetType="{x:Type ListViewItem}"> | |
| 53 | 新增: <Setter Property="OverridesDefaultStyle" Value="True"/> | |
| 54 | 新增: <Setter Property="Template"> | |
| 55 | 新增: <Setter.Value> | |
| 56 | 新增: <ControlTemplate TargetType="{x:Type ListViewItem}"> | |
| 57 | 新增: <Border> | |
| 58 | 新增: <ContentPresenter/> | |
| 59 | 新增: </Border> | |
| 60 | 新增: | |
| 61 | 新增: </ControlTemplate> | |
| 62 | 新增: </Setter.Value> | |
| 63 | 新增: </Setter> | |
| 64 | 新增: | |
| 65 | 新增: </Style> | |
| 66 | 新增: </ListBox.Resources> | |
| 67 | 新增: <ListBox.ItemsPanel> | |
| 68 | 新增: <ItemsPanelTemplate> | |
| 56 | 69 | <VirtualizingStackPanel/> |
| 57 | 70 | <!--<StackPanel/>--> |
| 58 | 71 | </ItemsPanelTemplate> |
| 59 | 删除: </ListBox.ItemsPanel> | |
| 60 | 删除: <ListView.ItemTemplate> | |
| 61 | 删除: <DataTemplate> | |
| 62 | 删除: <StackPanel > | |
| 63 | 删除: <Border HorizontalAlignment="Stretch"> | |
| 64 | 删除: <select:Option HorizontalAlignment="Stretch" IsChecked="{Binding IsChoosed,Mode=TwoWay}" Value="{Binding Value}"/> | |
| 65 | 删除: | |
| 66 | 删除: </Border> | |
| 67 | 删除: | |
| 68 | 删除: </StackPanel> | |
| 69 | 删除: </DataTemplate> | |
| 70 | 删除: </ListView.ItemTemplate> | |
| 71 | 删除: </ListView> | |
| 72 | 删除: | |
| 73 | 删除: <Button:Button Grid.Row="2" HorizontalAlignment="Right" Content="完成" Width="120" Margin="0,0,10,0" VerticalAlignment="Center" Command="{Binding ChoosedCommand}"/> | |
| 74 | 删除: </Grid> | |
| 75 | 删除: | |
| 76 | 删除: </Border> | |
| 72 | 新增: </ListBox.ItemsPanel> | |
| 73 | 新增: <ListView.ItemTemplate> | |
| 74 | 新增: <DataTemplate> | |
| 75 | 新增: <StackPanel > | |
| 76 | 新增: <Border HorizontalAlignment="Stretch"> | |
| 77 | 新增: <select:Option Visibility="{Binding Visibility}" HorizontalAlignment="Stretch" IsChecked="{Binding IsChoosed,Mode=TwoWay}" Value="{Binding Value}"/> | |
| 78 | 新增: | |
| 79 | 新增: </Border> | |
| 80 | 新增: | |
| 81 | 新增: </StackPanel> | |
| 82 | 新增: </DataTemplate> | |
| 83 | 新增: </ListView.ItemTemplate> | |
| 84 | 新增: </ListView> | |
| 85 | 新增: | |
| 86 | 新增: <Button:Button Grid.Row="3" HorizontalAlignment="Right" Content="完成" Width="120" Margin="0,0,10,0" VerticalAlignment="Center" Command="{Binding ChoosedCommand}"/> | |
| 87 | 新增: </Grid> | |
| 88 | 新增: | |
| 89 | 新增: </Border> | |
| 77 | 90 | </Grid> |
| 78 | 91 | <StackPanel Margin="20"> |
| 79 | 92 | <StackPanel Orientation="Horizontal" Margin="0,0,0,20"> |
| @@ -89,6 +102,12 @@ | ||
| 89 | 102 | <base:EmptyData/> |
| 90 | 103 | </base:View> |
| 91 | 104 | <ListView ItemsSource="{Binding Data}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" Margin="0,20,0,0"> |
| 105 | 新增: <ListView.ContextMenu> | |
| 106 | 新增: <ContextMenu> | |
| 107 | 新增: | |
| 108 | 新增: <MenuItem Header="从分类中移除" Command="{Binding DelCommand}" CommandParameter="{Binding SelectedItem}"/> | |
| 109 | 新增: </ContextMenu> | |
| 110 | 新增: </ListView.ContextMenu> | |
| 92 | 111 | <i:Interaction.Triggers> |
| 93 | 112 | <i:EventTrigger EventName="MouseLeftButtonUp"> |
| 94 | 113 | <i:InvokeCommandAction Command="{Binding GotoDetailCommand}" |
| @@ -121,11 +140,12 @@ | ||
| 121 | 140 | </Border.Effect> |
| 122 | 141 | <ContentPresenter/> |
| 123 | 142 | </Border> |
| 124 | 删除: | |
| 143 | 新增: | |
| 125 | 144 | <Border BorderBrush="Transparent" BorderThickness="2" x:Name="Border" Background="White" Margin="0,0,0,10" Padding="15" CornerRadius="10"> |
| 126 | 删除: | |
| 127 | 删除: <ContentPresenter/> | |
| 128 | 删除: </Border></Grid> | |
| 145 | 新增: | |
| 146 | 新增: <ContentPresenter/> | |
| 147 | 新增: </Border> | |
| 148 | 新增: </Grid> | |
| 129 | 149 | <ControlTemplate.Triggers> |
| 130 | 150 | <Trigger Property="IsMouseOver" Value="True"> |
| 131 | 151 | <!--<Setter TargetName="Border" Property="Background" Value="#FFE8E6FF"/>--> |
| @@ -159,7 +179,13 @@ | ||
| 159 | 179 | <Border> |
| 160 | 180 | <base:Img Width="25" Height="25" URL="{Binding IconFile}"/> |
| 161 | 181 | </Border> |
| 162 | 删除: <TextBlock Margin="10,0,0,0" VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Center" Text="{Binding Name}" /> | |
| 182 | 新增: <Grid Grid.Column="1"> | |
| 183 | 新增: <TextBlock Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Description}" /> | |
| 184 | 新增: <base:View Condition="empty" Value="{Binding Description}"> | |
| 185 | 新增: <TextBlock Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Name}" /> | |
| 186 | 新增: | |
| 187 | 新增: </base:View> | |
| 188 | 新增: </Grid> | |
| 163 | 189 | |
| 164 | 190 | |
| 165 | 191 | </Grid> |

