修复剪贴板被占用时无提示
This commit is contained in:
@@ -1021,22 +1021,20 @@ Public Module ModBase
|
|||||||
''' <summary>
|
''' <summary>
|
||||||
''' 设置剪贴板。将在另一线程运行,且不会抛出异常。
|
''' 设置剪贴板。将在另一线程运行,且不会抛出异常。
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Sub ClipboardSet(Text As String, Optional ShowSuccessHint As Boolean = True)
|
Public Sub ClipboardSet(Text As String, Optional ShowSuccessHint As Boolean = True, Optional SuccessHint As String = "")
|
||||||
RunInThread(
|
RunInThread(
|
||||||
Sub()
|
Sub()
|
||||||
Try
|
RunInUi(
|
||||||
Retrier.Attempt(delay:=Function(Attempt) TimeSpan.FromMilliseconds(200), maxAttempts:=4, isRetryAllowed:=Function(ex) True, action:=
|
Sub()
|
||||||
Sub()
|
Try
|
||||||
RunInUi(
|
My.Computer.Clipboard.Clear()
|
||||||
Sub()
|
If Not String.IsNullOrEmpty(Text) Then My.Computer.Clipboard.SetText(Text)
|
||||||
My.Computer.Clipboard.Clear()
|
If ShowSuccessHint Then Hint(If(String.IsNullOrEmpty(SuccessHint), "已成功复制!", SuccessHint), HintType.Green)
|
||||||
If Not String.IsNullOrEmpty(Text) Then My.Computer.Clipboard.SetText(Text)
|
Catch ex As Exception
|
||||||
End Sub)
|
Logger.Error(ex, behavior:=LogBehavior.None)
|
||||||
End Sub)
|
Hint("复制失败,可能由于剪贴板被其他程序占用!", HintType.Red)
|
||||||
If ShowSuccessHint Then Hint("已成功复制!", HintType.Green)
|
End Try
|
||||||
Catch ex As Exception
|
End Sub)
|
||||||
Logger.Error(ex, "可能由于剪贴板被其他程序占用,文本复制失败", LogBehavior.Toast)
|
|
||||||
End Try
|
|
||||||
End Sub)
|
End Sub)
|
||||||
End Sub
|
End Sub
|
||||||
''' <summary>
|
''' <summary>
|
||||||
|
|||||||
@@ -358,9 +358,8 @@ Public Class PageLinkMain
|
|||||||
'复制邀请码
|
'复制邀请码
|
||||||
Private Sub Copy() Handles BtnFinishCopy.Click
|
Private Sub Copy() Handles BtnFinishCopy.Click
|
||||||
Dim CodeText As String = $"在 PCL 启动器中输入邀请码【{GetInviteCode()}】,即可加入联机房间!"
|
Dim CodeText As String = $"在 PCL 启动器中输入邀请码【{GetInviteCode()}】,即可加入联机房间!"
|
||||||
ClipboardSet(CodeText, False)
|
ClipboardSet(CodeText, SuccessHint:="已复制邀请码!")
|
||||||
Settings.Set("LinkLastAutoJoinInviteCode", CodeText)
|
Settings.Set("LinkLastAutoJoinInviteCode", CodeText)
|
||||||
Hint("已复制邀请码!", HintType.Green)
|
|
||||||
End Sub
|
End Sub
|
||||||
Private Function GetInviteCode() As String
|
Private Function GetInviteCode() As String
|
||||||
Return $"{NetworkName}-{NetworkSecret}-{INVITE_CODE_VERSION.ToString.PadLeft(2, "0"c)}{ _
|
Return $"{NetworkName}-{NetworkSecret}-{INVITE_CODE_VERSION.ToString.PadLeft(2, "0"c)}{ _
|
||||||
@@ -369,8 +368,7 @@ Public Class PageLinkMain
|
|||||||
|
|
||||||
'复制 IP
|
'复制 IP
|
||||||
Private Sub BtnFinishIp_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles BtnFinishIp.MouseLeftButtonUp
|
Private Sub BtnFinishIp_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles BtnFinishIp.MouseLeftButtonUp
|
||||||
ClipboardSet(ClientAddress, False)
|
ClipboardSet(ClientAddress, SuccessHint:="已复制服务器地址!")
|
||||||
Hint("已复制服务器地址!", HintType.Green)
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|||||||
@@ -93,8 +93,7 @@ Public Class PageSpeedLeft
|
|||||||
Tb.Text = Loader.Error.GetDisplay(True)
|
Tb.Text = Loader.Error.GetDisplay(True)
|
||||||
AddHandler Tb.MouseLeftButtonDown,
|
AddHandler Tb.MouseLeftButtonDown,
|
||||||
Sub(sender As TextBlock, e As EventArgs)
|
Sub(sender As TextBlock, e As EventArgs)
|
||||||
ClipboardSet(sender.Text, False)
|
ClipboardSet(sender.Text, SuccessHint:="已复制错误详情!")
|
||||||
Hint("已复制错误详情!", HintType.Green)
|
|
||||||
End Sub
|
End Sub
|
||||||
Card.Children.Add(Tb)
|
Card.Children.Add(Tb)
|
||||||
#End Region
|
#End Region
|
||||||
|
|||||||
Reference in New Issue
Block a user