Try it. As a practice, if you need to copypaste a code without a reason, you are doing it wrong. thats the reason im looking into this! i thought i had to issue 100/200 separate picture box events. but i can make them share just the one! thanks for bringing this to attention once again.
ikurtz
Posts
-
C# TableLayoutPanel MouseMove Too Much CPU -
C# TableLayoutPanel MouseMove Too Much CPUi get what you are saying now. had not thought of it like that. make all the picturebox share only one method upon event? right?
-
C# TableLayoutPanel MouseMove Too Much CPUi hear what you are saying but that means i have to do it 200 times! ie th number of pictureboxes im using. im trying to code it short by using table methods.
-
C# TableLayoutPanel MouseMove Too Much CPUgreetings. i have an issue with the following code. for some reason whenever it is executed it is consuming around 60% of the CPU. this is strange, and was wondering if you had any comments?
private void HomeTableLayoutPanel\_MouseMove(object sender, MouseEventArgs e) { PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location)); TableLayoutPanelCellPosition HomeCurrentPosition = new TableLayoutPanelCellPosition(-1, -1); if (HomeCurrentPicBox != null) { HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox); gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row.ToString()); } }
thank you for your time.
-
C# TableLayoutPanel MouseLeaveno thats not going to work. i have made some progress. the reason im experiencing this behaviour is because mousemove is being called after the call of mouseleave.
-
C# TableLayoutPanel MouseLeavegreetings, i am developing a battleships clone game and i have an issue with TableLayoutPanel MouseLeave event. first MouseMove:
private PictureBox HomeLastPicBox = new PictureBox();
private TableLayoutPanelCellPosition homeLastPosition = new TableLayoutPanelCellPosition(0, 0); private void HomeTableLayoutPanel\_MouseMove(object sender, MouseEventArgs e) { PictureBox NowPicControl = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location)); if ((NowPicControl != null) && (NowPicControl != HomeLastPicBox)) { HomeLastPicBox = (PictureBox)(HomeTableLayoutPanel.GetControlFromPosition(homeLastPosition.Column, homeLastPosition.Row)); if (GameModel.HomeCellStatus(homeLastPosition.Column, homeLastPosition.Row) == Cell.cellState.WATER) { HomeLastPicBox.Image = Properties.Resources.water; } TableLayoutPanelCellPosition homeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(NowPicControl); if (GameModel.HomeCellStatus(homeCurrentPosition.Column, homeCurrentPosition.Row) == Cell.cellState.WATER) { NowPicControl.Image = Properties.Resources.scan; } homeLastPosition = homeCurrentPosition; } }
this appears to function properly. now the MouseLeave event:
private void HomeTableLayoutPanel\_MouseLeave(object sender, EventArgs e) { MessageBox.Show("col " + homeLastPosition.Column.ToString() + " row " + homeLastPosition.Row.ToString()); if (GameModel.HomeCellStatus(homeLastPosition.Column, homeLastPosition.Row) == Cell.cellState.WATER) { HomeLastPicBox.Image = Properties.Resources.water; MessageBox.Show("hi"); } HomeLastPicBox = new PictureBox(); }
this is acting strange. it goes through the code and even a "HI" is displayed but the PictureBox image is not changed to water. any ideas as to why? this does not happen all the time, only from time to time. what the above code is doing is basically scanning through the table cells and if the cell content is WATER then it updates the table cell image to SCAN and as the user moves onwards it is switching the cell image back to WATER. hope this is enough information. please ask if more is needed. thank you in advance.
-
TCPIP server single connectionperfect! i understand it now. thanks.
-
TCPIP server single connectionhi im coding c# sockets in Asynchronous mode. my app is running but i need to limit the number clients to one. so if a connection already exists i want the server to refuse any new connection. but using async methods i cant stop it from listening. the server will have to be restarted everytime the unique connection is terminated, so i dont need it to serve next new connection. how could i refuse new connections when async does not support it? thank you very much.
-
C# Override CheckedListBoxyes i have. but default behaviour is toggle between states. what i dont want.
-
C# Override CheckedListBoxi need to override the base CheckedListBox behaviour. it is possible to check and uncheck a CheckedListBox without any code attached to it. i need to disable this behaviour so that i can implement custom code. any ideas? for example: if (ListenCheckedListBox.GetItemChecked(0)) { ListenCheckedListBox.SetItemChecked(0, false); } if (!ListenCheckedListBox.GetItemChecked(0)) { ListenCheckedListBox.SetItemChecked(0, true); } does not work because the controls default behaviour already does this anyway. hopefully you can understand my issue. thanks.
-
c# sockets [modified]i need some guidance regarding c# winsock programming, im a beginner in programming and network applications. i understand the client/server idea. server -> socket() bind() listen() accept() {send() recv()} close() client -> socket() connect() {send() recv()} close() -- i also know Socket.Connected Property to test if connected. -- where i am having difficulty is in both server and client how to implement send() and recv() [events]. i know how to send and receive but to do it while keeping the connection seems to very vague in google links. most examples on google just creat the connection and may send some data or receive some data and the connection is closed. the while(true) on server runs in a loop and accepts new connections. i need to know how to implement send and recv (events) so the connected clients and server can keep on exchanging data using the same connection. lots of the web examples have the server running in a loop and the client makes a new connection whenever data needs to be sent, it doesn't seem efficient to me. i have also seen server loop running on its own thread to avoid gui lockups but there also the actual communication seems vague. so. i would like info on how to handle send and recv in a structured manner. thanks for reading and a very happy new year to you. --------------------- my current approach is wrong, it concerns blocking.. i should be using .NET asynchronous socket programming. thanks.
modified on Saturday, January 2, 2010 1:36 PM
-
c# multiple forms communicationgreetings, i have 3 forms that need to communicate with each other. what is the best way of achieving this? at present im considering using delegates. your comments are welcome. my app is c# windows forms.
-
[Message Deleted][Message Deleted]
-
C# send structure objects through socketthats exactly what i thought (after some thought!). because the data is embedded it should not make a difference. well one comes across all kinds of statements made on the web. one has to be able to use ones judgement also. :)
-
C# send structure objects through socketi just read the following: The Binary Formatter The Binary formatter provides binary encoding for compact serialization either for storage or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data is meant to be passed through a firewall. -------------------- is Xml Serialization good for going through firewalls?
-
C# send structure objects through socketi have done a bit of reading in client/server programming in c#. i am familiar enough with this process to ask the following question: how do i transmit structure objects through tcp/ip instead of just strings? my app is a networked game with chat capabilities. so instead of just transmitting text, i would like to imploy a data structure or class structure that will have two fields: i. packet type ii. the data for the packet type and i would transmit this when needed during the execution of the application, and decode the data object at the receiving end and place it where it belongs. im not looking for code, just some ideas and search statements i can feed to google so i will; have a better understanding. ive read about serialisation/de serialisation, is that he way to go? thanks.
-
C# RichTextBox strange behaviourthank you!
-
C# RichTextBox strange behaviourthank you for your response. it has solved my problem. may i introduce you to my new situation? i would like a way to make the "Home:" part in bold. i have found very little info on this on my searches. the following are the only actual code that i could understand. rtb1.Rtf = @"{\rtf1\ansi {\b hello} {\i World}}" ; richTextBox1.Rtf = @"{\rtf1\ansi This is in \b bold\b0.}"; ----------- im not sure how to proceed with this info. i just want the richtextbox to display "Home:" and "Away:" in bold and be able to handle URLs in text. please advise what should i specify when searching this potic on google or any reference your could think of would be of great help.
-
C# RichTextBox strange behaviourgreetings, for the first time ever im investigating RichTextBox control in C# windows forms. i know i need this control in my app as textBox is to simple for my needs. i have the followig code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace _19_richtextbox { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void richTextBoxHome_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == (char)(Keys.Return)) { richTextBoxChat.AppendText("Home:" + richTextBoxHome.Text + "\n"); richTextBoxHome.Clear(); } } } }
for the moment i just want whatever is typed in one richtextbox to be displayed on the other richtextbox on hitting return. the issue is everytime i hit return the data is being transfered to the other control but the first control is left with a carriage return before the cursor. this happens everytime i hit return. how do i make it stop doing this? both the controls accept multiline input. please advise if i need to provide more info. thank you for your time. -
tableLayoutPanel gell cell by mouse hoveris there any way of getting the cell location on a mouse over the table given no controls are present in the actual cells? thanks you.