Beispiel #1
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            if (matchNode.GetType() != MatchNode.Matchnode_Exprent)
            {
                return(null);
            }
            List <Exprent> lstAllExprents = GetAllExprents();

            if (lstAllExprents == null || (lstAllExprents.Count == 0))
            {
                return(null);
            }
            string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                             );

            if (position != null)
            {
                if (position.Matches("-?\\d+"))
                {
                    return(lstAllExprents[(lstAllExprents.Count + System.Convert.ToInt32(position)) %
                                          lstAllExprents.Count]);
                }
            }
            else if (index < lstAllExprents.Count)
            {
                // care for negative positions
                // use 'index' parameter
                return(lstAllExprents[index]);
            }
            return(null);
        }
Beispiel #2
0
        public void GenerateTournamentTree()
        {
            SingleEliminationGames = new List <MatchNode>();

            SingleEliminationFinal = GenerateMatchNode();

            ConnectLeafNodesToMatch(SingleEliminationFinal);

            while (DoMerge())
            {
            }

            if (SingleEliminationTeamEntryPoints.Count >= 2)
            {
                EndNode firstPlace  = new EndNode();
                EndNode SecondPlace = new EndNode();


                firstPlace.AddFinalist(SingleEliminationFinal, MatchOutcome.OneVsOneWinner);
                SecondPlace.AddFinalist(SingleEliminationFinal, MatchOutcome.OneVsOneLooser);
                SingleEliminationPlacements.Add(firstPlace);
                SingleEliminationPlacements.Add(SecondPlace);
            }
            if (SingleEliminationTeamEntryPoints.Count >= 4)
            {
                EndNode ThirdPlace  = new EndNode();
                EndNode FourthPlace = new EndNode();

                List <FinalistData> finalistData = SingleEliminationFinal.GetFinalists();

                if (finalistData.Count > 1)
                {
                    MatchNode thirdPlaceFianl = GenerateMatchNode();
                    thirdPlaceFianl.AddFinalist(
                        finalistData[0].GetNode(),
                        MatchOutcome.OneVsOneLooser);
                    thirdPlaceFianl.AddFinalist(
                        finalistData[1].GetNode(),
                        MatchOutcome.OneVsOneLooser);
                    thirdPlaceFianl.SetName("Third place final");
                    SingleEliminationThirdPlaceFinal = thirdPlaceFianl;

                    ThirdPlace.AddFinalist(thirdPlaceFianl, MatchOutcome.OneVsOneWinner);
                    FourthPlace.AddFinalist(thirdPlaceFianl, MatchOutcome.OneVsOneLooser);
                    SingleEliminationPlacements.Add(ThirdPlace);
                    SingleEliminationPlacements.Add(FourthPlace);
                    SingleEliminationGames.Add(thirdPlaceFianl);
                }
            }

            foreach (var v in SingleEliminationGames)
            {
                v.SetName("Third place Final");
            }

            SingleEliminationFinal.SetName("Final");
            SingleEliminationGames.Add(SingleEliminationFinal);

            RenameNodes();
        }
