|
I have Labels controls with some properties set in an ArrayList. I want to be able to easily qrite and read it from a file. Is Label serializable or do I have to mess with it's properties, store them as strings and use o lot of string handling while reading it from a file? Is ArrayList serializable?
|
|
|
|
|
Why don't you try? It should be.. as it derives from Control , and Control has SerializableAttribute attribute, and I don't see Inherit=false anywhere - so derived classes (e.g Label ) should be seriazable
Anonymous wrote:
Is ArrayList serializable?
dunno... look at MSDN.com, search for ArrayList ... if you see [Serializable] as attribute in class declaration, than it is forshizzle serializable.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Yes to both. You can figure the answer out yourself for other classes by looking to see if the base classes implement ISerializable or have a [Serializable] attribute.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Contrary to what dnh and Marc say above, Label s (or any other Control s) are NOT serializable. ArrayList s are serializable, but how much success you have depends on whether the objects contained inside are serializable.
Take a look at my article Themed Windows XP style Explorer Bar[^] for a way to get around the "Control s aren't serializable" problem. Also, it's probably wise to read what MSDN has to say about serializing[^]
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I need to do something like the following. The problem occurs because the Class library doesn't recognized the "CMainForm" class. I can make things compile and work if both classes are in the same file but I need them to be in separate files.
I can't use the "namespace" directive because the CMainForm class isn't a DLL/library.
Any help would be greatly appreciated.
Carol
File #1. EXE
---------------------------------------------------------
namespace ExampleCode
{
public class CMainForm : System.Windows.Forms.Form
{
}
}
File #2. DLL
---------------------------------------------------------
namespace MyClassLibNamespace
{
public class MyClassLib
{
CMainForm m_MainForm;
public CFactory(CMainForm MainForm)
{
m_MainForm = MainForm;
}
}
}
|
|
|
|
|
Sorry. I had a typo in my initial code. here's the same code with a minor correction:
File #1. EXE
---------------------------------------------------------
namespace ExampleCode
{
public class CMainForm : System.Windows.Forms.Form
{
}
}
File #2. DLL
---------------------------------------------------------
namespace MyClassLibNamespace
{
public class MyClassLib
{
CMainForm m_MainForm;
public MyClassLib(CMainForm MainForm)
{
m_MainForm = MainForm;
}
}
}
|
|
|
|
|
Add a reference to your dll in the IDE and then place them in the same directory and they will work.
|
|
|
|
|
hi,
you have to add reference to your aplication (to reference assembly in which CMainForm is defined) - because they are two different projects. Hope I won't make idiot from myself when I say you can reference .exe (.NET assembly) - in case you can't then* move your CMainForm to class library... you can then reference library in your application. (right click in project explorer ->Add reference->project tab) - or like that.
* just checked, you can't add reference to anything but .dll
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I have a dillema: I am writing 2 programs, and among others they use some classes which are the same. I have two choices: copy the cs files to them both, or create a Dll with them? Is it possible to do so? How? Thanks in advance!
|
|
|
|
|
It's possible...
Create a class library project...put your code into it...compile it, then reference the assembly in your other projects.
|
|
|
|
|
Ok, but what means "reference the assembly"?
|
|
|
|
|
Right click on your project in Project Explorer (if you have VisualStudio(.NET) - if not, read documentation to your IDE) and select "Add reference" Then there should be tab "from project" and list of your projects in solution.. select your class library and double click or something (I don't have VS opened now) and you should add reference to your library ( = assembly)
hope it helps.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I have a DLL I wrote that uses a web service. I set the 'Web Reference URL' to dynamic. I see in the app.config file that the value is present.
My problem is when I compile the DLL the config file is not generated.
Question #1: Is this normal behavior for a DLL.
Question #2: Could copy and rename the app.config file to '<assemblyname>.dll.config' and the DLL use it normally?
Any help would be greatly appreciated!
Thanks in advance!
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.
|
|
|
|
|
There are no config files for .DLL's like there are for applications (app.config.) Any settings code you write would be looking at the host application's config file, whatever that may be.
And your signature should be fixed:
I reject your reality and substitute my own
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
Any settings code you write would be looking at the host application's config file, whatever that may be.
I thought that to, but it doesn't seem to be true. So I guess the only true way of doing this would be to modify the Web Reference source file and modify it's constructor to require the URL to the web service. The only problem with this solution would be when you update the web reference then this file would be recreated and the changes would be lost.
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
|
|
|
|
|
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
|
|
|
|