mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-22 05:06:08 +03:00
add sort
This commit is contained in:
parent
6c79b07d3c
commit
eab70cc48c
@ -56,8 +56,42 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
File.WriteAllText("Data/Record.json", json);
|
File.WriteAllText("Data/Record.json", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SortDone(string id)
|
||||||
|
{
|
||||||
|
var item = Records.Where(x => x.Id == id).FirstOrDefault();
|
||||||
|
if (item == null) return;
|
||||||
|
|
||||||
|
var index = Records.IndexOf(item);
|
||||||
|
if (index >= Records.Count - 1) return;
|
||||||
|
|
||||||
|
Records.Remove(item);
|
||||||
|
Records.Insert(index + 1, item);
|
||||||
|
|
||||||
|
RaisePropertyChanged("Records");
|
||||||
|
SaveToJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SortUp(string id)
|
||||||
|
{
|
||||||
|
var item = Records.Where(x => x.Id == id).FirstOrDefault();
|
||||||
|
if (item == null) return;
|
||||||
|
|
||||||
|
var index = Records.IndexOf(item);
|
||||||
|
if (index <= 0) return;
|
||||||
|
|
||||||
|
Records.Remove(item);
|
||||||
|
Records.Insert(index - 1, item);
|
||||||
|
|
||||||
|
RaisePropertyChanged("Records");
|
||||||
|
SaveToJson();
|
||||||
|
}
|
||||||
|
|
||||||
public MvxObservableCollection<Record> Records { get; set; }
|
public MvxObservableCollection<Record> Records { get; set; }
|
||||||
|
|
||||||
|
public IMvxCommand SortUpCommand => new MvxCommand<string>(SortUp);
|
||||||
|
|
||||||
|
public IMvxCommand SortDoneCommand => new MvxCommand<string>(SortDone);
|
||||||
|
|
||||||
public IMvxCommand AddV2rayCommand => new MvxAsyncCommand(AddV2rayRecord);
|
public IMvxCommand AddV2rayCommand => new MvxAsyncCommand(AddV2rayRecord);
|
||||||
|
|
||||||
public IMvxCommand AddXrayCommand => new MvxAsyncCommand(AddXrayRecord);
|
public IMvxCommand AddXrayCommand => new MvxAsyncCommand(AddXrayRecord);
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<sys:String x:Key="MainDataGridColumnActionEdit">Edit</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionEdit">Edit</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionViewConfig">ViewConfig</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionViewConfig">ViewConfig</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionDelete">Delete</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionDelete">Delete</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortUp">Up</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortDone">Done</sys:String>
|
||||||
|
|
||||||
|
|
||||||
<!--Editor Window-->
|
<!--Editor Window-->
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<sys:String x:Key="MainDataGridColumnActionEdit">編輯</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionEdit">編輯</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionDelete">刪除</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionDelete">刪除</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortUp">上移</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortDone">下移</sys:String>
|
||||||
|
|
||||||
|
|
||||||
<!--Editor Window-->
|
<!--Editor Window-->
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<sys:String x:Key="MainDataGridColumnActionEdit">编辑</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionEdit">编辑</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</sys:String>
|
||||||
<sys:String x:Key="MainDataGridColumnActionDelete">删除</sys:String>
|
<sys:String x:Key="MainDataGridColumnActionDelete">删除</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortUp">上移</sys:String>
|
||||||
|
<sys:String x:Key="MainDataGridColumnActionSortDone">下移</sys:String>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,26 +91,38 @@
|
|||||||
<Button Command="{Binding DataContext.InstallCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
<Button Command="{Binding DataContext.InstallCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
CommandParameter="{Binding Id}"
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="5,2"
|
||||||
Content="{DynamicResource MainDataGridColumnActionInstall}" />
|
Content="{DynamicResource MainDataGridColumnActionInstall}" />
|
||||||
|
|
||||||
<Button Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
<Button Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
CommandParameter="{Binding Id}"
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="5,2"
|
||||||
Content="{DynamicResource MainDataGridColumnActionEdit}" />
|
Content="{DynamicResource MainDataGridColumnActionEdit}" />
|
||||||
|
|
||||||
<Button Command="{Binding DataContext.ViewConfigCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
<Button Command="{Binding DataContext.ViewConfigCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
CommandParameter="{Binding Id}"
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="5,2"
|
||||||
Content="{DynamicResource MainDataGridColumnActionViewConfig}" />
|
Content="{DynamicResource MainDataGridColumnActionViewConfig}" />
|
||||||
|
|
||||||
<Button Command="{Binding DataContext.RemoveCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
<Button Command="{Binding DataContext.RemoveCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
CommandParameter="{Binding Id}"
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="5,2"
|
||||||
Content="{DynamicResource MainDataGridColumnActionDelete}" />
|
Content="{DynamicResource MainDataGridColumnActionDelete}" />
|
||||||
|
|
||||||
|
<Button Command="{Binding DataContext.SortUpCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
|
Margin="5,0"
|
||||||
|
Padding="5,2"
|
||||||
|
Content="{DynamicResource MainDataGridColumnActionSortUp}" />
|
||||||
|
|
||||||
|
<Button Command="{Binding DataContext.SortDoneCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
|
Margin="5,0"
|
||||||
|
Padding="5,2"
|
||||||
|
Content="{DynamicResource MainDataGridColumnActionSortDone}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ItemContainerTemplate>
|
</ItemContainerTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
Loading…
Reference in New Issue
Block a user