1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 06:36:08 +03:00
This commit is contained in:
autumn 2021-08-21 11:56:20 +08:00
parent 6c79b07d3c
commit eab70cc48c
5 changed files with 56 additions and 4 deletions

View File

@ -56,8 +56,42 @@ namespace ProxySuper.Core.ViewModels
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 IMvxCommand SortUpCommand => new MvxCommand<string>(SortUp);
public IMvxCommand SortDoneCommand => new MvxCommand<string>(SortDone);
public IMvxCommand AddV2rayCommand => new MvxAsyncCommand(AddV2rayRecord);
public IMvxCommand AddXrayCommand => new MvxAsyncCommand(AddXrayRecord);

View File

@ -38,6 +38,8 @@
<sys:String x:Key="MainDataGridColumnActionEdit">Edit</sys:String>
<sys:String x:Key="MainDataGridColumnActionViewConfig">ViewConfig</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-->

View File

@ -38,6 +38,8 @@
<sys:String x:Key="MainDataGridColumnActionEdit">編輯</sys:String>
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</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-->

View File

@ -38,6 +38,8 @@
<sys:String x:Key="MainDataGridColumnActionEdit">编辑</sys:String>
<sys:String x:Key="MainDataGridColumnActionViewConfig">查看配置</sys:String>
<sys:String x:Key="MainDataGridColumnActionDelete">删除</sys:String>
<sys:String x:Key="MainDataGridColumnActionSortUp">上移</sys:String>
<sys:String x:Key="MainDataGridColumnActionSortDone">下移</sys:String>

View File

@ -91,26 +91,38 @@
<Button Command="{Binding DataContext.InstallCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
CommandParameter="{Binding Id}"
Margin="5,0"
Padding="12,3"
Padding="5,2"
Content="{DynamicResource MainDataGridColumnActionInstall}" />
<Button Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
CommandParameter="{Binding Id}"
Margin="5,0"
Padding="12,3"
Padding="5,2"
Content="{DynamicResource MainDataGridColumnActionEdit}" />
<Button Command="{Binding DataContext.ViewConfigCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
CommandParameter="{Binding Id}"
Margin="5,0"
Padding="12,3"
Padding="5,2"
Content="{DynamicResource MainDataGridColumnActionViewConfig}" />
<Button Command="{Binding DataContext.RemoveCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
CommandParameter="{Binding Id}"
Margin="5,0"
Padding="12,3"
Padding="5,2"
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>
</ItemContainerTemplate>
</DataGridTemplateColumn.CellTemplate>