Beispiel #3
0
 // *****************************************************************************
 // IMatchable implementation
 // *****************************************************************************
 public override bool Match(MatchNode matchNode, MatchEngine engine)
 {
     if (!base.Match(matchNode, engine))
     {
         return(false);
     }
     foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode
              .GetRules())
     {
         MatchNode.RuleValue        value = rule.Value;
         IMatchable.MatchProperties key   = rule.Key;
         if (key == IMatchable.MatchProperties.Exprent_Consttype)
         {
             if (!value.value.Equals(this.constType))
             {
                 return(false);
             }
         }
         else if (key == IMatchable.MatchProperties.Exprent_Constvalue)
         {
             if (value.IsVariable() && !engine.CheckAndSetVariableValue(value.value.ToString()
                                                                        , this.value))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
    /// <summary>
    /// Fills the match row.
    /// </summary>
    /// <param name="data">The data.</param>
    /// <param name="rowid">The rowid.</param>
    /// <param name="text">The text.</param>
    public static void FillMatchRow(object data, out SqlInt32 rowid, out SqlChars text)
    {
        MatchNode node = (MatchNode)data;

        rowid = new SqlInt32(node.RowId);
        text  = new SqlChars(node.Value.ToCharArray());
    }
Beispiel #5
0
        private void Print(MatchNode node, Label PrintLabel)
        {
            if (node != null)
            {
                List <ITeam> fighters = node.GetTeams();
                var          data     = node.GetBattleResult();

                PrintLabel.Text += node.ToString() + "\n";

                foreach (var t in data)
                {
                    //PrintLabel.Text += t.GetTeamName() + " " ;
                    PrintLabel.Text += t.GetTeam().GetTeamName() + ": " + t.GetScore() + "\n";
                }

                foreach (var t in node.GetNotConnectedFinialists())
                {
                    PrintLabel.Text += "[";
                    PrintLabel.Text += ToStringClass.ToString(t.GetPosition()) + " of " + t.GetNode().ToString();
                    PrintLabel.Text += "]\n";
                }

                PrintLabel.Text += "\n";
            }
        }
Beispiel #6
0
    public static void FillMatchRow(object data,
                                    out SqlInt32 index, out SqlChars text)
    {
        MatchNode node = (MatchNode)data;

        index = new SqlInt32(node.Index);
        text  = new SqlChars(node.Value.ToCharArray( ));
    }
Beispiel #7
0
 public SingleElimination()
 {
     SingleEliminationGameRule        = new BestOf(3);
     SingleEliminationTeamEntryPoints = new List <LeafNode>();
     SingleEliminationFinal           = GenerateMatchNode();
     SingleEliminationPlacements      = new List <EndNode>();
     SingleEliminationGames           = new List <MatchNode>();
 }
Beispiel #8
0
        public override bool Match(MatchNode matchNode, MatchEngine engine)
        {
            if (matchNode.GetType() != MatchNode.Matchnode_Statement)
            {
                return(false);
            }
            foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode
                     .GetRules())
            {
                switch (rule.Key.ordinal())
                {
                case 0:
                {
                    if (this.type != (int)rule.Value.value)
                    {
                        return(false);
                    }
                    break;
                }

                case 2:
                {
                    if (this.stats.Count != (int)rule.Value.value)
                    {
                        return(false);
                    }
                    break;
                }

                case 3:
                {
                    int exprsize = (int)rule.Value.value;
                    if (exprsize == -1)
                    {
                        if (this.exprents != null)
                        {
                            return(false);
                        }
                    }
                    else if (this.exprents == null || this.exprents.Count != exprsize)
                    {
                        return(false);
                    }
                    break;
                }

                case 1:
                {
                    if (!engine.CheckAndSetVariableValue((string)rule.Value.value, this))
                    {
                        return(false);
                    }
                    break;
                }
                }
            }
            return(true);
        }
 public bool MoveNext()
 {
     currentMatch = (currentMatch == null) ? regex.Match(input) : currentMatch.NextMatch();
     if (currentMatch.Success)
     {
         current = new MatchNode(++index, currentMatch.Value);
         return(true);
     }
     return(false);
 }
Beispiel #10
0
    //[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters")]
    public static void FillMatchRow(object data,
                                    out SqlInt16 index, out SqlInt32 startingPos, out SqlInt32 Length, out SqlString text)
    {
        MatchNode node = (MatchNode)data;

        index       = new SqlInt16((short)node.Index);
        text        = new SqlString(node.Value);
        startingPos = new SqlInt32(node.StartingPos + 1);
        Length      = new SqlInt32(node.Length);
    }
Beispiel #11
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override bool Match(MatchNode matchNode, MatchEngine engine)
        {
            if (!base.Match(matchNode, engine))
            {
                return(false);
            }
            int type = (int)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Functype
                                                   );

            return(type == null || this.funcType == type);
        }
Beispiel #12
0
    internal MatchNode(MatchNode original)
    {
        this.NodeProvider = original.NodeProvider;
        this.Match        = original.Match;

        this.SetAttributes(original.GetAttributes().ToList());
        foreach (var item in original.ChildElements)
        {
            this.AppendChild(item.CloneNode(true));
        }
    }
