Skip to content

Commit

Permalink
将WoL和RDP的页面整合在一起,配置共用。
Browse files Browse the repository at this point in the history
  • Loading branch information
SIXiaolong1117 committed Apr 2, 2023
1 parent 4617e1e commit a628fb1
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 46 deletions.
58 changes: 48 additions & 10 deletions WinWoL/AddConfigDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- GNU General Public License for more details. -->

<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program. If not, see -->
<!-- along with this program. If not, see -->
<!-- <https://www.gnu.org/licenses/> . -->

<ContentDialog
Expand All @@ -23,15 +23,53 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ScrollViewer Width="280">
<StackPanel Width="250" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="Test" Foreground="DarkGray" FontSize="12"/>
<TextBox x:Name="configName" TextChanged="TextChanged" Header="配置别名:" PlaceholderText="小禹的电脑" Width="250" Margin="0,8,0,0"/>
<TextBlock Text="配置别名" Foreground="DarkGray" FontSize="12"/>
<TextBox x:Name="macAddress" TextChanged="TextChanged" Header="Mac 地址:" PlaceholderText="AA:BB:CC:DD:EE:FF" Width="250" Margin="0,8,0,0"/>
<TextBlock Text="待唤醒设备的 MAC 地址" Foreground="DarkGray" FontSize="12"/>
<TextBox x:Name="ipAddress" TextChanged="TextChanged" Header="IP 地址:" PlaceholderText="255.255.255.255" Width="250" Margin="0,8,0,0"/>
<TextBlock Text="接收 Magic Packet 的 IP 地址" Foreground="DarkGray" FontSize="12"/>
<TextBox x:Name="ipPort" TextChanged="TextChanged" Header="端口:" PlaceholderText="7 or 9" Width="250" Margin="0,8,0,0"/>
<TextBlock Text="接收 Magic Packet 的端口" Foreground="DarkGray" FontSize="12"/>
<TextBox x:Name="Test" Header="[Developer] 输入参数:"/>
<TextBox x:Name="configName" TextChanged="TextChanged" Header="配置别名:" PlaceholderText="小禹的电脑" Width="250" Margin="0,8,0,16"/>

<TextBlock Text="WoL 相关设置" FontSize="20" FontWeight="Bold" Margin="0,16,0,16"/>

<TextBox x:Name="macAddress" TextChanged="TextChanged" Header="目标设备 Mac 地址:" PlaceholderText="AA:BB:CC:DD:EE:FF" Width="250" Margin="0,0,0,24"/>

<StackPanel Width="250" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,16">
<TextBox x:Name="ipAddress" TextChanged="TextChanged" Header="接收 Magic Packet 的 IP 地址:" PlaceholderText="255.255.255.255" Width="250"/>
<CheckBox
x:Name="Broadcast"
Content="向 LAN 网络广播"
Checked="Broadcast_Checked"
Unchecked="Broadcast_Unchecked"
Margin="0,0,0,-6"/>
</StackPanel>

<TextBox x:Name="ipPort" TextChanged="TextChanged" Header="WoL 端口:" PlaceholderText="7 or 9" Width="250" Margin="0,0,0,24"/>

<StackPanel Orientation="Vertical" Margin="0,16,0,16">
<TextBlock Text="RDP 相关设置" FontSize="20" FontWeight="Bold"/>
<ToggleSwitch
x:Name="rdpIsOpen" Toggled="rdpIsOpen_Toggled"
OffContent="关闭" OnContent="开启" Margin="0,-4,0,-4"/>
</StackPanel>
<StackPanel x:Name="RDPSettings">
<StackPanel Width="250" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,16">
<TextBox
x:Name="rdpIpAddress"
TextChanged="TextChanged"
Header="RDP 目标主机 IP 地址:" PlaceholderText="192.168.1.2" Width="250" />
<CheckBox
x:Name="SameIPAddr"
Content="同 接收 Magic Packet 的 IP 地址"
Checked="SameIPAddr_Checked"
Unchecked="SameIPAddr_Unchecked"
Margin="0,0,0,-6"/>
</StackPanel>

