|
Well, just like the topic said.
I read some articles on this site but it's written in C++.
Thx.
|
|
|
|
|
Help
I have 2 user controls on a windows form (i am using C#) frmMyForm.
UserControl1.cs has 2 radiobuttons (rad1 & rad2)
UserControl2.cs has 2 labels (lbl1 & lbl2) which are hidden(visible = false)
I need to show lbl1 when rad1 is clicked and lbl2 when rad2 is clicked.
would appreciate if somebody would help me.
thanks
:
|
|
|
|
|
Call an EventHandler in UserControl1, if a radiobutton is clicked.
The delegate and event arguments:
public delegate void RadioClickEventHandler(object sender, RadioClickEventArgs e);
public class RadioClickEventArgs : EventArgs {
private int radioButtonIndex;
public String RadioButtonIndex{
get{ return radioButtonIndex;}
}
public RadioClickEventArgs(int radioButtonIndex){
this.radioButtonIndex = radioButtonIndex;
}
}
Somewhere in UserControl1:
internal event RadioclickEventHandler RadioClick;
if(RadioClick != null){
RadioClick(this, new PhoneCallEventArgs(telefonNummer));
}
Somewhere in the main form:
userControl1.RadioClick += new RadioClickEventHandler(this.userControl1_RadioClick);
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hello All,
Problem Description,
I have a byte array in RGB form and created a bitmap using this byte array and was able to store it to hard disc as .bmp file.
Code for this:
IntPtr pIntData = Marshal.AllocCoTaskMem(aNewSize); //aNewSize = size of RGB array
Marshal.Copy(aTranslatedPixels, 0, pIntData, aNewSize); //aTranslatedPixels = RGB array
Bitmap pBitMap = new Bitmap(Columns, Rows , Columns * 3, System.Drawing.Imaging.PixelFormat.Format32bppRgb, pIntData);
Now I want to create a Icon from this Byte array, what steps should I be following for this?
Thank you for your help
Uday
|
|
|
|
|
i have recently started using gdi+.i integrated some gdi +code with existing mfc graphics code..smthg like
graphics g(hdc);
..
SetSmoothingMode(SmoothingModeAntiAlias);
and then drawing some simple curves and lines
g.drawline
g.drawcurve
....
..what happens is the first time the first draw fn(in this case drawline) takes a delay abt 500 ms..
same is the case when i try with sample proj..why does this occur??
|
|
|
|
|
Your question belongs in the Managed C++ Forum[^], not C#. C# doesn't support MFC.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I would like to write a C# Client-Server application, using Socket class (Not NetworkStreams or else)...
My problem is that I want to handle messages with unknown size... my server application uses a fixed-size receiving buffer (1024 bytes)... If I start flooding the server with small messages (let's say 20 bytes), server will store all the messages in the buffer with the same receive call... And I don't know how to recognize every message... I thought an end-tag would be a good idea, but since in the buffer could be every kind of data, I don't know if the tag could be a part of the message... if so, there could be decoding problems (if more than one message in the receiving buffer)... I thought about a start-tag and end-tag... but the problem remains... moreover this would increase too much packet length...
any suggestion?
|
|
|
|
|
Correct me if im wrong, but isnt the stream of data sent over a Socket of type NetworkStream?
Im not sure you've really provided enough info to give you some accurate answers. How will clients connect to this "server"? Are they not able to indicate to the server <bom>message<eom>? What are you expecting the server to do with the data? Can it not store each message separately? Why not? etc etc
|
|
|
|
|
> Correct me if im wrong, but isnt the stream of data sent over a Socket of type NetworkStream?
The socket I'm using actually is a Stream/Tcp socket... I meant I don't want to use too much elaborate classes (like NetworkStream)
> How will clients connect to this "server"?
With a TCP connection (Socket type: Stream)
> Are they not able to indicate to the server message [I suppose "length"]?
Sure, they're able to do so, but in this case I should decide how many bytes will store message lenght in the packet... example: if I decided to store lenght in 4 bytes, and I'm using a uint to identify message lenght, the max number I can record is 4,294,967,295... what if I have a 6GB message?
> What are you expecting the server to do with the data?
I'm trying to write a sort of framework... a customizable platform, so I don't want to know what kind of data will be received by server, and I don't want to use a too strict protocol... moreover I'm interested in performances... (that's why I would avoid end and begin tags)
> Can it not store each message separately? Why not?
That's the core of the problem, I can't find a way to receive a single message... when receiving too many messages (flooding) sockets, to optimize throughput, will receive and store in the buffer more than a single message sent... I would like something like this
while(Message is complete)
{
if(Message is complete)
store data;
else
receive another chunk;
}
The problem is how to find if Message is complete...
|
|
|
|
|
using while loop,
string strMsg = "";
try
{
int nSize = 1024;
if (m_socket != null && m_socket.Connected)
{
byte[] btRec = new byte[nSize];
//受信したバイト数
int bytes=0;
//受信したバイト数よりバッファまで受信を繰り返し実行します
do
{
bytes = m_socket.Receive(btRec,0, nSize, SocketFlags.Partial);
//デコードされた表現を含んでいる文字列を返します
strMsg += Encoding.Default.GetString(btRec, 0, bytes);
}
while(bytes != nSize);
}
}
catch
{
}
return strMsg;
|
|
|
|
|
quote:
do
{
bytes = m_socket.Receive(btRec,0, nSize, SocketFlags.Partial);
strMsg += Encoding.Default.GetString(btRec, 0, bytes);
}
while(bytes != nSize);
bytes variable will store only how many bytes of the buffer have been written with the Receive call, I'm wrong? Some times ago I tested it, but in this way my program tried to store as much data as it could in the buffer... from MSDN:
"If you are using a connection-oriented Socket, the Receive method will read as much data as is available, up to the size of the buffer."
In this way I can't know if I've received one or more messages with a single receive all
|
|
|
|
|
i am also having problems with socket class.
i am creating a client/server using sockets (tcp Client and TCP listener) but i want to make it work over the internet bypassing a proxy server. is there any possible way that i could make my program run over the internet with this code?
thank you
<
//for my client class
try
{
ByPassProxy();
clientsocket = new TcpClient(serveraddress, serverport);
ns = clientsocket.GetStream();
sr = new StreamReader(ns);
connected = true;
}
public static void ByPassProxy()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:8080/STUFF//game.exe");
/*
GenerateGetOrPostRequest("http://localhost:8080/STUFF//game.exe",
"GET",
null);
*/
// add the proxy info
HwrAddProxy(request,"proxyaddress:port","username","password","domain");
// or set it up to go through the same proxy for all responses
Uri proxyURI = new Uri("proxy.dlsu.edu.ph:80");
GlobalProxySelection.Select = new WebProxy(proxyURI);
}
public static HttpWebRequest HwrAddProxy(HttpWebRequest httpRequest,
string proxyUri,
string proxyID,
string proxyPwd,
string proxyDomain)
{
if(httpRequest != null)
{
// create the proxy object
WebProxy proxyInfo = new WebProxy();
// add the address of the proxy server to use
proxyInfo.Address = new Uri(proxyUri);
// tell it to bypass the proxy server for local addresses
proxyInfo.BypassProxyOnLocal = true;
// add any credential information to present to the proxy server
proxyInfo.Credentials = new NetworkCredential(proxyID,
proxyPwd,
proxyDomain);
// assign the proxy information to the request
httpRequest.Proxy = proxyInfo;
}
// return the request
return httpRequest;
}
// for my server class
listener = new TcpListener(IpAddr[0],listenport);
Console.WriteLine(IpAddr[0].ToString());
listener.Start();
while (true)
{
try
{
Socket s = listener.AcceptSocket();
clientsocket = s;
clientservice = new Thread(new ThreadStart(ServiceClient));
clientservice.Start();
}
catch(Exception e)
{
Console.WriteLine(e.ToString() );
}
>
|
|
|
|
|
I would like to create a class that could be used to return values. I stored those values in a property so at times I will just retrieve it. My class looks like this:
Class1<br />
{<br />
private string _name;<br />
<br />
public Class1(){}<br />
<br />
public string Name<br />
{ get { return _name; }<br />
set { _name = value; }<br />
}<br />
}
My problem now, lies here: I would like to call those property in a way that "name" variable is an array-like? Meaning if i will use this class, I could have code like this:
Class1 c1 = new Class1();<br />
string name1 = c1.Name[0];<br />
string name2 = c1.Name[1];<br />
...<br />
...<br />
...
Could anyone tell me if it's possible to have a property which is array-like? If yes, how is it done? Thank you very much!!!
|
|
|
|
|
clasClass1
{
private string _name; //declare the string in array.
public Class1(){}
public string[] Name
{ get { return _name; }
set { _name = value; }
}
}
Hope this helps, I`m not sure how it`s done. Tell me if it works
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
A slight error in one line. It should look like:
<br />
private string[] _name;<br />
|
|
|
|
|
Maybe use an ArrayList (from namespace System.Collections) intead of strings...
using System.Collections
Class1
{
private ArrayList _name=new ArrayList();
public Class1(){}
public string Name
{
get { return _name; }
set { _name=value; }
}
}
in this way this code
Class1 myClass=new Class1();
Console.WriteLine(myClass.Name[0].ToString());
will write on screen the first object stored converted to string... In this way you can store different types of data (or objects), since ArrayList class is supposed to store "object" objects :P
Obviusly you need to know what kind of data you are going to retrieve from the ArrayList... ^^
|
|
|
|
|
that didn't work, i've tried it... thanks anyway
|
|
|
|
|
Why don't you try property indexers. For eg,
<br />
class Class1<br />
{<br />
StringArrayClass cs;<br />
<br />
public StringArrayClass Name<br />
{<br />
return cs;<br />
}<br />
<br />
<br />
class StringArrayClass<br />
{<br />
public string this[int index]<br />
{<br />
return array[index];<br />
}<br />
}<br />
|
|
|
|
|
Yes! that's exactly how i did it.. I look on a couple of samples in msdn.. thanks!!!
|
|
|
|
|
Hi All,
I am wanting to Add some nodes to a treeview. I have a main node and have added a node under it which is fine but I want to add another node under my second level node. How can I do this? At the moment my new node I am adding adds at the second level and not the third level.
A sample, if possible, would be appreciated. I am reading in the data from an array.
Thanks in advance.
Stephen
|
|
|
|
|
An example:
<br />
TreeNode firstLevel = new TreeNode("First");<br />
TreeNode secondLevel = new TreeNode("Second");<br />
TreeNode thirdLevel = new TreeNode("Third");<br />
<br />
treeview1.Nodes.Add(firstLevel);<br />
firstLevel.Nodes.Add(secondLevel);<br />
secondLevel.Nodes.Add(thirdLevel);<br />
|
|
|
|
|
Anybody know of a quick and easy way to get the value of a custom attribute on an enum?
e.g.
public enum Example
{
[Url("http://www.AURL.com/")]
AnEnum,
}
I can do it using about three lines of convoluted code but I was hoping there was a nicer way. ta.
regards,
Paul Watson
South Africa
The Code Project
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
Paul Watson wrote:
I can do it using about three lines of convoluted code but I was hoping there was a nicer way. ta.
No
I use the following normally:
foreach (UrlAttribute ub in obj.GetType().GetCustomAttributes(typeof(UrlAttribute)))
{
}
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Dear Sir ,
I have a real problem when i deploy crystal report on any machine that only has .NET framework installed, but when the same project run on machine which has .NET installed it work proberly, i post Question before about the same issue and an expert send me link to MSDN to learn step-by-step how to deploy crystal report , and now after that all retries i have the same problem ..
When i run a progranm that has Crystal Report without making deployment it Generate "Commn language run time error" which an error i can't Understand it
at last i have a question : i want to be sure Which License Key must be provided to Properity of "Crystal_regwiz2003.msm" file :
C# .Net OR
Crystal Report for Visual Studio.Net
Sorry for my long Question
thank you ,
Shady Aly
|
|
|
|
|
I believe this needs to be the license key you get when you register the crystal reports.
|
|
|
|