Skip to content

Commit ae97121

Browse files
committed
fix: Fix the bug that there's a gap between parent menu and sub menu. fix #389
1 parent 32d5a17 commit ae97121

File tree

13 files changed

+154
-70
lines changed

13 files changed

+154
-70
lines changed

Ui/Controls/ServerCardItem.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<Grid Grid.Row="0" Grid.RowSpan="3">
5858
<TextBlock Name="TbServerType" Opacity="0.3"
59-
FontWeight="Bold" Text="{Binding Server.ProtocolDisplayNameInShort, Mode=OneWay}"
59+
FontWeight="Bold" Text="{Binding Server.ProtocolDisplayName, Mode=OneWay}"
6060
Width="40"
6161
TextAlignment="Center"
6262
HorizontalAlignment="Left" VerticalAlignment="Top">

Ui/Service/SessionControlService_OpenConnection.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,6 @@ private void ConnectRdpByMstsc(in RDP rdp)
3939
File.WriteAllText(rdpFile, text);
4040
}, actionOnError: exception => MsAppCenterHelper.Error(exception)))
4141
{
42-
var p = new Process
43-
{
44-
StartInfo =
45-
{
46-
FileName = "cmd.exe",
47-
UseShellExecute = false,
48-
RedirectStandardInput = true,
49-
RedirectStandardOutput = true,
50-
RedirectStandardError = true,
51-
CreateNoWindow = true
52-
}
53-
};
54-
p.Start();
55-
string admin = rdp.IsAdministrativePurposes == true ? " /admin " : "";
56-
p.StandardInput.WriteLine($"mstsc {admin} \"" + rdpFile + "\"");
57-
p.StandardInput.WriteLine("exit");
58-
5942
// delete tmp rdp file, ETA 10s
6043
Task.Factory.StartNew(() =>
6144
{
@@ -70,6 +53,30 @@ private void ConnectRdpByMstsc(in RDP rdp)
7053
SimpleLogHelper.Error(e);
7154
}
7255
});
56+
57+
try
58+
{
59+
var p = new Process
60+
{
61+
StartInfo =
62+
{
63+
FileName = "cmd.exe",
64+
UseShellExecute = false,
65+
RedirectStandardInput = true,
66+
RedirectStandardOutput = true,
67+
RedirectStandardError = true,
68+
CreateNoWindow = true
69+
}
70+
};
71+
p.Start();
72+
string admin = rdp.IsAdministrativePurposes == true ? " /admin " : "";
73+
p.StandardInput.WriteLine($"mstsc {admin} \"" + rdpFile + "\"");
74+
p.StandardInput.WriteLine("exit");
75+
}
76+
catch (Exception e)
77+
{
78+
MsAppCenterHelper.Error(e);
79+
}
7380
}
7481
}
7582

