|
Hi friends,
I want to access all members of Color enum one by one . any one can help me?
|
|
|
|
|
You are looking for Enum.GetNames[^]. Pass any enum type as a parameter and it returns a n array of strings containing the names of the enum elements. In your case, you need to call it as Enum.GetNames(typeof(Color)); .
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How can I Draw a string in reverse color of background?It is easy using code like this
private void tb_Paint(object sender, PaintEventArgs e)<br />
{<br />
string text = ((TouchButton)sender).strName;<br />
FontFamily fontFamily = new FontFamily("Times New Roman");<br />
Font font = new Font(fontFamily,12,FontStyle.Bold,GraphicsUnit.Point);<br />
Rectangle rect = new Rectangle(this.iHorizentalSpacing ,<br />
this.iVerticalSpacing , this.iWidth - 2 * this.iHorizentalSpacing<br />
, this.iHeight - 2 * this.iVerticalSpacing);<br />
e.Graphics.FillRectangle(Brushes.Black,rect);<br />
e.Graphics.DrawString(text,font,Brushes.White,rect);<br />
}
but I Want to generate colors and they reverses manually.
Ali Beirami
|
|
|
|
|
Does negating the hex value of the background color work? Something like
Color bgColor = Color.Black;
g.FillRectangle(new SolidBrush(bgColor), 0, 0, this.Width, this.Height);
int val = bgColor.ToArgb();
val = ~val;
Color foreColor = Color.FromArgb((0x000000FF & (val >> 16)), (0x000000FF & (val >> 8)) , (0x000000FF & (val)));
g.FillRectangle(new SolidBrush(foreColor), 0, 0, 100, 100);
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Dear All,
There is a squid server on WinXP (127.0.0.1:8081).
I have a C# application that I want to it redirect ALL HTTP request to squid(transparent proxy).
(application and squid run on same system)
I use GlobalProxySelection and below code in my application, but dont work.
Uri proxyURI = new Uri("http://127.0.0.1:8081");
GlobalProxySelection.Select = new WebProxy(proxyURI);
How can I redirect ALL http request to this proxy server?
Is correct this question!? Can I do it on windows OS?
--TNX
|
|
|
|
|
I have this problem too.
Can everybody help us?
|
|
|
|
|
If you are running a transparent proxy, you dont need to change anything on the clients. The proxy get automatically used for outgoing requests to port 80 as directed by iptables in linux. You can verify this by inspecting the http repsonse headers. Squid should add 1 or 2 headers to the response. If your are using this for webservices you mite wanna disable caching on the webservice else your requests will be cached by squid.
xacc-ide 0.0.99-preview
|
|
|
|
|
No, I want to run a transparent proxy that redirect all http packets to caqche server.
How can I do it?
|
|
|
|
|
Hi
I want to redirect all my network traffic especially UDP through proxy server. I want to change contents of some of my packets and then send that packet to the destination. Any idea how I can do this. I am not good in C, any solutions in C# will be a plus as I have to complete it early.
|
|
|
|
|
Hi,
I'm having some trouble with random numbers.
I'm building a BTree structure but wether the node I'm inserting goes left or right needs to be random.
The problem is that:
Random rand = new Random();
int num = rand.Next(1,3);
always produces the same number everytime time the function is called.
I tried generating 2000 numbers in a list and found that about 1/3 were 2, the next 1/3 were 1 and the next 1/3 were 2.
Basically the default seed is the current time's Millisecond property.
I tried setting my own seed and had the same results.
If I do System.Threading.Thread.Sleep(1000) I get what looks like a valid set of random numbers.
The problems is I can't wait for 1 second per Random number as I need to make thousands of these decisions in a short space of time.
Is there a seed I can provide, mayve a smaller number than Millisecond?
I was thinking of having an array of seeds, and everytime I need a random numbr, then choose the next seed in the list, and add it to the current time.
This way, even when the same element of the array is selected when it loops around the seed will be different.
The problem is I really couldn't be bothered coming up with thousands of numbers for this.
Is there an easier way?
Thanks,
Stephen York
|
|
|
|
|
How silly can I be?
I was creating a new Random object every time I needed a new number.
I took the declaration out and declared it globally and assigned it in my class's constructor.
Please ignore my silliness.
|
|
|
|
|
|
I have loaded and image into an imagelist. Now how can I convert this into a System.Drawing.Icon so that I can use it as an icon.
|
|
|
|
|
Do you actually want it output as a .ico file or just for use in your application ?
|
|
|
|
|
Here is a function which could run for a while.
So I put it into a thread.
Now I want get the result as soon as it returns.
How to do it?
Thanks!
|
|
|
|
|
The thread function can't return a value, because you don't know when it will complete. The only way is to share a variable and make the thread signal to the original thread when it has completed updating the variable.
class Test
{
int val = 0;
AutoResetEvent evt = new AutoResetEvent(false);
void MainThread()
{
new Thread(new ThreadStart(ThreadFunc)).Start();
evt.WaitOne();
Console.WriteLine(val);
}
void ThreadFunc()
{
Thread.Sleep(2000);
val = 1000;
evt.Set();
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Every time I new a TcpClient , it takes me almost 30 seconds.
Is it too slowly?
Is there any way to increase the speed?
Thanks a lot!
|
|
|
|
|
Hi,
do you know if there is an exam available for windows c# 2.0 ?
Thanks
|
|
|
|
|
|
Hi
I have created a utility class which contains static methods to do some utility functions. I believe that only one instance of this method is created for this class and all objects use the same instance.
My concern is this: If multiple threads access the method simultaneously, are the variables in the static method used thread safe? is it possible that they mgith be corrupt?
Please advise. I am wondering whether to make these methods instance methods.
Thanks
TSR
|
|
|
|
|
Local variables inside methods are always stored on the stack, and each thread has its own stack, so this is absolutely thread-safe.
Static fields inside the class are something different...
|
|
|
|
|
|
tsramkumar wrote:
y one instance of this method is created for this class
Not really. There are no instances for methods, static or otherwise. When your application loads up, these methods (the compiled code, actually) are loaded into memory (a special section called .text) and that's it.
That memory is totally different from memory used by local variables. Local variables are created on the stack and each invocation of the function creates them, so yeah, you are safe as long as the variables you refer to are local variables.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks. I have only local variables in my static method (it does call another static method in a utility class, but that too uses local variables only). So as long as I use only local variables in static methods, the code should be thread safe right.
Thanks once again for clarifying this.
Ram.
|
|
|
|
|
Anything static must be treated with care in a MT system. As you have guessed any thread could access it at any time causing wackiness to ensue. In general I would avoid any static members in objects that are going to be in an MT system. static methods aren't as toxic because any locals are stored on the stack of the thread but can be problematic if it access other things that have static members or worse members.
|
|
|
|