Skip to content

Commit

Permalink
1. bug fix close #30 #31
Browse files Browse the repository at this point in the history
2. improve for #22 https://github.com/VShawn/PRemoteM/issues/22#issuecomment-740849283
3. improve for #26 https://github.com/VShawn/PRemoteM/issues/26#issuecomment-740859060
4. right click link to import language json file.

Signed-off-by: Shawn <singlex@foxmail.com>
  • Loading branch information
VShawn committed Dec 9, 2020
1 parent c148b97 commit b24d3b6
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 105 deletions.
8 changes: 4 additions & 4 deletions PRM.Core/Languages/en-us.json
Expand Up @@ -2,9 +2,9 @@
"language_name": "English(US)",


"messagebox_title_warning": "Warning",
"messagebox_title_error": "Error",
"messagebox_title_info": "Info",
"messagebox_title_warning": "PRemote Warning",
"messagebox_title_error": "PRemote Error",
"messagebox_title_info": "PRemote Info",

"button_exit": "Exit",
"button_close": "Close",
Expand Down Expand Up @@ -103,7 +103,7 @@
"system_options_data_security_import_dialog_title": "Select a file",
"system_options_data_security_import_from_json": "from json",
"system_options_data_security_import_from_mremoteng_csv": "from mRemoteNG csv",
"system_options_data_security_import_done": "The import has been successful.",
"system_options_data_security_import_done": "The import has been successful, add {0}.",
"system_options_data_security_import_error": "Error data format!",
"system_options_data_security_info_data_processing": "Data processing, do not close app.",
"system_options_data_security_info_encrypt_private_key_warning": "Guard your private key carefully, it's the only key to decrypt your data!",
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/Languages/en-us.xaml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions PRM.Core/Languages/zh-cn.json
Expand Up @@ -2,9 +2,9 @@
"language_name": "中文(简体)",


"messagebox_title_warning": "警告",
"messagebox_title_error": "错误",
"messagebox_title_info": "提示",
"messagebox_title_warning": "PRemote 警告",
"messagebox_title_error": "PRemote 错误",
"messagebox_title_info": "PRemote 提示",

"button_exit": "退出",
"button_close": "关闭",
Expand Down Expand Up @@ -103,8 +103,8 @@
"system_options_data_security_import_dialog_title": "选择导入文件",
"system_options_data_security_import_from_json": "从 json",
"system_options_data_security_import_from_mremoteng_csv": "从 mRemoteNG csv",
"system_options_data_security_import_done": "导入完成.",
"system_options_data_security_import_error": "导入的数据文件格式有误!",
"system_options_data_security_import_done": "已导入{0}条记录.",
"system_options_data_security_import_error": "导入0条,输入的数据文件格式有误!",
"system_options_data_security_info_data_processing": "数据处理中,请勿关闭程序。",
"system_options_data_security_info_encrypt_private_key_warning": "请妥善保管私钥,丢失后数据将无法找回!",
"system_options_data_security_info_clear_rebuild_database": "是否重置数据库?确认后数据将无法找回!",
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/Languages/zh-cn.xaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion PRM.Core/Model/GlobalEventHelper.cs
Expand Up @@ -19,8 +19,9 @@ public static class GlobalEventHelper
/// Go to server edit by server id
/// param1 uint: server id
/// param2 boo: is duplicate?
/// param2 boo: show in animation?
/// </summary>
public static Action<uint, bool> OnGoToServerEditPage { get; set; } = null;
public static Action<uint, bool, bool> OnGoToServerEditPage { get; set; } = null;

