Skip to content

Commit

Permalink
now we get a real mulit-editer. #83
Browse files Browse the repository at this point in the history
  • Loading branch information
VShawn committed May 15, 2021
1 parent 23983ac commit 662ffc7
Show file tree
Hide file tree
Showing 37 changed files with 254 additions and 1,001 deletions.
21 changes: 7 additions & 14 deletions PRM.Core/Languages/de-de.json
Expand Up @@ -69,7 +69,6 @@
// sys menu
"system_menu_options_title": "Optionen",
"system_menu_about_title": "Über",
"system_menu_management_title": "Server Verwaltung",
"system_menu_toggle_server_list": "Karten/Liste umschalten",

// system options
Expand Down Expand Up @@ -137,19 +136,13 @@
"server_card_operate_copy_address": "Server-Adresse in die Zwischenablage kopieren",
"server_card_operate_copy_username": "Benutzername in die Zwischenablage kopieren",
"server_card_operate_copy_password": "Passwort in die Zwischenablage kopieren",
"string_delete_confirm": "Wirklich löschen?",
"managementpage_delete_selected_confirm": "Wirklich alle markierten Einträge löschen?",
"managementpage_import_dialog_title": "Dateiauswahl",
"managementpage_import_from_json": "von einer JSON-Datei",
"phrase_import_from_mremoteng_csv": "mRemoteNG CSV-Datei",
"managementpage_import_done": "Erfolgreich importiert, {0} Element hinzugefügt.",
"managementpage_import_error": "Falsches Datenformat!",
"managementpage_edit_selected": "Ausgewähltes bearbeiten",
"managementpage_edit_selected_info": "Ausgewählte Eigenschaft bearbeiten:",
"managementpage_edit_selected_info_to": "Zu",
"managementpage_edit_selected_error_empty_string": "Der neue Wert darf nicht leer sein!",
"managementpage_edit_selected_error_port": "Port sollte zwischen 1 - 65535 sein!",
"managementpage_edit_selected_confirm": "Sicher, um alle ausgewählten auf den neuen Wert zu aktualisieren: '",
"confirm_to_delete": "Wirklich löschen?",
"confirm_to_delete_selected": "Wirklich alle markierten Einträge löschen?",
"import_server_dialog_title": "Dateiauswahl",
"import_from_json": "von einer JSON-Datei",
"import_from_csv": "mRemoteNG CSV-Datei",
"import_done_0_items_added": "Erfolgreich importiert, {0} Element hinzugefügt.",
"import_failure_with_data_format_error": "Falsches Datenformat!",

// server editor
"server_editor_different_options": "<different options>",
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/Languages/de-de.xaml

Large diffs are not rendered by default.

21 changes: 7 additions & 14 deletions PRM.Core/Languages/en-us.json
Expand Up @@ -69,7 +69,6 @@
// sys menu
"system_menu_options_title": "Options",
"system_menu_about_title": "About",
"system_menu_management_title": "Server Management",
"system_menu_toggle_server_list": "Toggle Cards/List",

// system options
Expand Down Expand Up @@ -137,19 +136,13 @@
"server_card_operate_copy_address": "Copy address to clipboard",
"server_card_operate_copy_username": "Copy username to clipboard",
"server_card_operate_copy_password": "Copy password to clipboard",
"string_delete_confirm": "Sure to delete?",
"managementpage_delete_selected_confirm": "Sure to delete all selected?",
"managementpage_import_dialog_title": "Select a file",
"managementpage_import_from_json": "from json",
"phrase_import_from_mremoteng_csv": "from mRemoteNG csv",
"managementpage_import_done": "Imported successfully, {0} item added.",
"managementpage_import_error": "Error data format!",
"managementpage_edit_selected": "Edit selected",
"managementpage_edit_selected_info": "Edit selected property:",
"managementpage_edit_selected_info_to": "To",
"managementpage_edit_selected_error_empty_string": "New value can not be empty string!",
"managementpage_edit_selected_error_port": "Port should be 1 - 65535!",
"managementpage_edit_selected_confirm": "Sure to move all selected to new value: '",
"confirm_to_delete": "Sure to delete?",
"confirm_to_delete_selected": "Sure to delete all selected?",
"import_server_dialog_title": "Select a file",
"import_from_json": "from json",
"import_from_csv": "from mRemoteNG csv",
"import_done_0_items_added": "Imported successfully, {0} item added.",
"import_failure_with_data_format_error": "Error data format!",