@@ -195,7 +202,7 @@ private void Connect(in ProtocolBase protocol, in string fromView, in string ass
195202
protocolClone.ConnectPreprocess();
196203

197204
// apply alternate credential
198-
if(false == ApplyAlternateCredential(ref protocolClone, assignCredentialName))
205+
if (false == ApplyAlternateCredential(ref protocolClone, assignCredentialName))
199206
{
200207
return;
201208
}

Ui/Utils/MessageBoxHelper.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ public static class MessageBoxHelper
2222
/// show a confirm box on owner, the default value owner is MainWindowViewModel
2323
/// </summary>
2424
public static bool Confirm(string content, string title = "", bool useNativeBox = false, object? ownerViewModel = null)
25+
{
26+
return Confirm(content,
27+
IoC.Get<ILanguageService>().Translate("OK"),
28+
IoC.Get<ILanguageService>().Translate("Cancel"),
29+
title, useNativeBox, ownerViewModel);
30+
}
31+
32+
/// <summary>
33+
/// show a confirm box on owner, the default value owner is MainWindowViewModel
34+
/// </summary>
35+
public static bool Confirm(string content, string yesButtonText, string noButtonText, string title = "", bool useNativeBox = false, object? ownerViewModel = null)
2536
{
2637
if (string.IsNullOrEmpty(title))
2738
title = IoC.Get<ILanguageService>().Translate("Warning");
@@ -56,14 +67,17 @@ public static bool Confirm(string content, string title = "", bool useNativeBox
5667
buttons: MessageBoxButton.YesNo,
5768
buttonLabels: new Dictionary<MessageBoxResult, string>()
5869
{
59-
{ MessageBoxResult.Yes, IoC.Get<ILanguageService>().Translate("OK") },
60-
{ MessageBoxResult.No, IoC.Get<ILanguageService>().Translate("Cancel") },
70+
{ MessageBoxResult.Yes, yesButtonText},
71+
{ MessageBoxResult.No, noButtonText},
6172
});
6273
if (vm is Screen screen)
6374
{
6475
screen.Activated += MessageBoxOnActivated;
6576
}
66-
IoC.Get<IWindowManager>().ShowDialog(vm, ownerViewAware ?? mainWindowViewModel);
77+
Execute.OnUIThreadSync(() =>
78+
{
79+
IoC.Get<IWindowManager>().ShowDialog(vm, ownerViewAware ?? mainWindowViewModel);
80+
});
6781
var ret = MessageBoxResult.Yes == vm.ClickedButton;
6882
if (layerContainer != null)
6983
MaskLayerController.HideMask(layerId, layerContainer);

Ui/Utils/PRemoteM/PRemoteMTransferHelper.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Dapper;
2020
using Newtonsoft.Json;
2121
using Shawn.Utils;
22+
using Shawn.Utils.Wpf.FileSystem;
2223

2324
namespace _1RM.Utils.PRemoteM
2425
{
@@ -45,7 +46,8 @@ public static void TransAsync()
4546
{
4647
if (_servers?.Any() == true)
4748
{
48-
if (MessageBoxHelper.Confirm($"Do you want to transfer sessions from `{_dbPath}`?", "Data transfer", ownerViewModel: IoC.Get<MainWindowViewModel>()))
49+
if (MessageBoxHelper.Confirm($"Do you want to transfer sessions from PRemoteM?\r\n\r\nWe will read form database:\r\n `{_dbPath}`",
50+
"Data transfer from PRemoteM", ownerViewModel: IoC.Get<MainWindowViewModel>()))
4951
{
5052
MaskLayerController.ShowProcessingRing(msg: "Data transfer in progress", assignLayerContainer: IoC.Get<MainWindowViewModel>());
5153
Task.Factory.StartNew(() =>
@@ -66,7 +68,14 @@ public static void TransAsync()
6668
Debug.Assert(localSource != null);
6769
localSource!.Database_InsertServer(_servers);
6870
IoC.Get<GlobalData>().ReloadServerList(true);
69-
MessageBoxHelper.Info($"All done! \r\n\r\nYou may want to delete the old data at:\r\n`{_dbPath}`.", ownerViewModel: IoC.Get<MainWindowViewModel>());
71+
if (MessageBoxHelper.Confirm($"All done! \r\n\r\nYou may want to backup and delete the old data at:\r\n`{_dbPath}`.",
72+
yesButtonText: "Show old database in explorer",
73+
noButtonText: "Continue",
74+
title: "Data transfer from PRemoteM",
75+
ownerViewModel: IoC.Get<MainWindowViewModel>()))
76+
{
77+
SelectFileHelper.OpenInExplorerAndSelect(_dbPath);
78+
}
7079
}
7180
catch (Exception e)
7281
{
49.9 KB
Loading
3.83 KB
Loading

Ui/View/Host/ProtocolHosts/VmFileTransmitHost.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -905,26 +905,30 @@ public RelayCommand CmdShowTransmitDstPath
905905
{
906906
return _cmdShowTransmitDstPath ??= new RelayCommand((o) =>
907907
{
908-
if (Trans?.IsConnected() != true)
909-
return;
910-
if (o is TransmitTask t)
908+
try
911909
{
912-
var dst = t.TransmitDstDirectoryPath;
913-
if (dst != null && string.IsNullOrEmpty(dst) == false)
910+
if (Trans?.IsConnected() != true)
911+
return;
912+
if (o is TransmitTask t)
914913
{
915-
if (t.TransmissionType == ETransmissionType.HostToServer)
916-
{
917-
ShowFolder(dst);
918-
}
919-
else
914+
var dst = t.TransmitDstDirectoryPath;
915+
if (dst != null && string.IsNullOrEmpty(dst) == false)
920916
{
921-
if (Directory.Exists(dst))
917+
if (t.TransmissionType == ETransmissionType.HostToServer)
922918
{
923-
System.Diagnostics.Process.Start("explorer.exe", dst);
919+
ShowFolder(dst);
920+
}
921+
else
922+
{
923+
SelectFileHelper.OpenInExplorerAndSelect(dst);
924924
}
925925
}
926926
}
927927
}
928+
catch (Exception)
929+
{
930+
// ignored
931+
}
928932
});
929933
}
930934
}

Ui/View/Settings/General/GeneralView.xaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:local="clr-namespace:_1RM.View.Settings.General"
77
xmlns:controls="clr-namespace:Shawn.Utils.Wpf.Controls;assembly=Shawn.Utils.Wpf"
88
xmlns:shawnutils="clr-namespace:Shawn.Utils;assembly=Shawn.Utils"
9+
xmlns:attachProperty="clr-namespace:Shawn.Utils.WpfResources.Theme.AttachProperty;assembly=Shawn.Utils.WpfResources"
910
mc:Ignorable="d"
1011
d:DataContext="{d:DesignInstance local:GeneralSettingViewModel}"
1112
d:DesignHeight="450" d:DesignWidth="800">
@@ -110,10 +111,22 @@
110111
</Grid.ColumnDefinitions>
111112

112113
<TextBlock Style="{StaticResource TextBlockTitleColumn}" Text="Log"></TextBlock>
113-
<TextBox Grid.Column="1" Text="{x:Static shawnutils:SimpleLogHelper.LogFileName}"
114+
<TextBox Grid.Column="1" Text="{Binding LogPath, Mode=OneWay}"
114115
MaxWidth="400"
115-
ToolTip="{x:Static shawnutils:SimpleLogHelper.LogFileName}"
116+
ToolTip="{Binding LogPath, Mode=OneWay}"
116117
VerticalContentAlignment="Center" IsReadOnly="True"></TextBox>
118+
<Button Grid.Column="2" Background="Transparent"
119+
ToolTip="{DynamicResource 'Explore to...'}"
120+
Command="{Binding CmdExploreTo}"
121+
CommandParameter="{Binding}"
122+
Style="{StaticResource ButtonBarPrimaryStyle}"
123+
attachProperty:VisionElement.OpacityAccent="0.9"
124+
Width="30" Height="30">
125+
<Path Margin="2"
126+
Width="20" Height="20"
127+
Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}"
128+
Stretch="Uniform" Data="F1 M 20 19.316406 C 20 19.498697 19.94466 19.658203 19.833984 19.794922 C 19.723307 19.931641 19.570312 20 19.375 20 C 19.205729 20 19.059244 19.93815 18.935547 19.814453 L 11.269531 12.158203 C 10.644531 12.672526 9.95931 13.066406 9.213867 13.339844 C 8.468424 13.613281 7.688802 13.75 6.875 13.75 C 6.243489 13.75 5.634766 13.66862 5.048828 13.505859 C 4.462891 13.3431 3.916016 13.111979 3.408203 12.8125 C 2.900391 12.513021 2.436523 12.15332 2.016602 11.733398 C 1.59668 11.313477 1.236979 10.849609 0.9375 10.341797 C 0.638021 9.833984 0.406901 9.287109 0.244141 8.701172 C 0.08138 8.115234 0 7.506511 0 6.875 C 0 6.24349 0.08138 5.634766 0.244141 5.048828 C 0.406901 4.462891 0.638021 3.916016 0.9375 3.408203 C 1.236979 2.900391 1.59668 2.436523 2.016602 2.016602 C 2.436523 1.59668 2.900391 1.23698 3.408203 0.9375 C 3.916016 0.638021 4.462891 0.406902 5.048828 0.244141 C 5.634766 0.081381 6.243489 0 6.875 0 C 7.50651 0 8.115234 0.081381 8.701172 0.244141 C 9.287109 0.406902 9.833984 0.638021 10.341797 0.9375 C 10.849609 1.23698 11.313477 1.59668 11.733398 2.016602 C 12.153319 2.436523 12.51302 2.900391 12.8125 3.408203 C 13.111979 3.916016 13.343099 4.462891 13.505859 5.048828 C 13.668619 5.634766 13.75 6.24349 13.75 6.875 C 13.75 7.688803 13.613281 8.468425 13.339844 9.213867 C 13.066406 9.959311 12.672525 10.644531 12.158203 11.269531 C 12.255858 11.367188 12.443033 11.552734 12.719727 11.826172 C 12.996419 12.099609 13.32845 12.425131 13.71582 12.802734 C 14.103189 13.180339 14.526366 13.595378 14.985352 14.047852 C 15.444335 14.500326 15.906574 14.959311 16.37207 15.424805 C 16.837564 15.8903 17.28841 16.3444 17.724609 16.787109 C 18.160807 17.229818 18.548176 17.630209 18.886719 17.988281 C 19.22526 18.346354 19.495441 18.644205 19.697266 18.881836 C 19.899088 19.119467 20 19.264322 20 19.316406 Z M 6.875 12.5 C 7.649739 12.5 8.378906 12.351889 9.0625 12.055664 C 9.746094 11.75944 10.341797 11.357422 10.849609 10.849609 C 11.357422 10.341797 11.759439 9.746094 12.055664 9.0625 C 12.351888 8.378906 12.5 7.64974 12.5 6.875 C 12.5 6.100261 12.351888 5.371094 12.055664 4.6875 C 11.759439 4.003906 11.357422 3.408203 10.849609 2.900391 C 10.341797 2.392578 9.746094 1.990561 9.0625 1.694336 C 8.378906 1.398113 7.649739 1.25 6.875 1.25 C 6.10026 1.25 5.371094 1.398113 4.6875 1.694336 C 4.003906 1.990561 3.408203 2.392578 2.900391 2.900391 C 2.392578 3.408203 1.99056 4.003906 1.694336 4.6875 C 1.398112 5.371094 1.25 6.100261 1.25 6.875 C 1.25 7.64974 1.398112 8.378906 1.694336 9.0625 C 1.99056 9.746094 2.392578 10.341797 2.900391 10.849609 C 3.408203 11.357422 4.003906 11.75944 4.6875 12.055664 C 5.371094 12.351889 6.10026 12.5 6.875 12.5 Z " VerticalAlignment="Center" HorizontalAlignment="Center" />
129+
</Button>
117130
</Grid>
118131
</StackPanel>
119132
</Grid>

Ui/View/Settings/General/GeneralView.xaml.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.IO;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using System.Windows;
9-
using System.Windows.Controls;
10-
using System.Windows.Data;
11-
using System.Windows.Documents;
12-
using System.Windows.Input;
13-
using System.Windows.Media;
14-
using System.Windows.Media.Imaging;
15-
using System.Windows.Navigation;
16-
using System.Windows.Shapes;
17-
using _1RM.Service;
18-
using _1RM.Utils;
19-
using Shawn.Utils;
20-
using Shawn.Utils.Interface;
21-
using Shawn.Utils.Wpf;
22-
using Shawn.Utils.Wpf.FileSystem;
1+
using System.Windows.Controls;
232

243
namespace _1RM.View.Settings.General
254
{

0 commit comments

Comments
 (0)