Exemplo n.º 1
0
 public void Bought(Player player)
 {
     foreach (Token token in _Tokens)
     {
         if (token.Buying(_Game.Table, player))
         {
             _Tokens.Remove(token);
             _Game.Table.TokenPiles.Add(token);
             if (TokensChanged != null)
             {
                 TokensChangedEventArgs etcea = new TokensChangedEventArgs(token);
                 TokensChanged(this, etcea);
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Delete the selected token
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            TreeNode node = tvTokens.SelectedNode;
            Token    t    = (Token)node.Tag;

            if (MessageBox.Show("Do you want to delete the token '" +
                                t.TokenName + "'?", Constants.AppName, MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) ==
                DialogResult.Yes)
            {
                isDeleting = true;
                tokens.Remove(t);
                tvTokens.Nodes.Remove(node);

                if (tokens.Count == 0)
                {
                    txtTokenID.Text    = editor.Text = String.Empty;
                    txtTokenID.Enabled = editor.Enabled = btnDelete.Enabled = false;
                    editor.Refresh();
                }

                isDeleting = false;
                tvTokens.Focus();
            }
        }
Exemplo n.º 3
0
        private Tag Read()
        {
            Tag t = null;

            if (IsTagStart())
            {
                Token t1, t2;
                t1 = t2 = GetToken();
                TokenCollection tc = new TokenCollection();

                do
                {
                    this.index++;
                    t2.Next = GetToken();
                    t2      = t2.Next;

                    tc.Add(t2);
                } while (!IsTagEnd());

                tc.Remove(tc.Last);

                this.index++;

                try
                {
                    t = Read(tc);
                }
                catch (Exception.TemplateException)
                {
                    throw;
                }
                catch (System.Exception e)
                {
                    throw new Exception.ParseException(String.Concat("Parse error:", tc, "\r\nError message:", e.Message), tc.First.BeginLine, tc.First.BeginColumn);//标签分析异常
                }

                if (t != null)
                {
                    t.FirstToken = t1;
                    if (t.Children.Count == 0 || t.LastToken == null || t2.CompareTo(t.LastToken) > 0)
                    {
                        t.LastToken = t2;
                    }
                }
                else
                {
                    throw new Exception.ParseException(String.Concat("Unexpected  tag:", tc), tc.First.BeginLine, tc.First.BeginColumn); //未知的标签
                }
            }
            else
            {
                t            = new TextTag();
                t.FirstToken = GetToken();
                t.LastToken  = null;
                this.index++;
            }
            return(t);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Method to remove tokens from the main segment view.
 /// </summary>
 /// <param name="model"></param>
 public void RemoveTokens(AppModel model)
 {
     foreach (var item in TokenCollection)
     {
         if (item.Text == model.Name)
         {
             TokenCollection.Remove(item);
             break;
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Delete the selected token
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cmdDelete_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Token t = lbTokens.SelectedItem as Token;

            if (t != null && MessageBox.Show(String.Format(CultureInfo.CurrentCulture, "Are you sure you " +
                                                           "want to delete the token '{0}'?", t.TokenName), "Token Editor", MessageBoxButton.YesNo,
                                             MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
            {
                tokens.Remove(t);
                lbTokens.Focus();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reads the next tag from the tokens.
        /// </summary>
        private ITag Read()
        {
            ITag t = null;

            if (IsTagStart())
            {
                Token t1, t2;
                t1 = t2 = GetToken();
                TokenCollection tc = new TokenCollection();
                if (t1 == null)
                {
                    return(null);
                }
                do
                {
                    this.index++;
                    t2.Next = GetToken();
                    t2      = t2.Next;
                    if (t2 == null)
                    {
                        break;
                    }
                    tc.Add(t2);
                } while (!IsTagEnd());

                if (tc.Last != null && (tc.Last.TokenKind == TokenKind.TagEnd))
                {
                    tc.Remove(tc.Last);
                }

                this.index++;

                //if (tc.Count == 1 && tc[0] != null && tc[0].TokenKind == TokenKind.Comment)
                //{
                //    return new TextTag();
                //}

                try
                {
                    t = Read(tc);
                }
                catch (TemplateException)
                {
                    throw;
                }
                catch (System.Exception e)
                {
                    throw new ParseException($"Parse error:{tc.ToString()}\r\nError message:{e.Message}", tc.First.BeginLine, tc.First.BeginColumn);//标签分析异常
                }

                if (t != null)
                {
                    t.FirstToken = t1;
                    if (t.Children.Count == 0 || t.LastToken == null || t2.CompareTo(t.LastToken) > 0)
                    {
                        t.LastToken = t2;
                    }
                }
                else
                {
                    throw new ParseException($"Unexpected  tag: {tc.ToString()}", tc.First.BeginLine, tc.First.BeginColumn); //未知的标签
                }
            }
            else
            {
                t            = new TextTag();
                t.FirstToken = GetToken();
                t.LastToken  = null;
                this.index++;
            }
            return(t);
        }