-
Posts
196 -
Joined
-
Last visited
Personal Information
-
Visual Studio .NET Version
VB2010Express
-
.NET Preferred Language
VB.NET
JumpyNET's Achievements
Newbie (1/14)
0
Reputation
-
A simplified version of the MSDN StreamSocket sample (tested and working). TCP Client (Windows Phone 8 App) Imports Windows.Networking Imports Windows.Networking.Sockets Imports Windows.Storage.Streams Partial Public Class MainPage : Inherits PhoneApplicationPage Dim Socket As StreamSocket Private Async Sub ButtonConnect_Click(sender As Object, e As RoutedEventArgs) Handles ButtonConnect.Click Socket = New StreamSocket Await Socket.ConnectAsync(New HostName("192.168.1.7"), "1234") StartListening() End Sub Private Async Sub StartListening() Dim reader As New DataReader(Socket.InputStream) Do ' Read first 4 bytes (length of the subsequent string). Dim sizeFieldCount As UInteger = Await reader.LoadAsync(CUInt(Runtime.InteropServices.Marshal.SizeOf(New UInteger))) If sizeFieldCount <> Runtime.InteropServices.Marshal.SizeOf(New UInteger) Then ' The underlying socket was closed before we were able to read the whole data. Return End If ' Read the string. Dim stringLength As UInteger = reader.ReadUInt32() Dim actualStringLength As UInteger = Await reader.LoadAsync(stringLength) If stringLength <> actualStringLength Then ' The underlying socket was closed before we were able to read the whole data. Return End If ' Display the string. Dim MsgReceived As String = reader.ReadString(actualStringLength) System.Diagnostics.Debug.WriteLine(MsgReceived) Loop End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text To Send" Dim writer As New DataWriter(Socket.OutputStream) writer.WriteUInt32(writer.MeasureString(stringToSend)) writer.WriteString(stringToSend) Await writer.StoreAsync() writer.DetachStream() writer.Dispose() End Sub End Class TCP Server (Windows 8 Store App) Imports Windows.Networking Imports Windows.Networking.Sockets Imports Windows.Storage.Streams Public NotInheritable Class MainPage : Inherits Page Dim WithEvents ListenerSocket As StreamSocketListener Private Async Sub ButtonListen_Click(sender As Object, e As RoutedEventArgs) Handles ButtonListen.Click ListenerSocket = New StreamSocketListener ' Don't limit traffic to an address or an adapter. Await ListenerSocket.BindServiceNameAsync("1234") End Sub Dim Socket As StreamSocket Private Async Sub listener_ConnectionReceived(sender As StreamSocketListener, args As StreamSocketListenerConnectionReceivedEventArgs) Handles ListenerSocket.ConnectionReceived ' Invoked once a connection is established. Debug.WriteLine("Connection Established") Socket = args.Socket Dim reader As New DataReader(args.Socket.InputStream) Do ' Read first 4 bytes (length of the subsequent string). Dim sizeFieldCount As UInteger = Await reader.LoadAsync(CUInt(Runtime.InteropServices.Marshal.SizeOf(New UInteger))) If sizeFieldCount <> Runtime.InteropServices.Marshal.SizeOf(New UInteger) Then Return ' The underlying socket was closed before we were able to read the whole data. End If ' Read the string. Dim stringLength As UInteger = reader.ReadUInt32() Dim actualStringLength As UInteger = Await reader.LoadAsync(stringLength) If stringLength <> actualStringLength Then Return ' The underlying socket was closed before we were able to read the whole data. End If ' Display the string. Dim MsgReceived As String = reader.ReadString(actualStringLength) Debug.WriteLine(MsgReceived) Loop End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text Back" Dim writer As New DataWriter(Socket.OutputStream) writer.WriteUInt32(writer.MeasureString(stringToSend)) writer.WriteString(stringToSend) Await writer.StoreAsync() writer.DetachStream() writer.Dispose() End Sub End Class PS: Requesting to be moved to code library, please.
-
I am a hobbyist programmer. I have been using Visual Basic 2008 Express for all these years. I never got used to any of the more modern versions of Visual Studio. Windows Phone was an exception, though one short lived. I have been educating my self to move to the GNU/Linux world, but it has proven difficult to find a programming language and an integrated development environment as good as Visual Basic 2008 Express. I am open to suggestions if any of you might have any?
-
The text "oletus" is show when the app is run on the phone or the emulator. What should I change so that the text is shown on design time as well? Please see the attached screenshot for xaml and code behind.
-
A simplified version of the MSDN StreamSocket sample (tested and working). TCP Client (Windows Phone 8 App) Imports Windows.Networking Imports Windows.Networking.Sockets Imports Windows.Storage.Streams Partial Public Class MainPage : Inherits PhoneApplicationPage Dim Socket As StreamSocket Private Async Sub ButtonConnect_Click(sender As Object, e As RoutedEventArgs) Handles ButtonConnect.Click Socket = New StreamSocket Await Socket.ConnectAsync(New HostName("192.168.1.7"), "1234") StartListening() End Sub Private Async Sub StartListening() Dim reader As New DataReader(Socket.InputStream) Do ' Read first 4 bytes (length of the subsequent string). Dim sizeFieldCount As UInteger = Await reader.LoadAsync(CUInt(Runtime.InteropServices.Marshal.SizeOf(New UInteger))) If sizeFieldCount <> Runtime.InteropServices.Marshal.SizeOf(New UInteger) Then ' The underlying socket was closed before we were able to read the whole data. Return End If ' Read the string. Dim stringLength As UInteger = reader.ReadUInt32() Dim actualStringLength As UInteger = Await reader.LoadAsync(stringLength) If stringLength <> actualStringLength Then ' The underlying socket was closed before we were able to read the whole data. Return End If ' Display the string. Dim MsgReceived As String = reader.ReadString(actualStringLength) System.Diagnostics.Debug.WriteLine(MsgReceived) Loop End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text To Send" Dim writer As New DataWriter(Socket.OutputStream) writer.WriteUInt32(writer.MeasureString(stringToSend)) writer.WriteString(stringToSend) Await writer.StoreAsync() writer.DetachStream() writer.Dispose() End Sub End Class TCP Server (Windows 8 Store App) Imports Windows.Networking Imports Windows.Networking.Sockets Imports Windows.Storage.Streams Public NotInheritable Class MainPage : Inherits Page Dim WithEvents ListenerSocket As StreamSocketListener Private Async Sub ButtonListen_Click(sender As Object, e As RoutedEventArgs) Handles ButtonListen.Click ListenerSocket = New StreamSocketListener ' Don't limit traffic to an address or an adapter. Await ListenerSocket.BindServiceNameAsync("1234") End Sub Dim Socket As StreamSocket Private Async Sub listener_ConnectionReceived(sender As StreamSocketListener, args As StreamSocketListenerConnectionReceivedEventArgs) Handles ListenerSocket.ConnectionReceived ' Invoked once a connection is established. Debug.WriteLine("Connection Established") Socket = args.Socket Dim reader As New DataReader(args.Socket.InputStream) Do ' Read first 4 bytes (length of the subsequent string). Dim sizeFieldCount As UInteger = Await reader.LoadAsync(CUInt(Runtime.InteropServices.Marshal.SizeOf(New UInteger))) If sizeFieldCount <> Runtime.InteropServices.Marshal.SizeOf(New UInteger) Then Return ' The underlying socket was closed before we were able to read the whole data. End If ' Read the string. Dim stringLength As UInteger = reader.ReadUInt32() Dim actualStringLength As UInteger = Await reader.LoadAsync(stringLength) If stringLength <> actualStringLength Then Return ' The underlying socket was closed before we were able to read the whole data. End If ' Display the string. Dim MsgReceived As String = reader.ReadString(actualStringLength) Debug.WriteLine(MsgReceived) Loop End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text Back" Dim writer As New DataWriter(Socket.OutputStream) writer.WriteUInt32(writer.MeasureString(stringToSend)) writer.WriteString(stringToSend) Await writer.StoreAsync() writer.DetachStream() writer.Dispose() End Sub End Class PS: Requesting to be moved to code library, please.
-
I have put up a simple DatagramSocket test example with separate solutions/projects for client and server. Sending strings from client to server is working but sending a string from server to client results in the following error: "A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)" What could be the problem ??? Source code for the UDP Client (Windows Phone 8 App) Partial Public Class MainPage : Inherits PhoneApplicationPage Dim WithEvents Soketti As DatagramSocket Private Async Sub ButtonConnect_Click(sender As Object, e As RoutedEventArgs) Handles ButtonConnect.Click Soketti = New DatagramSocket Await Soketti.ConnectAsync(New HostName("192.168.1.7"), "4321") End Sub Private Sub Soketti_MessageReceived(sender As DatagramSocket, args As DatagramSocketMessageReceivedEventArgs) Handles Soketti.MessageReceived Dim reader As DataReader = args.GetDataReader Dim actualStringLength As UInteger = reader.UnconsumedBufferLength Dim MsgReceived As String = reader.ReadString(actualStringLength) System.Diagnostics.Debug.WriteLine(MsgReceived) End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text To Send" Dim writer As New DataWriter(Soketti.OutputStream) writer.WriteString(stringToSend) Await writer.StoreAsync() writer.DetachStream() writer.Dispose() End Sub End Class Source code for the UDP Server (Windows 8.0 Store App) Public NotInheritable Class MainPage : Inherits Page Dim WithEvents not_just_a_listener As DatagramSocket Private Async Sub ButtonListen_Click(sender As Object, e As RoutedEventArgs) Handles ButtonListen.Click not_just_a_listener = New DatagramSocket Await not_just_a_listener.BindServiceNameAsync("4321") End Sub Private Sub listener_MessageReceived(sender As DatagramSocket, args As DatagramSocketMessageReceivedEventArgs) Handles not_just_a_listener.MessageReceived Dim reader As DataReader = args.GetDataReader Dim actualStringLength As UInteger = reader.UnconsumedBufferLength Dim MsgReceived As String = reader.ReadString(actualStringLength) Debug.WriteLine(MsgReceived) End Sub Private Async Sub ButtonSend_Click(sender As Object, e As RoutedEventArgs) Handles ButtonSend.Click Dim stringToSend As String = "Some Text Back" Dim writer As New DataWriter(not_just_a_listener.OutputStream) writer.WriteString(stringToSend) Await writer.StoreAsync() ' ** This will crash *** writer.DetachStream() writer.Dispose() End Sub End Class
-
What would be the best way to do the following in XAML? <StackPanel Grid.Row=IIF(Orientation="Portrait","2","1") Grid.Column=IIF(Orientation="Portrait","0","2") > ------------------------------------------------------------------------ At first I was thinking of using a ValueConverter but they do not seem to support multiple parameters. I guess passing both of the parameters in a single string such as "2|1" (which I would them split in my ValueConverter) would be bad practice, I was wondering could it be possible to do something like the following? <StackPanel Grid.Row="{Binding Orientation, ConverterParameter=[[new CustomClass(2,0)]], Converter={StaticResource OrientationToIntegerConverter}, ElementName=phoneApplicationPage}" Grid.Column="{Binding Orientation, ConverterParameter=[[new CustomClass(1,2)]], Converter={StaticResource OrientationToIntegerConverter}, ElementName=phoneApplicationPage}" >
-
Setting Up Local Home Network for Remote Debugging a Surface Tablet
JumpyNET replied to JumpyNET's topic in Water Cooler
Issue Solved After configuring all the computers in windows control panel pinging them started working also. No modifications to F-secure or the router was done or required. -
I am trying to convert the C# LongListSelectorSample from http://phone.codeplex.com/ to VisualBasic. Here is the original C# code (with the problematic linq-query included): private void LoadLinqMovies() { List<Movie> movies = new List<Movie>(); for (int i = 0; i < 50; ++i) { movies.Add(Movie.CreateRandom()); } var moviesByCategory = from movie in movies group movie by movie.Category into c orderby c.Key select new PublicGrouping<string, Movie>(c); linqMovies.ItemsSource = moviesByCategory; } And here is my VB attempt to populate the LongListSelector with grouped movie items: Private Sub LoadLinqMovies() Dim MovieList As New List(Of Movie) For i As Integer = 0 To 49 MovieList.Add(Movie.CreateRandom()) Next Dim MoviesByCategory = _ From OneMovie In MovieList _ Group OneMovie By Cat = OneMovie.Category _ Into GroupedMovies = Group _ Select New PublicGrouping(Of String, Movie)(GroupedMovies) Movies_LLS.ItemsSource = MoviesByCategory End Sub Apparently something goes wrong with the linq query but what?
-
RichTextBox does support TextAlignment="Justify".
-
I cannot seem to find any way to change priority of threads on the Windows Phone 8 platform. The default priority seems to be too high as my app takes now 2,5 seconds to startup, but if I make my background thread sleep alot the startup time will be only 0,8 seconds. Any advice?
-
How can I replace text inside angle brackets? My best try so far: Dim Input As String = "Aaaa [abc] Bbbb [7] Ccc" Dim Output As String = Regex.Replace(Input, "\[.+\]\s", "") ' Output is "Aaaa Ccc" but should be "Aaaa Bbbb Ccc"
-
Is there any way to get Justified TextAlignment on Windows Phone? At least TextBlock does not seem to support that. Is it possible to somehow use Silverlight components or do you know if some one has made a custom TextBlock?
-
Your thorough response is much appreciated. Thank you.
-
Googling for instructions spesific to Windows Phone seems impossible. Can someone please help me how to replace the following VB-code with WP alternatives? Dim Beginning As String = Left("Some Text", 2) Dim Answer As Boolean = "Some Text" Like "S*"