|
true
a simple list and a return list.Contains(key) would do. Saves a lot of duct tape. Joel, where are you?
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Until someone adds "Maybe".
|
|
|
|
|
Oh, and are there blank lines in there? I don't see any.
|
|
|
|
|
yes, two of them, here is the source:
true :laugh:
a simple list and a <code lang='text'>return list.Contains(key)</code> would do. Saves a lot of duct tape. Joel, where are you?
:)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
OK, I see none, even though it has SPACEs.
|
|
|
|
|
No no no... I meant in my code... I see no blank lines in the code I posted.
|
|
|
|
|
When you type (not paste) a PRE tag, a line of text, ENTER, ENTER, a line of text, and a closing PRE tags with IE7 or FF3; and then look at it, the result should be IE7 does not show an empty line, and FF3 does. That is what I get, and I understood that is what Chris gets.
Is yours different, then please specify in detail.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I'll try it and respond on the other thread, it doesn't really belong here.
|
|
|
|
|
0) So people will ask why I put them there.
1) Completeness, orthogonality
2) So I can use the same Dictionary for other purposes.
2.1) I don't know what I may need in the future.
2.2) A stitch in time saves nine.
3) Because that belt goes so well with the suspenders.
4) That's just the kind o' guy I am.
Actually because otherwise there's no need for a Dictionary. I considered using a HashSet, but that requires .net 3.5 and I have this particular project set to 2.0 and I don't feel like changing it to 3.5 just for this little bit of code that I may rework later anyway. Of course, I could also use my Set[^] class, but again I may decide on a completely different tack later.
Hmmm... maybe an enumeration and my EnumTransmogrifier... that's how I do some other input parsing...
|
|
|
|
|
people who want it in one line should write:
if ("yYtT".IndexOf(Console.ReadLine().Trim()[0])>=0) doSomething();
BTW: this was the de-luxe model; the case-insensitivity and the trimming are optional.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
And if the user doesn't type anything before pressing RETURN?
|
|
|
|
|
then he needs some more duct tape, as in
if ("yYtT".IndexOf((Console.ReadLine()+"!").Trim()[0])>=0) doSomething();
FYI: there are no empty lines in this message
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Here's yet another way, in case you don't want the user to have to press RETURN:
public static bool
YesNo
(
string Prompt
)
{
System.Console.Write ( Prompt ) ;
while ( true )
{
System.ConsoleKeyInfo ch = System.Console.ReadKey ( true ) ;
if ( ( ch.Modifiers | System.ConsoleModifiers.Shift ) == System.ConsoleModifiers.Shift )
{
switch ( ch.Key )
{
case System.ConsoleKey.Y :
{
return ( true ) ;
}
case System.ConsoleKey.Enter :
case System.ConsoleKey.N :
{
return ( false ) ;
}
}
}
}
}
|
|
|
|
|
Hi i'm using C# in visual estudio 2005, i need to open 16 bits png images, not raw images. i have a code in which one i can open a 8 bit image and i can get a pixel from that image. the code works, but what i need is to open a 16 bit images. i need your help. thankyou. some of the code i have is the next:
-------------------------------------------------------------------------------------------------------------------------
private void pictureBox_Click(object sender, System.EventArgs e)
{
int[] pos = new int[2];
pos = m_Coord.GetXY();
if (this.pictureBox.Image != null)
if ((pos[0]<this.pictureBox.Image.Width) && (pos[1]<this.pictureBox.Image.Height))
{
m_Coord.AgregarPunto(pos);
// para obtener color
Bitmap b = (Bitmap)this.pictureBox.Image;
int[] color = new int[3] ;
unsafe
{
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
byte * p = (byte *)(void *)Scan0;
p += pos[1]*stride + pos[0]*3;
color[0] = (int)p[2];
color[1] = (int)p[1];
color[2] = (int)p[0];
b.UnlockBits(bmData);
}
FormPadre f = (FormPadre)this.ParentForm;
f.statusBar.Panels[1].Text = "Click=(" + System.Convert.ToString(pos[0]) + "," + System.Convert.ToString(pos[1]) + ")";
f.statusBar.Panels[2].Text = "RGB =" + System.Convert.ToString(color[0])+ "," +System.Convert.ToString(color[1])+ "," + System.Convert.ToString(color[2]);
g = this.pictureBox.CreateGraphics();
g.DrawEllipse(pen, pos[0] - 3, pos[1] - 3, 6, 6);
}
else
{
MessageBox.Show("El punto está fuera de los límites de la imagen", "Important", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
----------------------------------------------------------------------------------------------------------------------------------------
above, there are some functions that i have in other clases. what i need is to open 16 bit png images.
i have tried doing the next: but the intensity pixel values are not corrects
---------------------------------------------------------------------------------------------------------------------------------------
private void pictureBox_Click(object sender, System.EventArgs e)
{
int[] pos = new int[2];
pos = m_Coord.GetXY();
if (this.pictureBox.Image != null)
if ((pos[0]<this.pictureBox.Image.Width) && (pos[1]<this.pictureBox.Image.Height))
{
m_Coord.AgregarPunto(pos);
// para obtener color
Bitmap b = (Bitmap)this.pictureBox.Image;
int[] color = new int[3];
unsafe
{
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, b.PixelFormat);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
byte* p = (byte*)(void*)Scan0;
p += pos[1]*stride + pos[0]*6;
color[0] =(int)p[2];
color[1] =(int)p[1];
color[2] =(int)p[0];
b.UnlockBits(bmData);
}
FormPadre f = (FormPadre)this.ParentForm;
f.statusBar.Panels[1].Text = "Click=(" + System.Convert.ToString(pos[0]) + "," + System.Convert.ToString(pos[1]) + ")";
f.statusBar.Panels[2].Text = "RGB =" + System.Convert.ToString(color[0])+ "," +System.Convert.ToString(color[1])+ "," + System.Convert.ToString(color[2]);
g = this.pictureBox.CreateGraphics();
g.DrawEllipse(pen, pos[0] - 3, pos[1] - 3, 6, 6);
}
else
{
MessageBox.Show("El punto está fuera de los límites de la imagen", "Important", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
------------------------------------------------------------------------------------------------------------------------------------
please help me
|
|
|
|
|
Rosana2009 wrote: g = this.pictureBox.CreateGraphics();
This is such an utter disaster. There are so many levels on which it's clear you have no idea what you're doing.
I am not sure if windows will open 16 bit PNGs. If it won't, odds are you need a third party library to help you do it, because you need to decompress it before you start looking at pixel data.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi, Christian thanks for your support,
sorry if i am not clear, but what i really need is to open and display 16 bits PNG images, and get the RGB channels in C#.
Rosana Rodriguez.
|
|
|
|
|
Hello everyone,
Is there any way I can create WCF web sevice from a wsdl? (not a proxy class from svcutil).
I know how to create one in normal way but when I createit manually , the WSDL file gets changed which I dont wont.
Thanks in advance,
Regards ,
Nishu
|
|
|
|
|
I've been having some problems with admin rights. Im developing an application to be installed by a network admin but what i need is for the program to maintain admin rights when anyone uses it. Is this possible?
Duncan
|
|
|
|
|
Yes and no. You really don't want your application to run as an administrator unless the user is an administrator. That is one of the security features of Windows. However, you can impersonate a given user or you can design your application as a service and set the service to run under a specific user account.
|
|
|
|
|
Thank you for replying and i understand what your saying. Kinda...lol
To define my problem better though, my app is installed on the root drive which also means my settings are installed on root, if a user wants to change these settings they must have admin rights, how do i get round this
many thanks
Duncan
|
|
|
|
|
You don't. You application can request that it runs as the users admin account, if they have one (Vista and above), using a manifest. On XP and below, you simply have to trust that the user is an administrator and handle the case of not being able to write to the file if the user is not. Administrative permissions only go to user accounts, not applications. When a user launches an application, the application inherits the users security token, in effect, impersonating the user that launched the app. The application cannot get more permissions than the user has available to him/her.
|
|
|
|
|
Install your application in %program files% as suggested by MS and then read/write user settings to and from Application.UserAppDataPath
|
|
|
|
|
hey there,
to set custom headers to a datagridview, you can use the DisplayNameAttribute. Any idea how to change the order of the columns likewise?
Greetings and thanks in advantage!
|
|
|
|
|
Did you mean PropertyGrid , rather than DataGridView ?
AFAIK the DisplayNameAttribute class alters the displayed name of a property in a PropertyGrid . I have not tried it on a DataGridView , but am disinclined to think it would work.
If you are sure that you mean DataGridView , then please post the relevant section of your code, so that people can more easily understand your problem.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|