/// <summary>
/// Invoke to notify a newer version of te software was released
Expand Down
30 changes: 17 additions & 13 deletions PRM.Core/Model/SystemConfig.DataSecurity.cs
Expand Up @@ -788,7 +788,7 @@ public RelayCommand CmdImportFromJson
}
}
GlobalData.Instance.ServerListUpdate();
MessageBox.Show(SystemConfig.Instance.Language.GetText("system_options_data_security_import_done"), SystemConfig.Instance.Language.GetText("messagebox_title_info"), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
MessageBox.Show(SystemConfig.Instance.Language.GetText("system_options_data_security_import_done").Replace("{0}", list.Count.ToString()), SystemConfig.Instance.Language.GetText("messagebox_title_info"), MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
}
catch (Exception e)
{
Expand Down Expand Up @@ -861,7 +861,7 @@ public RelayCommand CmdImportFromCsv
{
string getValue(string fieldName)
{
var i = title.IndexOf(fieldName);
var i = title.IndexOf(fieldName.ToLower());
if (i >= 0)
{
var val = arr[i];
Expand All @@ -878,7 +878,10 @@ string getValue(string fieldName)
var pwd = getValue("password");
var address = getValue("hostname");
int port = 22;
int.TryParse(getValue("hostname"), out port);
if(int.TryParse(getValue("port"), out var new_port))
{
port = new_port;
}
// todo ADD RD GATEWAY
switch (protocol)
Expand All @@ -905,8 +908,8 @@ string getValue(string fieldName)
EnablePorts = string.Equals(getValue("RedirectPorts"), "TRUE", StringComparison.CurrentCultureIgnoreCase),
EnablePrinters = string.Equals(getValue("RedirectPrinters"), "TRUE", StringComparison.CurrentCultureIgnoreCase),
EnableSmartCardsAndWinHello = string.Equals(getValue("RedirectSmartCards"), "TRUE", StringComparison.CurrentCultureIgnoreCase),
GatewayMode = string.Equals(getValue("RDGatewayUsageMethod"), "Never", StringComparison.CurrentCultureIgnoreCase) ? EGatewayMode.DoNotUseGateway:
(string.Equals(getValue("RDGatewayUsageMethod"), "Detect", StringComparison.CurrentCultureIgnoreCase)? EGatewayMode.AutomaticallyDetectGatewayServerSettings: EGatewayMode.UseTheseGatewayServerSettings),
GatewayMode = string.Equals(getValue("RDGatewayUsageMethod"), "Never", StringComparison.CurrentCultureIgnoreCase) ? EGatewayMode.DoNotUseGateway :
(string.Equals(getValue("RDGatewayUsageMethod"), "Detect", StringComparison.CurrentCultureIgnoreCase) ? EGatewayMode.AutomaticallyDetectGatewayServerSettings : EGatewayMode.UseTheseGatewayServerSettings),
GatewayHostName = getValue("RDGatewayHostname"),
GatewayPassword = getValue("RDGatewayPassword"),
};
Expand Down Expand Up @@ -970,15 +973,16 @@ string getValue(string fieldName)
}
if (list?.Count > 0)
{
if (Rsa != null)
foreach (var serverBase in list)
{
EncryptPwd(serverBase);
Server.AddOrUpdate(serverBase, true);
}
foreach (var serverBase in list)
{
EncryptPwd(serverBase);
Server.AddOrUpdate(serverBase, true);
}
GlobalData.Instance.ServerListUpdate();
MessageBox.Show(SystemConfig.Instance.Language.GetText("system_options_data_security_import_done").Replace("{0}", list.Count.ToString()), SystemConfig.Instance.Language.GetText("messagebox_title_info"), MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
}
GlobalData.Instance.ServerListUpdate();
MessageBox.Show(SystemConfig.Instance.Language.GetText("system_options_data_security_import_done"), SystemConfig.Instance.Language.GetText("messagebox_title_info"), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
else
MessageBox.Show(SystemConfig.Instance.Language.GetText("system_options_data_security_import_error"), SystemConfig.Instance.Language.GetText("messagebox_title_error"), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
}
catch (Exception e)
{
Expand Down
14 changes: 11 additions & 3 deletions PRM.Core/Model/SystemConfig.Language.cs
Expand Up @@ -234,10 +234,18 @@ private ResourceDictionary GetResourceDictionaryByCode(string code)
return null;
}

private void AddOrUpdateLanguage(string code, string name, string path)
public void AddOrUpdateLanguage(string code, string name, string path)
{
LanguageCode2Name.Add(code, name);
_languageCode2ResourcePath.Add(code, path);
if (LanguageCode2Name.ContainsKey(code))
{
LanguageCode2Name[code] = name;
_languageCode2ResourcePath[code] = path;
}
else
{
LanguageCode2Name.Add(code, name);
_languageCode2ResourcePath.Add(code, path);
}
}

public string GetText(string textKey)
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/PRMVersion.cs
Expand Up @@ -11,7 +11,7 @@ public static class PRMVersion
public const int Major = 0;
public const int Minor = 5;
public const int Build = 5;
public const int ReleaseDate = 2012072119;
public const int ReleaseDate = 2012091614;
public static string Version => $"{Major}.{Minor}.{Build}.{ReleaseDate}";
}
}
16 changes: 9 additions & 7 deletions PRM.Core/Utils/SetSelfStartingHelper.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -57,10 +58,10 @@ private static string MD5EncryptString(string str)
}
private static string GetShortCutPath()
{
var startUpPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);
var startUpPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
var exePath = Process.GetCurrentProcess().MainModule.FileName;
string md5 = MD5EncryptString(exePath);
var shortcutPath = System.IO.Path.Combine(startUpPath, string.Format("{0}_{1}.lnk", SystemConfig.AppName, md5));
var shortcutPath = System.IO.Path.Combine(startUpPath, $"{SystemConfig.AppName}_{md5}.lnk");
return shortcutPath;
}
/// <summary>
Expand Down Expand Up @@ -178,15 +179,15 @@ public static async Task<bool> IsSelfStart()
#endif
}
}
public static async void SetSelfStart(bool isSelfStart)
public static async void SetSelfStart(bool isSetSelfStart)
{
try
{
var result = await StartupTask.GetAsync(StartupTaskId);
switch (result.State)
{
case StartupTaskState.Disabled:
if (isSelfStart)
if (isSetSelfStart)
{
var newState = await result.RequestEnableAsync();
}
Expand All @@ -202,7 +203,7 @@ public static async void SetSelfStart(bool isSelfStart)
Debug.WriteLine("Startup disabled by group policy, or not supported on this device");
break;
case StartupTaskState.Enabled:
if (!isSelfStart)
if (!isSetSelfStart)
result.Disable();
break;
case StartupTaskState.EnabledByPolicy:
Expand All @@ -215,7 +216,8 @@ public static async void SetSelfStart(bool isSelfStart)
{
Console.WriteLine(e);
#if !FOR_MICROSOFT_STORE_ONLY
if (isSelfStart)
var hasStartup = await IsSelfStart();
if (isSetSelfStart && hasStartup == false)
{
if (AppElvatedHelper.IsElvated())
{
Expand Down Expand Up @@ -254,7 +256,7 @@ public static async void SetSelfStart(bool isSelfStart)
AppElvatedHelper.RunElvatedTask(StartupMode.SetSelfStart);
}
}
else
else if(isSetSelfStart == false && hasStartup)
{
var shortcutPath = GetShortCutPath();
if (File.Exists(shortcutPath))
Expand Down
2 changes: 1 addition & 1 deletion PRemoteM/Controls/ServerCard.xaml
Expand Up @@ -10,7 +10,7 @@
<UserControl.Resources>
<s:Double x:Key="CardWidth">144</s:Double>
</UserControl.Resources>
<Grid>
<Grid MouseRightButtonDown="UIElement_OnMouseRightButtonDown">
<Grid Name="DispServerContext">
<Grid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding CmdConnServer}"></MouseBinding>
Expand Down
8 changes: 8 additions & 0 deletions PRemoteM/Controls/ServerCard.xaml.cs
Expand Up @@ -71,5 +71,13 @@ private void ButtonExportToFile_OnClick(object sender, RoutedEventArgs e)
File.WriteAllText(dlg.FileName, server.ToJsonString(), Encoding.UTF8);
}
}

private void UIElement_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
if (VmServerCard != null && VmServerCard.CmdEditServer.CanExecute())
{
VmServerCard.CmdEditServer.Execute();
}
}
}
}

0 comments on commit b24d3b6

Please sign in to comment.