|
How about this instead?
<categories>
<category name="ASP">
<sniplet>
<name>1st Sniplet</name>
<code>Response.Write "Hello World!"</code>
</sniplet>
</category>
</categories>
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
How about this instead?
Thanks, I switched it around and added some more code and it appears to be working fine now. Thanks again.
-Nick Parker
|
|
|
|
|
Im writing a game in C# with .net and DirectX 9. I'm using DirectInput for in-game input, but when it comes to entering text (chat, player names, etc) directX isnt really something you want to use (Im using action mapping btw so that would be a real pain). I'm wondering if anyone has, or has any advice, on creating a simple but effecient way of getting keyboard text in C# w/ .net. When programming under win32 I use to grab the WM_CHAR message and manually process that.
So far I've come up with making a onKeyDown event handler and writing a function to manually add each character, casted from EventArgs.KeyValue, to a string. The problem with this is its a pain to keep track if shift is pressed down, and Im having problems accepting symbols such as . , ; ' etc. It just seems there should be an easier way. I'd like to have case sensitivity, symbols, backspacing, etc without spending too much time writing a robust text grabber.
Any ideas? Just to clarfiry - Im not looking at like a windows control or other type of form component for inputting text into. This is a full screen game and I need to have text input and I cant use DirectX to do it.
Thanks for any help
Dave Ratti
|
|
|
|
|
is it possible to instantiate a .NET type within
Internet Explorer ?
For example I would like to write some component (using c#)
that would expose interface with a single method calculating
something, and I would like to use it within a web page
(interpreted in IExplore) just like i used to make use
of ActiveX components from within JScript code.
Is it possible ?
Thanx for any info
Michal Januszczyk
|
|
|
|
|
Yes! Definitely. Create a Class Library Project (WinForm) and then this DLL you can use from within WebPages.
.NET SDK/.NET Runtime must be available on the client machine running the .NET ActiveX Control.
No ClassIds are there. Instead you will say
NameSpaceName.ClassName as the Identifier.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
|
One of the guys here posted a good question regarding enums. Basically questioning type safety with enums. Given the following:
using System;
namespace Poker
{
class PokerTable
{
[STAThread]
static void Main(string[] args)
{
PlayingCard fiveOfHearts = new PlayingCard( 4, 1 );
PlayingCard fiveOfHearts = new PlayingCard( (PlayingCard.Rank) 4, (PlayingCard.Suit) 1 );
fiveOfHearts.ViewHand();
PlayingCard rulesCard = new PlayingCard( (PlayingCard.Rank) 343, (PlayingCard.Suit) (-1) );
rulesCard.ViewHand();
PlayingCard emptyHand = new PlayingCard( 0, 0 );
emptyHand.ViewHand();
Console.In.ReadLine();
}
}
public class PlayingCard
{
public enum Suit
{
SPADES, HEARTS, DIAMONDS, CLUBS
}
public enum Rank
{
ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN,
EIGHT, NINE, TEN, JACK, QUEEN, KING
}
private Rank rank;
private Suit suit;
public PlayingCard( Rank rank, Suit suit )
{
this.rank = rank;
this.suit = suit;
}
public void ViewHand()
{
Console.WriteLine(rank + " " + suit);
}
}
}
Why is PlayingCard( 0, 0 ) acceptable? Shouldn't this have a compile time error as does PlayingCard( 4, 1 )? I would think they should both fail!
Thanks!
ed
Regulation is the substitution of error for chance.
|
|
|
|
|
Enums in C# do dual purpose. They are used for the usual enum use, and they're also used for bit fields. When I'm dealing with bit fields, you often want to AND a value with the bit field and check if it's true.
Our initial rules meant that you had to write:
if ((myVar & MyEnumName.ColorRed) != (MyEnumName) 0)
which we thought was difficult to read. One alernative was to define a zero entry:
if ((myVar & MyEnumName.ColorRed) != MyEnumName.NoBitsSet)
which was also ugly.
We therefore decided to relax our rules a bit, and permit an implicit conversion from the literal zero to any enum type, which allows you to write:
if ((myVar & MyEnumName.ColorRed) != 0)
which is why PlayingCard(0, 0) works.
|
|
|
|
|
Could not the end-developper ideally control that using a compiler attribute?
my 2 cents
R/
|
|
|
|
|
It would be possible to allow the developer to control that behavior, but I think that allowing the user to change the language rules is a bad idea, as it complicates the language. Adding options often makes the user's lives harder, not easier.
|
|
|
|
|
I think it's a good idea. Those who don't like it can just not use it.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I don't think so.
Isn't 0 valid for both enums, but 4 is invalid for the first?
Aren't the valid numbers for the Suit enum 0 - 3, while the valid numbers for the Rank enum 0 - 12 ?
That's why you shouldn't use "number" to access. Always use them in the true OO model, like Rank.JACK instead of a number.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
You'll always need to explicitly cast an int value to an enum unless the int value is zero.
|
|
|
|
|
Any enum is based on an integer type, which has a defualt value of 0, thus Enum as a ValueType it needs also some kind of default state, thus 0.
<a TITLE="See my user info" href=http:
|
|
|
|
|
I have a form where i call a class with and start a subroutine
Class1 Class1 = Class1();
Class1.StartSub();
In my Mainform from where i call the class there is for example a label called "label1". Now i want to change the label1 from within the Class Subroutine ...
I tried following:
in the MainForm (Form1) set the label from private to public
and then in the Class:
Form1 Form1 = new Form1();
Form1.label1.text = "test";
It compiles without any error but it doesn't change the label.
Thanks for you help!
|
|
|
|
|
When you created the new Form1(), you created a whole new instantiation of that form in memory, so you changed HIS label and not the one that is visible.
You could tackle that a couple of ways.
You could put in the Class1's constructor an argument for a label like this
Class1(label FormsLabelIWantToChange)
{
FormsLabelIWantToChange = "test";
}
Another way to do it (I think) would be to make Form1's label member s public static, then as you are in the same namespace you could do something like this in your class:
Form1.label1.text = "test";
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
If the XML file has whitespaces then it crashes my app. What I am doing wrong??
I get this "An error occured while parsing EntityName. Line 8, position 14."
That position it has whitespaces. I am actually testing my app.
<br />
<br />
FileInfo fileInfo = new FileInfo(fileName);<br />
<br />
XmlNode xmlRootNode;<br />
XmlTextReader xmlReader = null;<br />
if (fileInfo.Exists)<br />
{<br />
using (Stream strm = fileInfo.OpenRead())<br />
{<br />
using (StreamReader sr = new StreamReader(strm))<br />
{<br />
<br />
xmlReader = new XmlTextReader(sr);<br />
xmlReader.WhitespaceHandling = WhitespaceHandling.None;<br />
try<br />
{<br />
XmlDocument myDocument = new XmlDocument();<br />
<br />
myDocument.Load(xmlReader);<br />
....<br />
}<br />
<br />
}<br />
}<br />
Even if I open the XML file in IE, it fails. I get this error. "Whitespace is not allowed at this location. Error processing resource 'file:///C:/abcd.xml'. Line 8, Position 14"
I want to avoid those nodes where whitespaces exist.
Thx
Don't and drive.
|
|
|
|
|
you xml file is not valid - you what a whitespace where it is not allowed, post up the xml so we can see it.
if IE won't load it then theres no way your c# will load it.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
you xml file is not valid - you what a whitespace where it is not allowed, post up the xml so we can see it.
I know it's invalid. But in my app if any user uses invalid XML file, then I want to ignore the nodes where whitespaces exist.
If that's is not possible then what's the use of "WhitespaceHandling"??
Currently I am catching the exception. But the exception won't give much information like the one in IE. ('Whitespace is not allowed at this location. Error processing resource 'file:///C:/abcd.xml'. Line 8, Position 14")
Is there any specific exception to catch this kinda of errors?
Don't and drive.
|
|
|
|
|
white space handling is for manaing tabs and newlines - not for handling errors in XML documents.
My frst reaction would be to say you can't do this.
However, try using an XmlReader, you might be able to do some kind of partial loading of the document.
In general however, if the Xml document is not valid then you can't load it - not even partially.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
white space handling is for manaing tabs and newlines - not for handling errors in XML documents.
As I mentioned earlier I am testing my app for different scenarios where it crash, say if at all any user uses a XML file which contains whitespaces then I want to catch them and report the error properly.
Philip Fitzsimons wrote:
In general however, if the Xml document is not valid then you can't load it - not even partially.
Thx Philip.
One more question.
Is the same rule applies to "&", "<" and ">"??
Do I need to convert them to "&am p;" "&l t;" and "&g t;" ? (ignore the spaces)
Don't and drive.
|
|
|
|
|
You don't sound too sure of what you are doing - i.e. are you trying to REPORT the error or FIX it?
if you just want to report the error then use the exception information or use and XmlReader.
If you want to fix the error then you are going to have to do a lot of work with no real chance of being sure if your "fix" will result in the correct document.
Personally I would just report the error.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
You don't sound too sure of what you are doing - i.e. are you trying to REPORT the error or FIX it?
Intially I thought of FIX the error but after few hiccups I gave up that idea and just REPORTing error.
Thx for clarifying my stupid newbie questions.
Don't and drive.
|
|
|
|
|
Hi, everyone:
I am using VS.NET 2003 to create a winForm application ( Same result in VS.NET 2002). The application accesses MS Access DB so that an user can edit the DB.
When I have Datagrid bounded to the tables, all the updates (Insert,Delete and Update) work perfect. However, I have one table that I have to bound it to TextBoxes and CheckBoxes. If I insert or delete a record, it updates the DB fine. When I change the text in the texboxes, or click on the checkboxes, The record is supposed to be modified. When I click on my save button, I use table.GetChanges(DataRowState.Modified) to retrieve the changes. Surprisely, there is no changes, even though I thought I have the right binding.
Apparently, when I change the textboxes or checkboxes, the datarow status did not change to Modified. I can not figure out what I missed here. Please help. Thanks in advance.
Dion
More info:
I have columns as Text, Number and Yes/No in the MS Access DB. Here are the simplified code to do the binding:
For Number:
Binding b1 = new Binding("Text", dsMain1, "LMMaster.LMMasterLMSimConfig.LessonTime");
b1.Parse+=new ConvertEventHandler(TextStringToInteger);
b1.Format+=new ConvertEventHandler(IntegerToTextString);
txtLessonTime.DataBindings.Add(b1);
For Text:
txtConfig.DataBindings.Add(new Binding("Text", dsMain1, "LMMaster.LMMasterLMSimConfig.Config"));
For CheckBox:
chkboxHelp.DataBindings.Add(new Binding("Checked", dsMain1, "LMMaster.LMMasterLMSimConfig.Help"));
|
|
|
|
|
Hi,
You should end edit for the row. To do so, you need to run
txtConfig.DataBindings["Text"].CurrencyManager.EndCurrentEdit()
(more or less this way-I wrote it from my memory not copied from VS ) )
when user changes text or when textBox loss focus.
h.
|
|
|
|