[Win10] some small summary about incomplete archiving (Forgive me for this damn title) and win10 Archiving
1. Obtain the screen resolution of a device in synchronous Mode
Public static class ScreenResolution {/// <summary> /// obtain the screen height. /// </Summary> public static int Height {get {var rect = PointerDevice. getPointerDevices (). last (). screenRect; var scale = DisplayInformation. getForCurrentView (). rawPixelsPerViewPixel; return (int) (rect. height * scale) ;}//< summary> /// obtain the screen width. /// </Summary> public static int Width {get {var rect = PointerDevice. getPointerDevices (). last (). screenRect; var scale = DisplayInformation. getForCurrentView (). rawPixelsPerViewPixel; return (int) (rect. width * scale );}}}
First thought Source: http://bbs.wfun.com/thread-860192-1-1.html
Test results:
Desktop (device win10. 10240)
Correct Value: 1920x1080
Test Result: 1920x1080
Mobile (emulator W10M 10240 WXGA 4.5 inch)
Correct Value: 768x1280
Test Result: 768x1280
Mobile (emulator W10M 10240 WVGA 4 inch)
Correct Value: 480x800
Test Result: 480x854
The last one is not equal. I personally think it is because of the virtual navigation bar. Therefore, I think this code is theoretically correct and can be put into the production environment.
If you are not at ease, you can use the Win32 API to obtain the screen resolution.(The API has been verified and cannot be used in the store application package. Thank you.@ FlashcancerNote)
[DllImport("user32.dll")]public static extern int GetSystemMetrics(SystemMetric smIndex);
int x = GetSystemMetrics(SystemMetric.SM_CXSCREEN);int y = GetSystemMetrics(SystemMetric.SM_CYSCREEN);
SystemMetric is an enumeration type, which can be defined as: http://pinvoke.net/default.aspx/Enums.SystemMetric
The obtained Result is the same as the Test Result above, and this API can be used in both desktop and mobile. (However, the store cannot be used)
List of Win32 APIs allowed in the store: https://msdn.microsoft.com/zh-cn/library/windows/apps/jj662956 (v = vs.105). aspx (the link is WP8, but Win10 should be similar)
2. Access the Package. appxmanifest file during runtime
Some data is written in the Package. appxmanifest file. For example, the image used for the tile and the image used to start the screen. You can only access the Package. appxmanifest file when you obtain the information during the runtime.
string manifestPath = Path.Combine(Package.Current.InstalledLocation.Path, "AppxManifest.xml");XDocument document = XDocument.Load(manifestPath);
After compilation, we know that it will become the AppxManifest. xml file. Then we can use XDocument or XmlDocument to explain it.
Schema document address for manifest: https://msdn.microsoft.com/zh-cn/library/windows/apps/dn934760.aspx
3. Obtain GB2312 Encoding
In the past, WP8.1 got this Encoding from codeplex, and now it's not used.
// You can execute these two statements once. Of course, repeated execution is not bad. EncodingProvider provider = CodePagesEncodingProvider. instance; Encoding. registerProvider (provider); Encoding gb2312 = Encoding. getEncoding ("gb2312"); // throw ArgumentException // Encoding doge = Encoding. getEncoding ("doge ");
The first two sentences can be placed in App. cs (of course, it is no big problem for some people to change the entry point to another one. You can run it once. Next we can get the Encoding. Of course, the premise is that you have this Encoding on your machine. If not, an ArgumentException will be thrown just like the doge above.
4. AccentColor)
public static Color AccentColor{ get { return new UISettings().GetColorValue(UIColorType.Accent); }}
UIColorType is an enumeration type with Background colors.
Of course, you can continue to use the WP8.1 method and obtain it through Resource, but the ResourceKey in Win10 has changed.
V. What is the difference between Launched and Actived in App. cs?
A graph stream is not explained.
I did not know how to arrange the weekend break. It turned out to be so messy. It's a bit difficult to use Paint. Net for a long time.
This figure is organized by myself. Do not take it seriously. If there are any mistakes or omissions, please comment out in the comments.
Finally, I hope that my job interview will be successful, I will get an offer, and I will hand it over early and quit. Now I have a good rest for a few days (recently I feel a little tired ).