Tag: windows phone 7

如何在WP7芒果上播放UDP数据包?

我想从手机发送UDP数据包到有限的广播地址(IPAddress.Broadcast = 255.255.255.255)。 这是我到目前为止,它适用于Windows应用程序: Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); byte[] data = Encoding.UTF8.GetBytes(“test data”); SocketAsyncEventArgs a = new SocketAsyncEventArgs(); a.RemoteEndPoint = new IPEndPoint(IPAddress.Broadcast, 11000); a.SetBuffer(data, 0, data.Length); a.Completed += new EventHandler(delegate(object s, SocketAsyncEventArgs e) { Console.WriteLine(e.SocketError); }); socket.SendToAsync(a); 需要SetSocketOption调用以防止“拒绝访问”exception。 不幸的是,WP7似乎没有这种方法。 App Hub社区站点上提供的UDP示例代码使用多播来实现类似的结果,但我尝试联系的设备无法处理多播。 有没有办法在芒果上做这种广播?

WP7(windows phone 7)HttpWebRequest丢失POST数据

我发送了大量的POST数据(超过5000个字符),似乎WP7 HttpWebRequest正在丢失这个过程中的一些内容…… 数据是png转换为字节数组,然后转换为base64字符串。 如果我的数据是4941个字符长,它将只发送1448个字符,请求的内容长度(通过wiresharkvalidation)很好(Content-Length:4991)。 我如何发送数据: void SendPost() { // Create the web request object HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.Method = “POST”; webRequest.ContentType = “application/x-www-form-urlencoded”; // Start the request webRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), webRequest); } void GetRequestStreamCallback(IAsyncResult asynchronousResult) { HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState; // End the stream request operation Stream postStream = webRequest.EndGetRequestStream(asynchronousResult); // Create the post data […]

如何在Windows Phone 7中检查3G,wifi,EDGE,蜂窝网络?

如何使用C#检查Windows Phone 7中的3G,wifi,EDGE,蜂窝网络?

Deployment.Current.Dispatcher.BeginInvoke(()=> {…})有什么用?

我在一些代码中看到过这种Deployment.Current.Dispatcher.BeginInvoke(()=> {…})格式。它曾经在后台做过一些工作吗?它的一般用途是什么?

Listpicker错误SelectedItem必须始终设置为有效值

我在Windows Phone 7应用程序中有一个页面,用户可以在其中编辑或删除Transaction对象。 Transaction对象是一个Linq-to-Sql类,它与Account类和Category类有关系。 在页面中,我使用ListPicker让用户选择给定事务的帐户和类别,如下所示: ListPicker_Tap事件是针对Windows Phone的WPF Toolkit的Aug / 2011版本中的错误的修复,简单地说: private void ListPicker_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ListPicker lp = (ListPicker)sender; lp.Open(); } 如果用户编辑事务,一切都很好,但如果用户尝试删除它,我会收到一条错误消息,说“SelectedItem必须始终设置为有效值”。 如果用户单击TransactionPage.xaml.cs中appbar中的delete按钮,则代码如下: private void appBarDelete_Click(object sender, EventArgs e) { MessageBoxResult result = MessageBox.Show(“Are you sure?\n”, “Confirm”, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { App.ViewModel.DeleteTransaction(transaction); } NavigationService.GoBack(); } 我的ViewModel.DeleteTransaction方法: public void DeleteTransaction(Transaction transaction) { […]

ContextMenu点击而不是点击并按住

我需要打开一个菜单,因为WP7 not designed执行这些操作not designed ,所以我正在使用Toolkit。 以下是示例代码: 现在只要用户按下并保持动作,这就可以正常工作。 但我不能要求用户采取这样的行动。 我需要在单击/点击/触摸/手势(您要调用它的水)上显示菜单。 有人可以建议吗? 如果您认为工具包不是最佳方式,那么请使用示例代码建议替代方案。 我试过弹出窗口,但这比我的应用程序更糟糕

到达最后一项时WP7 Auto Grow ListBox

我正在尝试实现一种效果,当用户向下滚动到最后一项时,会有更多项目附加到列表中。 我还没有找到一种方法来确定用户是否已滚动到列表的末尾。 我没有在ListBox上看到当用户到达列表底部时触发的事件。 告诉我什么时候一个项目滚动到视图中的东西会很棒,但据我所知,没有类似的东西。 这在WP7中甚至可能吗? 编辑:另一种说法是,我们可以检测到列表何时“退回”?

以块的forms下载文件(Windows Phone)

在我的应用程序中,我可以从网上下载一些媒体文件。 通常我使用WebClient.OpenReadCompleted方法下载,解密并将文件保存到IsolatedStorage。 它运作良好,看起来像这样: private void downloadedSong_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e, SomeOtherValues someOtherValues) // delegate, uses additional values { // Some preparations try { if (e.Result != null) { using (isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()) { // working with the gained stream, decryption // saving the decrypted file to isolatedStorage isolatedStorageFileStream = new IsolatedStorageFileStream(“SomeFileNameHere”, FileMode.OpenOrCreate, isolatedStorageFile); // and use […]

我应该如何在Windows Phone 7上使用RestSharp实现ExecuteAsync?

我正在尝试使用RestSharp GitHub wiki上的文档来实现对我的REST API服务的调用,但特别是我遇到了ExecuteAsync方法的问题。 目前我的代码对于API类来说是这样的: public class HarooApi { const string BaseUrl = “https://domain.here”; readonly string _accountSid; readonly string _secretKey; public HarooApi(string accountSid, string secretKey) { _accountSid = accountSid; _secretKey = secretKey; } public T Execute(RestRequest request) where T : new() { var client = new RestClient(); client.BaseUrl = BaseUrl; client.Authenticator = new HttpBasicAuthenticator(_accountSid, _secretKey); […]

处理“动态”音频(C#,WP7)

有没有办法,在C#中,在.NET上,“在运行中”处理音频? 例如,如果我想在录制时评估音频AT的平均强度(为此,我将需要最后几毫秒)。