Home  >  Article  >  WeChat Applet  >  WeChat mini program development--how to create confession pictures?

WeChat mini program development--how to create confession pictures?

php是最好的语言
php是最好的语言Original
2018-08-06 17:14:223945browse

You may have used Douyin, that kind of confession app, but in my opinion it is better to express your love in person. This kind of app is only suitable for surprising each other during some ordinary small festivals. Without further ado, let’s get to the point:

First, you need to install Microsoft’s compilation software on your computer. I am using VS2017 here. If there is no other need during installation, just choose to download the wpf component. good. Otherwise, the download volume will be large and the installation time will be long.

After installation, click on the file, create a new project, select wpf application

WeChat mini program development--how to create confession pictures?

Then the window design, the code is as follows:

<Window x:Name="closing" x:Class="BBdemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:lacal="clr-namespace:BBdemo"
        mc:Ignorable="d"
        Title="******窗口标题(我的是大宝贝***)" Height="450" Width="800" Closing="closing_Closing">
    <Grid>
        <Grid.Background>
            <ImageBrush/>
        </Grid.Background>
        <Button Name="btn1" Content="好" HorizontalAlignment="Left" Margin="168,326,0,0"
VerticalAlignment="Top" Width="93" Height="42" Click="Button_Click"/>
        <Label Name="lab1" Content="小可爱**:" HorizontalAlignment="Left" Margin="1,4,0,0"
VerticalAlignment="Top" Height="59" Width="218" FontSize="36" FontStyle="Italic"/>
        <Label Name="lab2" Content="永远做我的小宝贝好吗&#xD;&#xA;&#x9;"
HorizontalAlignment="Left" Height="60" Margin="398,200,0,0" VerticalAlignment="Top"
Width="384" FontSize="36"/>
        <Button Name="btn3" Visibility="Hidden"  Content="退出" HorizontalAlignment="Left"
Height="42" Margin="326,326,0,0" VerticalAlignment="Top" Width="90" Click="Button_Click_1"/>
        <Image x:Name="biaobai" Margin="168,10,399,109" Source="biaobai.png" RenderTransformOrigin="0.362,0.515"/>
        <Button Name="btn2" Content="不好" HorizontalAlignment="Left" 
Margin="493,326,0,0" VerticalAlignment="Top" Width="93" Height="42" 
MouseEnter="Button_MouseEnter"/>
    </Grid>
</Window>

Effect As follows:

WeChat mini program development--how to create confession pictures? Then the code, the mouse detection ones:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;
namespace BBdemo{    /// <summary>    /// MainWindow.xaml 的交互逻辑    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();        }        private void Button_MouseEnter(object sender, MouseEventArgs e)        {            Random rd = new Random();            Button btn = sender as Button;            double maxW = this.Width;            double maxH = this.Height;            double w = btn.Width;            double h = btn.Height;            double l = rd.Next(0, (int)(maxW - w));            double t = rd.Next(0, (int)(maxH - h));            btn.Margin = new Thickness(1, t, 0, 0);        }
        private void closing_Closing(object sender, System.ComponentModel.CancelEventArgs e)        {            MessageBox.Show("不许关!");            e.Cancel = true;        }        private void Button_Click(object sender, RoutedEventArgs e)        {            lab1.Visibility = System.Windows.Visibility.Hidden;            lab2.Content = "谢谢媳妇!";            btn3.Visibility = System.Windows.Visibility.Visible;            btn2.Visibility = System.Windows.Visibility.Hidden;            btn1.Visibility = System.Windows.Visibility.Hidden;        }
        private void Button_Click_1(object sender, RoutedEventArgs e)        {            System.Environment.Exit(0);        }    }}

Okay, a small confession program is ready. After generating the solution, you can find it in the project file Just extract the .exe program and send it to the other party.

tips: Replace the pictures in the program yourself, add existing items to the project, select the image format, select the picture you found, and click OK.

Related articles:

Develop image compression function in WeChat mini program

How to develop WeChat mini program WeChat mini program develops high-definition graphics and text Tutorial

The above is the detailed content of WeChat mini program development--how to create confession pictures?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn