|
Helloo all
am using xmltextWriter to write node in xml file
XmltextWriter w=null
w=new Xmltextwriter(-----);
but the problem not in using writer
the problem is
I have listbox have this values
----------
Level1
Level2
Level2
Level2
Level3
Level3
Level1
Level2
Level3
Level4
Level2
Level2
-----------
and soon on
i want to make witer get values for list and write it to xml
every level1 present base node(root node) and sublevels is subnodes
i want be unlimeted level
xml file show be appear like this
<root>
<level1>
<level2/>
<level2/>
<level2>
<level3/>
<level3/>
</level2>
</level1>
<level1>
<level2>
<level3>
<level4/>
</level3>
</level2>
</level2>
</level2>
</level1>
</root>
I want make it recursive;;;;
|
|
|
|
|
Tkml236 wrote: I want make it recursive;;;;
Sounds like a TreeView might go along with want you want better than a listbox will.
|
|
|
|
|
no ...data is stored in listbox
(my real problem is stored in othere place but i simplifeid the problem to me clear)
i went to get data and write it in XML
|
|
|
|
|
It's easy.
In this routine, you will iterate throught the items in the listbox, fetching their values one by one.
Now i assume that you are getting the info on which list-item is a child and which is a parent from the value of the listbox item. In that case, you need to assign all items in the list box with a unique level number (depending on their nesting in the XML). Based on this, when you iterate through items in the list box, you would know which item to nest under which node and at which level.
It won't help much by trying to make this recursive. Keep it simple and straight. Any by the way, it's pretty hard understanding your written english Please be a little more clearer with your questions.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
ok..how can I solve this problem if I have unlimeted nested levels for level1
please see the example it will be clear for you?
|
|
|
|
|
As I said.... If you have unlimited nested levels for level 1, keep on making a list of all the nestings that you have already written in a stringdictionary or so. the key wud be level number and value would be name, in the StringDict. This list will kee on growing as your list size. if ur list item is unlimited, recursive is a real bad idea since it will give you stack overflow soon enough. Putting in a bit of logic to use a normal collection instead of a recursive stack is a much much better idea for unlimited list items.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
but how can I do that ...did you use xmlTextWriter?
I want to use it for writing in xml???
|
|
|
|
|
Dear friends,
In my organization, the employees are sending me messages through net send command . I want to create a application or sercive to listen all the messages and save it in the database.
( Because the messages are like requests. so we need record of them.
at last we need to give report to the authority)
If you have ideas and solutions plz give me.
thanks in advance.
By
Joe
|
|
|
|
|
You would be better blocking off the Windows Messenger Service in your box.
That will disable the net send command operation since that is a sensible thing to do since it can be easily used by spammers and exploited. Vista has this blocked by default.
However, if you still wanna capture the net send message, then you will need to coide for the Windows Messenger Service using the API's to listen to the same. Net Send uses the NetBEUI protocol and you will need to code in COm for capturing the message through the exposed Interfaces of the API.
Another easy way would be to observe the net send popups displaying and capturing the message in it. There is also a sample around it: Check this out http://msdn2.microsoft.com/en-us/library/ms940840.aspx[^]
Accept the reply if it helped you!
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
sorry for the late replay
thank u for u r replay.
thanks a lot.
|
|
|
|
|
Hello everyone,
I am trying to read a CSV file and place its data into a ListView. Each line of the CSV file contains 4 values seperated by comma. Can someone tell me how I can place each value under its correct column as I have 4 column in the ListView?
I am using the following code and that is going to populate the first Column with the four values.
StreamReader streamReader = new StreamReader("MyFileList.txt");<br />
while (streamReader.ReadLine() != null)<br />
{<br />
listView4.Items.Add(streamReader.ReadLine());<br />
}<br />
<br />
streamReader.Close();
Thank you very much for your help and have a great day.
Khoramdin
|
|
|
|
|
Perhaps this will do the trick:
<br />
StreamReader streamReader = new StreamReader("MyFileList.txt");<br />
<br />
while (streamReader.ReadLine() != null)<br />
{<br />
ListViewItem listViewItem = new ListViewItem(streamReader.ReadLine().Split(new char[] { ',' }));<br />
listView4.Items.Add(listViewItem);<br />
}<br />
<br />
streamReader.Close();<br />
|
|
|
|
|
OK, forget the Dog/Vet metaphor I posted yesterday.[^]. It was the easiest way to describe my original question which was general in nature and not specific to my problem. Here is the actual scenario.
I have an editor (type of data being edited is irrelevant). In this editor, I want to support undo/redo operations. I have employed the Command pattern for this purpose. All changes to underlying data must be encapsulated in a command object. For example, to set text you would create a SetText command and call its “Execute” method. To undo this operation, you would call the SetText object’s “Unexecute” method.
This architecture is working really well but it has one flaw. Every time an engineer executes a command he is responsible for managing command history (i.e. the undo/redo stacks). If the execution is successful, he MUST add the command to the undo stack. If the execution fails, he MUST NOT add the command to the undo stack. If the execution throws an exception, he MUST CLEAR THE STACK as we cannot allow the undo stack at any time to be out of sync with the application state (this logic is somewhat simplified for the purposes of this post).
If the engineer forgets to do any of these things he poses a risk of undefined behavior in the application. Furthermore, the logic will be the same for every command that gets executed, so there’s no need to write this command-history-management-logic every time a command is executed.
In steps the factory pattern. The factory encapsulates the creation of commands. Because the factory controls the creation of the commands, it can setup a relationship between the UndoManager class (manages command history) and each command that gets created. Voila!
Now here’s my problem (and perhaps it’s not a problem at all. Perhaps this is where I’m rubegoldberging). Any engineer can create a command and execute it. If the UndoManager class has no knowledge of this command, he cannot manage it and the undo history could get out of sync with the application state. Obviously this is really bad.
To solve this problem, I have nested a private UndoManager class in the command factory. This class implements the IUndoManager interface. All commands require an IUndoManager at construction. So, because the UndoManager is private to the factory, only the factory can create commands. For example, to create a generic command:
public ICommand GetGenericCommand()
{ return new GenericCommand(this.undoManager); }
It is true that any engineer could implement IUndoManager and then begin creating rogue commands, but this is unlikely.
I would love to hear comments on this solution. Am I being overly cautious? Is this a hack? Or have I implemented a reasonable safeguard in a reasonable fashion? Is there a pattern that matches this solution? (Hopefully not an antipattern… )
Thanks!
|
|
|
|
|
Edmundisme wrote: I would love to hear comments on this solution.
Sounds reasonable to me.
led mike
|
|
|
|
|
Edmundisme wrote: This architecture is working really well but it has one flaw. Every time an engineer executes a command he is responsible for managing command history (i.e. the undo/redo stacks). If the execution is successful, he MUST add the command to the undo stack. If the execution fails, he MUST NOT add the command to the undo stack. If the execution throws an exception, he MUST CLEAR THE STACK as we cannot allow the undo stack at any time to be out of sync with the application state (this logic is somewhat simplified for the purposes of this post).
If the engineer forgets to do any of these things he poses a risk of undefined behavior in the application. Furthermore, the logic will be the same for every command that gets executed, so there’s no need to write this command-history-management-logic every time a command is executed.
In steps the factory pattern. The factory encapsulates the creation of commands. Because the factory controls the creation of the commands, it can setup a relationship between the UndoManager class (manages command history) and each command that gets created. Voila!
I was about to suggest that the logic for managing the undo stack be placed in the commands, i.e. when a command is executed, it's responsible for placing itself on the undo stack (or not depending on the results). But it sounds like you've solved this problem?
Edmundisme wrote: Now here’s my problem (and perhaps it’s not a problem at all. Perhaps this is where I’m rubegoldberging). Any engineer can create a command and execute it. If the UndoManager class has no knowledge of this command, he cannot manage it and the undo history could get out of sync with the application state. Obviously this is really bad.
Underlying the commands is a document of some type that is being acted upon, correct? You're concern is that rogue command objects can be created that execute an action against a document. Being rogue command objects, they're not being managed, so they're never placed on the undo stack? As a result, a document's history could become corrupted.
The question is how could a rogue command object obtain access to the document in the first place?
I haven't looked at GOF in awhile regarding the Command pattern as it's applied to undo functionality, so I'm not sure how they implemented it. But how about the document itself being responsible for creating commands. The document has several private Command classes that implement an interface. And perhaps the document holds an UndoManager object for managing the commands.
When a client wants to execute an action against a document, they first ask for the appropriate command. The document gives them back a command it has created and is responsible for. The client, however, only sees the command object through some generic interface. This approach makes rogue commands impossible.
Edmundisme wrote: To solve this problem, I have nested a private UndoManager class in the command factory. This class implements the IUndoManager interface. All commands require an IUndoManager at construction. So, because the UndoManager is private to the factory, only the factory can create commands. For example, to create a generic command:
public ICommand GetGenericCommand()
{ return new GenericCommand(this.undoManager); }
This may be close to what I've suggested above, I'm not sure. I need to know more about how the actual document, or model, is being used by the commands.
|
|
|
|
|
I like your suggestion about encapsulating the document access - forcing modifications through a single access point. Unfortunately I'm adding Undo/Redo to an existing application and this solution would require a complete rework of the document management.
Basically, if I can get everyone to understand that all modifications must be done via command objects we'll be OK. However, any code at anytime could directly change the document...
Thanks for your ideas!
|
|
|
|
|
Hi,
I need to develop a commercial use application and I found
some code source that is under GNU version 2, license term agreement.
For GNU, does it mean that I can incorporate the binary format (the dll)
of the code (I didn't modify the source code) into my application
without contributing back my application source code ?
Thanks
|
|
|
|
|
As far as I know using GNU code forces you to label your application GNU too.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
I beleive that under both GPL and GNU open source liceneces, you must make your source code freely available.
Linksys found themselves having to publish the source code for thier router firmware:
http://www.wi-fiplanet.com/tutorials/article.php/3562391
Hope this helps
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
But the case is that I doesn't modify their source code, just use it as a dll, and this will lead to open source my part of application code also ?
|
|
|
|
|
Yes. There might be a slight hope for you if and only if you only use the library only, and not the source code (including not using any header files), ie maybe if you were doing something like distributing a GPL plug-in dll for your application, you might be safe from open-sourcing your product. Even in that best case scenario, you might still lose, and you definitely would be open to legal problems.
More than likely (say you used a library like the GNU Scientific Library, which does things like solve equations, and which has a GPL license), you would have to release your entire product under the GPL license. That means two things. The first is that whenever you give your software to someone, you have to include all the source code (I dont know whether it would include things like associated media files). Secondly, whoever legally obtains your software/source code can redistribute it in original, or modified form (which themselves has to be GPL).
Basically, unless you want to have your application be put on Sourceforge, when the first person who buys your software decides to fork your project, (and as someone who makes my living writing OSS, I have to say there are some great, though not always applicable reasons for doing this) DO NOT INCLUDE THAT CODE IN YOUR APPLICATION, either in modified or unmodified form.
|
|
|
|
|
I'm trying to use the the following code to show pdf or xls file generated by ReportViewer.
After application closes, temporary files remain in disk.
How to delete PDF files after Adobe Reader is closed ?
Is the best way to save pdf files to temporary directory and delete whole directory if application exits or use filewatcher?
Any sample how to implement this ?
void ShowPDF( byte[] bytes ) {
static int i=0;
string outputfile = "temp"+(i++).ToString()+".pdf";
FileStream fs = new FileStream(outputFile, FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
System.Diagnostics.Process p = new System.Diagnostics.Process();
p = new System.Diagnostics.Process();
p.StartInfo.FileName = outputFile;
p.Start();
}
Andrus
|
|
|
|
|
Hi,
I have a preview form for several type of contents.
I want to adapt the form size to the contents size dynamicly.
For example, I have a mediaPlayer COM named mpPreview.
I tried to do this:
this.Size.Height = mpPreview.Size.Height;
But it gives me the following error:
Error 1 Cannot modify the return value of 'System.Windows.Forms.Form.Size' because it is not a variable D:\Os meus documentos\Visual Studio\Coordinator\Preview.cs 78 13 Coordinator
Why?
Thx,
Nuno
|
|
|
|
|
Try using this:
<br />
this.Size = new Size(this.Size.Width, mpPreview.Size.Height);<br />
|
|
|
|
|
To understand the reason why C# prevents you from doing this, you need to understand the basics of value types (or structures).
Unlike reference types, when value types are returned from methods (or set via an assignment), a copy of the value type is returned and not the orginal version.
In the situation above, Form.Size is a property (which is a method underneath) and it returns the Size value type.
So when you attempt to assign a value to Size.Height, you are actually attempting to assign it to a copy and not the underlying Size structure.
Although, it is technically valid to do this, the C# compiler makes the assumption that this is not what you want to do, and hence fires the compiler error.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|