Skip to content

Commit cf8c186

Browse files
committed
feat: Allow you rearrange items in main window via drag & drop #368
1 parent 2ae6444 commit cf8c186

17 files changed

+424
-75
lines changed

Ui/Resources/Languages/cs-cz.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">Zobrazit informace o přihlašovacích údajích</s:String>
264+
<s:String x:Key="Sorting">Řazení</s:String>
265+
<s:String x:Key="Sort by drag">Seřadit přetažením</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/de-de.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">Informationen zu Anmeldeinformationen anzeigen</s:String>
264+
<s:String x:Key="Sorting">Sortierung</s:String>
265+
<s:String x:Key="Sort by drag">Sortieren nach Ziehen</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/en-us.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">Show credentials info</s:String>
264+
<s:String x:Key="Sorting"> Sorting</s:String>
265+
<s:String x:Key="Sort by drag"> Sort by drag</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/fr-fr.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">Afficher les informations d'identification</s:String>
264+
<s:String x:Key="Sorting">Tri</s:String>
265+
<s:String x:Key="Sort by drag">Trier par glissement</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/glossary.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,5 @@ Detecting your alternate host...,Detecting your alternate host...,正在检测
277277
XXX is already existed!,`{0}` is already existed!,`{0}`已经存在!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!
278278
XXX is not existed!,`{0}` is not existed!,`{0}` 不存在!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!
279279
Show credentials info,Show credentials info,显示地址账号信息,,,,,
280+
Sorting, Sorting, 排序,,,,,
281+
Sort by drag, Sort by drag, 自定义拖拽排序,,,,,

Ui/Resources/Languages/glossary_translated_by_google.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,5 @@ Detecting your alternate host...,Detecting your alternate host...,正在检测
289289
XXX is already existed!,`{0}` is already existed!,`{0}`已经存在!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!,`{0}` is already existed!
290290
XXX is not existed!,`{0}` is not existed!,`{0}` 不存在!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!,`{0}` is not existed!
291291
Show credentials info,Show credentials info,显示地址账号信息,Zobrazit informace o přihlašovacích údajích,Informationen zu Anmeldeinformationen anzeigen,Afficher les informations d'identification,Mostrar informações de credenciais,資格情報を表示
292+
Sorting, Sorting, 排序,Řazení,Sortierung,Tri,Ordenação,並べ替え
293+
Sort by drag, Sort by drag, 自定义拖拽排序,Seřadit přetažením,Sortieren nach Ziehen,Trier par glissement,Classificar por arrastar,ドラッグで並べ替え

Ui/Resources/Languages/ja-jp.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">資格情報を表示</s:String>
264+
<s:String x:Key="Sorting">並べ替え</s:String>
265+
<s:String x:Key="Sort by drag">ドラッグで並べ替え</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/pt-br.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}` is already existed!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` is not existed!</s:String>
263263
<s:String x:Key="Show credentials info">Mostrar informações de credenciais</s:String>
264+
<s:String x:Key="Sorting">Ordenação</s:String>
265+
<s:String x:Key="Sort by drag">Classificar por arrastar</s:String>
264266
</ResourceDictionary>

Ui/Resources/Languages/zh-cn.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,6 @@
261261
<s:String x:Key="XXX is already existed!">`{0}`已经存在!</s:String>
262262
<s:String x:Key="XXX is not existed!">`{0}` 不存在!</s:String>
263263
<s:String x:Key="Show credentials info">显示地址账号信息</s:String>
264+
<s:String x:Key="Sorting"> 排序</s:String>
265+
<s:String x:Key="Sort by drag"> 自定义拖拽排序</s:String>
264266
</ResourceDictionary>

Ui/Service/LocalityService.cs

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
using System.Linq;
77
using System.Text;
88
using System.Windows;
9+
using System.Windows.Documents;
910
using Newtonsoft.Json;
1011
using _1RM.Model.Protocol;
1112
using _1RM.View.Launcher;
1213
using Shawn.Utils;
14+
using _1RM.View;
1315

1416
namespace _1RM.Service
1517
{
@@ -24,6 +26,7 @@ public enum EnumServerOrderBy
2426
//TagDesc = 5,
2527
AddressAsc = 6,
2628
AddressDesc = 7,
29+
Custom,
2730
}
2831

2932
internal class LocalitySettings
@@ -37,26 +40,13 @@ internal class LocalitySettings
3740
public WindowState TabWindowState = WindowState.Normal;
3841
public WindowStyle TabWindowStyle = WindowStyle.SingleBorderWindow;
3942
public EnumServerOrderBy ServerOrderBy = EnumServerOrderBy.IdAsc;
43+
public Dictionary<string, int> ServerCustomOrder = new Dictionary<string, int>();
4044
public ConcurrentDictionary<string, RdpLocalSetting> RdpLocalities = new ConcurrentDictionary<string, RdpLocalSetting>();
4145
public List<QuickConnectionItem> QuickConnectionHistory = new List<QuickConnectionItem>();
4246
}
4347

4448
public sealed class LocalityService
4549
{
46-
public LocalityService()
47-
{
48-
_localitySettings = new LocalitySettings();
49-
try
50-
{
51-
var tmp = JsonConvert.DeserializeObject<LocalitySettings>(File.ReadAllText(AppPathHelper.Instance.LocalityJsonPath));
52-
if (tmp != null)
53-
_localitySettings = tmp;
54-
}
55-
catch
56-
{
57-
// ignored
58-
}
59-
}
6050

6151
public double MainWindowWidth
6252
{
@@ -181,6 +171,8 @@ public EnumServerOrderBy ServerOrderBy
181171

182172
private readonly LocalitySettings _localitySettings;
183173

174+
public Dictionary<string, int> ServerCustomOrder => _localitySettings.ServerCustomOrder;
175+
184176
#region Interface
185177

186178
#region Save local settings for every rdp session by session id
@@ -240,6 +232,17 @@ public void QuickConnectionHistoryRemove(QuickConnectionItem item)
240232
Save();
241233
}
242234

235+
public void ServerCustomOrderRebuild(IEnumerable<ProtocolBaseViewModel> servers)
236+
{
237+
int i = 0;
238+
_localitySettings.ServerCustomOrder.Clear();
239+
foreach (var server in servers)
240+
{
241+
_localitySettings.ServerCustomOrder.Add(server.Id, i);
242+
++i;
243+
}
244+
Save();
245+
}
243246

244247
public bool CanSave = true;
245248
private void Save()
@@ -257,6 +260,25 @@ private void Save()
257260
}
258261
}
259262

263+
/// <summary>
264+
/// Load
265+
/// </summary>
266+
public LocalityService()
267+
{
268+
// Load
269+
_localitySettings = new LocalitySettings();
270+
try
271+
{
272+
var tmp = JsonConvert.DeserializeObject<LocalitySettings>(File.ReadAllText(AppPathHelper.Instance.LocalityJsonPath));
273+
if (tmp != null)
274+
_localitySettings = tmp;
275+
}
276+
catch
277+
{
278+
// ignored
279+
}
280+
}
281+
260282
#endregion Interface
261283
}
262284
}

0 commit comments

Comments
 (0)