// server editor
"server_editor_different_options": "<different options>",
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/Languages/en-us.xaml

Large diffs are not rendered by default.

21 changes: 7 additions & 14 deletions PRM.Core/Languages/zh-cn.json
Expand Up @@ -69,7 +69,6 @@
// sys menu
"system_menu_options_title": "设置",
"system_menu_about_title": "关于",
"system_menu_management_title": "服务器配置管理",
"system_menu_toggle_server_list": "切换卡片/列表",

// system options
Expand Down Expand Up @@ -137,19 +136,13 @@
"server_card_operate_copy_address": "复制地址到剪贴板",
"server_card_operate_copy_username": "复制用户名到剪贴板",
"server_card_operate_copy_password": "复制密码到剪贴板",
"string_delete_confirm": "确认要删除吗?",
"managementpage_delete_selected_confirm": "确认要删除所选全部项目吗?",
"managementpage_import_dialog_title": "选择导入文件",
"managementpage_import_from_json": "从 json",
"phrase_import_from_mremoteng_csv": "从 mRemoteNG csv",
"managementpage_import_done": "已导入{0}条记录.",
"managementpage_import_error": "导入0条,输入的数据文件格式有误!",
"managementpage_edit_selected": "编辑选中",
"managementpage_edit_selected_info": "将所选项目的属性:",
"managementpage_edit_selected_info_to": "修改为",
"managementpage_edit_selected_error_empty_string": "不能输入空字符串",
"managementpage_edit_selected_error_port": "端口号应当为:1 - 65535!",
"managementpage_edit_selected_confirm": "确认要将所选项目变更为 '",
"confirm_to_delete": "确认要删除吗?",
"confirm_to_delete_selected": "确认要删除所选全部项目吗?",
"import_server_dialog_title": "选择导入文件",
"import_from_json": "从 json",
"import_from_csv": "从 mRemoteNG csv",
"import_done_0_items_added": "已导入{0}条记录.",
"import_failure_with_data_format_error": "导入0条,输入的数据文件格式有误!",

// server editor
"server_editor_different_options": "<不同的选项>",
Expand Down
2 changes: 1 addition & 1 deletion PRM.Core/Languages/zh-cn.xaml

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions PRM.Core/Model/GlobalData.cs
Expand Up @@ -49,7 +49,7 @@ public ObservableCollection<VmProtocolServer> VmItemList
}
}

public void ServerListUpdate(ProtocolServerBase protocolServer = null)
public void ServerListUpdate(ProtocolServerBase protocolServer = null, bool doInvoke = true)
{
if (_dbOperator == null)
{
Expand All @@ -76,6 +76,7 @@ public void ServerListUpdate(ProtocolServerBase protocolServer = null)
// edit
else if (protocolServer.Id > 0 && VmItemList.First(x => x.Server.Id == protocolServer.Id) != null)
{
ServerListClearSelect();
_dbOperator.DbUpdateServer(protocolServer);
int i = VmItemList.Count;
if (VmItemList.Any(x => x.Server.Id == protocolServer.Id))
Expand All @@ -86,13 +87,22 @@ public void ServerListUpdate(ProtocolServerBase protocolServer = null)
}

VmItemList.Insert(i, new VmProtocolServer(protocolServer));
VmItemListDataChanged?.Invoke();
if (doInvoke)
VmItemListDataChanged?.Invoke();
}
// add
else
{
_dbOperator.DbAddServer(protocolServer);
ServerListUpdate();
ServerListUpdate(null, doInvoke);
}
}

public void ServerListClearSelect()
{
foreach (var item in VmItemList)
{
item.IsSelected = false;
}
}

