basic基本项.docx
- 文档编号:7418800
- 上传时间:2023-01-23
- 格式:DOCX
- 页数:20
- 大小:40.23KB
basic基本项.docx
《basic基本项.docx》由会员分享,可在线阅读,更多相关《basic基本项.docx(20页珍藏版)》请在冰豆网上搜索。
basic基本项
BasicComponents
TableofContents
▪Button
▪Canvas
▪CheckBox
▪Clock
▪Image
▪Label
▪ListPicker
▪PasswordTextBox
▪Screen
▪TextBox
▪TinyDB
Button
Buttonsarecomponentsthatuserstouchtoperformsomeactioninyourapp.
Buttonsdetectwhenuserstapthem.Manyaspectsofabutton'sappearancecanbechanged.Youcanusethe Enabled propertytochoosewhetherabuttoncanbetapped.
Properties
BackgroundColor
Colorforbuttonbackground.
Enabled
Ifset,usercantapbuttontocauseaction.
FontBold
Ifset,buttontextisdisplayedinbold.
FontItalic
Ifset,buttontextisdisplayedinitalics.
FontSize
Pointsizeforbuttontext.
FontTypeface
Fontfamilyforbuttontext.
Height
Buttonheight(y-size).
Width
Buttonwidth(x-size).
Image
Imagetodisplayonbutton.
Text
Texttodisplayonbutton.
TextAlignment
Left,center,orright.
TextColor
Colorforbuttontext.
Events
Click()
Usertappedandreleasedthebutton.
GotFocus()
Buttonbecamethefocusedcomponent.
LostFocus()
Buttonstoppedbeingthefocusedcomponent.
Canvas
Atwo-dimensionaltouch-sensitiverectangularpanelonwhichdrawingcanbedoneandspritescanbemoved.
The BackgroundColor, PaintColor, BackgroundImage, Width,and Height oftheCanvascanbesetineithertheDesignerorintheBlocksEditor.The Width andHeight aremeasuredinpixelsandmustbepositive.
AnylocationontheCanvascanbespecifiedasapairof(X,Y)values,where
▪XisthenumberofpixelsawayfromtheleftedgeoftheCanvas
▪YisthenumberofpixelsawayfromthetopedgeoftheCanvas
ThereareeventstotellwhenandwhereaCanvashasbeentouchedora Sprite (ImageSprite or Ball)hasbeendragged.Therearealsomethodsfordrawingpoints,lines,andcircles.
Properties
BackgroundColor
Thecolorofthecanvasbackground.
BackgroundImage
Thenameofafilecontainingthebackgroundimageforthecanvas
Height
LineWidth
Thewidthoflinesdrawnonthecanvas.
PaintColor
Thecolorinwhichlinesaredrawn
Visible
Whetherthecomponentisvisible
Width
Events
Dragged(numberstartX,numberstartY,numberprevX,numberprevY,numbercurrentX,numbercurrentY,booleandraggedSprite)
Whentheuserdoesadragfromonepoint(prevX,prevY)toanother(x,y).Thepair(startX,startY)indicateswheretheuserfirsttouchedthescreen,and"draggedSprite"indicateswhetheraspriteisbeingdragged.
Touched(numberx,numbery,booleantouchedSprite)
Whentheusertouchesacanvas,providingthe(x,y)positionofthetouchrelativetotheupperleftcornerofthecanvas.Thevalue"touchedSprite"istrueifaspritewasalsointhisposition.
Methods
Clear()
Clearsthecanvas,withoutremovingthebackgroundimage,ifonewasprovided.
DrawCircle(numberx,numbery,numberr)
Drawsacircle(filledin)atthegivencoordinatesonthecanvas,withthegivenradius.
DrawLine(numberx1,numbery1,numberx2,numbery2)
Drawsalinebetweenthegivencoordinatesonthecanvas.
DrawPoint(numberx,numbery)
Drawsapointatthegivencoordinatesonthecanvas.
Save()
SavesapictureofthisCanvastothedevice'sexternalstorageandreturnsthefullpathnameofthesavedfile.IfanerroroccurstheScreen's ErrorOccurred eventwillbecalled.
SaveAs(textfilename)
SavesapictureofthisCanvastothedevice'sexternalstorageinthefilenamedfileName.fileNamemustendwithoneof".jpg",".jpeg",or".png"(whichdeterminesthefiletype:
JPEG,orPNG).Returnsthefullpathnameofthesavedfile.
CheckBox
Checkboxcomponentscandetectusertapsandcanchangetheirbooleanstateinresponse.
Acheckboxcomponentraisesaneventwhentheusertapsit.TherearemanypropertiesaffectingitsappearancethatcanbesetintheDesignerorBlocksEditor.
Properties
BackgroundColor
Colorforcheckboxbackground.
Checked
Trueiftheboxischecked,falseotherwise.
Enabled
Ifset,usercantapcheckboxtocauseaction.
Height
Checkboxheight(y-size).
Width
Checkboxwidth(x-size).
Text
Texttodisplayoncheckbox.
TextColor
Colorforcheckboxtext.
Visible
Ifset,checkboxisvisible.
Events
Click()
Usertappedandreleasedcheckbox.
GotFocus()
Checkboxbecamethefocusedcomponent.
LostFocus()
Checkboxstoppedbeingthefocusedcomponent.
Clock
Useaclockcomponenttocreateatimerthatsignalseventsatregularintervals.Theclockcomponentalsodoesvariousconversionsandmanipulationswithtimeunits.
Oneuseoftheclockcomponentisaa timer:
setthetimerinterval,andthetimerwillfirerepeatedlyattheinterval,signallingatimerevent.
Aseconduseoftheclockcomponentistomanipulatetime,andexpresstimeinvariousunits.Theinternaltimeformatusedbytheclockiscalledan instant.Theclock'sNow methodreturnsthecurrenttimeasaninstant.Theclockprovidesmethodstomanipulateinstants,forexample,returnaninstantthatisseveralseconds,ormonths,oryearsfromthegiveninstant.Italsoprovidesmethodstoshowthesecond,minute,hour,day,…,correspondingtoagiveninstant.
Properties
TimerInterval
timerintervalinmilliseconds
TimerEnabled
Iftrue,thenthetimerwillfire
TimerAlwaysFires
iftrue,thetimerwillfireeveniftheapplicationisnotshowingonthescreen
Events
Timer()
Thiseventissignaledwhenthetimerfires
Methods
SystemTime()
Thephone'sinternaltimeinmilliseconds
Now()
Theinstantintimereadfromphone'sclock
MakeInstant(Textfrom)
MakeaninstantspecifiedbyMM/DD/YYYYhh:
mm:
ssorMM/DD/YYYYorhh:
mm.
MakeInstantFromMillis(Numbermillis)
Makeaninstantspecifiedbytimeinmilliseconds
GetMillis(instant)
Theinstantintimemeasuredasmillisecondssince1970
AddSeconds(instant,Numberseconds)
Aninstantintimesomenumberofsecondsafterthegiveninstant
AddMinutes(instant,Numberminutes)
Aninstantintimesomenumberofminutesafterthegiveninstant
AddHours(instant,Numberhours)
Aninstantintimesomenumberofhoursafterthegiveninstant
AddDays(instant,Numberdays)
Aninstantintimesomenumberofdaysafterthegiveninstant
AddWeeks(instant,Numberweeks)
Aninstantintimesomenumberofweeksafterthegiveninstant
AddMonths(instant,Numbermonths)
Aninstantintimesomenumberofmonthsafterthegiveninstant
AddYears(instant,Numberyears)
Aninstantintimesomenumberofyearsafterthegiveninstant
Duration(Calendarstart,Calendarend)
Millisecondsbetweeninstants
Second(Calendarinstant)
Thesecondoftheminute
Minute(Calendarinstant)
Theminuteofthehour
Hour(Calendarinstant)
Thehouroftheday
DayOfMonth(Calendarinstant)
Thedayofthemonth,anumberfrom1to31
Weekday(Calendarinstant)
Thedayoftheweek.anumberfrom1(Sunday)to7(Saturday)
WeekdayName(Calendarinstant)
Thenameofthedayoftheweek
Month(Calendarinstant)
Themonthoftheyear,anumberfrom1to12)
MonthName(Calendarinstant)
Thenameofthemonth
Year(Calendarinstant)
Theyear
FormatDateTime(Calendarinstant)
Textdescribingthedateandtimeofaninstant
FormatDate(Calendarinstant)
Textdescribingthedateofaninstant
FormatTime(Calendarinstant)
Textdescribingtimetimeofaninstant
Image
Youuseimagecomponentstorepresentimagesthatusersselectandmanipulate.
Animagecomponentdisplaysanimage.Youcanspecifythepicturetodisplayandotheraspectsoftheimage'sappearanceintheDesignerorintheBlocksEditor.
Properties
Picture
Picturedisplayedbythisimage.
Visible
Iftrue,imageisdisplayed.
Height
Imageheight(y-size).
Width
Imagewidth(x-size).
Label
Labelsarecomponentsusedtoshowtext.
Alabeldisplaystextwhichisspecifiedbythe Text property.Otherproperties,allofwhichcanbesetintheDesignerorBlocksEditor,controltheappearanceandplacementofthetext.
Properties
BackgroundColor
Colorforlabelbackground.
FontBold
Ifset,labeltextisdisplayedinbold.
FontItalic
Ifset,labeltextisdisplayedinitalics.
FontSize
Pointsizeforlabeltext.
FontTypeface
Fontfamilyforlabeltext.
Height
Labelheight(y-size).
Width
Labelwidth(x-size).
Text
Texttodisplayonlabel.
TextAlignment
Left,center,orright.
TextColor
Colorforlabeltext.
Visible
Ifset,labelisvisible.
ListPicker
Userstapalistpickercomponenttoselectoneitemfromalistoftextstrings.
Whenausertapsalistpicker,itdisplaysalistoftextitemsfortheusertochoosefrom.ThetextitemscanbespecifiedthroughtheDesignerorBlocksEditorbysettingthe ElementsFromString propertytotheircomma-separatedconcatenation(forexample, choice1,choice2,choice3)orbysettingthe Elements propertytoaList intheBlocksEditor.
Otherproperties,including TextAlignment and BackgroundColor,affecttheappearanceofthebuttonandwhetheritcanbetapped(Enabled).
Properties
Selection
Selectedlistelement.
Items
Comma-separatedlistofitemstodisplayincomponent.
ElementsFromString
(Descriptiontocome.)
BackgroundColor
Colorforlistpickerbackground.
FontBold
Ifset,listpickertextisdisplayedinbold.
FontItalic
Ifset,listpickertextisdisplayedinitalics.
FontSize
Pointsizeforlistpickertext.
FontTypeface
Fontfamilyforlistpickertext.
Height
Listpickerheight(y-size).
Width
Listpickerwidth(x-size).
Text
Titletexttodisplayonlistpicker.
TextAlignment
Left,center,orright.
TextColor
Colorforlistpickertext.
Visible
Ifset,listpickerisvisible.
Events
AfterPicking()
Userselectedanitemfromthelistpicker.
BeforePicking()
Userhastappedthelistpickerbuthasn'tyetselectedanitem.
GotFocus()
Listpickerbecamethefocusedcomponent.
LostFocus()
Listpickerisnolongerthefoc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- basic 基本
![提示](https://static.bdocx.com/images/bang_tan.gif)