WPX component "hex grid"

Jumping into the world of custom WPF controls and wondered what would be the best way to develop a HexGrid control? Think about your favorite board game; or, equally, your favorite video game that steals design from the proud history of board war games.

The model is based on one significant method as part of the map class:

Hex GetHex(int x, int y, int z)*;

Hex contains all the relevant data (at the moment, the Terrain enumeration, which maps 1: 1 to the background color, starting from small ...).

Appropriate restrictions are possible: The
card does not change in size and the Hex data changes in a very predictable time (always in direct response to user actions).

Ideally, a component will expand to fully fill its container and be declared directly in XAML.

What I'm looking for is a schematic diagram of what I need to do to build this, and not a finished component.

* I, although I am pretty smart with this addressing scheme, but apparently I was late for the party .

+3
source share
2 answers

: , . http://blois.us/Projects.html , , pathfinding, Hex Grid, , , , . . Silverlight 3, , . .

Ralph

ORIGINAL: silverlight 2 by peter blois .

. , . .. . .

, google , minysweeper silverlight blois

Peter Blois , ... http://blois.us/Projects.html

, , - .

+1

, WPF HexGrid Panel, UserControl. ( HexGrid - ). , , .

: HexGrid ( )

CodeProject

GitHub

HexList: ItemsControl, HexItem HexGrid

HexGrid: ,

HexItem: ContentControl

:

<hx:HexList Name="HexColors" Orientation="Vertical"
            Grid.Row="1"
            Padding="10"
            SelectedIndex="0"
            Background="{Binding Path=SelectedItem.Background, RelativeSource={RelativeSource Self}}"
            RowCount="5" ColumnCount="5">
    <hx:HexItem Grid.Row="0" Grid.Column="1" Background="#006699"/>
    <hx:HexItem Grid.Row="0" Grid.Column="2" Background="#0033CC"/>
    <hx:HexItem Grid.Row="0" Grid.Column="3" Background="#3333FF"/>
    <!--...-->
    <hx:HexItem Grid.Row="4" Grid.Column="1" Background="#CC9900"/>
    <hx:HexItem Grid.Row="4" Grid.Column="2" Background="#FF3300"/>
    <hx:HexItem Grid.Row="4" Grid.Column="3" Background="#CC0000"/>
</hx:HexList>

hexadecimal color selector

, - oldie,

0

Source: https://habr.com/ru/post/1710729/


All Articles