Visualize graph algorithms (step-by-step) with data binding in WPF - wpf

I'm developing an WPF application that models the graph algorithms. I use ListBox with DataTemplates to display the graph by binding it to an ObservableCollection of Nodes and Edges. At this stage, everything is displayed correctly but the algorithm cannot run step-by-step! I have searched and tried many, from BackgroundWorker to Dispatcher, but nothing worked!
So, how can I make the algorithm displayed step-by-step? Is it possible to do with data-binding? Or must I choose another way to render the graph?
In WinForm, there is Sleep() to stop on each Node for an amount of time and do some rendering tasks, then move on. But I think that solution only works if the algorithm and rendering task are mixed together.

Related

WPF - Interactive real-time rendering(C#)

I am currently working on a project where i want to display data of a game and my own graphs on a rebuilt minimap.
The data is given as ticks of the game with the entitydata changed in that tick. At first i want to draw the map and then all entities existing at the first tick. Then for every tick i want to update positions and draw lines between entities
My WPF User Interface is set up with the MVVM Pattern.
Now i am struggling with the creation of and techniques for the minimap.
What i want the minimap to support/create:
Interactivity
Click on entities on the field to display more information about them.
Zoom the map
Follow entities(with a zoomed in game field)
Toogle different visuals (disable one team, highlight sth etc)
...(and other interactions like the above)
Performance
Graphics should look as smooth as possible(Map,Images, anti-aliasing, no stuttering)
High framerate (at least 30FPS)
At best it should be a solution with most of the above features built in(see 1.)
Exporting screenshots and a video of the whole game(with my own graphs and stuff)
What i already considered(from this post WPF real-time rendering)
Data binding and canvas
Problem: Slow and not performant..at least as I implemented it)
- WriteableBitmap(Problem: No funcitionalities built in(see 1.)
DrawingVisuals
Problem: How to realize as MVVM? Is it efficient?
WriteableBitMap
Problem: I have to build the functionality of 1.) on my own. But looks like it is efficient
Before i start implementing a lot of my wanted features myself i wanted to ask if there is anything fitting my needs or if any of the above technologies is not suited.
I hope that my question is clear enough.
Feel free to let me know if anything is missing.
DataBinding is nice for connecting view models to input controls, but not for updating the state of graphic objects in real-time.
I would go with DrawingVisual because it is relative lightweight and supports hit testing. Even if you don't have MVVM support, it is easy to update the visuals "manually".

Panel Control Windows Forms

I am just wondering if anybody knows anything about the speed of the WinsForms panel control relative to the number of controls placed in it.
I have panels that I need to populate with hundreds of controls and it seems to slow down exponentially. I have tried making the panel invisible when populating it and this doesn't seem to help.
I am asking for two reasons:
To determine if this slow down is the result of the panel control or
a quite complicated (for me) bit of code that is handling the panel
and adding the items to it.
If it is the result of the panel, then I would like to determine if there
is anything I can do about it. I am quite a ways into the project
and the project depends upon panels that contain these controls.
Thanks for your time.
My level of expertise is fairly amateur BTW.
You have not shown your code to load the panel. Moreover you need to add more information in your problem about the controls and loading process. With general assumptions, to speed up you can do :-
Lazy load. User will not interact with hundreds of control at a given time. So, load the controls on demand.
Populate the controls in background thread, and make them ready just before they are required to be shown.
Load them based on the priority of the user interaction.

UI Intensive Application

In my program, there is a map editor, after loading the information from the database, I need to generate some custom controls (6000-10000 depending on the map). Unfortunately it locks the user's screen for 10-20 seconds.
How can I do using lazy loading? How can I do without crash and lock screen?
This question is much to broad. But i can give you a number of hints.
First of all i'am pretty sure you don't need so many custom controls. Think about how many input devices the user has, he can't interact with that many controls at the same time. So you can "cheat" about these controls in a couple of different ways. For example, display an image of the control, and switch it if the user starts to interact with it.
Another thing is, you don't need what you don't see. Why create a list of 10000 Elements if only 10 will fit on the screen? There is no reason, thats why there are ways to mitigate that, one is called Virtualization which can be done in a number of ways. You can use UI Virtualization, by defer the loading of the ui components or use data virtualization.
Another thing, in cooperation with data virtualization is to use threads or a background worker to handle the load of that much data. Create your data in batches to give the UI Thread time to handle the windows messages.
Look into Binding or doing the work in a Background thread?
If they are in a ListView, look into VirtualMode:
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.virtualmode.aspx
What are you loading these controls into? Are you doing it in the UI thread?
Use TPL (Task Parallel Library) to do the DB tasks on a separate thread... it looks like this:
Task.Factory.StartNew(() => MyLongRunningMethod));
Check out this great article over on CodeProject for more information...
EDIT: As noted below the original answer implied that somehow controls can be generated on a separate thread but in reality as a part of the visual tree and therefore the UI, controls must be generated on the UI thread so that was not a valid suggestion...
EDIT: Don't see how it would be possible to fit 10000 custom controls on a signle screen so there must be a way to use some type of virtualization schema where only visible controls would get generated and the rest of the controls would get generated on demand...

What kind of WPF composition would I need to implement a two way node diagram?

I shall create a visual component to display and navigate a large network of nodes. Nodes have input terminals and output terminals. The total network is too large to be displayed on a single screen.
I see that GUI component vendors have visio-like flowchart/diagramming components for free form placement. It's not exactly what I am looking for. The output should look flowchart-ish, but the functionality is more of a bunch of listboxes / stackpanel / treeview control. I suppose I could make this into a grid or something so that everything should reposition itself dynamically as the user navigates and expand sections, but it is unclear to me how I would then make the connection lines "follow" the item that it is connected to. The nodes are of various types, so there should absolutely be some kind of visual template selection (like datatemplate).
I assume that the topic of visualizing interconnected nodes is a general problem. I've also learned that WPF layout panels are powerful if you apply them correctly, so I am hoping somebody who are more versed in their functionality will be able to break it down into a sensible composition of controls.
BTW I have the Telerik UI RadControls for WPF.
Do you have any tips or solution for how this functionality can be achieved by composing WPF (and/or Telerik) controls?

Silverlight Organisation chart control

Anyone know which control they used on this site to get the Organisation chart? http://www.yworks.com/products/yfilessilverlight/SilverChart.html
Or any other controls that are similiar?
If not, could you suggest a way on how to get started building one? (Interface-wise, I think I know how to get the data binding to work).
The organisation chart control is their own, thats whole point of the demo page.
The UI elements involved are quite simple rectangular items. The real trick is calculating their placement on panel and routing the connecting lines.
I guess the missing peice of the puzzle is what generically we would call that. If you know that then you have a basis for a web search for algorithms for doing this sort of thing either academically or in some other product entirely, then bring that knowledge to your own Silverlight code.
Alternatively you could just go out buy the product.

Resources