|
ok, i wrote my own:
Image ImageToGrayScale(Image orig)
{
Bitmap bm = new Bitmap(orig);
for (int i=0; i<bm.Width; ++i)
for (int j=0; j<bm.Height; ++j)
{
Color pixel = bm.GetPixel(i,j);
if (pixel.A>0)
{
int grayVal = 175+(pixel.R+pixel.G+pixel.B)/12;
bm.SetPixel(i,j,Color.FromArgb(grayVal,grayVal,grayVal));
}
}
return bm;
}
:wq
|
|
|
|
|
Hello friends,
In my application i want to add favourites from Internet Explorer as well as Netscape.
I dont want to take favourite folder path from user.I want to get that folder path dynamically using C#.
Has anyone tried this out?
Thanks in advance.
Pranoti
|
|
|
|
|
I think if you use the environment class and get the APPDATA environment variable, that will point you to the correct location.
|
|
|
|
|
Hi,
I'm trying to write a service that exposes a remote object through a channel. I also want a 'management console' application that allows me to configure the service remotely. Again, I expose a remote object. Now comes the tricky part:
When a client instantiates a remote object and the service manager is 'connected' through the other type of remote object, I want to send events (messages) from the client object, through the manager object to the manager app. On the manager PC I would like to have a real time log for all clients connected to a server.
Any help is highly appreciated,
G
By the way anyone knows if the .Net CF and SDE supports remoting? Got it, but didn't install it yet...
Any idea when a new release can be expected?
|
|
|
|
|
HG,
I'm not sure I followed your question, but I'll make a hack at it. I think you will need to basically have your middle object echo the method (event) back to the manager application. There is no such thing as a 'pass through method' if that's what you are asking.
As far as .Net CF, Remoting is NOT supported. I was VERY upset to learn this myself, although I understand the size limitations. CF does support web services, however, which means you can at least do semi-remoting one-way. I don't think there is any way to receive events from a web service though. Soemone correct me if I'm wrong. One last note, even though web services are supported, ISerializable seems to be missing from the CF. Anyone know where that went?
Jared Bienz
jbienz@hotmail.com
|
|
|
|
|
I found an MSDN article that demonstrated how to call SHGetFileInfo (using InterOperability services) to retrieve system icons. I am in the process of building a kind of management class (manages a large and small imagelist, and retains a list of extensions already handled etc.) with the eventual aim of putting it all up here for others to use in their C# apps.
However, it doesn't like the new XP icons with alpha channels. (as far as I can make out).
When you retrieve the icon for an Excel spreadsheet it looks fine, same for Word etc. However, if you add a text file, the notepad icon appears but with a black border around the edge, this is also true when retrieving folder icons.
I've found some examples of people producing MFC classes to retrieve icons and they work fine so I'm guessing its something I've mashed myself.
Does anybody know what might be causing this to happen?
The code looks like:
Shell32.SHGetFileInfo( name, Shell32.FILE_ATTRIBUTE_NORMAL, ref shfi, (uint) System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags );
System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shfi.hIcon).Clone();
The icon is cloned so that DestroyIcon can be called to remove the handle -- since I'm adding it to an imagelist DestroyIcon can be called as soon as its been added, however a clone must be made so as not to make the reference to the icon invalid.
If anyone has any suggestions as to how I might sort this out I'd very much appreciate it.
Regards,
Paul
|
|
|
|
|
Paul,
As far as I can tell, the black border is a .Net Framework problem. In my article just posted yesterday, I too retreive this icons. I am dealing with disk drive icons, but I obtain them the same way. In my other article also posted yesterday, I show a control that uses these system icons. The way that I get around the black borders is to resize the image. In my control, I use the 32x32 image and resize it to 16x16 using a soft resampling. That actually works quite nicely. If you need the 32x32, I'm not sure I can help much unless upsampling and then downsampling/averaging works there too. I sure can't tell you why the bug is there...
Hope that helps a little.
Jared Bienz
jbienz@hotmail.com
|
|
|
|
|
Hi,
I know it is a C# forum, but i really need help!!! Let's see my code first:
*****************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1)
{
perror("Pipe");
exit(2);
}
if (fork()==0)
{
}
else
{
for (j=1; j<=5; j++)
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid());
operation(f_des, temp);
}
}
while (X>0)
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1)
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message));
waitprocess(getpid());
X--;
}
else
{
printf("error");
}
}
}
}
****************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
What in the hell is WRONG with you ? The VC++ forum was a stretch, but asking here is just plain rude.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
The VC++ forum was a stretch
And the managed C++ forum
James
|
|
|
|
|
Yeah, but someone beat me to that one
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
She left out the lounge, so some credit goes to her.
|
|
|
|
|
Christian Graus wrote:
What in the hell is WRONG with you ? The VC++ forum was a stretch, but asking here is just plain rude.
I think you are being a bit harsh.
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
You're entitled to your opinion. Would you suggest we post ALL questions and discussions in the lounge ? IF not, why have different sections at all ? He's asked this twice in the VC forum, once in the MC++ and once in the C#.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
You're entitled to your opinion. Would you suggest we post ALL questions and discussions in the lounge ? IF not, why have different sections at all ? He's asked this twice in the VC forum, once in the MC++ and once in the C#.
You should ignore it then. I responded to his post in the VC++ forum and directed him to a newsgroup that would help him. He is probably desperate for an answer and doesn't need anymore stress.
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
Martin Marvinski wrote:
He is probably desperate for an answer and doesn't need anymore stress.
Yeah, that's fair. I'm pretty stressed about my Oracle problem. I might just spam all the forums, what do you think ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
Yeah, that's fair. I'm pretty stressed about my Oracle problem. I might just spam all the forums, what do you think ?
What's your Oracle problem?
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
It sucks. I posted details yesterday, basically a stored procedure that worked fine for ages now hangs. It's a simple, vanilla insert. Doing it as text results in a 'invalid char' error, but passing the same text into SQL+ works fine.
My screensaver reads 'die, larry, die'
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
I'm pretty stressed about my Oracle problem.
It's not yet solved. ? Did you check the network share stuff which I told you.
|
|
|
|
|
I am not at work, so I can't try it, but I will first thing tomorrow.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
How do events MouseUp and Paint become available to derived classes?
I have a control that extends Control and is then further extended by another set of controls like so:
<br />
Class BaseImpl: Control, IBaseEdit<br />
{<br />
public virtual event EventHandler ValueChanged;<br />
...<br />
}<br />
and extending that-
<br />
Class MyTextEdit: BaseImpl<br />
{...}<br />
but this class does not have ValueChanged as an available event.
whats the missing link?
-dull
[.. if you've enjoyed today's post, you'll love previous posts including: "..im an idiot." and "way to go, youre dumb." ...]
|
|
|
|
|
Okay, so ive deduced that declaring an event virtual makes it invisible to it's derived classes unless it is overridden.
if you make the OnEvent method that fires the event virtual, you can re-route what happens when the event would otherwise be called by overriding [base.OnEvent].
so there's no obvious reason to make an event virtual. since you cant mutate it in any way, you might as well just declare it as public. unless you wish to selectivly hide it.. but then youre breaking your own abstract class model.
this is so much cheaper than therapy.
|
|
|
|
|
I have to agree, I believe the recommended practice is to have a protected virtual method that is called; in the default implementation it fires the event list.
public class Base
{
public event MyObjectChangedEventHandler MyObjectChanged;
protected virtual void OnObjectChanged(MyObjectChangedEventArgs e)
{
if( MyObjectChanged != null )
{
MyObjectChanged(this, e);
}
}
} Now if someone wants to change what happens when the event happens in a child class they override the OnObjectChanged method to add their implementation.
James
|
|
|
|
|
poodull wrote:
so there's no obvious reason to make an event virtual.
Except I would think that making an event virtual means that you want to overload it's add and remove accessors.
public event Event1
{
add
{
}
remove
{
}
}
So if someone add's an handler you may want to keep a count or something like that.
|
|
|
|
|
Hello!
Using SMTPMail class to send mail.. Having problem with finding out how to find host name of the server that I am running on... If I am typing host name myself -- it works, but I am not expecting user to know what to type...Can I find it automatically?
Please help!
|
|
|
|
|