Skip to content

Commit

Permalink
SSH功能实现完毕。
Browse files Browse the repository at this point in the history
  • Loading branch information
SIXiaolong1117 committed Aug 20, 2023
1 parent a51fe76 commit d9d84c1
Show file tree
Hide file tree
Showing 11 changed files with 744 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# 排除VSCodeCounter
.VSCodeCounter/
19 changes: 19 additions & 0 deletions WinWoL/AddSSHConfigDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ContentDialog
x:Class="WinWoL.AddSSHConfigDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Grid>
<ScrollViewer Width="280">
<StackPanel Width="250" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox x:Name="SSHConfigName" TextChanged="TextChanged" Header="配置别名:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
<TextBox x:Name="SSHCommand" TextChanged="TextChanged" Header="SSH 命令:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
<TextBox x:Name="SSHHost" TextChanged="TextChanged" Header="SSH 主机:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
<TextBox x:Name="SSHPort" TextChanged="TextChanged" Header="SSH 端口:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
<TextBox x:Name="SSHUser" TextChanged="TextChanged" Header="SSH 用户:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
<TextBox x:Name="SSHPasswd" TextChanged="TextChanged" Header="SSH 密码:" PlaceholderText="" Width="250" Margin="0,0,0,8"/>
</StackPanel>
</ScrollViewer>
</Grid>
</ContentDialog>
67 changes: 67 additions & 0 deletions WinWoL/AddSSHConfigDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text.RegularExpressions;
using Validation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Services.Maps;
using Windows.Storage;
using static System.Net.Mime.MediaTypeNames;

namespace WinWoL
{
public sealed partial class AddSSHConfigDialog : ContentDialog
{
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
public AddSSHConfigDialog()
{
this.InitializeComponent();

string configInner = localSettings.Values["SSHConfigIDTemp"] as string;
if (configInner != null)
{
string[] configInnerSplit = configInner.Split(',');
SSHConfigName.Text = configInnerSplit[0];
SSHCommand.Text = configInnerSplit[1];
SSHHost.Text = configInnerSplit[2];
SSHPort.Text = configInnerSplit[3];
SSHUser.Text = configInnerSplit[4];
SSHPasswd.Text = configInnerSplit[5];
}
}
private void InnerChanged()
{
localSettings.Values["SSHConfigIDTemp"] =
SSHConfigName.Text + "," + SSHCommand.Text + ","
+ SSHHost.Text + "," + SSHPort.Text + ","
+ SSHUser.Text + "," + SSHPasswd.Text;

//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)
{
// ÄÚÈݱä¸ü
InnerChanged();
}
}
}
5 changes: 5 additions & 0 deletions WinWoL/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xeda3;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="SSH 脚本" Tag="SSHWoL">
<NavigationViewItem.Icon>
<FontIcon FontFamily="Segoe Fluent Icons" Glyph=""/>
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationView.MenuItems>
<NavigationView.FooterMenuItems>
<NavigationViewItem Content="关于" Tag="About">
Expand Down
4 changes: 4 additions & 0 deletions WinWoL/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi
{
contentFrame.Navigate(typeof(WoL));
}
if ((string)selectedItem.Tag == "SSHWoL")
{
contentFrame.Navigate(typeof(SSHWoL));
}
else if ((string)selectedItem.Tag == "About")
{
contentFrame.Navigate(typeof(About));
Expand Down
2 changes: 1 addition & 1 deletion WinWoL/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity
Name="53093SIXiaolong.WakeonLAN"
Publisher="CN=SI Xiaolong"
Version="1.0.7.0" />
Version="1.0.8.0" />

<Properties>
<DisplayName>网络唤醒(Wake on LAN)</DisplayName>
Expand Down
168 changes: 168 additions & 0 deletions WinWoL/SSHWoL.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="WinWoL.SSHWoL"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinWoL"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Width="268" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">

<TextBlock x:Name="Header" FontSize="24" Text="SSH 脚本" HorizontalAlignment="Center" />

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,8,0,0">
<ComboBox x:Name="configNum"
ItemsSource="{x:Bind ConfigSelector}"
SelectionChanged="configNum_SelectionChanged"
Header="配置编号:"
Width="268">
</ComboBox>
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,8,0,0">
<Button
x:Name="HidePasswd"
Click="HidePasswd_Click"
Content="隐藏密码"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0"
/>
<Button
x:Name="ImportConfig"
Click="ImportConfig_Click"
Content="导入配置"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0"
/>
<Button
x:Name="ImportAndReplaceConfig"
Content="覆盖配置"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0"
>
<Button.Flyout>
<Flyout>
<StackPanel>
<TextBlock
Style="{ThemeResource BaseTextBlockStyle}"
Text="您确定要覆盖此配置文件吗?"
Margin="0,0,0,12" />
<Button
Click="ImportConfig_Click"
Content="确定" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
<Button
x:Name="ExportConfig"
Click="ExportConfig_Click"
Content="导出配置"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="84"
/>
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,8,0,0">
<StackPanel Width="268" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="SSHConfigName"/>
<TextBlock x:Name="SSHCommand"/>
<TextBlock x:Name="SSHHost"/>
<TextBlock x:Name="SSHPort"/>
<TextBlock x:Name="SSHUser"/>
<TextBlock x:Name="SSHPasswd"/>
<TextBlock x:Name="SSHPing"/>
</StackPanel>
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,8,0,0">
<Button
x:Name="AddConfig" Click="AddConfigButton_Click"
Content="添加配置"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0"/>
<Button
x:Name="DelConfig"
Content="删除配置"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="84"
Margin="0,0,8,0">
<Button.Flyout>
<Flyout>
<StackPanel>
<TextBlock
Style="{ThemeResource BaseTextBlockStyle}"
Text="您确定要删除此配置文件吗?"
Margin="0,0,0,12" />
<Button
Click="DelConfigButton_Click"
Content="确定" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
<Button
x:Name="RefConfig" Click="RefConfigButton_Click"
Content="Ping"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="84" />
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,8,0,0">
<Button
x:Name="RunSSH"
Click="RunSSHButton_Click"
Content="执行脚本"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="268"
Margin="0,0,0,0"
/>
</StackPanel>

</StackPanel>
</StackPanel>
</StackPanel>

<TeachingTip x:Name="SSHResponse"
Title="SSH 输出"
Subtitle=""
PreferredPlacement="Auto"
PlacementMargin="20"
IsLightDismissEnabled="True"
CloseButtonContent="明白!">
</TeachingTip>
<TeachingTip x:Name="SaveConfigTips"
Title=""
Subtitle=""
PreferredPlacement="Auto"
PlacementMargin="20"
IsLightDismissEnabled="True"
CloseButtonContent="确认">
</TeachingTip>
<TeachingTip x:Name="SSHCommandNotSendTips"
Title="SSH 链接失败"
Subtitle="请检查您填写的配置以及网络状况"
PreferredPlacement="Auto"
PlacementMargin="20"
IsLightDismissEnabled="True"
CloseButtonContent="确认">
</TeachingTip>
</Grid>
</Page>
Loading

0 comments on commit d9d84c1

Please sign in to comment.