Server 2008 is x64 only, Win7 was released in both varieties.
Echilon
Posts
-
Windows 7 x86 -
Icon resources from nameI'm trying to access image resources in my application, but I can't the resources from the application, I just end up with null. I've added the resources in the properties section in visual studio 2008, and the code I'm using is
private ResourceManager res = new ResourceManager("MyNameSpace.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
Image myImage = (Image)res.GetObject("myImage.png");But myImage is always null. I know I could use MyNameSpace.Properties.Resources.myImage.png, but I need to get the resource from a string.
-
Docking/Anchoring controlsLooks like mountains of code it is then. :-D I always try to avoid excessive code, especially in OnPaint methods, but there are times when it's unavoidable.
-
Docking/Anchoring controlsThanks for the quick response. I didn't explain myself very well. The number of child controls isn't a fixed value. In the example there are two items with the same Y value, but there may be just one, or four or five.
-
Docking/Anchoring controlsI have a user control (which for the purposes of this post is just a container), and several nested user controls. I want to lay out the child controls inside the container in a similar way to the following picture: http://mi6.nu/docking.jpg I've tried different combinations of Anchor and Dock properties as well as using a Flow Layout Panel, but I can't get it to work. The two things I know are: 1) The location of each child control on the Y-axis 2) The height of the control I need some way to assign these controls a combination of properties and have them stack up as shown in the picture. Full width child controls should float to the left, and if there's more than one child control at a Y location (eg: 3 and 4), the available space should be split. I managed to get it sort of working, but items were overlapping.
-
Subclassing SocketI'm trying to use sockets to create a proxy connection to a server. The whole thing worked perfectly until I tried to add a custom class to deal with the proxy (authentication etc). I have two sockets, ListeningSocket and DataSocket. The problem is that I can't see to get listeningsocket to accept datasocket as a ProxySocket, only as a standard socket. ProxySocket extends Socket, but I can't get it to work. Here's the code: In the head of the class
private ProxySocket dataSocket = null; private Socket listeningSocket = null; // used to accept active connections
The in the method to accept the connection.listeningSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listeningSocket.Bind(localEnd); listeningSocket.Listen(1); Socket dataSockTemp = listeningSocket.Accept(); // at this point, dataSockTemp is a connected Socket (shown via a breakboint) dataSocket = dataSockTemp as ProxySocket; listeningSocket.Close();
I'd really appreciate any help. -
ListView Single Range SelectionI have a ListView, and I'd like to only allow a single range to be selected. I need the equivalent of Java's SINGLE_SELECTION_INTERVAL ( http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListSelectionModel.html#SINGLE\_INTERVAL\_SELECTION ). For example: If a ListView has 5 rows, #1,#2 could be selected, or #3,#4,#5, or just #3, but not #1,#3,#4. Is there any way of adding this functionality in C# without getting heavily into rewriting the control?
-
Truncating ListView CellOk, Thanks.
-
Truncating ListView CellI have a ListView set to details mode, which contains file paths. Is it possible to truncate the cells from the left hand side instead of the right? For example: If a cell contains a string (C:\Windows\Some directory\file.txt), then if the column is too small, the cell just reads C:\Windows\So... I need it to truncate from the other side, so it reads ...ctory\file.txt. Is this possible?
-
Overlapping components with form designerI'm trying to create an application in C# using the forms designer in Visual Studio 2008. Coming from Java, it's a welcome relief not to have to hand code the whole layout, but there's something that doesn't seem to be working. The 'Dock' setting for components. I have a split pane, inside each pane of which are two more split panes. Whenever I set the main split pain to dock horizontally and vertically (the middle button in the designer), it underlaps the toolbar, and the same happens in the sub-panes - they overlap the drop down box I've set to dock at the top. Is it best to have just one docking component per panel or is there a way around this? The window looks fine at the default size, but once it's resized nothing changes size to fit. The code from the designer is at http://mi6.nu/FrmMain.Designer.resx if anyone could take a look and see if I'm doing something wrong. It's probably something simple, but maybe someone else has had a similar problem. Thanks.
-
Threads and BeginReceiveI'm coding an FTP client in C#, and I'm trying to use System.Net.Socket's BeginReceive method to stop the UI from freezing when receiving data. At present, it works as it should, but whenever there's a transfer in progress (upload/download or directory listing), the UI freezes until it's complete. I want to use BeginReceive to recive data in a different thread. This is what I have to far: Two classes - FTP and FrmMain. In FTP I have a delegate:
public delegate void DirListDelegate(object sender, ArrayList items); public event DirListDelegate OnDirListComplete;
The I have three methods:private void OnDataReceived(IAsyncResult asyn) { int bytes = dataSocket.EndReceive(asyn); bldBuffer.Append(Encoding.ASCII.GetString(buffer, 0, bytes)); if(bytes < buffer.Length) { dataSocket.Close(); // Trimmed code to process data into "itemsList" OnDirListComplete(this, itemsList); } else { WaitForData(); } } private void WaitForData() { dataSocket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(OnDataReceived), null); } public void ListDir() { dataSocket = openSocket(); //trimmed code to make server initiate transfer ("LIST -al") bldBuffer.Remove(0, bldBuffer.Length); WaitForData(); }
Then I call FTP.ListDir() from FrmMain. What should happen is the main program should be free to respond to user clicks etc and not freeze, but it's as though I'm just using Receive instead of BeginReceive. I'm really stuck on this and I'd appreciate any help. :) -
Sockets and ThreadsI'm working on an FTP client, and using sockets to receive data from a server. When the server sends any data back to the application, I have to wait before the application repsonds. I'd like to starts the transfer for the data in a new thread if possible, leaving the rest of the app free to respond to the user and not just show an hourglass. Is this possible? I'm unsure how to get the data back from the thread.
Socket socket = openSocket(); SendCommand("MLSD"); if(statusCode != 125 && statusCode != 150) { LogText = "Error opening connection\n"; return; } DateTime timeOutDate = DateTime.Now.AddSeconds(timeOut); bldBuffer.Remove(0, bldBuffer.Length); while(DateTime.Now < timeOutDate) { int bytes = socket.Receive(buffer, buffer.Length, 0); bldBuffer.Append(Encoding.ASCII.GetString(buffer, 0, bytes)); if(bytes < buffer.Length) { // there weren't enough bytes to fill the buffer, so the stream is finished break; } } socket.Close();
OpenSocket() creates a new socket to the server, and SendCommand() send the specified command over the control connection. The application works, it's just that I have to wait for it to respond. Thanks for any input.