Expand Down
8 changes: 7 additions & 1 deletion PRM.Core/NotifyPropertyChangedBase.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace PRM.Core
{
Expand All @@ -15,7 +16,7 @@ public void SetNotifyPropertyChangedEnabled(bool isEnabled)

public event PropertyChangedEventHandler PropertyChanged;

public void RaisePropertyChanged(string propertyName)
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
if (NotifyPropertyChangedEnabled)
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Expand All @@ -30,6 +31,11 @@ protected virtual void SetAndNotifyIfChanged<T>(string propertyName, ref T oldVa
RaisePropertyChanged(propertyName);
}

protected virtual void SetAndNotifyIfChanged<T>(ref T oldValue, T newValue, [CallerMemberName] string propertyName = null)
{
SetAndNotifyIfChanged(propertyName, ref oldValue, newValue);
}

#endregion INotifyPropertyChanged
}
}
Expand Up @@ -42,19 +42,6 @@
</Grid>
</StackPanel>
</Grid>

<Grid Name="GridPwd">
<Grid.Style>
<Style TargetType="Grid" BasedOn="{StaticResource EditorRowGrid}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=CbUsePrivateKey,Path= IsChecked}" Value="True">
<Setter Property="Visibility" Value="Collapsed"></Setter>
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
</Grid>
</StackPanel>
</StackPanel>
</baseClassForm:ProtocolServerFormBase>
Expand Up @@ -44,17 +44,16 @@
</StackPanel>
</Grid>

<Grid Style="{StaticResource EditorRowGrid}">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource server_editor_connection_username}"></TextBlock>
<Grid Style="{StaticResource EditorRowGridInput}">
<TextBox Text="{Binding UserName,UpdateSourceTrigger=PropertyChanged}"></TextBox>
</Grid>
</StackPanel>
</Grid>

<Grid Name="GridPwd">
<Grid.Style>
<Style TargetType="Grid" BasedOn="{StaticResource EditorRowGrid}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=CbUsePrivateKey,Path= IsChecked}" Value="True">
<Setter Property="Visibility" Value="Collapsed"></Setter>
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource server_editor_connection_password}"></TextBlock>
<Grid Style="{StaticResource EditorRowGridInput}">
Expand Down
@@ -1,4 +1,5 @@
using System;
using PRM.Core.Model;

namespace PRM.Core.Protocol
{
Expand All @@ -22,15 +23,22 @@ public int GetPort()
{
if (int.TryParse(Port, out var p))
return p;
return 0;
return 1;
}

private string _port = "3389";

public string Port
{
get => _port;
set => SetAndNotifyIfChanged(nameof(Port), ref _port, value);
set
{
if (value == base.Server_editor_different_options
|| (int.TryParse(value, out int port) == true && port > 0 && port <= 65535))
SetAndNotifyIfChanged(ref _port, value);
else
RaisePropertyChanged();
}
}

protected override string GetSubTitle()
Expand Down
22 changes: 0 additions & 22 deletions PRM.Core/Protocol/FileTransmit/FTP/ProtocolServerFTPForm.xaml
Expand Up @@ -52,16 +52,6 @@
</Grid>

<Grid Name="GridPwd">
<Grid.Style>
<Style TargetType="Grid" BasedOn="{StaticResource EditorRowGrid}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=CbUsePrivateKey,Path= IsChecked}" Value="True">
<Setter Property="Visibility" Value="Collapsed"></Setter>
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource server_editor_connection_password}"></TextBlock>
<Grid Style="{StaticResource EditorRowGridInput}">
Expand All @@ -71,18 +61,6 @@
</StackPanel>
</Grid>

<Grid Name="GridPrivateKey" Height="Auto">
<Grid.Style>
<Style TargetType="Grid" BasedOn="{StaticResource EditorRowGrid}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=CbUsePrivateKey,Path= IsChecked}" Value="True">
<Setter Property="Margin" Value="0"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
</Grid>

<Grid Style="{StaticResource EditorRowGrid}">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource server_editor_advantage_sftp_startup_path}"></TextBlock>
Expand Down
Expand Up @@ -19,13 +19,11 @@ public ProtocolServerFTPForm(ProtocolServerBase vm) : base(vm)

GridUserName.Visibility = Visibility.Collapsed;
GridPwd.Visibility = Visibility.Collapsed;
GridPrivateKey.Visibility = Visibility.Collapsed;


