原文:https://blog.c12th.cn/archives/34.html
前言
边学边写的…
基于 PCL2 启动器 的自定义主页
效果展示
效果展示
彩虹
<TabControl Margin="0,0,0,15">
<TabItem Background="{DynamicResource ColorBrush}">
<TabItem.Header>
出租
</TabItem.Header>
<TextBlock FontSize="56" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="top">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard Duration="0:0:1.0" RepeatBehavior="Forever" Storyboard.TargetName="top" Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames>
<DiscreteDoubleKeyFrame Value="0.0" KeyTime="80%" />
<DiscreteDoubleKeyFrame Value="0.2" KeyTime="60%" />
<DiscreteDoubleKeyFrame Value="0.4" KeyTime="40%" />
<DiscreteDoubleKeyFrame Value="0.6" KeyTime="20%" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</TextBlock.Triggers>
<Run Foreground="red" Text="R" ToolTip="R" />
<Run Foreground="orange" Text="O" ToolTip="A" />
<Run Foreground="yellow" Text="Y" ToolTip="I" />
<Run Foreground="green" Text="G" ToolTip="N" />
<Run Foreground="blue" Text="B" ToolTip="B" />
<Run Foreground="indigo" Text="I" ToolTip="O" />
<Run Foreground="purple" Text="P" ToolTip="W" />
</TextBlock>
</TabItem>
<TabItem Background="{DynamicResource ColorBrush}">
<TabItem.Header>
独占
</TabItem.Header>
<TextBlock Text=" https://github.com/12thstan/PCL2-XAML https://gitee.com/c12th/PCL2-XAML" />
</TabItem>
</TabControl>
图片
<local:MyCard Title="如图" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<Image Height="150" HorizontalAlignment="Center" Source="http://5b0988e595225.cdn.sohucs.com/images/20171104/e39b3eed62bc4b489cb71d5b56bcce65.jpeg" ToolTip="看什么看快学习!" />
<TextBlock TextWrapping="Wrap" Margin="0,10,0,4" HorizontalAlignment="Center" Text="图 1.1 今天你学习了吗?" ToolTip="论文格式后遗症" />
</StackPanel>
</local:MyCard>
网格
<Grid Margin="0,0,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<TabControl SelectedIndex="{Binding ElementName=te,Path=SelectedIndex}">
<TabItem>
<local:MyButton IsEnabled="{Binding ElementName=tb,Path=IsChecked}" HorizontalAlignment="Center" Width="20" Text="?" ColorType="Highlight" EventType="打开文件" EventData="explorer.exe|/select,Setup.ini" ToolTip="Starry Sky" />
</TabItem>
<TabItem>
<CheckBox Name="tb" Content="42" ToolTip="?" />
</TabItem>
</TabControl>
<ComboBox SelectedIndex="0" Name="te" Grid.Column="1">
<ComboBoxItem Content="La" HorizontalAlignment="Left" VerticalAlignment="Center" />
<ComboBoxItem Content="Th" HorizontalAlignment="Right" VerticalAlignment="Center" />
</ComboBox>
</Grid>
网站
<local:MyCard Title="网站" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<!-- 第一行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="B 站" EventType="打开网页" EventData="https://www.bilibili.com/" ToolTip="我已经两分钟没逛B站了" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="MCBBS" EventType="打开网页" EventData="https://www.mcbbs.net/portal.php" ToolTip="每日签到emmm" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="MC WiKi" EventType="打开网页" EventData="https://wiki.biligame.com/mc/Minecraft_Wiki" ToolTip="B站镜像WiKi" />
</StackPanel>
<!-- 第二行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="Sakur Frp" EventType="打开网页" EventData="https://www.natfrp.com/user/sign" ToolTip="内网穿透" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="问号" EventType="打开网页" EventData="https://gametame.com/earn/" ToolTip="¿ ¿ ¿"/>
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="Bai Du" EventType="打开网页" EventData="https://www.baidu.com/" ToolTip="有问题,找🡑🡑🡑"/>
</StackPanel>
<!-- 第三行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="LTW3" EventType="启动游戏" EventData="1.18.2|mc.hexdragon.top" ToolTip="lmyyds" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Center" Padding="13,0,13,0" ColorType="Highlight" Text="Hypixel" EventType="启动游戏" EventData="1.8|mc.hypixel.net" ToolTip="Minecraft 1.8" />
</StackPanel>
</StackPanel>
</local:MyCard>
下载
<local:MyCard Title="下载" Margin="0,0,0,15" CanSwap="True" IsSwaped="True">
<StackPanel Margin="25,40,23,15">
<local:MyHint IsWarn="True" Text="链接必须为以http://或https://开头的网址,部分网址可能无法下载" />
<StackPanel Orientation="Horizontal" Height="50" Width="800">
<TextBlock Text="下载链接:" VerticalAlignment="Center" />
<local:MyTextBox Margin="3" Name="web" Height="30" Width="380" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<local:MyButton EventType="下载文件" EventData="{Binding ElementName=web,Path=Text}" Text="开始下载" Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight"/>
<local:MyButton EventType="弹出窗口" EventData="假的|旁边那个才是" Text="开始下载" Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" />
</StackPanel>
</StackPanel>
</local:MyCard>
辅助
<!-- 辅助部分-->
<local:MyCard Title="辅助" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<!-- 第一行 -->
<local:MyHint IsWarn="False" Text="测试专用" />
<!-- 第二行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="刷新主页" EventType="刷新主页" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="定位文件" EventType="打开文件" EventData="explorer.exe|/select,Custom.xaml" ToolTip="定位XAML" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="下载路径" EventType="打开文件" EventData="{path}\PCL\MyDownload" ToolTip="自定义下载路径" />
</StackPanel>
</StackPanel>
</local:MyCard>
完整代码
<!-- 顶端-->
<TabControl Margin="0,0,0,15">
<TabItem Background="{DynamicResource ColorBrush}">
<TabItem.Header>
出租
</TabItem.Header>
<TextBlock FontSize="56" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="top">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard Duration="0:0:1.0" RepeatBehavior="Forever" Storyboard.TargetName="top" Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames>
<DiscreteDoubleKeyFrame Value="0.0" KeyTime="80%" />
<DiscreteDoubleKeyFrame Value="0.2" KeyTime="60%" />
<DiscreteDoubleKeyFrame Value="0.4" KeyTime="40%" />
<DiscreteDoubleKeyFrame Value="0.6" KeyTime="20%" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</TextBlock.Triggers>
<Run Foreground="red" Text="R" ToolTip="R" />
<Run Foreground="orange" Text="O" ToolTip="A" />
<Run Foreground="yellow" Text="Y" ToolTip="I" />
<Run Foreground="green" Text="G" ToolTip="N" />
<Run Foreground="blue" Text="B" ToolTip="B" />
<Run Foreground="indigo" Text="I" ToolTip="O" />
<Run Foreground="purple" Text="P" ToolTip="W" />
</TextBlock>
</TabItem>
<TabItem Background="{DynamicResource ColorBrush}">
<TabItem.Header>
独占
</TabItem.Header>
<TextBlock Text=" https://github.com/12thstan/PCL2-XAML https://gitee.com/c12th/PCL2-XAML" />
</TabItem>
</TabControl>
<!-- 图片部分-->
<local:MyCard Title="如图" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<Image Height="150" HorizontalAlignment="Center" Source="http://5b0988e595225.cdn.sohucs.com/images/20171104/e39b3eed62bc4b489cb71d5b56bcce65.jpeg" ToolTip="看什么看快学习!" />
<TextBlock TextWrapping="Wrap" Margin="0,10,0,4" HorizontalAlignment="Center" Text="图 1.1 今天你学习了吗?" ToolTip="论文格式后遗症" />
</StackPanel>
</local:MyCard>
<!-- test-->
<Grid Margin="0,0,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<TabControl SelectedIndex="{Binding ElementName=te,Path=SelectedIndex}">
<TabItem>
<local:MyButton IsEnabled="{Binding ElementName=tb,Path=IsChecked}" HorizontalAlignment="Center" Width="20" Text="?" ColorType="Highlight" EventType="打开文件" EventData="explorer.exe|/select,Setup.ini" ToolTip="Starry Sky" />
</TabItem>
<TabItem>
<CheckBox Name="tb" Content="42" ToolTip="?" />
</TabItem>
</TabControl>
<ComboBox SelectedIndex="0" Name="te" Grid.Column="1">
<ComboBoxItem Content="La" HorizontalAlignment="Left" VerticalAlignment="Center" />
<ComboBoxItem Content="Th" HorizontalAlignment="Right" VerticalAlignment="Center" />
</ComboBox>
</Grid>
<!-- 网站部分-->
<local:MyCard Title="网站" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<!-- 第一行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="B 站" EventType="打开网页" EventData="https://www.bilibili.com/" ToolTip="我已经两分钟没逛B站了" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="MCBBS" EventType="打开网页" EventData="https://www.mcbbs.net/portal.php" ToolTip="每日签到emmm" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="MC WiKi" EventType="打开网页" EventData="https://wiki.biligame.com/mc/Minecraft_Wiki" ToolTip="B站镜像WiKi" />
</StackPanel>
<!-- 第二行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="Sakur Frp" EventType="打开网页" EventData="https://www.natfrp.com/user/sign" ToolTip="内网穿透" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="问号" EventType="打开网页" EventData="https://gametame.com/earn/" ToolTip="¿ ¿ ¿"/>
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="Bai Du" EventType="打开网页" EventData="https://www.baidu.com/" ToolTip="有问题,找🡑🡑🡑"/>
</StackPanel>
<!-- 第三行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="LTW3" EventType="启动游戏" EventData="1.18.2|mc.hexdragon.top" ToolTip="lmyyds" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Center" Padding="13,0,13,0" ColorType="Highlight" Text="Hypixel" EventType="启动游戏" EventData="1.8|mc.hypixel.net" ToolTip="Minecraft 1.8" />
</StackPanel>
</StackPanel>
</local:MyCard>
<!-- 下载部分-->
<local:MyCard Title="下载" Margin="0,0,0,15" CanSwap="True" IsSwaped="True">
<StackPanel Margin="25,40,23,15">
<local:MyHint IsWarn="True" Text="链接必须为以http://或https://开头的网址,部分网址可能无法下载" />
<StackPanel Orientation="Horizontal" Height="50" Width="800">
<TextBlock Text="下载链接:" VerticalAlignment="Center" />
<local:MyTextBox Margin="3" Name="web" Height="30" Width="380" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<local:MyButton EventType="下载文件" EventData="{Binding ElementName=web,Path=Text}" Text="开始下载" Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight"/>
<local:MyButton EventType="弹出窗口" EventData="假的|旁边那个才是" Text="开始下载" Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" />
</StackPanel>
</StackPanel>
</local:MyCard>
<!-- 辅助部分-->
<local:MyCard Title="辅助" Margin="0,0,0,15">
<StackPanel Margin="25,40,23,15">
<!-- 第一行 -->
<local:MyHint IsWarn="False" Text="测试专用" />
<!-- 第二行 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="刷新主页" EventType="刷新主页" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="定位文件" EventType="打开文件" EventData="explorer.exe|/select,Custom.xaml" ToolTip="定位XAML" />
<local:MyButton Margin="0,0,10,0" Width="140" Height="35" HorizontalAlignment="Left" Padding="13,0,13,0" ColorType="Highlight" Text="下载路径" EventType="打开文件" EventData="{path}\PCL\MyDownload" ToolTip="自定义下载路径" />
</StackPanel>
</StackPanel>
</local:MyCard>