<TextBox
x:Name="rdpIpPort"
TextChanged="TextChanged"
Header="RDP 端口:"
PlaceholderText="3389"
Width="250"
Margin="0,0,0,24"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
</ContentDialog>
68 changes: 66 additions & 2 deletions WinWoL/AddConfigDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,76 @@ public AddConfigDialog()
macAddress.Text = configInnerSplit[1];
ipAddress.Text = configInnerSplit[2];
ipPort.Text = configInnerSplit[3];
rdpIsOpen.IsOn = configInnerSplit[4] == "True";
rdpIpAddress.Text = configInnerSplit[5];
rdpIpPort.Text = configInnerSplit[6];
Broadcast.IsChecked = configInnerSplit[7] == "True";
SameIPAddr.IsChecked = configInnerSplit[8] == "True";
}

redIsOpenCheck();
}
private void InnerChanged()
{
localSettings.Values["ConfigIDTemp"] = configName.Text + "," + macAddress.Text + ","
+ ipAddress.Text + "," + ipPort.Text + ","
+ rdpIsOpen.IsOn + "," + rdpIpAddress.Text + "," + rdpIpPort.Text + ","
+ Broadcast.IsChecked + "," + SameIPAddr.IsChecked;

if (localSettings.Values["DeveloperImpartIsOpen"] as string == "True")
{
Test.Text = localSettings.Values["ConfigIDTemp"] as string;
Test.Visibility = Visibility.Visible;
}
else
{
Test.Visibility = Visibility.Collapsed;
}
}
public void TextChanged(object sender, TextChangedEventArgs e)
{
localSettings.Values["ConfigIDTemp"] = configName.Text + "," + macAddress.Text + "," + ipAddress.Text + "," + ipPort.Text;
Test.Text = localSettings.Values["ConfigIDTemp"] as string;
InnerChanged();
}
private void Broadcast_Checked(object sender, RoutedEventArgs e)
{
ipAddress.Text = "255.255.255.255";
ipAddress.IsEnabled = false;
SameIPAddr.IsEnabled = false;
InnerChanged();
}
private void Broadcast_Unchecked(object sender, RoutedEventArgs e)
{
ipAddress.IsEnabled = true;
SameIPAddr.IsEnabled = true;
InnerChanged();
}

private void SameIPAddr_Checked(object sender, RoutedEventArgs e)
{
rdpIpAddress.Text = ipAddress.Text;
rdpIpAddress.IsEnabled = false;
InnerChanged();
}
private void SameIPAddr_Unchecked(object sender, RoutedEventArgs e)
{
rdpIpAddress.IsEnabled = true;
InnerChanged();
}
private void rdpIsOpen_Toggled(object sender, RoutedEventArgs e)
{
redIsOpenCheck();
InnerChanged();
}
private void redIsOpenCheck()
{
if (rdpIsOpen.IsOn == true)
{
RDPSettings.Visibility = Visibility.Visible;
}
else
{
RDPSettings.Visibility = Visibility.Collapsed;
}
}
}
}
10 changes: 5 additions & 5 deletions WinWoL/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xe724;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="远程桌面 (RDP)" Tag="RDP">
<NavigationViewItem.Icon>
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xe8af;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<!--<NavigationViewItem Content="远程桌面 (RDP)" Tag="RDP">-->
<!--<NavigationViewItem.Icon>-->
<!--<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xe8af;"/>-->
<!--</NavigationViewItem.Icon>-->
<!--</NavigationViewItem>-->
</NavigationView.MenuItems>
<NavigationView.FooterMenuItems>
<NavigationViewItem Content="关于" Tag="About">
Expand Down
16 changes: 5 additions & 11 deletions WinWoL/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,13 @@ public MainWindow()
{
this.InitializeComponent();

// Hide default title bar.
// 隐藏默认TitleBar
ExtendsContentIntoTitleBar = true;
SetTitleBar(AppTitleBar);

TrySetSystemBackdrop();

if (localSettings.Values["adb"] == null)
{
localSettings.Values["adb"] = "adb";
}

NavView.SelectedItem = NavView.MenuItems[0];
//contentFrame.Navigate(typeof(DragandDrop));
}

