Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Scrcpy): 添加虚拟屏幕功能 #60

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions UotanToolbox/Assets/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions UotanToolbox/Assets/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@
<data name="Scrcpy_RecordScreen" xml:space="preserve">
<value>Record Screen</value>
</data>
<data name="Scrcpy_Enable_Virtual_Screen" xml:space="preserve">
<value>Enable the virtual screen</value>
</data>
<data name="Scrcpy_Virtual_Screen_Package" xml:space="preserve">
<value>Virtual Screen Package name</value>
</data>
<data name="Scrcpy_ScrcpyCastingTool" xml:space="preserve">
<value>Scrcpy Casting Tool</value>
</data>
Expand All @@ -600,6 +606,9 @@
<data name="Scrcpy_WindowTopping" xml:space="preserve">
<value>Window topping</value>
</data>
<data name="Scrcpy_VirtualDisplay" xml:space="preserve">
<value>Virtual display</value>
</data>
<data name="Modifypartition_CreatePart" xml:space="preserve">
<value>Create</value>
</data>
Expand Down Expand Up @@ -1488,4 +1497,10 @@ If you wish to replace Magisk, please first select your Magisk on the Basic Flas
<data name="Common_FBRoot" xml:space="preserve">
<value>Fastboot device detected, but it seems that the current system has not written relevant USB rules. Should you try to execute with root privileges?</value>
</data>
<data name="Scrcpy_VS_DisplaySize" xml:space="preserve">
<value>Virtual Screen Display Size</value>
</data>
<data name="Scrcpy_VS_DisplaySizeExample" xml:space="preserve">
<value>1920x1080/460 (Height × Width)/dpi</value>
</data>
</root>
17 changes: 16 additions & 1 deletion UotanToolbox/Assets/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,17 @@
<value>等比缩放</value>
</data>
<data name="Scrcpy_RecordDictionary" xml:space="preserve">
<value> </value>
<value>录屏目录</value>
</data>
<data name="Scrcpy_RecordScreen" xml:space="preserve">
<value>录制屏幕</value>
</data>
<data name="Scrcpy_Enable_Virtual_Screen" xml:space="preserve">
<value>启用虚拟屏幕</value>
</data>
<data name="Scrcpy_Virtual_Screen_Package" xml:space="preserve">
<value>虚拟屏幕包名</value>
</data>
<data name="Scrcpy_ScrcpyCastingTool" xml:space="preserve">
<value>Scrcpy投屏工具</value>
</data>
Expand All @@ -600,6 +606,9 @@
<data name="Scrcpy_WindowTopping" xml:space="preserve">
<value>窗口置顶</value>
</data>
<data name="Scrcpy_VirtualDisplay" xml:space="preserve">
<value>虚拟屏幕</value>
</data>
<data name="Modifypartition_CreatePart" xml:space="preserve">
<value>创建分区</value>
</data>
Expand Down Expand Up @@ -1485,4 +1494,10 @@
<data name="Common_FBRoot" xml:space="preserve">
<value>检测到Fastboot设备,但当前系统似乎存未写入相关USB规则,是否尝试以Root权限执行?</value>
</data>
<data name="Scrcpy_VS_DisplaySize" xml:space="preserve">
<value>虚拟屏幕大小</value>
</data>
<data name="Scrcpy_VS_DisplaySizeExample" xml:space="preserve">
<value>1920x1080/460 (高 × 宽)/dpi</value>
</data>
</root>
41 changes: 41 additions & 0 deletions UotanToolbox/Features/Scrcpy/ScrcpyView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,47 @@
</StackPanel>
</Grid>
</suki:GlassCard>
<!-- Virtual display -->
<suki:GlassCard Width="475"
Height="215"
Margin="10"
VerticalAlignment="Top">
<Grid>
<StackPanel>
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
FontWeight="DemiBold"
Text="{x:Static assets:Resources.Scrcpy_VirtualDisplay}" />
<StackPanel Margin="0,15,0,0" Orientation="Horizontal">
<TextBlock Width="90"
Margin="8,0,0,0"
VerticalAlignment="Center"
FontSize="13"
Foreground="{DynamicResource SukiLowText}"
Text="{x:Static assets:Resources.Scrcpy_Enable_Virtual_Screen}" />
<ToggleSwitch Margin="275,0,0,0" IsChecked="{Binding EnableVirtualScreen}" />
</StackPanel>
<StackPanel Margin="0,5,0,0" Orientation="Horizontal">
<TextBlock Width="90"
Margin="8,0,0,0"
VerticalAlignment="Center"
FontSize="13"
Foreground="{DynamicResource SukiLowText}"
Text="{x:Static assets:Resources.Scrcpy_Virtual_Screen_Package}" />
<TextBox Width="330" Name="VirtualScreenPackage" Watermark="{x:Static assets:Resources.Scrcpy_Virtual_Screen_Package}" Text="{Binding VirtualScreenPackage, Mode=TwoWay}" theme:TextBoxExtensions.AddDeleteButton="False"/>
</StackPanel>
<StackPanel Margin="0,5,0,0" Orientation="Horizontal">
<TextBlock Width="90"
Margin="8,0,0,0"
VerticalAlignment="Center"
FontSize="13"
Foreground="{DynamicResource SukiLowText}"
Text="{x:Static assets:Resources.Scrcpy_VS_DisplaySize}" />
<TextBox Width="330" Name="VirtualScreenDisplaySize" Watermark="{x:Static assets:Resources.Scrcpy_VS_DisplaySizeExample}" Text="{Binding VirtualScreenDisplaySize, Mode=TwoWay}" theme:TextBoxExtensions.AddDeleteButton="False"/>
</StackPanel>
</StackPanel>
</Grid>
</suki:GlassCard>
</WrapPanel>
</ScrollViewer>
</UserControl>
25 changes: 22 additions & 3 deletions UotanToolbox/Features/Scrcpy/ScrcpyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public partial class ScrcpyViewModel : MainPageBase
{
[ObservableProperty]
private bool _recordScreen = false, _windowFixed = false, _computerControl = true, _fullScreen = false, _showBorder = true,
_showTouch = true, _closeScreen = false, _screenAwake = false, _screenAwakeStatus = true, _clipboardSync = true, _cameraMirror = false;
_showTouch = true, _closeScreen = false, _screenAwake = false, _screenAwakeStatus = true, _clipboardSync = true, _cameraMirror = false,_enableVirtualScreen = false;
[ObservableProperty] private bool _IsConnecting;
[ObservableProperty] private string _windowTitle, _recordFolder;
[ObservableProperty] private string _windowTitle, _recordFolder, _virtualScreenPackage, _virtualScreenDisplaySize;

[ObservableProperty][Range(0d, 50d)] private double _bitRate = 8;
[ObservableProperty][Range(0d, 144d)] private double _frameRate = 60;
Expand Down Expand Up @@ -77,6 +77,25 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
{
arg += $"--max-size {SizeResolution} ";
}

if (EnableVirtualScreen)
{
if (VirtualScreenDisplaySize != "")
{
arg += $"--new-display={VirtualScreenDisplaySize} ";
}
else
{
arg += $"--new-display ";
}
}

if (VirtualScreenPackage != "")
{
arg += $"--start-app={VirtualScreenPackage} ";
}



if (WindowTitle is not "" and not null)
{
Expand All @@ -89,7 +108,7 @@ await Dispatcher.UIThread.InvokeAsync(async () =>

if (FullScreen)
{
arg += "--fullscreen ";
arg += "--fullscreen --no-vd-destroy-content ";
}

if (!ShowBorder)
Expand Down
Loading