i have a huge Problem and i donĀ“t know with which methode i should solve it...
The current state of the Program: The User is currently able to create new Items of a ToolMenuStrips during runtime. The MenuStrip ALWAYS has 3 Layers. for example: Parent - Child 1 - Child of Child1. There can be multiple Parents, multiple Childs and multiple Child of Childs, only Rule is they cant have the same name. If i click on the 3. Layer it opens an Event which gives me the Name of the 3. Layer i clicked on. (Note: The ID/Names of the Items are like this : Parent= ParentName ; Child= ParentName+ChildName ; Child of Child = ParentName+ChildName+Child of ChildName) This all works great!
The "Problem" : Now the 3rd Layer (child of child) is created along with some Informations(including a Path and Filename), which are stored in an array. This array need to be bound to the 3rd layer.
My goal: When adding a new 3rd Layer the Filename and Path of it should be add to a list of an Observer who is waiting for new Files with the FIlename to be created in the Folder. (So i have multiple Paths im observing at the same time) Furthermore when the User clicks on a 3rd Layer it opens an instance of a Form, to create the istance of this Form i need to pass the Informations bound to this 3. Layer. Which then will be displayed.
The next steps of the Program:
I need the dynamic created MenuStripItems with the Informations to be stored in settings or XML so the program can load the whole datas again upon different Runtime (closing and restarting the program)
My Question: What is the best way to accomplish this? My ideas:
a.) using tuples -> (its hard to understand and probably garbage coding)
<string Parent, multidimensional array [childs,child of childs], map <string Filename, string Filepath>>
b.) using Model Classes -> Creating dynamic Classes *(I have no clue how to do that, i mean yes 1. dynamic Class = "Parents" Which gets the informations about all the Childs and Child of Childs and the other Informations as parameters on initialization, but how to deal with deleting some elements / adding some to it)
c.) I read something about "treeview" where you can initialize .Node with some Key Values, but i do not know if its the right thing for this?
d.)...?
Maybe this is easy to solve but i am lacking of knowledge... I know this is a farily open question but i have absolutely NO CLUE how this should be dealt with... I had an idea of storing all of it in just 1 Multidimensional Array but this is so messy that i dropped it... Since its hard to distinguish between Parent and its Childs and its Child of CHilds and so on... (a 10 Dimensional array would do though xD)
THANK YOU in advance!
Best regards,
Christian
Edit: Example of the Informations:
Example with 1 Parent (there can be Multiple of them named different than A1 -> A2 for example with the same Name of childs)
A1 // Parent
B1 // child of HG1
B2 // other child of HG1
C1 // Child of B1
C2 // another Child of B1
C3 // child of B2
Now when C1,C2,C3 are created each of them has a List like this:
List ListC1= {StringnameC1,StringpathC1,PictureC1;}
List ListC2= {StringnameC2,StringpathC2,PictureC2;}
List ListC3= {StringnameC3,StringpathC3,PictureC3;}
The Problem is currently i dont save the List i get from a 2nd Form, i just overwrite it when i create a new ToolStripItems ( i need a way to store all Lists and acces them cleanly) And when i Click on the MenuStripItem C3 i need to access the ListC3 with its Items. On Top of that i need a simple way to Store all these Informations during runtimes.
Related
My initial thought was to create an Umbraco Relation and associate the Umbraco Member to the Nested Content node. Sadly, I found this form post asking a similar question and as you can see in Matt Bailsford's first response:
Unfortunately nested content can't have an ID value as they don't truely exist
I did find the issue/feature that was discussed in the forum post; however, it just adds parent information to the DetachedPublishedContent object and doesn't solve my issue. After reading the form post and the conversations of Hendy Racher, Matt Bailsford and Lee Kelleher in the github pull request, I still don't understand why Nested Content doesn't create a node in Umbraco.
So basically I need the Nested Content nodes to be created as Umbraco nodes and then stored as a JSON string in the property field. There are a few ways that I see this could be accomplished:
Create a Custom Property Editor for Umbraco Backoffice - I would start with a copy of Nested Content and add code to create the node and attach it before saving the node as a JSON string.
Use the Umbraco Multinode Treepicker control - This control was suggested by Hendy and Jeavon in this forum post as a way to allow a user to select multiple content nodes. Unfortunately going this route would require the user to create the "nested content" nodes first. Then they could associate those "nested content" nodes with the original node. We really like the user experience of the Nested Content control where it allows you to create nodes dynamically in the property editor.
Find a way to associate the Member to the "Nested Content" node - This option would require that I store an association between the top node and it's respective "nested content" node to a Member in Umbraco. There are two issues that come to mind when trying to go this route:
How should I associate the "nested content" node to the Member in a standard Umbraco way? - I immediately think of creating a link table in the database but, in my understanding, that is not the standard Umbraco way. I am still fuzzy about the best way to do this inside Umbraco.
Is there a way to uniquely identify the "nested content" node? - I realize there is a sort order value being set according to the pull request I found above but if the user reorders the nested content items will it change the "nested content" node to member association?
At this point, I am leaning towards going with option 1, but I wonder if option 3 is a better direction. In reality, I don't believe this is a new problem that someone hasn't already solved, and I hate to create another custom property editor if there is one just like it out there already.
So if you know of a better way to solve this problem please let me know.
The problem is - as you mention it - that Nested Content nodes aren't really real nodes. I don't think the right way to solve your problem is to try hacking Nested Content into doing something it really wasn't created to do.
The problem about creating nodes and also having references to them on the Nested Content node is that essentially every node in Umbraco needs to "live" somewhere.
You could choose to say that a node lives under the parent it is nested into, but how would you then differentiate between nested nodes and actual child nodes - this would require another hack as it is really working around how nodes are meant to be structured and handled in the Umbraco core.
Even if you did manage to get this working, I suspect you would have a lot to deal with to actually make it work as good as Nested Content currently does:
You would have somehow wrap every single node in the Nested Content editor into a object to be able to store meta data like the node ID it is connected to and the sortOrder when reordering all of the nested content nodes you have on there.
(edit: I think it actually already stores some sort of wrapper object here, but you would have to change the logic in here to actually handle a reference to another node instead of just deserializing json stored here, as a node)
You would also have to manually hook into events making sure the actual edits you do while on the parent node actually ends up being persisted to the nested nodes.
Deleting a nested content node, or a parent that has any nested nodes - you would have to handle deleting any orphaned nodes.
There's most likely a lot of stuff I've missed but my point is - you will have a lot of trouble trying to do this.
I think you should consider another approach if you really need to do this:
It would be possible to create a picker similar to a normal node picker, that simply allows you to browse through nodes as a normal picker would do. When you pick a node, instead of just selecting it, it should then fetch the nested content nodes and show those in the UI.
There's however the little quirk that you could essentially be having multiple properties storing each their set of nested content nodes on one single content item - so you would need some nice way of handling this in the UI.
When you select one or multiple of the nested nodes, what your picker would store would be something similar to [guid-of-the-real-node]_[propertyAlias]_[guid-of-nested-content-item].
I am not certain if Nested Content ever got the GUID unique ID/key feature implemented - Matt and I discussed it some time last year and we tried adding it in, in a custom build I needed for a project. If it isn't there I would suggest you ask Matt if he can get that in. It was essentially just giving each nested content item a "fake" unique ID (GUID) that you could use to identify it from other nested content items stored in the property. (You would have to ask Matt about the status of this)
Doing this would allow you to (on your member) have a reference that you lets you find the actual content node, then the property where the content is stored, and lastly the actual nested content node you have picked.
You should however note that this is very prone to breaking and needs a lot of null handling:
If you change the property alias of the property you are storing nested content in on the parent, it will lose the reference.
If you delete the content item storing the nested items, the picked items no longer exist and you have a missing reference in the picker on your member (needs null handling)
If you delete a nested content item - same as above. You have a missing reference in your picker.
Apart from the solution above, I don't really see another way of doing this currently with the requirements you have.
The kind of structure I am talking about is shown in the picture below.
By now my DB contains each item with giver_id (the previous item) | receiver_id (the next item). When I retrieve these items in-memory, I would like to show them in a meaningful way to the user.
I have researched and this seems to be called a "vertex/edge graph". The only option I've found is QuickGraph, and I don't seem to be able to implement it in my WindowsForm application (which is my other constraint).
Anybody knows about any other options to solve this problem?
Note: my solution does not need to be perfect, it will be used internally as a helper to configure the node chain in the DB.
I have a collection that populates a treeview, and I want to add functionality that allows a node to be added with custom properties. Would the best way to go about it to clone the selected node and then edit the properties from there, or to add a completely new blank node?
The following method is how I'm currently trying to add nodes.
public void add()
{
hClass clone = new hClass();
clone = SelectedNode;
Topics.Add(clone);
}
And then I call the method via a command.
It really depends on what you do with these nodes and which pieces of code an access them. Eric Lippert wrote a blog post focused on immutable collections which might shed more light on your problem.
The collection is a set of references (pointers) to the nodes. If you assign an existing instance of hClass to the collection, a change to the instance will be visible in every place that can access it. If you're using it in a WPF GUI, read about Responding to data source changes
I am doing it since last many days but I am not sure how can i build my logic for this in c#. I have to build logic something like this.
For example
The scenario is A has two childs B and C. Now B has no child and C has
childs records of D,E,F . same way it can be at any depth. but lets
for now we are considering this case. Now I am starting from A and
want to find all the descendant elements of A. so the result should be
B,C,D,E,F.
but I am not sure how can i build my logic till n hierarchy. can anybody please suggest. I am planning to start my logic like this
Find all the childs of A
Now For Looop
........
you can sort this out with a simple recursive function.
here is the logic you want. I am not writing the while C# code would be happy to help any questions.
parent send as param
Find all the childs of parent
Now For Looop
check parent has child then write it and call this method again whit parent.child
end loop
in the main of your code call the method with A
I am trying to use/understand Interop.EA and EA class in C# and how to create diagrams programmatically.
I'm working with user data (.XML file (not XMI)) from another web application.
I have tried CSAddinDemo from Sparx and it works fine, but does not show how to add/create new.
My goal is to create EA class diagram form XML data, in C#.
Something like this??
public void EA_create()
{
EA.DiagramObject d = new DiagramObject();
EA.Element e = new Element();
EA.Element elementEa = EA.Element.AddNew("Requirement", "non-functional");
elementEa.Update();
elements.Refresh();
//MessageBox.Show("Class created");
}
First off, you need an EA project (aka "repository") to work in. In order to create a new EA project (.EAP file), use Repository.CreateModel(). In order to open an existing one, use Repository.OpenFile().
Other than the Repository class, which is the top-level class for all interactions with EA, you don't create objects yourself. Instead, you call AddNew() on the various Collections you traverse -- this goes for packages, elements, diagrams, diagram objects, connectors, attributes, tagged values, etc etc.
Repository.Models is such a collection (of Packages).
A Package then contains additional collections, such as Packages, Elements and Diagrams. A Diagram has a collection of DiagramObjects.
A DiagramObject is the graphical representation of an element within one (1) diagram (remember that an element is stored in exactly one package but can be shown in any number of diagrams).
EA does not allow you to create any diagrams or elements at the top level of the package tree (called the root node); you must first create a child package. So at the very least you need to create one Package and one Diagram, a number of Elements and one DiagramObject for each element.
So in the code you've got, AddNew() doesn't work because you're trying to call it on an Element and you need to call it on a Collection.
Your use of Update() and Refresh() are correct, assuming that elements is a Collection. You must always call Update after any changes to an object, and Refresh after any changes to a collection.
There's some good getting-started stuff in the help file. Look in Automation and Scripting -- Enterprise Architect Object Model, and read the section titled Using the Automation Interface.
Then, look at Reference -- Code Samples, especially Open the Repository and Add and Manage Diagrams.
Finally, note that an Add-In is a piece of code which extends EA and is run from within an EA process. This isn't necessary if you want to create a new model or make changes to an existing one; you only need to write an Add-In if you want to integrate with EA's GUI or respond to various events triggered by EA.