if (Vm.GetType() == typeof(ProtocolServerFTP)
|| Vm.GetType().BaseType == typeof(ProtocolServerWithAddrPortUserPwdBase))
{
GridPrivateKey.Visibility =
GridUserName.Visibility =
GridPwd.Visibility = Visibility.Visible;
}
Expand Down
Expand Up @@ -40,7 +40,7 @@ public RelayCommand CmdDelete
if (Trans?.IsConnected() != true)
return;
if (MessageBox.Show(
SystemConfig.Instance.Language.GetText("string_delete_confirm"),
SystemConfig.Instance.Language.GetText("confirm_to_delete"),
SystemConfig.Instance.Language.GetText("messagebox_title_warning"),
MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.None) == MessageBoxResult.Yes)
{
Expand Down
Expand Up @@ -33,6 +33,10 @@ public ProtocolServerSFTPForm(ProtocolServerBase vm) : base(vm)
if (Vm.GetType() == typeof(ProtocolServerSFTP))
{
CbUsePrivateKey.IsChecked = false;
if(((ProtocolServerSFTP)Vm).PrivateKey == vm.Server_editor_different_options)
{
CbUsePrivateKey.IsChecked = null;
}
if (!string.IsNullOrEmpty(((ProtocolServerSFTP)Vm).PrivateKey))
{
CbUsePrivateKey.IsChecked = true;
Expand Down
3 changes: 3 additions & 0 deletions PRM.Core/Protocol/Putty/ProtocolPuttyForm.xaml
Expand Up @@ -8,7 +8,9 @@
xmlns:controls="clr-namespace:PRM.Core.Resources.Controls"
xmlns:passwordEx="clr-namespace:Shawn.Utils"
xmlns:baseClassForm="clr-namespace:PRM.Core.Protocol.BaseClassForm"
xmlns:ssh="clr-namespace:PRM.Core.Protocol.Putty.SSH"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance ssh:ProtocolServerSSH}"
d:DesignHeight="1450" d:DesignWidth="800">
<StackPanel>
<StackPanel.Resources>
Expand Down Expand Up @@ -135,6 +137,7 @@
<ComboBox SelectedIndex="{Binding SshVersion, Converter={StaticResource ConverterESshVersion}}">
<ComboBoxItem Content="V1" />
<ComboBoxItem Content="V2" />
<ComboBoxItem Visibility="{Binding SshVersion, Converter={StaticResource ConverterEqual2Visible}, ConverterParameter={x:Null}}" Content="{DynamicResource server_editor_different_options}" />
</ComboBox>
</Grid>
</StackPanel>
Expand Down
6 changes: 6 additions & 0 deletions PRM.Core/Protocol/Putty/ProtocolPuttyForm.xaml.cs
Expand Up @@ -48,6 +48,10 @@ public ProtocolPuttyForm(ProtocolServerBase vm) : base(vm)
if (Vm.GetType() == typeof(ProtocolServerSSH))
{
CbUsePrivateKey.IsChecked = false;
if (((ProtocolServerSSH)Vm).PrivateKey == vm.Server_editor_different_options)
{
CbUsePrivateKey.IsChecked = null;
}
if (!string.IsNullOrEmpty(((ProtocolServerSSH)Vm).PrivateKey))
{
CbUsePrivateKey.IsChecked = true;
Expand Down Expand Up @@ -109,6 +113,8 @@ public class ConverterESshVersion : IValueConverter
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return Enum.GetValues(typeof(ProtocolServerSSH.ESshVersion)).Cast<int>().Max();
return ((int)((ProtocolServerSSH.ESshVersion)value) - 1).ToString();
}

Expand Down
4 changes: 2 additions & 2 deletions PRM.Core/Protocol/Putty/SSH/ProtocolServerSSH.cs
Expand Up @@ -30,9 +30,9 @@ public string PrivateKey
set => SetAndNotifyIfChanged(nameof(PrivateKey), ref _privateKey, value);
}

private ESshVersion _sshVersion = ESshVersion.V2;
private ESshVersion? _sshVersion = ESshVersion.V2;

public ESshVersion SshVersion
public ESshVersion? SshVersion
{
get => _sshVersion;
set => SetAndNotifyIfChanged(nameof(SshVersion), ref _sshVersion, value);
Expand Down

0 comments on commit 662ffc7

Please sign in to comment.