42 Replies
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
You'll need to implement 2 systems
1- a system that renders cells based on an offset
2- a system that maps elements/cells from world coordinates to grid coordinates
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Again you should really not try to create any kind of notion of an "infinite" canvas
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
nice, well done
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
You probably can't have an actual infinite canvas for a problem like this where each cell has state. I imagine there's a lot of scenarios where the "life" propagates infinitely...unless you're limiting the "universe's" lifetime to a few thousand time steps.
There are some WPF infinite canvas libraries like https://github.com/mircea21S/RichCanvas, but they're more for art and less for computational units.
I've done similar for a pixel art editor, but it's not really an infinite canvas when it comes to state either.
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
That sounds unnecessarily memory ineffective
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
How much is the difference now?
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Oh 😅
I meant, surely making the canvas really large would incur more memory usage
You don't have to store stuff as contiguous arrays though, plenty of applications can use something like a
Dictionary<(x, y), Whatever>
- that way you essentially have a "space" to put things in but only if there's anything there.
It's going to have limitations too though.Specifically for Game of Life you can just use a hash set of all live cells since dead cells which do not have any live neighbors don't do anything.
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
If it's general use, then you should provide approaches for both sparse (Dictionary is better here) and dense representations (contiguous types are better here).
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Contiguous means all of the items are consecutive in memory. eg. Array and
List<T>
types are contiguous. Linked lists, dictionaries, (usually) trees are not.
Dense representations mean that the data is dense with information...as opposed to being mostly zeros.
An image would be dense, whereas Conway's Game of Life is relatively sparse.Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Why wouldn't a user be able to retrieve all placed cells?
Those 3 operations can work for both
List<T>
and Dictionary<TKey, TValue>
types.Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
You can.
You can also expose a slightly more convenient method if that's required.
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
What do you mean separately? How is your
Dictionary
defined?Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
You shouldn't need
ToTuple
, just the Item1
.
You might be able to use a named tuple here instead, but I'm not sure.
I'd probably prefer a Point
type as key.Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
It's not obvious unless you're familiar with C# tuples. 🤷♂️
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Just disable the WPF designer and then there's no crash. 

Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
TBH, I'm not even sure how your stuff is working.
You aren't using dependency properties for
InfiniteBoardControl
. You're using standard properties.Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
It's a lot to go through: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/dependency-properties-overview?view=netframeworkdesktop-4.8
Basically, it's a supercharged property that lets you use it from XAML properly with binding and automatic value converter support.
propdp
is the code snippetUnknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
zonedetec#9544
Name: Wpf Infinite Board
Purpose: An infinite and fully customizable grid control where you can navigate and place cells
Main Contributor : Me
Source : https://github.com/zonetecde/WpfInfiniteBoard & https://www.nuget.org/packages/WpfInfiniteBoard/1.0.3
Embed Type
Article
Quoted by
<@!698293804897271809> from #showcase (click here)
React with ❌ to remove this embed.
Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
Still no dependency properties.
eg. Look at
Border
https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Border.cs#L108 and its BackgroundProperty
, too.Unknown UserOP•3y ago
Message Not Public
Sign In & Join Server To View
First,
BorderProperty
there is misspelled. Second, you should already have a Background
dp by deriving from Control
, AFAIK.