windows-runtime

Xbox 360 Wireless Controller is not working via C++/WinRT and Windows.Gaming.Input API in console application

烂漫一生 提交于 2020-06-13 07:06:59
问题 I trying to use Windows.Gaming.Input API via C++/WinRT from Windows Console Application and it is not working as supposed with Xbox 360 Wireless Controller (reported as Xbox 360 Wireless Receiver for Windows (0x045e:0x0000) ). I got GamepadAdded event, then trying to read gamepad state via gamepad.GetCurrentReading() and seems GamepadReading struct is not filled at all for Xbox 360 Wireless Controller . Also I found that there is some strange error message on MSVS debug console: onecoreuap

Equivalent of Platform::IBoxArray in C++/WinRT

大憨熊 提交于 2020-05-31 06:29:12
问题 I am currently porting an UWP application from C++/CX to C++/WinRT. I encountered a safe_cast<Platform::IBoxArray<byte>^>(data) where data is of type Windows::Foundation::IInspectable ^ . I know that the safe_cast is represented by the as<T> method, and I know there are functions for boxing ( winrt::box_value ) and unboxing ( winrt::unbox_value ) in WinRT/C++. However, I need to know the equivalent of Platform::IBoxArray in order to perform the cast (QueryInterface). According to https://docs

Async lambda expression with await returns Task?

我与影子孤独终老i 提交于 2020-05-26 10:22:51
问题 I have the following code: // Get all of the files from the local storage directory. var files = await folder.GetFilesAsync(); // Map each file to a stream corresponding to that file. var streams = files.Select(async f => { return await f.OpenStreamForWriteAsync(); }); I would expect streams to be of type IEnumerable<Stream> but in fact it is of IEnumberable<Task<Stream>> , which is what I would've expected had I omitted the await keyword. The return type of OpenStreamForWriteAsync is Task

Convert a List<T> into an ObservableCollection<T>

混江龙づ霸主 提交于 2020-04-29 05:32:22
问题 I have a List<T> which is being populated from JSON. I need to convert it into an ObservableCollection<T> to bind it to my GridView . Any suggestions? 回答1: ObservableCollection < T > has a constructor overload which takes IEnumerable < T > Example for a List of int : ObservableCollection<int> myCollection = new ObservableCollection<int>(myList); One more example for a List of ObjectA : ObservableCollection<ObjectA> myCollection = new ObservableCollection<ObjectA>(myList as List<ObjectA>); 回答2

Sending POST request to get OAuth Acess Token

扶醉桌前 提交于 2020-03-26 07:20:12
问题 Google API has documents on implementing OAuth 2.0. However I am quite confused at how your supposed to obtain the access token. The documentation says that I must send a POST request in the following format POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu& client_id=8819981768.apps.googleusercontent.com& client_secret={client_secret}& redirect_uri=https://oauth2-login-demo.appspot.com/code& grant_type

The component cannot be found. (Exception from HRESULT: 0x88982F50)

左心房为你撑大大i 提交于 2020-03-21 11:37:46
问题 The above exception occurs at line await bitmapImage.SetSourceAsync(fileStream); whenever I tried to retrieve image from local file. This is the method I'm using for storing and retrieving the image file. public async Task<BitmapImage> RetrieveImageFromFile(String fileName) { try { StorageFile localFile = await _storageFolder.GetFileAsync(fileName + "Img"); BitmapImage bitmapImage = new BitmapImage(); using (IRandomAccessStream fileStream = await localFile.OpenAsync(FileAccessMode.Read)) {

Converting stream encryption method from .NET to RT

折月煮酒 提交于 2020-02-25 04:32:47
问题 I'm trying to convert Encryption/Decryption methods from managed .NET to WinRT version for use in Windows Store app. The managed .NET encryption methods are already used largely in production, so the assumption is they work correctly. This is the managed .NET encryption method: public static byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; public static void EncryptFile(string sInputFilename, string sOutputFilename, string sKey) { FileStream fsInput = null; FileStream fsOutput = null;

Detect the difference between WinRT and Windows 8

依然范特西╮ 提交于 2020-02-24 07:45:07
问题 For statistic tracking, I'd like to be able to tell if the application is running on Windows RT or Windows Pro. This thread says that there's no way to get the system version info: Get OS-Version in WinRT Metro App C# Any ideas? 回答1: One thing you could do is to go to Configuration Manager in Visual Studio and instead of the default Any CPU configuration - create separate ARM/x86/x64 configurations and in project properties/Conditional compilation symbols define a symbol that is different for

The ScrollViewer does not scroll

牧云@^-^@ 提交于 2020-02-13 16:14:45
问题 I would like to have an interface with 3 components one next to the other. The first would be a ListView and the two others being Grids. Since the components will overflow on the right, I want to put them in a ScrollViewer. I did not succeed. I tried to do a really simple example to try, but even the example fails. <ScrollViewer Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="600" Height="400"> <StackPanel Width="1200" Height="400" Orientation=

HtmlAgilityPack and windows 8 winRT

怎甘沉沦 提交于 2020-02-07 04:07:47
问题 I'm trying to build a metro app for windows 8. In this app i'm trying to parse data from a website. For that i'm using HtmlAgilityPack 1.4.6. BUT i'm getting really confused about 'Dose HAP 1.4.6 works with windows 8?' and 'Dose it support Xpath?' Too much confusing info on Codeplex. As for now it seems that it works on windows 8 BUT i can't see HtmlNode.SelectNode method. If Xpath is not working, is there any other option to do the parsing? Can you direct me to a tutorial or examples? please