public void pushVis(string data, Panel panel) { Bunifu.Framework.UI.BunifuThinButton2 btn = buttonCreator(); btn.ButtonText = (data).ToString(); panel.Controls.Add(btn); this.Refresh(); finalpanel.Refresh(); }
public void popVis() { Thread.Sleep(delay); this.Refresh(); Bunifu.Framework.UI.BunifuThinButton2 btn = new Bunifu.Framework.UI.BunifuThinButton2(); btn = Stack1.Controls[Stack1.Controls.Count - 1] as Bunifu.Framework.UI.BunifuThinButton2; Stack1.Controls.Remove(btn); btn.BackColor = Color.Red; Thread.Sleep(delay); this.Refresh(); }
//////==============================CODE===================================///// public bool PolishNotation(ref string infix, out string postfix) { int prio = 0; postfix = ""; infix += " "; Stack <string> s1 = new Stack <string>(); for (int i = 0; i < infix.Length; i++) { //charColorChange(i); richTextBox1.Select(0, richTextBox1.Text.Length - 1); richTextBox1.SelectionColor = Color.Black; richTextBox1.Select(0, richTextBox1.Text.Length - 1); richTextBox1.SelectionBackColor = Color.White; richTextBox1.Select(i, 1); richTextBox1.SelectionColor = Color.White; richTextBox1.Select(i, 1); richTextBox1.SelectionBackColor = Color.Red; //= Color.Red; string ch = ""; if (infix[i + 1] <= '9' && infix[i + 1] >= '0' && infix[i] <= '9' && infix[i] >= '0') { ch += infix[i]; ch += infix[i + 1]; i++; } else { ch = infix[i].ToString(); } if (ch == "+" || ch == "-" || ch == "*" || ch == "/") { //current value// Bunifu.Framework.UI.BunifuThinButton2 btn = buttonCreator(); btn.ButtonText = (ch).ToString(); flowLayoutPanel2.Controls.Add(btn); ///////////////////////////// if (s1.Count <= 0) { pushVis(ch, Stack1); Thread.Sleep(delay); s1.Push(ch); this.Refresh(); } else { if (s1.Peek() == "*" || s1.Peek() == "/") { //Button b1 = flowLayoutPanel1.Controls[flowLayoutPanel1.Controls.Count - 1] as Button; //b1.BackColor = Color.Red; prio = 1; } else { prio = 0; } if (prio == 1) { if (ch == "+" || ch == "-") { pushVis(s1.Peek(), finalpanel); this.Refresh(); Thread.Sleep(delay); popVis(); this.Refresh(); postfix += s1.Pop(); i--; } else { pushVis(s1.Peek(), finalpanel); this.Refresh(); Thread.Sleep(delay); popVis(); postfix += s1.Pop(); i--; } } else // IF PRIORITY IS = 0 { if (ch == "+" || ch == "-") { if (s1.Peek() == "+" || s1.Peek() == "-") { pushVis(s1.Peek(), finalpanel); this.Refresh(); Thread.Sleep(delay); popVis(); } pushVis(ch, Stack1); this.Refresh(); Thread.Sleep(delay); // Button b = Stack1.Controls[Stack1.Controls.Count - 1] as Button; // BunifuThinButton2 b = Stack1.Controls[Stack1.Controls.Count - 1] as BunifuThinButton2; //b.BackColor = Color.Teal; // Thread.Sleep(delay); // this.Refresh(); // popVis(); postfix += s1.Pop(); //popVis(); s1.Push(ch); } else { s1.Push(ch); pushVis(ch, Stack1); // Thread.Sleep(600); this.Refresh(); Thread.Sleep(delay); } } } } else { pushVis(ch, finalpanel); Thread.Sleep(1000); this.Refresh(); Thread.Sleep(delay); //popVis(); postfix += ch; } flowLayoutPanel2.Controls.Clear(); if (infix[i + 1].ToString() == " ") { break; } } int len = s1.Count; for (int j = 0; j < len; j++) { pushVis(s1.Peek(), finalpanel); postfix += s1.Pop(); popVis(); //Thread.Sleep(delay); } return(true); }