您好,欢迎访问一九零五行业门户网

微信小程序开发--如何制作表白图片?

大家可能都会在抖音上刷过,那种表白小程序,但在我看来表白还是亲口说出来比较好,这类小程序只适合在平常的一些小节日给对方一个惊喜。话不多说,现在进入正题:
        首先,要在电脑上安装微软的编译软件,我这里是使用的vs2017,安装的时候如果没有别的需要,直接选择下载wpf的组件就好。否则,下载量大,安装时间长。
        安装完之后,点击文件,新建项目,选择wpf应用
然后是窗口设计,代码如下:
<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>
效果如下:
然后是代码,鼠标检测那些:
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); } }}
好了,一个表白小程序就弄好了,生成解决方案之后,就可以在工程文件中找到.exe的程序,提取出来,发给对方即可。
tips:程序中的图片,自己替换,在项目中添加现有项,选择图像格式,在选中你找到的图片,点击确认即可。
相关文章:
微信小程序开发图片压缩功能
微信小程序怎么开发之微信小程序开发高清图文教程
以上就是微信小程序开发--如何制作表白图片?的详细内容。
其它类似信息

推荐信息