.Net语言Smobiler开发之如何仿微信朋友圈的消息样式
程序员文章站
2023-12-01 21:17:58
最前面的话:smobiler是一个在vs环境中使用.net语言来开发app的开发平台,也许比xamarin更方便
一、目标样式
我们要实现上图中的效果,需要如下的操...
最前面的话:smobiler是一个在vs环境中使用.net语言来开发app的开发平台,也许比xamarin更方便
一、目标样式
我们要实现上图中的效果,需要如下的操作:
1.从工具栏上的”smobiler components”拖动一个microblog控件到窗体界面上
2.用代码添加手机界面上显示的内容
load事件代码:
vb:
private sub testmicroblog_load(sender as object, e as eventargs) handles mybase.load try me.microblog1.defaultusername = "伟斌" me.microblog1.defaultuserid = "伟斌" contentarray(0) = "把青春献给身后那座"+ vbcrlf + "辉煌的城市" + vbcrlf + "为了这个美梦" + vbcrlf + "我们付出着代价" userarray(0) = "伟斌" picturearray(0) = 0 initialmicroblogdata() catch ex as exception messagebox.show(ex.message, sub() me.close()) end try end sub c#: private void testmicroblog_load(object sender, eventargs e) { try { this.microblog1.defaultusername = "伟斌"; this.microblog1.defaultuserid = "伟斌"; contentarray[0] = "把青春献给身后那座" + system.environment.newline + "辉煌的城市" + system.environment.newline + "为了这个美梦"+ system.environment.newline + "我们付出着代价"; userarray[0] = "伟斌"; picturearray[0] = "0"; initialmicroblogdata(); } catch (exception ex) { messagebox.show(ex.message, (object s, messageboxhandlerargs args) => this.close()); } }
其他代码:
vb:
dim contentarray(4) as string dim userarray(4) as string dim picturearray(8) as string dim voice(5) as string private sub initialmicroblogdata(optional count as integer = 10, optional byval insert as boolean = false) dim user as string = userarray(0) dim picturerandomnum as integer = 6 dim imagelist as new list(of string) imagelist.add(6) dim item as new microblogitem(user, user, contentarray(0), datetime.now.tostring) item.pictures = imagelist item.ilikes.add(userarray(0), userarray(0)) if insert = false then me.microblog1.blogitems.add(item) else me.microblog1.blogitems.addtop(item) end if next end sub c#: string[] contentarray = new string[5]; string[] userarray = new string[5]; string[] picturearray new string[9]; string[] voice = new string[6]; private void initialmicroblogdata(int count = 10, bool insert = false) { string user = userarray[0]; list<string> imagelist = new list<string>(); imagelist.add("6"); microblogitem item = new microblogitem(user, user, contentarray[0], datetime.now.tostring()); item.pictures = imagelist; item.ilikes.add(userarray[0], userarray[0]); if (insert == false) { this.microblog1.blogitems.add(item); } else this.microblog1.blogitems.addtop(item); } }
二、手机效果显示
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。