|
OK, so there's several steps here.
1 - make your form a control. This is really easy, just create a blank control and move your form to it.
2 - put it in a dll. The only issue I see here, is making sure you import the Windows.Forms dll so you have that stuff inside the scope of your code
3 - make it appear in the designer. Not sure if this just happens or if you need to add some sort of attribute to make it happen
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.
|
|
|
|
|
Christian Graus wrote: 3 - make it appear in the designer. Not sure if this just happens or if you need to add some sort of attribute to make it happen
You mean add it to the Toolbox? That's where I stumble too. I wrestled with one for a while this morning then gave up. I'm pretty sure I've gotten it to work before though. Also that it was covered in a class I took years ago, so I have the book here and I intend to have a look... later.
|
|
|
|
|
hi everyone
I'm sure that thw solution is going to very simple.
i'm trying to get a yes or no answer from in my program. I don't understand it is not working:
Console.WriteLine("Would you like to transform another grade (Y/N)");
char yesOrNoAgain = char.Parse(Console.ReadLine());
char.ToUpper(yesOrNoAgain);
if (yesOrNoAgain == 'Y')
{
}
else if (yesOrNoAgain =='N')
{
else
{
}
the grogram doesn't recognize the capital Y or capital N.
can someone show me my error.
thanks
|
|
|
|
|
the problem is on the char.ToUpper line. If you check carefully you'll see that ToUpper returns a new char, it doesn't alter the existing one (google for immutable).
To fix it you need to use:
yesOrNoAgain = char.ToUpper(yesOrNoAgain);
|
|
|
|
|
|
Before posting here again please read this[^]
"Help is need" Of course it is, why else are you here!
only two letters away from being an asset
|
|
|
|
|
Why not a switch?
switch ( Console.ReadLine() [ 0 ].ToUpper() )
{
case 'Y' : ...
case 'N' : ...
}
Though even that will blow up when the user hits RETURN without typing anything.
On the other hand, in light of the Lounge thread concerning "duct tape programmers", I present some code I wrote a few days ago:
private readonly static System.Collections.Generic.Dictionary<string,bool> boolifier ;
boolifier = new System.Collections.Generic.Dictionary<string,bool>
(
System.StringComparer.CurrentCultureIgnoreCase
) ;
boolifier [ "TRUE" ] = true ;
boolifier [ "TRU" ] = true ;
boolifier [ "TR" ] = true ;
boolifier [ "T" ] = true ;
boolifier [ "YES" ] = true ;
boolifier [ "YE" ] = true ;
boolifier [ "Y" ] = true ;
boolifier [ "1" ] = true ;
boolifier [ "FALSE" ] = false ;
boolifier [ "FALS" ] = false ;
boolifier [ "FAL" ] = false ;
boolifier [ "FA" ] = false ;
boolifier [ "F" ] = false ;
boolifier [ "NO" ] = false ;
boolifier [ "N" ] = false ;
boolifier [ "0" ] = false ;
private static bool
PromptForYesNo
(
string Prompt
)
{
string temp = PromptForEntry ( Prompt , false ) ; // Basically WriteLine and ReadLine like you have
return
(
boolifier.ContainsKey ( temp )
&&
boolifier [ temp ]
) ;
}
|
|
|
|
|
Then why even put in the falses? If you leave all of those out, you'll still get false when you need it
|
|
|
|
|
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
|
|
|
|