在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
无意间发现抖音里有一个段视频,逼迫批准辞职的小程序。虽然小白菜,但闲来无事,举手投足间打发时间。 这里主要分以下几步骤:
先看一下源码: 1 <Window x:Class="Resignation.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="MainWindow" Height="350" Width="525"> 5 <Grid Background="Black"> 6 <DockPanel VerticalAlignment="Top"> 7 <StackPanel DockPanel.Dock="Top"> 8 <TextBlock HorizontalAlignment="Center" Foreground="White" Width="auto" FontWeight="Bold" FontSize="24"> 9 I have to resign, please kindly approve. 10 </TextBlock> 11 </StackPanel> 12 <StackPanel DockPanel.Dock="Left" Orientation="Vertical"> 13 <Button Name="btn00_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 14 <Button Name="btn01_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 15 <Button Name="btn02_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 16 <Button Name="btn03_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 17 </StackPanel> 18 <StackPanel DockPanel.Dock="Left" Orientation="Vertical"> 19 <Button Name="btn10_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 20 <Button Name="btn11_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 21 <Button Name="btn12_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 22 <Button Name="btn13_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 23 </StackPanel> 24 <StackPanel DockPanel.Dock="Left" Orientation="Vertical"> 25 <Button Name="btn20_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 26 <Button Name="btn21_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 27 <Button Name="btn22_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 28 <Button Name="btn23_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 29 </StackPanel> 30 <StackPanel DockPanel.Dock="Left" Orientation="Vertical"> 31 <Button Name="btn30_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 32 <Button Name="btn31_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 33 <Button Name="btn32_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 34 <Button Name="btn33_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 35 </StackPanel> 36 <StackPanel DockPanel.Dock="Left" Orientation="Vertical"> 37 <Button Name="btn40_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 38 <Button Name="btn41_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 39 <Button Name="btn42_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 40 <Button Name="btn43_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 41 </StackPanel> 42 </DockPanel> 43 <DockPanel VerticalAlignment="Bottom"> 44 <StackPanel DockPanel.Dock="Left" Orientation="Horizontal"> 45 <Button Name="btn50_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter"/> 46 <Button Name="btn51_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 47 <Button Name="btn52_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 48 <Button Name="btn53_ok" Content="Disapproved" Width="80" Height="30" Margin="10" MouseEnter="btn1_ok_MouseEnter" Visibility="Hidden"/> 49 <Button Name="btn54_ok" Content="Approved" Width="80" Height="30" Margin="10" FontWeight="Bold" FontSize="14" Click="approved_Click"/> 50 </StackPanel> 51 </DockPanel> 52 </Grid> 53 </Window> 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows; 7 using System.Windows.Controls; 8 using System.Windows.Data; 9 using System.Windows.Documents; 10 using System.Windows.Input; 11 using System.Windows.Media; 12 using System.Windows.Media.Imaging; 13 using System.Windows.Navigation; 14 using System.Windows.Shapes; 15 16 namespace Resignation 17 { 18 /// <summary> 19 /// Interaction logic for MainWindow.xaml 20 /// </summary> 21 public partial class MainWindow : Window 22 { 23 public MainWindow() 24 { 25 InitializeComponent(); 26 Closing += window_close; 27 } 28 int i = 0; 29 bool IsApproved = false; 30 string[] abuf = { 31 "btn00_ok", "btn01_ok", "btn02_ok", "btn03_ok", 32 "btn10_ok", "btn11_ok", "btn12_ok", "btn13_ok", 33 "btn20_ok", "btn21_ok", "btn22_ok", "btn23_ok", 34 "btn30_ok", "btn31_ok", "btn32_ok", "btn33_ok", 35 "btn40_ok", "btn41_ok", "btn42_ok", "btn43_ok", 36 "btn50_ok", "btn51_ok", "btn52_ok", "btn53_ok", 37 }; 38 private void btn1_ok_MouseEnter(object sender, MouseEventArgs e) 39 { 40 var d = sender as Button; 41 d.Visibility = Visibility.Hidden; 42 i = DateTime.Now.Millisecond % 24; 43 if (abuf[i] == d.Name) 44 { 45 if (++i >= 24) 46 i = 0; 47 } 48 ((Button)this.FindName(abuf[i++])).Visibility=Visibility.Visible; 49 } 50 private void approved_Click(object sender, RoutedEventArgs e) 51 { 52 btn54_ok.Content = "Thank You"; 53 btn54_ok.Foreground = new SolidColorBrush(Colors.LightCyan); 54 btn54_ok.Background = System.Windows.Media.Brushes.ForestGreen; 55 IsApproved = true; 56 } 57 private void window_close(object sender, System.ComponentModel.CancelEventArgs ex) 58 { 59 if (IsApproved == false) 60 { 61 MessageBox.Show("Please Approved, thanks."); 62 ex.Cancel = true; 63 return; 64 } 65 MessageBox.Show("Thank you! GoodBye!"); 66 } 67 } 68 } 效果: End. Thank you. |
请发表评论