Beispiel #13
0
        private MatchNode tree(List <SeveralObjects> list, int count)
        {
            int bigCount           = (int)Math.Pow(2, count - 1);
            List <MatchNode> lprev = null;
            MatchNode        head  = null;

            for (int i = 0; i < count; ++i)
            {
                List <SeveralObjects> l_ = new List <SeveralObjects>();
                foreach (var v in list)
                {
                    if ((int)v.O9 == i + 1)
                    {
                        l_.Add(v);
                    }
                }
                /*list.Where(x => (int)x.O9 == i + 1);*/
                List <MatchNode> l = new List <MatchNode>();
                foreach (var x in l_)
                {
                    l.Add(new MatchNode((int)x.O1, (int)x.O2, (int)x.O3, (int)x.O5, (string)x.O4, (string)x.O6, count - (int)x.O9));
                }
                //l_.Select(x => new MatchNode((int)x.O1, (int)x.O2, (int)x.O3, (int)x.O5, (string)x.O4, (string)x.O6, count - (int)x.O9));
                foreach (var v in l)
                {
                    if (lprev == null)
                    {
                        head       = v;
                        head.left  = 0;
                        head.right = bigCount - 1;
                        continue;
                    }
                    foreach (var V in lprev)
                    {
                        if (v.p1id == V.p1id || v.p2id == V.p1id)
                        {
                            v.left  = V.left;
                            v.right = V.left + (V.right - V.left) / 2;
                            V.child.Add(v);
                        }
                        else if (v.p1id == V.p2id || v.p2id == V.p2id)
                        {
                            v.left  = V.left + (V.right - V.left) / 2 + 1;
                            v.right = V.right;
                            V.child.Add(v);
                        }
                    }
                }
                lprev = l;
            }
            return(head);
        }
Beispiel #14
0
        private static void ButtonGivePoints(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            List <object> list = (List <object>)button.Tag;
            MatchNode     mn   = (MatchNode)list[0];
            ITeam         team = (ITeam)list[1];

            mn.GiveTeamOnePoint(team);

            if (Parent != null)
            {
                Parent.MegaUpdate();
            }
        }
 public void Visit(MatchNode node, bool beforeChildren)
 {
     System.Drawing.Font currentFont = richTextBox.SelectionFont;
     System.Drawing.Font boldFont    = new System.Drawing.Font(currentFont, System.Drawing.FontStyle.Bold);
     richTextBox.SelectionFont = boldFont;
     if (beforeChildren)
     {
         colorStack.Push(richTextBox.SelectionColor);
         richTextBox.SelectionColor = System.Drawing.Color.Green;
     }
     richTextBox.AppendText(beforeChildren ? "[" : "]");
     if (!beforeChildren)
     {
         richTextBox.SelectionColor = colorStack.Pop();
     }
     richTextBox.SelectionFont = currentFont;
 }
Beispiel #16
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            int node_type = matchNode.GetType();

            if (node_type == MatchNode.Matchnode_Statement && !(this.stats.Count == 0))
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Statement_Position
                                                                 );
                if (position != null)
                {
                    if (position.Matches("-?\\d+"))
                    {
                        return(this.stats[(this.stats.Count + System.Convert.ToInt32(position)) % this.stats
                                          .Count]);
                    }
                }
                else if (index < this.stats.Count)
                {
                    // care for negative positions
                    // use 'index' parameter
                    return(this.stats[index]);
                }
            }
            else if (node_type == MatchNode.Matchnode_Exprent && this.exprents != null && !(this
                                                                                            .exprents.Count == 0))
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                                 );
                if (position != null)
                {
                    if (position.Matches("-?\\d+"))
                    {
                        return(this.exprents[(this.exprents.Count + System.Convert.ToInt32(position)) % this
                                             .exprents.Count]);
                    }
                }
                else if (index < this.exprents.Count)
                {
                    // care for negative positions
                    // use 'index' parameter
                    return(this.exprents[index]);
                }
            }
            return(null);
        }
Beispiel #17
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            IMatchable @object = base.FindObject(matchNode, index);

            if (@object != null)
            {
                return(@object);
            }
            if (matchNode.GetType() == MatchNode.Matchnode_Exprent)
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                                 );
                if ("head".Equals(position))
                {
                    return(GetHeadexprent());
                }
            }
            return(null);
        }
Beispiel #18
0
 // *****************************************************************************
 // IMatchable implementation
 // *****************************************************************************
 public override bool Match(MatchNode matchNode, MatchEngine engine)
 {
     if (!base.Match(matchNode, engine))
     {
         return(false);
     }
     MatchNode.RuleValue rule = matchNode.GetRules().GetOrNull(IMatchable.MatchProperties
                                                               .Exprent_Var_Index);
     if (rule != null)
     {
         if (rule.IsVariable())
         {
             return(engine.CheckAndSetVariableValue((string)rule.value, this.index));
         }
         else
         {
             return(this.index == int.Parse((string)rule.value));
         }
     }
     return(true);
 }
