In the previous Windows.Andy.Code4App.dll win8.1/wp8.1 General class library @ver1.0.0 has already explained the Win8.1 and WP8.1 partial extension General Class library, this article continues to extend to the common class library. Write not good, also please each road big God many advice ~
WINDOWS.ANDY.CODE4APP win8.1/wp8.1 General Class Library @ver1.0.1 project structure:
Compare the last 1.0.0 to see the following extensions: Async (Asynchronous Class), Converter (transformation Class), Device (appliance Class), Encrypt (cryptographic Class), Helper (helper Class), net (network Class). These extension classes are described below (some are more, only the extension methods are listed).
First, async (asynchronous Class)
1, AsyncProperty
Asynchronous properties, the main problem here is an asynchronous binding that implements arbitrary dependency properties in the MVVM design pattern. For example, the source property of the image control is bound, sometimes directly bound to a network address, but at the same time want to see whether the local presence of the specified picture file, to see whether the local presence is asynchronous, and the value of this source binding requires asynchrony, At this point, you can use AsyncProperty.
Image Binding code Example:
Define an asynchronous property in model:
To get a value by using an async method:
The following is the wording in view:
Second, Converter (conversion Class)
The conversion class currently contains: Booleantodatatemplateconverter, Booleantodoubleconverter, Booleantovisibilityconverter, Colortobrushconverter, Doubletointconverter
It is very simple not to do explanations and examples.
Third, device (equipment Class)
1, Devicehelper
This is the only way to get the device ID.
Method Name: Getdeviceid ()
Iv. Encrypt (Encryption Class)
1, MD5
Take MD5 for string and byte[].
2. DES
Because WP and WIN8 Microsoft does not provide DES encryption and decryption class, but sometimes in the development process to encounter, so the previous DES encryption method can be modified.
Method: Encrypt/decrypt string, encrypt/decrypt character array.
V. Extension (Extended Class)
1, Commonobjectex
①, Collectionex
Extended to Ienumerable<t>:asenumerable<t>, and<t>, and<t>, foreach<t>
Extended to List<t>:lockadd<t>, lockremove<t>
Extended to Observablecollection<t>:lockadd<t>, lockremove<t>
②, Datetimeex
Only one extension was made: Tounixtime
③, Objectarraryex
Extended:toenumerable<t>
④, Stringex
This extension is more, just some of the common method requirements of encapsulation:
GetBytesWithUTF8, Getbyteswithunicode, UrlEncode, UrlDecode, Asuri, Upperfirst, Checkstringisnullorblankorempry
2, Dependencyobjectex
①, Bitmapimageex
Extensions: Waitforloadedasync, LoadAsync, Setsourceasync, loadfrombase64string
②, Controlex
Extension: Gotovisualstateasync
③, Frameworkelementex
Extensions: Waitforloadedasync, Waitforunloadedasync, Waitforlayoutupdateasync, Waitfornonzerosizeasync, Waitforimagestoload
④, Gridviewex
Extension: itemisvisibility
⑤, Imageex
This is the main animation extension of image opened, the view is written as follows:
The above XAML identity is then animated. These two can be used in conjunction or alone to apply, to see their own development needs. Random animations include: FadeIn, Slideup, Slideleft, Slidedown, Slideright
⑥, Scrollviewerex
Extensions: Scrolltohorizontaloffsetwithanimation, scrolltoverticaloffsetwithanimation, Zoomtofactorwithanimation, ChangeView
⑦, Storyboardex
Extension: Beginasync Asynchronous start animation
⑧, Styleex
Extension: GetPropertyValue gets the object in the style style that specifies the dependency property
⑨, Textblockex
Extensions: Getcharacterrect,
⑩, Writeablebitmapex
Extensions: Waitforloadedasync, LoadAsync, Frombitmapimage, Setsourceasync, SaveToFile
3, Dependencypropertyex
①, Tilteffect
Add the enabled dependency property to specify whether the dependent object has a skew attribute.
②, Visualstateex
Adds a state dependency property that specifies the transition of the dependent object to the specified status.
VI. Helper
1, Commonhelper
Common helper class, which contains some common methods:
Isconnectedtointernet, Streamtobytes, Objtobytes, Bytestoobj, asencodingstring, Formdatacombine
2, Scrollviewhelper
Include Method: Scrollgridviewtoitem
3, Visualstatehelper
Include method: Getstoryboardforvisualstate. Gets the corresponding storyboard according to the specified visualstate
Vii.. Net
This is mainly the operation of the network
1, WebData
①, get, form forms require user name and password to get data : getfromurlwithauthreturnstring, Getfromurlwithauthreturnbytearrary, Getfromurlwithauthreturnstream
②, GET, form forms do not require user name and password to get data : getfromurlreturnstring, Getfromurlreturnbytearrary, Getfromurlreturnstream
③, Post, form forms require user name and password method to obtain data : posttourlwithauthreturnstring, Posttourlwithauthreturnbytearrary, Posttourlwithauthreturnstream
④, Post, form forms do not require user name and password to obtain data : posttourlreturnstring, Posttourlreturnbytearrary, Posttourlreturnstream
⑤, GET, Body jsondata need user name and password way to get data : getfromurlwithauthandjsonreturnstring, Getfromurlwithauthandjsonreturnstream, Getfromurlwithauthandjsonreturnbytearrary
⑥, GET, Body jsondata do not require user name and password method to obtain data : getfromurlwithjsonreturnstring, Getfromurlwithjsonreturnstream, Getfromurlwithjsonreturnbytearrary
⑦, Post, Body jsondata need user name and password method to obtain data : posttourlwithauthandjsonreturnstring, Posttourlwithauthandjsonreturnstream, Posttourlwithauthandjsonreturnbytearrary
⑧, Post, Body jsondata do not require user name and password method to obtain data : posttourlwithjsonreturnjsonstring, Posttourlwithjsonreturnstream, Posttourlwithjsonreturnbytearrary
2, Webdownfile
This class is primarily provided for downloading and saving files via HTTP or backgrounddownloader.
Methods included: Saveasyncwidthhttpandtimeout, Saveasyncwithhttp, Saveasyncwithbackgrounddownloader, Saveasyncwithbackgrounddownloaderandprogress
The above is the new extension of the @ver1.0.1 version of the content, some methods have done a lot of overloading, you can view it yourself.
Animation (animation class library), Contol (Control Library), and style (style library) are reserved in the project and will be added in the next release.
Component: Windows.Andy.Code4App.dll
Windows.Andy.Code4App.dll win8.1/wp8.1 General Class library @ver1.0.1