日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Win 8 app 获取窗口的宽度和高度, 本地化, 及文本读取

發(fā)布時(shí)間:2025/3/21 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Win 8 app 获取窗口的宽度和高度, 本地化, 及文本读取 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在Windows 8的程序中:

1. 獲取用戶窗口的寬高;

double height = Windows.UI.Xaml.Window.Current.Bounds.Height;double width = Window.Current.Bounds.Width;

2. 獲取用戶的語言設(shè)置;

this._cultureInfo = System.Globalization.CultureInfo .CurrentUICulture .Name .ToString ();

注釋: 我現(xiàn)在還不清楚這個(gè)CurrentUICulture是怎么使用的。 我的應(yīng)用中是通過獲取用戶的區(qū)域來決定顯示的語言的:

this._region = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion;

如果返回的值_region是“CN”, 那么我的程序就顯示中文。

3. 文件的讀取, text方式;

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Windows.Storage;namespace QpuzzleTouch.DataModel {public class FileAccess:QpuzzleTouch .Common .BindableBase{private static FileAccess _fileAccess=new FileAccess();public StorageFile StorageFile = null;string _fileName = null;public string UserData = string.Empty;public FileAccess(){this._fileName = "QpuzzleCustomConfig.txt";}public static async void InitStorageFile(){try{StorageFolder storageFolder = KnownFolders.DocumentsLibrary;_fileAccess.StorageFile = await storageFolder .GetFileAsync (_fileAccess ._fileName );if (_fileAccess.StorageFile != null){_fileAccess.UserData = await FileIO.ReadTextAsync(_fileAccess.StorageFile);}}catch { }}public static string GetData(){InitStorageFile();try{if (_fileAccess.UserData != string.Empty)return _fileAccess.UserData;elsereturn string.Empty;}catch {return string.Empty;}}public static async void CreateFile(string fileName){try{StorageFolder storageFolder = KnownFolders.DocumentsLibrary;_fileAccess.StorageFile = await storageFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);}catch { }}public static async void WriteText(string userContent){CreateFile(_fileAccess._fileName);try{if (_fileAccess.StorageFile != null){await FileIO.WriteTextAsync(_fileAccess.StorageFile, userContent);}}catch { }}} }

?向程序的本地目錄里邊寫配置文件。

Windows.Storage.ApplicationData.Current.LocalFolder.

async void ReadFromFile(){StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;StorageFile storageFile = await storageFolder.CreateFileAsync("text.txt", CreationCollisionOption.OpenIfExists);string result =await FileIO.ReadTextAsync(storageFile);textbox1.Text = result;}private async void btwrite_Click(object sender, RoutedEventArgs e){StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;StorageFile storageFile =await storageFolder.CreateFileAsync("text.txt", CreationCollisionOption.OpenIfExists);await FileIO.AppendTextAsync(storageFile, "abc");}

?

轉(zhuǎn)載于:https://www.cnblogs.com/qixue/archive/2012/12/15/2819843.html

總結(jié)

以上是生活随笔為你收集整理的Win 8 app 获取窗口的宽度和高度, 本地化, 及文本读取的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。