|
Snowjim wrote:
If i have got this 2# right
Then i first need a collection(ArrayList)
int this Collection i will store smal byte arrays like byte[128] or somthing like that.
Then when i have i howl byte buffert(byte[128]) full then i will have to create a new byte array that i write to and place this on the second place in the Collection.
Yes this was my intention. Although, I was thinking of a default size of the byte arrays to be maybe 1024 or 2048 bytes. The performance could be optimized by changing the array sizes to best fit the expected use. My idea is that you want only a few byte arrays at any one time. I think it is much faster to access a byte in a byte array than a member of an arraylist, but I haven't checked. The only performance problem comes when you need to add a new byte array to the arraylist, but if it causes too much performance problem, it could be optomozed with a pre-existing pool of byte arrays which you add or remove from the arraylist.
If using an arraylist provides good enough performance, then use it! Some time later, the performance might not be good enough for a project that needs more speed, so then you optimize your class with a new internal implementation.
Snowjim wrote:
Its important that you can work against this stream as any regular stream. It is posible that it will be connected to controls that reads from streams. Will this be posible if I maintain the override funktion of Stream? like WriteByte(), ReadByte(); and so on?
The stream object inherits from MarshalByRefObject and implements iDisposable, so I don't know what you mean by "connected to controls". Your class should work fine if you have implemented the major stream methods.
|
|
|
|
|
Hi,
In our project we want to be able to load a report from file,
try to rebuild the query (adapt if necessary)
create a dataset from that query
set the dataset as source of the report.
Now I can create the query (more or less ), but when I set the dataset to the datasource the report is still what it was in design.
I do something like this:
<br />
string query = "Select " + fields + " FROM " + tables + " " + whereclause + " " + groupby;<br />
txtbox_query.Text = query;<br />
DataBaseConnector.EXECUTE_STATUS dbstat = dbconnector.ExecuteSelect(query);<br />
if(dbstat == DataBaseConnector.EXECUTE_STATUS.EXECUTE_SUCCESFUL){<br />
txtbox_status.Text = "The query " + txtbox_query.Text + " executed correctly.";<br />
txtbox_status.ForeColor = System.Drawing.Color.Green;<br />
reportdoc.SetDataSource(dbconnector.GetDataSet());<br />
dg_select.DataSource = dbconnector.GetDataSet();<br />
}
else{<br />
txtbox_status.Text = "The query " + txtbox_query.Text + " failed. " + dbconnector.GetLastErrorMessage();<br />
txtbox_status.ForeColor = System.Drawing.Color.Red;<br />
}
crv_test.ReportSource = reportdoc;<br />
the dataset is correctly set in my datagrid, but not in my report.
the report is loaded from file and the query is generated from that reportobject.
I hope somebody can help me
tnx!
No hurries, no worries.
|
|
|
|
|
Hey Guys i'm currently working on a school assignment. So far i have created a combo box, text box and a datagrid. when the user selects which database to list using the combo box (say they choose movies) it then lists the movies database in the datagrid then when the user types a in the text box it will only show the movies or items starting with a or A. OKAY now the fun begins :P now i want it so when the user clicks on the item in the datagrid it fills the text box with that name?
can someone please help me or show me a link to a tutorial
|
|
|
|
|
i succeeded to create multithreaded server that can accept multiple clients connection while running alright and every client can send to the server messages but when i try to send from the server message for all clients connected now it through and exception and it doesn't send anything i want to handle the connection for all users to send them back messages for all of them something like hashtable to handle tcp clients who are now connected any one knows how to do it .
my code is
<br />
private Hashtable connections; <br />
public void runserver()<br />
{<br />
connections = new Hashtable();<br />
TcpListener server;<br />
try<br />
{<br />
server = new TcpListener(5151);<br />
server.Start();<br />
do<br />
{<br />
try<br />
{<br />
if(counter < 1 || counter == 1)<br />
{<br />
generalchat.Items.Add("Waiting for connection");<br />
}<br />
<br />
Socket connection = server.AcceptSocket();<br />
Thread Anotherthread = new Thread(new <br />
ThreadStart(HandleConnection));<br />
connections.Add(Anotherthread, connection);<br />
++counter;<br />
generalchat.Items.Add("Connection " + counter + " Recieved");<br />
Anotherthread.Start();<br />
}<br />
catch (Exception)<br />
{<br />
break;<br />
}<br />
} while (true);<br />
}<br />
catch (System.Exception caught)<br />
{<br />
MessageBox.Show(caught.Message);<br />
}<br />
}<br />
private Hashtable myclients;<br />
private TcpClient clients;<br />
private void HandleConnection()<br />
{<br />
Socket connection = connections[Thread.CurrentThread] as Socket;<br />
NetworkStream socketstream = new NetworkStream(connection);<br />
BinaryReader reader = new BinaryReader(socketstream);<br />
BinaryWriter writer = new BinaryWriter(socketstream);<br />
writer.Write("Server : " + "Welcome Client");<br />
myclients = new Hashtable();<br />
clients = new TcpClient();<br />
myclients.Add(connection,clients.GetStream());<br />
string message = "";<br />
do<br />
{<br />
message = reader.ReadString();<br />
if(message == "terminate")<br />
{<br />
generalchat.Items.Add("Client Terminated the connection");<br />
--counter;<br />
break;<br />
}<br />
if(message.IndexOf("@") != -1)<br />
{<br />
clientTable.Add(this.flush(message),splittedwords[1].ToString());<br />
generalchat.Items.Add(this.flush(message) + " : Already Connected");<br />
}else<br />
generalchat.Items.Add(message);<br />
<br />
} while (connection.Connected);<br />
}<br />
any one knows how please
Miss With The Best And Die Like The Rest
|
|
|
|
|
You'd have to iterate through the hashtable's keys and get the client sockets. You'd then have to get the NetworkStream and write to it.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm having quite a problem figuring this out. In the microsoft SDK i found some functions to make controls transparent:
<br />
SetStyle(ControlStyles.SupportsTransparentBackColor, true);<br />
this.BackColor = Color.Transparent;<br />
and they said something about it had to be placed in the constructor????? Kinda lost. Can i apply this to the standart listboxes in the .Net framework, or do i have to create my own control which inherits the functions of a listbox?
thanks in advance!
|
|
|
|
|
can't you just change the opacity?
|
|
|
|
|
ListBox doesn't support transparency on it's own. If you want a transparent ListBox, then your going to have to create your own, inheriting from the current ListBox control and adding the code you posted. Search the articles for "custom listbox" and you'll come up with some examples.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Okay.. I'll do that!
Thanks a lot for the help
Regards!
**EDIT**
Back again. Now i have created a inherited custom control with listbox attributes. But when i set the color to transparen they just turn white. The thing is that you have to be able to see the picture behind the listboxes. Hope some of you have a solution to this!
|
|
|
|
|
I'm a musician and beginner to programming. I want to make music programs. What can I do?
|
|
|
|
|
Really it's very strange and nice to give you an answer.First of all you have to go in www.google.com.Type your question (how to make programs related to music).You can definitely get some help from it.You may also go in www.MSDN.com . You can also get help from it.
P.J.Contractor
|
|
|
|
|
|
Hey!
I'm working on some code that reads a .csv file into a datagrid. I'm using OdbcDataAdapter. It works fine with file names with no spaces in it - how do I do it with file names that have spaces in it. I've already tried [FileName] in the Select query. Please help
my code:
<br />
string ConnectionString =<br />
@"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=";<br />
OdbcConnection conn = new OdbcConnection(ConnectionString);<br />
conn.Open(); <br />
<br />
OdbcDataAdapter da = new OdbcDataAdapter("Select * FROM " + FileName, conn); <br />
<br />
DataSet ds = new DataSet();<br />
da.Fill(ds,0,20,DataMember());<br />
<br />
conn.Close();<br />
chukkkzn
chukkykzn@webmail.co.za
|
|
|
|
|
Hi,
I have a win Application in which I use toolbar bottons.when I roll over the buttons my computer CPU usage shows up to 70 % percent CPU usage.
More info.
I use .NET Framework 1.1
Any help would be apprecited
|
|
|
|
|
Hi i want to sort the tree nodes,but only the nodes which i want.For example
-A
+AA
AAA
-N
-XX
-ZZ
-F
EE
HH
+B
+Z
Now i only want to sort the nodes present between Node A and Node B,measn i want to sort node N and F.can anyone helps me in this regard
|
|
|
|
|
You can work with the nodes collection of the tree control. Since nodes can contain child nodes you may need to apply this recursively.
What I typically do is put the nodes I want to sort into an ArrayList. This is pretty trivial since the ArrayList constructor can be passed the TreeNodeCollection directly. I then sort the nodes appropriately -- if you want to get fancy you can create one or more classes which implement the IComparer interface for tree nodes and then use the ArrayList.Sort(IComparer) routine.
Then clear the existing nodes and add the resorted nodes from the array list.
For example, if nodes is the TreeNodeCollection and alNodes is the array list...
nodes.Clear();
nodes.AddRange((TreeNode[])alNodes.ToArray(typeof(TreeNode)));
I've been thinking about writing an article which shows this in some more detail.
Regards,
Chris
|
|
|
|
|
Thx Chris,
But now u can consider one more problem with this,now if u add or delete nodes and expand or collapse diffrenet nodes,then after this if u sort the nodes and assign to the tree,then the previous STATE of the tree is not retained,means all the tree nodes collapse again.
Tree STATE can be retained in another array list for expand or collapse node(array list conatins node info which are collapsed and expanded) and while redrawing the tree we can maintain by checking the previous status of the nodes,but this all we have to do recursivly,this makes system slow.If the tree is really big then its a real problem itself.
Now can u help me again considering these situations.
My english is really bad . As its not my native language.
Regards,
Umair
|
|
|
|
|
It doesn't seem like it would be difficult to reapply the expanded or collapsed state of the nodes during the recursion -- I'm actually surprised its necessary since expanded/collapsed is a property of the individual nodes and all we are doing is reordering the references -- perhaps the state gets reset when the nodes get re-added to the tree control (I haven't tried it so can't answer with certainty).
Once you've sorted the tree once you may want to handle inserted nodes in a slightly different way -- that is, the code which creates the node would also determine where the node should be placed. Its more work but might be preferable to resorting the branch every time a node is added. Again without actually trying it I'm not sure if this is difficult or not.
When sorting a large tree I would try to make use of SuspendLayout() and ResumeLayout() so that screenupdating is a non-issue. I would guess that once you have done this your tree would need to get very large before sorting gets slow.
For really large trees, recursion could be an issue -- although when you think about it, its really only the depth of the tree that matters. If recursion is no longer viable to get to the maximum depth in your tree chances are that your users probably hate you (who wants to drill down through a hundred nodes to find something?). Same comment stands for the number of nodes in a tree -- you can sort thousands of items in no time so the tree would have to be huge before it got to be a problem. At that point you're probably into virtual trees which you populate as the user is expanding them.
One last comment. I've done treeview sorting the old fashioned way (in C++ with callback functions and TV_ITEM structures). It was pretty painful. Given the choice I'll take the .Net approach any day.
|
|
|
|
|
OKz,
I will try the way which u have told me.
Thx n regards
Umair
|
|
|
|
|
Here's the deal. I got an image of a building plan loaded in my Picturebox.
Now I have to mark the rooms on it... and to a room I need to assign certain parameters.
2 problems:
1. I need to use a kind of magnetic lasso tool or pen tool (photoshop) to mark the rooms
2. how do I draw "object/controls" on top of an image?
Thanx in advance
"Paranoia is reality on a tighter edge"
|
|
|
|
|
From GDI+ you can use Graphics.Draw//anything() .
but at this you must make that image the background image.
|
|
|
|
|
I'm currently experementing with Graphicpath... and seems to work out great.
|
|
|
|
|
Hi folks,
Do you guys know how to check if a folder is shared and what users have permission on it?
Thanks.
|
|
|
|
|
I have to use SQL queries and generate a dataset and then attach it to a crystal report. All this to be done through coding and not using any experts
i wrote the following ...but it showed a blank form . Please Help
string st="server=localhost;user id=sa;password=ims;database=ProActiveTrainingDB";
SqlConnection s=new SqlConnection(st);
SqlDataAdapter sd=new SqlDataAdapter("Select * from JobTitleMaster",s);
DataSet dset=new DataSet();
try
{
sd.Fill(dset, "JobTitleMaster");
bRpt.SetDataSource(dset);
crystalReportViewer1.ReportSource = bRpt;
crystalReportViewer1.RefreshReport();
}
catch(Exception ex)
{
MessageBox.Show("Report causing Problems");
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Sukanya
|
|
|
|
|
I wrote a control. It is a timer with 1 button (Start/Stop) and 3 readonly textboxes to show the start time, stop time, running time. It also has a public method Start() which is also used in the ClickEvent of the button to start the timer. While the timer is running, the textbox that shows the running time is updated every second.
Here's the weird part. When Timer.Start() is called in another thread, the textboxes that should show the details are not updated on a certain interval. The reason why I put the call to Timer.Start() in another thread is that it's called by a remote host via sockets. The remote host sends its hostname which corresponds to a certain field in a set of MyTimer controls.
The update is in the Tick event of a Timer control within my control. I tried putting messageBox routines and I did find out, they are not executed. The Tick event does not fire!!! The timer works fine when using the start button to start it. Is this due to the fact that the event occurs in the _main_ thread?
Please enlighten me about this weird behaviour.
|
|
|
|