mirror of https://github.com/2dust/v2rayN
add move to group
parent
781fab5aab
commit
576696b25e
|
@ -1217,6 +1217,22 @@ namespace v2rayN.Handler
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int MoveToGroup(Config config, List<ProfileItem> lstProfile, string subid)
|
||||||
|
{
|
||||||
|
foreach (var it in lstProfile)
|
||||||
|
{
|
||||||
|
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.subid = subid;
|
||||||
|
SqliteHelper.Instance.Update(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
|
@ -807,6 +807,15 @@ namespace v2rayN.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Move to group 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string menuMoveToGroup {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("menuMoveToGroup", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Move to top (T) 的本地化字符串。
|
/// 查找类似 Move to top (T) 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1060,4 +1060,7 @@
|
||||||
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
||||||
<value>Show console</value>
|
<value>Show console</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="menuMoveToGroup" xml:space="preserve">
|
||||||
|
<value>Move to group</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -1060,4 +1060,7 @@
|
||||||
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
<data name="TbSettingsTunModeShowWindow" xml:space="preserve">
|
||||||
<value>显示控制台</value>
|
<value>显示控制台</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="menuMoveToGroup" xml:space="preserve">
|
||||||
|
<value>移至订阅分组</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -62,6 +62,8 @@ namespace v2rayN.ViewModels
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public SubItem SelectedSub { get; set; }
|
public SubItem SelectedSub { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
|
public SubItem SelectedMoveToGroup { get; set; }
|
||||||
|
[Reactive]
|
||||||
public RoutingItem SelectedRouting { get; set; }
|
public RoutingItem SelectedRouting { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ComboItem SelectedServer { get; set; }
|
public ComboItem SelectedServer { get; set; }
|
||||||
|
@ -205,6 +207,7 @@ namespace v2rayN.ViewModels
|
||||||
|
|
||||||
SelectedProfile = new();
|
SelectedProfile = new();
|
||||||
SelectedSub = new();
|
SelectedSub = new();
|
||||||
|
SelectedMoveToGroup = new();
|
||||||
SelectedRouting = new();
|
SelectedRouting = new();
|
||||||
SelectedServer = new();
|
SelectedServer = new();
|
||||||
|
|
||||||
|
@ -220,6 +223,10 @@ namespace v2rayN.ViewModels
|
||||||
x => x.SelectedSub,
|
x => x.SelectedSub,
|
||||||
y => y != null && !y.remarks.IsNullOrEmpty() && _subId != y.id)
|
y => y != null && !y.remarks.IsNullOrEmpty() && _subId != y.id)
|
||||||
.Subscribe(c => SubSelectedChanged(c));
|
.Subscribe(c => SubSelectedChanged(c));
|
||||||
|
this.WhenAnyValue(
|
||||||
|
x => x.SelectedMoveToGroup,
|
||||||
|
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||||
|
.Subscribe(c => MoveToGroup(c));
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedRouting,
|
x => x.SelectedRouting,
|
||||||
|
@ -767,7 +774,7 @@ namespace v2rayN.ViewModels
|
||||||
private int GetProfileItems(out List<ProfileItem> lstSelecteds)
|
private int GetProfileItems(out List<ProfileItem> lstSelecteds)
|
||||||
{
|
{
|
||||||
lstSelecteds = new List<ProfileItem>();
|
lstSelecteds = new List<ProfileItem>();
|
||||||
if (SelectedProfiles == null && SelectedProfiles.Count() <= 0)
|
if (SelectedProfiles == null || SelectedProfiles.Count() <= 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1015,6 +1022,26 @@ namespace v2rayN.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
//move server
|
//move server
|
||||||
|
private void MoveToGroup(bool c)
|
||||||
|
{
|
||||||
|
if (!c)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetProfileItems(out List<ProfileItem> lstSelecteds) < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.id);
|
||||||
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|
||||||
|
RefreshServers();
|
||||||
|
SelectedMoveToGroup = new();
|
||||||
|
//Reload();
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveServer(EMove eMove)
|
public void MoveServer(EMove eMove)
|
||||||
{
|
{
|
||||||
var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId);
|
var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId);
|
||||||
|
|
|
@ -451,6 +451,23 @@
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
Header="{x:Static resx:ResUI.menuShareServer}" />
|
Header="{x:Static resx:ResUI.menuShareServer}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
|
<MenuItem
|
||||||
|
x:Name="menuMoveToGroup"
|
||||||
|
Height="{StaticResource MenuItemHeight}"
|
||||||
|
Header="{x:Static resx:ResUI.menuMoveToGroup}">
|
||||||
|
<MenuItem Height="Auto">
|
||||||
|
<MenuItem.Header>
|
||||||
|
<DockPanel>
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbMoveToGroup"
|
||||||
|
Width="200"
|
||||||
|
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuSubscription}"
|
||||||
|
DisplayMemberPath="remarks"
|
||||||
|
Style="{StaticResource MaterialDesignFilledComboBox}" />
|
||||||
|
</DockPanel>
|
||||||
|
</MenuItem.Header>
|
||||||
|
</MenuItem>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="menuMoveTop"
|
x:Name="menuMoveTop"
|
||||||
Height="{StaticResource MenuItemHeight}"
|
Height="{StaticResource MenuItemHeight}"
|
||||||
|
|
|
@ -66,6 +66,9 @@ namespace v2rayN.Views
|
||||||
this.BindCommand(ViewModel, vm => vm.ShareServerCmd, v => v.menuShareServer).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.ShareServerCmd, v => v.menuShareServer).DisposeWith(disposables);
|
||||||
|
|
||||||
//servers move
|
//servers move
|
||||||
|
this.OneWayBind(ViewModel, vm => vm.SubItems, v => v.cmbMoveToGroup.ItemsSource).DisposeWith(disposables);
|
||||||
|
this.Bind(ViewModel, vm => vm.SelectedMoveToGroup, v => v.cmbMoveToGroup.SelectedItem).DisposeWith(disposables);
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.MoveTopCmd, v => v.menuMoveTop).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.MoveTopCmd, v => v.menuMoveTop).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.MoveUpCmd, v => v.menuMoveUp).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.MoveUpCmd, v => v.menuMoveUp).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.MoveDownCmd, v => v.menuMoveDown).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.MoveDownCmd, v => v.menuMoveDown).DisposeWith(disposables);
|
||||||
|
|
Loading…
Reference in New Issue