|
BillWoodruff wrote: What do you think: can anyone else benefit ?
I hope not - that has "kludge" written all over it!
I understand why you are doing it, and as long as you document in well it won't be a problem, but it's an...um...inelegant solution.
I am really surprised that byte[] or stream data rather than string aren't the default inputs to a serializer, but hey! What do I know
Out of interest, is it a well-known 3rd party control set?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
^upvotedOriginalGriff wrote: Out of interest, is it a well-known 3rd party control set? Hi OG,
It's a very lesser known specific control in a "suite" that (undeservedly, imho) is not as well known as it should be: definitely not in the Telerik, DevXPress, league, etc. It does not include a grid/Excel-thingee, though. It also costs a fraction of the cost of the big-name suites
In fairness, I should mention that I have not yet tried seeing what I could do to custom serialize the 3rd. party control in toto myself, and that there are some other avenues I have not yet explored using other features in the control to possibly "bootleg" in my custom objects: so, in no way am I complaining about the control/suite !
The developer, who's become a good friend over the last six years, is very responsive, and is thinking about the scenario I have, and what he might do in the future to make it easily possible.
The control, as is, supports serializing its entire state/content to either an XML file, or an in-memory stream, or to an SQL compatible format. I'd call that a more than "half-full cup," rather than "half-empty"
What I have working right now, is, I agree with you, a "kludge," but it is working quite well under a modest test load: by "load" I mean with a few hundred instances where I am creating a custom sub-class of the "atomic element" of the control to which I've added my own custom classes.
Again, thanks for your responses.
cheers, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
modified 29-Jun-13 23:14pm.
|
|
|
|
|
Have you considered Base64 encoding via Convert.ToBase64String/FromBase64String. It's guaranteed to give a reversible Byte[] <-> String conversion.
Alan.
|
|
|
|
|
^voted
Thanks, Alan, I will try out Base64 encoding.
yours, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
BillWoodruff wrote: I am successfully using a BinaryFormatter to serialize, and de-serialize, instances of a moderately complex class.... I need to get the in-memory serialized stream into a string, and, later, convert it from string format back to MemoryStream.
Doesn't matter why. It is a bad idea.
If you want a class serialized into a string (versus attempting to force binary into a string) then either create a customer formatter, or use json or xml.
|
|
|
|
|
^voted
Thanks JSchell, for your response.
As you might see, if you read my responses to OriginalGriff's responses, there are reasons I tried this strategy first, compared to XML, or JSON, and I did mention that a next step I will pursue is trying out Mehdi Gholam's remarkable FastJSON facility here on CP.
I have never written a custom formatter (and hope not to), but I suspect it would be more work than the current experiment with Byte[]=>string, which "boils down" to a surprisingly small amount of code.
In prototyping, I prefer to think of trying different types of implementation, in a case where I am constrained by the factors I am constrained by now, as "expedient experiments:" only when they prove useful/efficient, or less useful/efficient, in comparison with other implementations, do I evaluate them, and even then, I wouldn't use the word "bad"
yours, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
BillWoodruff wrote: with Byte[]=>string, which "boils down" to a surprisingly small amount of
code.
It isn't a matter of implementation. It is a matter of mapping.
There is binary data that will not map into a string in such a way that one can reverse the process.
|
|
|
|
|
Dear Sir/Madam,
I wrote a function as follow:
public void ShowValueOnGrid(DevExpress.XtraGrid.GridControl grd)
{
String sValue="";
int m=0;
DevExpress.XtraGrid.Views.Grid.GridView MyGridView = new DevExpress.XtraGrid.Views.Grid.GridView();
grd.MainView = MyGridView;
MyGridView.GridControl = grd;
for (m = 1; m <= MyGridView.RowCount; m++)
{
sValue = Convert.ToString(MyGridView.GetRowCellValue(m,“InvoiceNO"));
MessageBox.Show(sValue);
}
}
I don't know why sValue contains nothing althought the I have just inputed data in InvoiceNo column on this grid control.
Please help me!
|
|
|
|
|
DevExpress.XtraGrid.Views.Grid.GridView MyGridView = new DevExpress.XtraGrid.Views.Grid.GridView();
You have created a new empty grid in this function, so none of the cells will contain any data.
Use the best guess
|
|
|
|
|
Dear Mr.Richard MacCutchan,
Thansk for your instruction
I want to get cell value on some grid via only one function
so the input parameter of this functon is a grid. How to get cell value on the grid(input parameter)?
Help me please
|
|
|
|
|
Just like it is ok
public void ShowValueOnGrid(DevExpress.XtraGrid.GridControl grd)
{
String sValue="";
int m=0;
for (m = 0; m <= ((gridview)grd).RowCount; m++)
{
sValue = ((gridview)grd).GetRowCellValue(m,“InvoiceNO").toString());
MessageBox.Show(sValue);
}
}
|
|
|
|
|
Member 2532800 wrote: I want to get cell value Check the documentation for the method(s) to access individual cells.
Use the best guess
|
|
|
|
|
I understand how to create animation like pacman, but to move the pacman, I can only think of using location.
Problem is, how could I know there is obstacle or not?
|
|
|
|
|
Ultimately, the object will have a coordinate. This could be used to perform a rudimentary collision detection. The process could be as simple as this:
public class BaseGameObject
{
public int X { get; set; }
public int Y { get; set; }
}
public class GameObjects : BaseGameObject
{
public List<BaseGameObject> GameObjects { get; set; }
public BaseGameObject HitTest(int x, int y)
{
foreach (BaseGameObject gameObject in GameObjects)
{
if (gameObject.X == x && gameObject.Y == y)
{
return gameObject;
}
}
return null;
}
}
|
|
|
|
|
Thank you very much for the help.
I will try to understand it as I never use get set or that kind of class.
|
|
|
|
|
What you are looking for, as the above poster pointed out, is Collision Detection, you should be able to find plenty of sources on it, I will list a few:
Collision Detection[^] on wikipedia (theory)
Testing for Collisions[^] on MSDN, this is for (the now unsupported) XNA Framework
Pacman in C# (map & collision detection)[^] A question here in CodeProject
C# Game Programming for Teens[^] In this book you will follow the chapters to make a 2D Dungeon Crawler. Chapter 4 deals with collision detection
EDIT:
If you are using sprites (which I guess is the case) you have to check if the object's rectangle intersects with any other object's rectangle, take into account that the rectangle also counts the transparent pixels of your sprite. You could do your own way of checking for an intersection between two rectangles, but you can use the IntersectsWith[^] method.
If your object is non-player controlled, it most likely has a velocity, so you can predict the collision by calculating the coordinates for the next iteration and checking for intersections with those coordinates.
Example:
Player controlled object:
public class PlayerObject
{
public Point Location {get; set;}
public Size ObjectSize (get; set;}
public Rectangle Bounds {get; set;}
public PlayerObject(Point loc, Size objSize)
{
Location = loc;
ObjectSize = objSize;
Bounds = new Rectangle(Location.X, Location.Y, Location.X + Size.Width, Location.Y + Size.Height);
}
public bool IsColliding(ref GameObject obj)
{
bool collides = Bounds.IntersectsWith(obj.Bounds);
return collides;
}
}
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
Hi all,
please excuse that I like to get your attention to my post in the "Regular Expressions" section . Unfortunately, the forum there seems to be fairly unattended... to avoid crossposting (to the sensible extent), I put my question there, hoping someone of you helps me out of some more sophisticated (I guess) regex stuff.
Thank you very much,
Mick
|
|
|
|
|
Michael Schäuble wrote: to avoid crossposting (to the sensible extent) Avoiding it? I also came across the same question in the VB.NET forum.
Michael Schäuble wrote: but I urgently need a solution very soon. Ah, so it's allowed because it's urgentz?
Sorry, I'm gonna skip this one.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
SORRY, I meant that I'd deleted this post as well as the original question in the "Regular Expressions" forum, which I saw didn't have any questions or answers since february... BTW deleting both of them was my only idea after I saw how someone anonymously downvoted my question in the C# forum - why it didn't work here I can't tell, deletion of the original obviously worked (broken link).
But instead of ranting, you might at least give your advice on how you would stay with the forum structure and still reach someone of the community who might even be in a better mood and willing to help.
It seems that this post isn't deletable anymore now (maybe because of your helpful answers). But it's been downvoted anyway... So thanks for your time - and have a better weekend.
|
|
|
|
|
Michael Schäuble wrote: But instead of ranting, you might at least give your advice on how you would
stay with the forum structure and still reach someone of the community who might
even be in a better mood and willing to help.
Most readers will check multiple forums here; it's annoying to come across the same question over and over. The board also highlights the places with "new" messages, so it kinda feels impatient.
Michael Schäuble wrote: (maybe because of your helpful answers)
Yes, could have been friendlier. Make that "should have been".
Michael Schäuble wrote: So thanks for your time - and have a better weekend.[Rose] Enjoy your weekend
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This post serves no purpose, and your link appears to be broken. Please follow the rules and post in one place only.
Use the best guess
|
|
|
|
|
SORRY, Richard,
I meant that I'd deleted this post as well as the original question in the "Regular Expressions" forum, which I saw didn't have any questions or answers since february... BTW deleting both of them was my only idea after I saw how someone anonymously downvoted my question in the C# forum - why it didn't work here I can't tell, deletion of the original obviously worked (that's the reason for the broken link - but I update the link, that really makes sense..).
Maybe you can recognize my attempt to follow the rules.
I'd posted the original question in the VB forum, as I said meaning to have the other ones deleted. Now it seems that this post isn't deletable anymore now (maybe because of being answered now). I will if you can tell me how to do it.
Thank you still [Rose]
|
|
|
|
|
Michael Schäuble wrote: I'd posted the original question in the VB forum But that was still the wrong place.
Use the best guess
|
|
|
|
|
I've tried my best first, by putting the question into a completely unattended forum and linking to it. What would you suggest to do in such a case? Wait another four months? I wonder why unattended forums aren't closed down...
And: Can a place which is visited be a wrong place, anyway? My posting there resulted in a good, simple and working solution of the problem some minutes ago, from someone who looked at the question itself instead of judging helpless attempts to follow the rules for the remaining rulebreaking. I guess that's what a forum needs and what other searchers want to read even after years, right?
I'm German and know a lot about useless formalities - this seems like one of them. All I did was what you yourself write in your signature:Richard MacCutchan wrote: Use the best guess Have a nice weekend, still!
|
|
|
|
|
Michael Schäuble wrote: I've tried my best first, by putting the question into a completely unattended forum There is no such thing. Each forum is dedicated to a different subject and peple who are interested in that subject will visit those forums in their own time. The site makes no guarantees about responses or their validity.
Use the best guess
|
|
|
|
|