Beispiel #19
0
 public override bool Match(MatchNode matchNode, MatchEngine engine)
 {
     if (matchNode.GetType() != MatchNode.Matchnode_Exprent)
     {
         return(false);
     }
     foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode
              .GetRules())
     {
         IMatchable.MatchProperties key = rule.Key;
         if (key == IMatchable.MatchProperties.Exprent_Type && this.type != (int)rule.Value
             .value)
         {
             return(false);
         }
         if (key == IMatchable.MatchProperties.Exprent_Ret && !engine.CheckAndSetVariableValue
                 ((string)rule.Value.value, this))
         {
             return(false);
         }
     }
     return(true);
 }
 // *****************************************************************************
 // IMatchable implementation
 // *****************************************************************************
 public override bool Match(MatchNode matchNode, MatchEngine engine)
 {
     if (!base.Match(matchNode, engine))
     {
         return(false);
     }
     foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode
              .GetRules())
     {
         MatchNode.RuleValue        value = rule.Value;
         IMatchable.MatchProperties key   = rule.Key;
         if (key == IMatchable.MatchProperties.Exprent_Invocation_Parameter)
         {
             if (value.IsVariable() && (value.parameter >= lstParameters.Count || !engine.CheckAndSetVariableValue
                                            (value.value.ToString(), lstParameters[value.parameter])))
             {
                 return(false);
             }
         }
         else if (key == IMatchable.MatchProperties.Exprent_Invocation_Class)
         {
             if (!value.value.Equals(this.classname))
             {
                 return(false);
             }
         }
         else if (key == IMatchable.MatchProperties.Exprent_Invocation_Signature)
         {
             if (!value.value.Equals(this.name + this.stringDescriptor))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Beispiel #21
0
        private bool DoMerge()
        {
            bool canMerge = CanMerge();

            if (canMerge)
            {
                FinalistData first = GetShallowNode();
                SingleEliminationFinal.RemoveFinalist(first);

                FinalistData second = GetShallowNode();
                SingleEliminationFinal.RemoveFinalist(second);

                MatchNode newMatch = GenerateMatchNode();
                newMatch.AddFinalist(first);
                newMatch.AddFinalist(second);

                SingleEliminationFinal.AddFinalist(newMatch, MatchOutcome.OneVsOneWinner);
                SingleEliminationGames.Add(newMatch);

                canMerge = CanMerge();
            }

            return(canMerge);
        }
Beispiel #22
0
        public void Visit(MatchNode node)
        {
            var predicate = Expression.Lambda <Func <LogItem, bool> >(node.Predicate(), QueryFactory.ItemVariable).Compile();

            Items = Items.Where(predicate);
        }
Beispiel #23
0
 public static MatchNode Matches(this MatchNode tree, string message)
 {
     if (tree is PhraseNode phrase && new Pattern(phrase.Phrase).IsMatch(message))
     {
         return(tree);
     }
 protected internal virtual void VisitMatch(MatchNode node)
 {
     VisitLeaf(node);
 }
Beispiel #25
0
        public static Control CreateVisualElement(MatchNode toVisualize)
        {
            List <CompetitorData> competitors = toVisualize.GetBattleResult();
            List <FinalistData>   notDone     = toVisualize.GetNotConnectedFinialists();
            int   height   = 24;
            int   padding  = 1;
            int   widht    = 250;
            Panel matchBox = new Panel();

            matchBox.Size = new Size(widht, height * 2 + padding);

            List <Panel> panels = new List <Panel>();

            foreach (CompetitorData cd in competitors)
            {
                Panel box = new Panel();
                box.Text = toVisualize.ToString();
                box.Size = new Size(widht, height);

                Label teamName = new Label();
                teamName.Text      = cd.GetTeam().GetTeamName();
                teamName.Location  = new Point(0, 0);
                teamName.Size      = new Size(200, height);
                teamName.ForeColor = Color.LightGray;
                teamName.Font      = new Font("Arial", 12, FontStyle.Bold);


                Button teamScore = new Button();
                teamScore.FlatStyle = FlatStyle.Flat;
                teamScore.ForeColor = Color.LightGray;
                teamScore.Text      = "" + cd.GetScore();
                teamScore.Location  = new Point(200, 0);
                teamScore.Size      = new Size(32, height);
                teamScore.Font      = teamName.Font;

                List <object> myShit = new List <object>();
                myShit.Add(toVisualize);
                myShit.Add(cd.GetTeam());
                teamScore.Click += new System.EventHandler(MatchVisualizer.ButtonGivePoints);
                teamScore.Tag    = myShit;

                box.Controls.Add(teamName);
                box.Controls.Add(teamScore);

                panels.Add(box);
            }

            foreach (FinalistData fd in notDone)
            {
                Panel teamPanel = new Panel();
                teamPanel.Size = new Size(widht, height);

                Label teamName = new Label();
                teamName.Text     = "[" + ToStringClass.ToString(fd.GetPosition()) + " of " + fd.GetNode().ToString() + "]";
                teamName.Location = new Point(0, 0);
                teamName.Size     = new Size(widht, height);

                teamPanel.Controls.Add(teamName);

                panels.Add(teamPanel);
            }



            Point p = new Point(0, 0);

            for (int i = 0; i < panels.Count; i++)
            {
                Control current = panels[i];
                if (toVisualize.IsGameFinished())
                {
                    var  winner   = toVisualize.GetCompeditor(MatchOutcome.OneVsOneWinner);
                    bool winnerIs = false;
                    foreach (Control c in current.Controls)
                    {
                        if (c.Text == winner.GetTeamName())
                        {
                            winnerIs = true;
                        }
                    }

                    if (winnerIs)
                    {
                        //current.BackColor = ColorTranslator.FromHtml("#658944");
                        current.BackColor = colors.colorTwo;
                    }
                    else
                    {
                        //current.BackColor = ColorTranslator.FromHtml("#c85252");
                        current.BackColor = colors.colorThree;
                    }
                }
                else
                {
                    if ((i & 1) == 1)
                    {
                        //current.BackColor = ColorTranslator.FromHtml("#0a3936");
                        current.BackColor = colors.colorFour;
                    }

                    else
                    {
                        current.BackColor = colors.colorFive;
                        //current.BackColor = ColorTranslator.FromHtml("#196f61");
                    }
                }


                current.Location = p;
                matchBox.Controls.Add(current);
                p.Y += current.Size.Height + padding;
            }



            return(matchBox);
        }
Beispiel #26
0
        /// <summary>
        /// Creates a query tree for the given query elements
        /// </summary>
        /// <param name="match"><see cref="MatchNode"/> for matching log items</param>
        /// <param name="parser"><see cref="IParser"/> for parsing log items</param>
        /// <param name="filter">An <see cref="Expression"/> for filtering log items</param>
        /// <param name="grouping">An enumerable of tuples of group names and grouping <see cref="Expression"/>s for grouping the log items</param>
        /// <param name="selects">An enumerable of tuples of projection labels and <see cref="Expression"/>s for projecting log items</param>
        /// <param name="order">An enumerable of tuples indicating sorting fields and sort order</param>
        /// <param name="limit">The number of items to return</param>
        /// <returns>A query tree for executing the query</returns>
        private static Node CreateQueryTree(
            MatchNode match,
            IOption <Tuple <string, IParser> > parser,
            IOption <Expression> filter,
            IOption <IEnumerable <Tuple <string, Expression> > > grouping,
            IOption <IEnumerable <Tuple <string, IAggregate> > > selects,
            IOption <IEnumerable <Tuple <string, bool> > > order,
            IOption <int> limit)
        {
            Node query = match;

            if (!parser.IsEmpty)
            {
                query = new ParseNode(query, parser.Get().Item2, parser.Get().Item1);
            }

            if (!filter.IsEmpty)
            {
                query = new PredicateNode(query, filter.Get());
            }

            if (!grouping.IsEmpty)
            {
                var keyNames       = grouping.Get().Select(g => g.Item1).ToArray();
                var keyExpressions = grouping.Get().Select(g => g.Item2).ToArray();
                if (selects.IsEmpty)
                {
                    query = new GroupByNode(query, keyNames, keyExpressions, new string[0], new IAggregate[0]);
                }
                else
                {
                    var aggregateNames = selects.Get().Select(s => s.Item1).ToArray();
                    var aggregates     = selects.Get().Select(s => s.Item2).ToArray();
                    query = new GroupByNode(query, keyNames, keyExpressions, aggregateNames, aggregates);
                }
            }
            else if (!selects.IsEmpty)
            {
                var aggregateNames = selects.Get().Select(s => s.Item1).ToArray();
                var aggregates     = selects.Get().Select(s => s.Item2).ToArray();
                if (aggregates.All(a => a is ListAggregate))
                {
                    query = new ProjectNode(query, aggregateNames, aggregates.Cast <ListAggregate>().Select(a => a.Expression).ToArray());
                }
                else
                {
                    query = new AggregateNode(query, aggregateNames, aggregates);
                }
            }

            if (!order.IsEmpty)
            {
                query = new OrderByNode(query, order.Get().Select(a => a.Item1).ToArray(), order.Get().Select(a => a.Item2).ToArray());
            }

            if (!limit.IsEmpty)
            {
                query = new LimitNode(query, limit.Get());
            }

            return(query);
        }
Beispiel #27
0
 private void bracketButton_Click(object sender, RoutedEventArgs e)
 {
     //0 - matches.id, 1 - matches.team1score, 2 - matches.team2score, 3 - matches.team1_id,
     //4 - team1.name, 5 - matches.team2_id, 6 - team2.name, 7 - matchformats.id,
     //8 - matchformats.name, 9 - l.id, 10 - matchcategories.name
     if (tournamentsLeftDataGrid.SelectedItem == null)
     {
         return;
     }
     HidePanels();
     try
     {
         BracketGrid.Children.Clear();
         BracketGrid.RowDefinitions.Clear();
         BracketGrid.ColumnDefinitions.Clear();
         BracketGrid.RowDefinitions.Add(new RowDefinition());
         List <SeveralObjects> list = ((List <SeveralObjects>)matchesDataGrid.ItemsSource);
         int count    = (int)list.Select(x => x.O9).Max();
         int bigCount = (int)Math.Pow(2, count) / 2;
         for (int i = 0; i < count; ++i)
         {
             BracketGrid.ColumnDefinitions.Add(new ColumnDefinition());
             Label l = new Label();
             var   y = new List <SeveralObjects>(list.Where(x => (int)x.O9 == count - i));
             l.Content             = y[0].O10;
             l.HorizontalAlignment = HorizontalAlignment.Center;
             l.VerticalAlignment   = VerticalAlignment.Center;
             l.SetValue(Grid.ColumnProperty, i);
             BracketGrid.Children.Add(l);
         }
         for (int i = 0; i < bigCount; ++i)
         {
             BracketGrid.RowDefinitions.Add(new RowDefinition());
         }
         MatchNode         head = tree(list, count);
         Queue <MatchNode> q    = new Queue <MatchNode>();
         q.Enqueue(head);
         while (q.Count != 0)
         {
             MatchNode mn = q.Dequeue();
             foreach (var v in mn.child)
             {
                 q.Enqueue(v);
             }
             StackPanel sp = new StackPanel();
             sp.Orientation         = Orientation.Vertical;
             sp.HorizontalAlignment = HorizontalAlignment.Center;
             sp.VerticalAlignment   = VerticalAlignment.Center;
             sp.SetValue(Grid.ColumnProperty, mn.col);
             sp.SetValue(Grid.RowProperty, 1 + mn.left);
             sp.SetValue(Grid.RowSpanProperty, mn.right - mn.left + 1);
             int[]    ar = { mn.p1score, mn.p2score };
             string[] s  = { mn.p1name, mn.p2name };
             for (int j = 0; j < 2; ++j)
             {
                 StackPanel sp1 = new StackPanel();
                 sp1.Orientation        = Orientation.Horizontal;
                 sp1.FlowDirection      = FlowDirection.RightToLeft;
                 sp.HorizontalAlignment = HorizontalAlignment.Center;
                 sp.VerticalAlignment   = VerticalAlignment.Center;
                 TextBlock tb2 = new TextBlock();
                 tb2.Text    = ar[j].ToString();
                 tb2.Padding = new Thickness(10);
                 //tb2.HorizontalAlignment = HorizontalAlignment.Right;
                 sp1.Children.Add(tb2);
                 TextBlock tb = new TextBlock();
                 tb.Text = s[j];
                 //tb.Padding = new Thickness(10);
                 sp1.Children.Add(tb);
                 sp.Children.Add(sp1);
             }
             BracketGrid.Children.Add(sp);
         }
         BracketGrid.Visibility = Visibility.Visible;
     }
     catch
     {
         HidePanels();
         ShowTournaments_Click(null, null);
     }
 }
Beispiel #28
0
 public virtual XzaarExpression Visit(MatchNode match)
 {
     return(null);
 }
Beispiel #29
0
 public virtual MatchNode Visit(MatchNode match)
 {
     return(match);
 }