대괄호 토너먼트 테니스 스타일을 자동으로 생성하는 asp.net 페이지를 만들어야합니다. 데이터베이스의 일치 관리와 관련해서는 문제가되지 않습니다.토너먼트 브래킷 알고리즘
문제는 대괄호로 동적 그래픽을 만드는 것입니다. 사용자는 2-4 ... 32 명으로 토너먼트를 생성 할 수 있습니다. 실버 및 그리드를 사용 그리고 내가 HTML 또는 GDI의 그래픽 브래킷을 만들 호 모른다 ...
대괄호 토너먼트 테니스 스타일을 자동으로 생성하는 asp.net 페이지를 만들어야합니다. 데이터베이스의 일치 관리와 관련해서는 문제가되지 않습니다.토너먼트 브래킷 알고리즘
문제는 대괄호로 동적 그래픽을 만드는 것입니다. 사용자는 2-4 ... 32 명으로 토너먼트를 생성 할 수 있습니다. 실버 및 그리드를 사용 그리고 내가 HTML 또는 GDI의 그래픽 브래킷을 만들 호 모른다 ...
, 당신은 같은 것을 생성 할 수 있습니다 : bracket display http://i32.tinypic.com/30uqywy.jpg
그것을 할을하는 정의 Grid를 포함하는 일반 UserControl입니다. Silverlight 3.0 SDK를 사용하여 VS2008에서 Silverlight 응용 프로그램을 빌드 할 때 기본값입니다.
그리고, 사용자 제어를위한 생성자 다음에 호출을 추가 위에서
private void SetupBracket(int n)
{
var black = new SolidColorBrush(Colors.Gray);
// number of levels, or rounds, in the single-elim tourney
int levels = (int)Math.Log(n, 2) + 1;
// number of columns in the Grid. There's a "connector"
// column between round n and round n+1.
int nColumns = levels * 2 - 1;
// add the necessary columns to the grid
var cdc = LayoutRoot.ColumnDefinitions;
for (int i = 0; i < nColumns; i++)
{
var cd = new ColumnDefinition();
// the width of the connector is half that of the regular columns
int width = ((i % 2) == 1) ? 1 : 2;
cd.Width = new GridLength(width, GridUnitType.Star);
cdc.Add(cd);
}
var rdc = LayoutRoot.RowDefinitions;
// in the grid, there is one row for each player, and
// an interleaving row between each pair of players.
int totalSlots = 2 * n - 1;
for (int i = 0; i < totalSlots; i++)
{
rdc.Add(new RowDefinition());
}
// Now we have a grid of the proper geometry.
// Next: fill it.
List<int> slots = new List<int>();
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("Bridge.png", UriKind.Relative));
// one loop for each level, or "round" in the tourney.
for (int j = 0; j < levels; j++)
{
// Figure the number of players in the current round.
// Since we insert the rounds in the reverse order,
// think of j as the "number of rounds remaining."
// Therefore, when j==0, playersThisRound=1.
// When j == 1, playersThisRound = 2. etc.
int playersThisRound = (int)Math.Pow(2, j);
int x = levels - j;
int f = (int)Math.Pow(2, x - 1);
for (int i = 0; i < playersThisRound; i++)
{
// do this in reverse order. The innermost round is
// inserted first.
var r = new TextBox();
r.Background = black;
if (j == levels - 1)
r.Text = "player " + (i + 1).ToString();
else
r.Text = "player ??";
// for j == 0, this is the last column in the grid.
// for j == levels-1, this is the first column.
// The grid column is not the same as the current
// round, because of the columns used for the
// interleaved connectors.
int k = 2 * (x - 1);
r.SetValue(Grid.ColumnProperty, k);
int m = (i * 2 + 1) * f - 1;
r.SetValue(Grid.RowProperty, m);
LayoutRoot.Children.Add(r);
// are we not on the last round?
if (j > 0)
{
slots.Add(m);
// Have we just inserted two rows? Then we need
// a connector between these two and the next
// round (the round previously added).
if (slots.Count == 2)
{
string xamlTriangle = "<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "+
"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' " +
"Data='M0,0 L 100 50 0 100 Z' Fill='LightBlue' Stretch='Fill'/>";
Path path = (Path)System.Windows.Markup.XamlReader.Load(xamlTriangle);
path.SetValue(Grid.ColumnProperty, 2 * (x - 1) + 1);
path.SetValue(Grid.RowProperty, slots[0]);
path.SetValue(Grid.RowSpanProperty, slots[1] - slots[0] + 1);
this.LayoutRoot.Children.Add(path);
slots.Clear();
}
}
}
}
}
을, 커넥터는 오른쪽 정점 가리키는 단지 이등변 삼각형이다. 문자열에 대해 XamlReader.Load()에 의해 생성됩니다.
다른 색상과 글꼴로 멋지게 꾸밀 수도 있습니다.
이 실버 라이트 "사용자 정의"를 임의의 HTML 웹 페이지에 삽입 할 수 있습니다. 이는 플래시 앱을 페이지에 삽입하는 것과 같습니다. IE, Firefox, Opera, Safari 및 Chrome 용 실버 라이트 플러그인이 있습니다.
Silverlight를 사용하지 않으려는 경우 유사한 방법으로 HTML 표를 구성 할 수 있습니다.
정말 감사드립니다! – stighy
최상의 답변! 나는 많이 배웠다. – neontapir