bool TrySetSystemBackdrop()
Expand Down Expand Up @@ -169,10 +163,10 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi
{
contentFrame.Navigate(typeof(WoL));
}
else if ((string)selectedItem.Tag == "RDP")
{
contentFrame.Navigate(typeof(RDP));
}
//else if ((string)selectedItem.Tag == "RDP")
//{
// contentFrame.Navigate(typeof(RDP));
//}
else if ((string)selectedItem.Tag == "Ping")
{
contentFrame.Navigate(typeof(Ping));
Expand Down
2 changes: 1 addition & 1 deletion WinWoL/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="fe263fa7-295e-4f47-a1e3-87f6be98f05e"
Publisher="CN=SI Xiaolong"
Version="1.0.1.0" />
Version="1.0.2.0" />

<Properties>
<DisplayName>WinWoL</DisplayName>
Expand Down
8 changes: 7 additions & 1 deletion WinWoL/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@

<Grid>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Vertical" Margin="0,0,0,16">
<TextBlock Text="开发者模式"/>
<ToggleSwitch
x:Name="DeveloperImpart" Toggled="DeveloperImpart_Toggled"
OffContent="关闭" OnContent="开启" Margin="0,-4,0,-4"/>
</StackPanel>
<ComboBox x:Name="backgroundMaterial"
ItemsSource="{x:Bind material}"
SelectionChanged="backgroundMaterial_SelectionChanged"
Header="背景材料:"
Width="268"
Margin="0,8,0,0">
Margin="0,0,0,16">
</ComboBox>
</StackPanel>
</Grid>
Expand Down
13 changes: 13 additions & 0 deletions WinWoL/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public SettingsPage()
// 非法输入,扔出警报
//throw new Exception($"Wrong material type: {localSettings.Values["materialStatus"]}");
}

DeveloperImpart.IsOn = (localSettings.Values["DeveloperImpartIsOpen"] as string == "True");
}

// 背景材料设置ComboBox改动事件
Expand Down Expand Up @@ -138,5 +140,16 @@ private void CMDDisplay_SelectionChanged(object sender, SelectionChangedEventArg
break;
}
}
private void DeveloperImpart_Toggled(object sender, RoutedEventArgs e)
{
if (DeveloperImpart.IsOn == true)
{
localSettings.Values["DeveloperImpartIsOpen"] = "True";
}
else
{
localSettings.Values["DeveloperImpartIsOpen"] = "False";
}
}
}
}
4 changes: 2 additions & 2 deletions WinWoL/WinWoL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230217.4" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230313.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
Expand Down
22 changes: 17 additions & 5 deletions WinWoL/WoL.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<TextBlock Text="{x:Bind MacAddress}"/>
<TextBlock Text="{x:Bind IpAddress}"/>
<TextBlock Text="{x:Bind IpPort}"/>
<TextBlock Text="{x:Bind RDPIpAddress}"/>
<TextBlock Text="{x:Bind RDPIpPort}"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
Expand All @@ -69,14 +71,13 @@
x:Name="AddConfig" Click="AddConfigButton_Click"
Content="添加配置"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="84"
Width="130"
Margin="0,0,8,0"/>
<Button
x:Name="DelConfig"
Content="删除配置"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0">
Width="130">
<Button.Flyout>
<Flyout>
<StackPanel>
Expand All @@ -91,13 +92,24 @@
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,8,0,0">
<Button
x:Name="WoLConfig"
Click="WoLConfigButton_Click"
Content="网络唤醒"
Content="网络唤醒(WoL)"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="130"
Margin="0,0,8,0"
/>
<Button
x:Name="RDPConfig"
Click="RDPConfigButton_Click"
Content="远程桌面(RDP)"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="84"
Width="130"
/>
</StackPanel>

Expand Down
Loading

0 comments on commit a628fb1

Please sign in to comment.