|
Why don't you have your own .config XML file, and access it like XML file not like config file? e.g. with XPath document... or am I missing something badly??? (I admit I more read that sig/quote part )
jklucker wrote:
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
Yeah you won[^]
Looks like you are both wrong, guys... Dave with quote and you because you misspelled word "substitute" ;P
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
You are right I can create my own config file and access like XML. I was looking to use the app.config functionality that System.Configuration.AppSettings gives us access to.
I like the google fight, I never heard that before. I'll have to remember that.
It just goes to show how spell checkers are relied upon.:->
I reject to reality and subsitute my own!
- Adam Savage, Mythbuster
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
Im making a game, but i need to give different objects different depths, y'know so you could walk BEHIND a tree or something.
I just need to know how you do it.
With game making software (which im not using right now)
You can give the tree a depth of 50 for example and the guy a depth of 60, the guy would walk behind the tree right. Or if the guy had a depth of 40 he would walk infront of it.
So any ideas?
I also would like to know how to have a window that follows the character around a larger room, this is necessary because i cant fit the whole of one 'room' on the screen and you need to be able to see what your doing, so any info on that would be good to.
|
|
|
|
|
This could be answered in many different ways depending on the technology you're using. GDI+? Windows Forms? DirectX's Direct3d? Managed DirectX? DirectX's DirectDraw? OpenGL? A 3rd party 3d engine? A 3rd party 2d engine?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Oh sorry 'bout that im just using directX and its a 2D game so ya dont need to worry about any 3D type things.
|
|
|
|
|
Then it'd just be a matter of drawing one object after another. Objects that are "deeper" in the scene (i.e. have a greater z buffer) would be drawn first, while objects shallower in the scene (i.e. have a smaller z buffer closest to 0) would be draw last.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
So basically, create my own int called depth or whatever, and when my character gets past the tree (int is greater than the trees) re-draw the tree.
Even simpler than i thought.
|
|
|
|
|
You need to setup a Depth order. often this is as easy as starting your drawing from the upper left. But if your using a more 3d approch then you need to setup a list of items to draw by there depth. Draw the farthest objects first. The simplist way is create a static list. When you load your map organize the list for all you static (non moving objects). Then add your dynamic objects into the list. When a dynamic object is change you update the list. This way your only changing the list when somthing changes its depth.
As for making a "window" to see the player behind objects. this can be done by checking when we draw somthing. You need to make a bounding box or circle around the player. Simlpy the X,Y poition and and Radi. If the object your drawing is in fron of the play (ie: Obj.Depth < player.Depth) and Object.X-player.X < Radi and Object.Y-player.Y <radi then="" your="" dont="" draw="" the="" object.="" now="" this="" simple="" way="" will="" just="" not="" object="" at="" all="" which="" may="" cause="" some="" unwated="" visuals.="" in="" case="" we="" want="" to="" make="" a="" cusom="" function.="" if="" be="" is="" players="" bounding="" box="" instead="" of="" drawing="" it="" call="" our="" own="" cheack="" each="" pixel="" drawn="" see="" falls="" box.="" you="" can="" get="" clean="" circle="" around="" player.
ex:
px="" and="" py="" are="" point
void="" draw(object,px,py){
for="" (int="" x="0;" <="" object.width;="" x++){
="" for="" (y="0;" y="" object.height;="" y++{
="" (="" (math.abs((px+x)-(player.x))="">Radi) && (Math.Abs((pY+Y)-(player.Y))>Radi))
{
//Made up function Screen is your backbuffer or where your drawing to, then the X,Y location on the screen, then the source image pixel
SetPixel(Screen,pX+X,pY+Y,Object.image,X,Y);
}
}
}
}
|
|
|
|
|
I have been trying to run this program called mysqlbinlog.exe from my main c# application using the Process class(See example below). The way that mysqlbinlog functions is to read the first file in the command line and pipe the results to the second file.
This works fine when actually run from a command window on XP, but when I try to execute mysqlbinlog from the process class, mysqlbinlog runs but does not pipe the result to the second file. Can anybody see what I may be doing wrong here, or is there some trick that I do not know about. Any assistance or suggestions would be very much appreciated.
private void Form1_Load(object sender, System.EventArgs e)
{
//Declare and instantiate a new process component.
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
// Program file to run
string szProgFile = @"C:\Data\mysqlbinlog.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"C:\Data\rslog.001 > C:\Data\file1.txt";
System.Diagnostics.Process.Start(szProgFile, strCmdLine);
process1.Close();
}
Craig
|
|
|
|
|
View Message Thread (2 replies)
Results 1 - 3 of 3
Piping data when using Process class
From: Tenacious
Date Posted: 5/3/2005 12:22:00 PM
I have been trying to run this program called mysqlbinlog.exe from my
main c# application using the Process class(See example below). The way
that mysqlbinlog functions is to read the first file in the command
line and pipe the results to the second file.
This works fine when actually run from a command window on XP, but when
I try to execute mysqlbinlog from the process class, mysqlbinlog runs
but does not pipe the result to the second file. Can anybody see what I
may be doing wrong here, or is there some trick that I do not know
about. Any assistance or suggestions would be very much appreciated.
private void Form1_Load(object sender, System.EventArgs e)
{
//Declare and instantiate a new process component.
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
// Program file to run
string szProgFile = @"C:\Data\mysqlbinlog.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"C:\Data\rslog.001 > C:\Data\file1.txt";
System.Diagnostics.Process.Start(szProgFile, strCmdLine);
process1.Close();
}
I received this answer from a post I made on another web site and it appears to have fixed the problem:
The problem is that the output redirect, when run from the command line, is performed by the cmd shell. Try altering your program as follows
// Program file to run
string szProgFile = Environment.SystemDirectory + @"\cmd.exe";
// Cmd line arg to pipe results from rslog.001 to file1.txt
string strCmdLine = @"/c C:\Data\mysqlbinlog.exe C:\Data\rslog.001
C:\Data\file1.txt";
Craig
|
|
|
|
|
Hello Code Project Community!
Our Case:
The Customer has to unlock his application by passing a valid combination of a username and his serial number/key which we generated for him, using our own key generator.
Example:
Username: Jack Miller
Serial-#: 0954F43A-90C4AC01-F09951CF-9012387A
Currently we are doing a simple check: We encrypt the Username with a hardcoded salt and check if the result equals to the serial number (this is how we in fact generated it )
We dont need a perfect security here and we know everything can be bypassed but this is currently really enough.
But now we would like to keep additional information inside of the serial number, for example, a License type (would be enough if we have numbers for it from 1 = demo to 4 = enterprise) and also a date for evaluation versions.
So we would like the user to type in his Username and his Serial, and we could show him, that the Serial provided is a demo key, valid until 05.06.2005, for example.
There must be a good practice or strategy how to hide this information inside of the serial number, but we have no idea, because we have to keep the length of the serial number! Can you help?
Thanks in Advance!
Thomas
|
|
|
|
|
Hi!
From your description you're using a one-way encryption, where you only verify that a calculated hashkey matches the one in your serial number.
To be able to do so you don't need a reversible algorithm.
In order to decode the additional information you would need a reversible algorithm. I haven't found a way to decode information without placing the information on how to encode the same information in the same program. So it's always possible to encode modified information in a way that matches your algorithm. Your serial would be breakable quite easily.
The solution I've found to suit my needs best is to use a plain-text license file (XML) that contains a private key signature.
That way I can put arbitrary information into the license file and only have to give the public key in my program.
I can verify that the signature matches the license file's contents (i.e. the contents have not been tampered with) and don't have to worry that anybody can use the public key to compute a new signature.
Regards,
mav
|
|
|
|
|
Hello mav,
first of all thanks for your reply. i guess this is a not so bad attempt how to keep the key quite secure. but i am also missing the direct context to my problem...
Ok, i wrote my little encryption library and just keep the key hardcoded. i know that its easy to retrieve the key by disassembling or just debugging the libraries but currently that doesnt matter at all. So currently i am using the TripleDES symmetrical provider to encode the data. in contrast to the MD5 hash algorithm, where i always get very nice 32-bit strings, which are very usable for serial numbers, the encryption results in varying lengths of the encoded string as "ugly" Base64 Encoded Strings or Hex-Strings, which look better but are also longer.
ok now i could create my object which holds all the information needed, it could be xml-serialized then, and encrypted. but i get a very long encrypted string, much to long: We will send the most of our serials by Fax! I wonder, how i could keep the Serial Number still quite plain, maximum 32-40 Characters, and keep the information stored?
Regards,
Thomas
|
|
|
|
|
If you don't care about anybody finding out the algorithm, key and IV, then the symmetric algorithms in the framework are perfectly OK.
But the size of your encrypted information will be depending on the input data size. I tried encrypting a name followed by a separator character ('#') and a date and ended up with a Base64 encoded string of length 44 to 56.
I didn't manage to reduce the size of output by varying the key size.
Of course, Hex-strings are easier to type than Base64, but due to the limited alphabet are also longer.
You could work on the input data, though.
For example, instead of encrypting the whole name as it is you could just create a hashcode and encrypt this. Follow the hash code with a separator character and append the additional information you want to store.
That way you should be able to reduce the serial key reasonably.
Regards,
mav
|
|
|
|
|
ok, so far... thanks for the great support! * thumbs up *
|
|
|
|
|
Hello,
How do a strip Alpha-Numeric chars from a string?
Thank you.
|
|
|
|
|
I would recommend using regular expressions (System.Text.RegularExpressions ). In particular, look at System.Text.RegularExpressions.Regex.Replace method.
Your regular expression would look something like:
string myString = "Blessed! Happy! Fortunate! Are those who delight in the Lord."
string nonAlphaNumericString = Regex.Replace(myString, @"\w", string.Empty);
After executing the above regex, nonAlphaNumericString will == "! ! ! ."
As an alternative, you can use char.IsLetterOrDigit to determine if a character is a letter or digit, then you could construct a new string without letters or digits.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Currently I'm facing problems displaying Unicode russian characters in RichTextBox controls in .NET 1.1 Windows Forms on a German Windows 2000 (Although normal TextBox controls correctly display russian characters).
When I use this code:
byte[] rawBytes = Encoding.Default.GetBytes( rawRtf );
using ( MemoryStream ms = new MemoryStream( rawBytes ) )
{
this.LoadFile( ms, RichTextBoxStreamType.RichText );
} The output looks like this: rtf-unicode-russian-01.gif (2.6 Kb)
And when I use this code:
byte[] rawBytes = Encoding.Unicode.GetBytes( rawRtf );
using ( MemoryStream ms = new MemoryStream( rawBytes ) )
{
this.LoadFile( ms, RichTextBoxStreamType.UnicodePlainText );
} The output looks like this: rtf-unicode-russian-02.gif (2.6 Kb)
So once it correctly displays the Unicode characters but literally outputs the RTF-formattings and one time it does the other way.
Question:
Can anyone explain whether it is possible to combine RTF text and Unicode characters at the same time?
Thanks
Uwe
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Just guessing here, but would the following work?
this.LoadFile( ms, RichTextBoxStreamType.UnicodePlainText | RichTextBoxStreamType.RichText );
I doubt that could work, since you're simultaneously specifying plain text (unicode) and rich text, which one would think is incompatible. But I might be worth a try anyways.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Thanks for your feedback tip! I tried and although the doc of RichTextBoxStreamTypes does not show that it has the Flags attribute set, it compiles and runs without errors!
Unfortunately the results look bad, i.e. are unusable, i.e. it still renders wrong.
But thanks anyway for your time!
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Hi!
What happens when you use Encoding.Unicode.GetBytes(); but RichTextBoxStreamType.RichText ?
The latter is a must, otherwise the RichTextBox will not evaluate the control sequences like \rtf1 and so on.
The correct Encoding for your GetBytes() call depends on the Encoding you used when you created the rawRtf .
Regards,
mav
|
|
|
|
|
mav.northwind wrote:
What happens when you use Encoding.Unicode.GetBytes(); but RichTextBoxStreamType.RichText ?
Already tried that, creates garbage.
mav.northwind wrote:
The correct Encoding for your GetBytes() call depends on the Encoding you used when you created the rawRtf.
This is a very good hint, I will look at this. Thanks!
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Is it possible to put a "Procedure Line Separator" (line between methods) in C# / VS.NET 2003, just line with VB.NET?
I can't find the option and I think this line helps a lot. If it's not possible with VS.NET, maybe it is with an addin?
Thanks!
|
|
|
|
|
I'm making a simple application which creatres controls (labels and pictures) at runtime. When I create a new control, I add it to the Controls member of the main form. When I create two of them and drag the seccond one on the first, it hides behind it. How can I make it cover the first one? Are there any specific ControlCollection methods to to this?
|
|
|
|
|
You mean make them on same location and view them by BringToFront() method?
If so you can add them by this.Controls.AddRange(collection);
and that collectionmust contain the code that makes them at the same location .
That is if i get it ?.
|
|
|
|