Tag: windows 8

使用C#在WinRT中获取可用磁盘空间

[DllImport(“kernel32.dll”, SetLastError = true)] static extern bool GetDiskFreeSpaceEx( string lpDirectoryName, out ulong lpFreeBytesAvaliable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes); // Returns free disk space from directory. public static ulong GetFreeDiskSpace(string directory) { ulong a, b, c; if (GetDiskFreeSpaceEx(directory, out a, out b, out c)) { Debug.WriteLine(a); } return a; } 我正在开发一个Windowsapp store应用。 我打电话时为什么变量包含0: GetFreeDiskSpace(“C:\\”); ? […]

将C#reflection代码移植到Metro-Ui

我正在尝试移植使用reflection的现有C#类(通用工厂),但我无法编译这段代码: Type[] types = Assembly.GetAssembly(typeof(TProduct)).GetTypes(); foreach (Type type in types) { if (!typeof(TProduct).IsAssignableFrom(type) || type == typeof(TProduct)) … 我试着查看.NET Framework for Windows Metro Style Apps和Assembly Class中的Reflection ,在那里我找到了一个因为“使用System.Security.Permissions”而无法编译的示例。

在后台异步进程运行时,开发人员可以“强制”系统以防止“Metro”应用程序被暂停吗?

当一个应用程序当前在Win8中不是“正面和中心”时,它将被暂停。 这是否会阻止应用程序在后台显式保持活动状态,例如在电子邮件客户端中,使用异步操作轮询邮件服务器以获取新邮件,然后下载它们(然后使用新邮件计数更新Tile)? 如果这是不可能的(暂停的应用程序无法执行后台处理,或者无法强制系统允许它保持活动状态,尽管不可见),那么解决方法是什么 – 单独的Windows服务?

获取Clicked ListView项属性

我有一个带有ListView的Windows 8应用程序: 有一些Event对象(一个单独的类,其字符串属性,如EventType,Description,Time等),它是ListView的源代码: List eventlist = new List{ new Event(CONNECTION, “Disconnected”, DateTime.Now.ToString(), MONITOR, “SAMSUNG M5”, CONNECTION_IMG, RED), new Event(SYNC, “Synchronised”, DateTime.Now.ToString(), LAPTOP, “ASUS X402”, SYNC_IMG, BLUE), new Event(WARNING, “Overheated!”, DateTime.Now.ToString(), PRINTER, “CANON MP280”, WARING_IMG, YELLOW), }; EventListView.ItemsSource = eventlist; 我试图访问被点击的项目的信息,但它似乎没有设置: private void EventListView_ItemClick_1(object sender, ItemClickEventArgs e) { Event item = sender as Event; GetInfoText.Text = […]

如何实现Windows 7/8的AutoPlay

快速信息:我使用的是Visual Studio 2008,Windows 8(64位)。 我正在尝试创建一个自动播放处理程序,当WPD设备插入计算机时自动呈现。 如果选择了我的自动播放选项,我想要它只是启动我的应用程序。 由于最近没有任何实现Windows自动播放的例子,我希望有人可以帮我解决一些问题并回答几个问题: 1)。 我创建了一个带有COM对象的ATL项目,该对象实现了IHWEventHandler接口。 最初,我试图让COM对象做的就是在我的C盘中创建一个.txt文件,表明它已成功调用。 我试过让我的AutoPlay事件指向这个COM对象,但是当我选择我的AutoPlay条目时没有任何反应。 这是我的COM类的.h代码: class ATL_NO_VTABLE CSimpleAutoPlayCom : public CComObjectRootEx, public CComCoClass, public IHWEventHandler //public ISimpleAutoPlayCom { public: CSimpleAutoPlayCom() { ofstream myfile; myfile.open (“C:\\AutoPlayExerciseWorked.txt”); myfile << "Called from Constructor.\n"; myfile.close(); } DECLARE_REGISTRY_RESOURCEID(IDR_SIMPLEAUTOPLAYCOM) DECLARE_NOT_AGGREGATABLE(CSimpleAutoPlayCom) BEGIN_COM_MAP(CSimpleAutoPlayCom) //COM_INTERFACE_ENTRY(ISimpleAutoPlayCom) COM_INTERFACE_ENTRY(IHWEventHandler) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { […]

修饰符异步对此项无效

这似乎不是具有相同错误的数百个其他问题的重复。 我看了他们所有人,发现他们是无关的。 我正在制作一个小笔记应用程序,我正在尝试从目录中读取文件。 在MSDN示例之后,我有以下代码,但它给出了一个错误: 错误1修饰符’async’对此项无效C:\ Users \ Jase \ documents \ visual studio 2012 \ Projects \ AppNameHere \ AppNameHere \ DataModel \ AppNameHereDataSource.cs 192 9 AppNameHere 我的代码是: async public NotesDataSource() { StorageFolder documentsFolder = KnownFolders.DocumentsLibrary; StringBuilder outputText = new StringBuilder(); IReadOnlyList fileList = await documentsFolder.GetFilesAsync(); outputText.AppendLine(“Files:”); foreach (StorageFile file in fileList) { if (file.FileType […]

流stream = WriteableBitmap.PixelBuffer.AsStream()缺失

我正在写windows store app(8.1),我有样本(可能是win 8.0): private WriteableBitmap WriteableBitmap; … WriteableBitmap = new WriteableBitmap(500,500); … using (Stream stream = WriteableBitmap.PixelBuffer.AsStream()) { … } 所以我创建了新的win 8.1项目并尝试以同样的方式完成,但是当我到达时: using (Stream stream = WriteableBitmap.PixelBuffer.AsStream()) 我的项目不认识*.AsStream()方法,谁能告诉我为什么?

windows 8 App从App.xaml.cs访问页面方法

可能是一个愚蠢的问题所以我提前道歉。 我是构建Windows 8商店应用程序的新手。 当应用程序被挂起时,我需要在我的页面脚本上运行一些方法。 我只有一个页面,我在Page1.xaml.cs文件中有一些公共方法。 我想从App.xaml.cs文件中的OnSuspending()方法调用它们。 我需要确保保存一些文本文件。 如何创建对Page1脚本的引用?

没有为.winmd文件提供实施文件

我在VS2012中构建Windows 8 App项目时收到警告: No implementation file was provided for the .winmd file ‘C:\Users\luke\LApp\LApp\bin\x86\Debug\Bing.Maps.winmd’. To generate registration information in the app manifest, specify the ‘Implementation’ metadata on the .winmd reference item in the project file. 我真的不知道提供什么其他信息。 我用谷歌搜索,它没有提供任何相关的结果。 它给出了一个链接: http : //msdn.microsoft.com/en-us/library/hh708954.aspx但我不确定它是正确的。 我很确定我有正确的参考资料: 这是一个C#项目。 我使用NuGet添加Bing Maps SDK,它可以在我的应用程序中运行 – 我可以拖动地图界面并在应用程序中使用它。 这只是建筑时出现的警告,我不知道如何摆脱它。 任何帮助表示感谢,谢谢。

在Windows 8 Metro风格的应用程序中使用.NET GeoCoordinate.GetDistanceTo等效

Metro风格Windows 8应用程序中System.Device.Location.GeoCoordinate.GetDistanceTo方法的等效项是什么。 Metro应用程序具有Geocoordinate类(使用小写“C”)但没有GetDistanceTo方法。 其次,Metro Geocoordinate类没有构造函数。 我该如何创建它的实例。