/// <summary> /// generates postfix expression for infix expression currently in infix box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GenerateButton_Click(object sender, EventArgs e) { PostFix pf = new PostFix( ); string resultingPostfix; string selectedInfix = InfixBox.Text; if (!selectedInfix.Equals(null)) { pf.InfixExpression = selectedInfix; resultingPostfix = pf.PostfixExpression; InfixBox.Text = selectedInfix; PostFixBox.Text = resultingPostfix; } }
/// <summary> /// when new infix expression selected in ListBox, generate postfix expression /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void infixListBox_SelectedIndexChanged(object sender, EventArgs e) { PostFix pf = new PostFix( ); //create new postfix object string resultingPostfix; //holds postfix string string selectedInfix = infixListBox.GetItemText(infixListBox.SelectedItem); //holds infix expression //if infix expression is not null, generate postfix if (!selectedInfix.Equals(null)) { pf.InfixExpression = selectedInfix; //passes infix to pf object resultingPostfix = pf.PostfixExpression; //stores created postfix expression InfixBox.Text = selectedInfix; //displays infix expression PostFixBox.Text = resultingPostfix; //displays postfix expression } }