Esempio n. 1
0
        public AlgebraTextBox()
        {
            InitializeComponent();

            Type ts = typeof(SymbolicAlgebra.SymbolicVariable);

            var lib_ver = (AssemblyFileVersionAttribute)ts.Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0];

            string copyright =
                @"Silver Algebra  " + lib_ver.Version + @"  Alpha Edition
Copyright (c) 2010-2015 at Lost Particles Network [LPN]
All rights reserved for Ahmed Sadek 

[email protected]

Depends on SymbolicAlgebra Open Source Library 
http://SymbolicAlgebra.CodePlex.com

SA> x+x   will produce 2*x

To Differentiate  use '|' operator
SA> (sin(x)*cos(x))|x   will produce  cos(x)^2-sin(x)^2

Enjoy
";

            ConsoleTextBox.Text  = copyright;
            ConsoleTextBox.Text += (Prompt);
            ConsoleTextBox.Select(ConsoleTextBox.Text.Length, 0);
            ConsoleTextBox.Focus();
        }
Esempio n. 2
0
        private void ConsoleTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Up)
            {
                int lp = ConsoleTextBox.Text.LastIndexOf(Prompt);  // specify latest prompt
                //delete after that from text
                ConsoleTextBox.Text = ConsoleTextBox.Text.Substring(0, lp + Prompt.Length);

                ConsoleLinesIndex--;
                if (ConsoleLinesIndex > 0)
                {
                    var r = (ConsoleLines[ConsoleLinesIndex - 1]);
                    ConsoleTextBox.Text += r;
                }
                else
                {
                    ConsoleLinesIndex = 0;
                }

                e.Handled = true;
            }

            if (e.Key == Key.Down)
            {
                int lp = ConsoleTextBox.Text.LastIndexOf(Prompt);  // specify latest prompt
                //delete after that from text
                ConsoleTextBox.Text = ConsoleTextBox.Text.Substring(0, lp + Prompt.Length);

                ConsoleLinesIndex++;
                if (ConsoleLinesIndex <= ConsoleLines.Count)
                {
                    var r = (ConsoleLines[ConsoleLinesIndex - 1]);
                    ConsoleTextBox.Text += r;
                }
                else
                {
                    ConsoleLinesIndex = ConsoleLines.Count + 1;
                }

                //ConsoleTextBox.CaretIndex = ConsoleTextBox.Text.Length;
                ConsoleTextBox.Select(ConsoleTextBox.Text.Length, 0);
                e.Handled = true;
            }
        }
Esempio n. 3
0
 private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     this.Invoke(new MethodInvoker(() =>
     {
         if (!String.IsNullOrEmpty(e.Data))
         {
             if (!string.IsNullOrWhiteSpace(ConsoleTextBox.Text))
             {
                 ConsoleTextBox.AppendText("\r\n" + e.Data);
                 if (e.Data.Contains("UUID of player"))
                 {
                     string[] line   = e.Data.Split(' ');
                     this.playerUUID = line[line.Length - 1];
                 }
                 string data = e.Data;
                 if (data.Contains("Done (") && data.Contains("type \"help\" or \"?\""))
                 {
                     if (this.playerManager.FileNotFound())
                     {
                         this.playerManager.RetryFileParsing();
                     }
                 }
                 if (data.Contains("logged in"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[2].Split('[')[0];
                     Console.WriteLine(name);
                     Dictionary <object, string> player_information = new Dictionary <object, string>
                     {
                         ["name"]        = name,
                         ["ip"]          = line[2].Split('/')[1].Replace("]", string.Empty),
                         ["uuid"]        = this.playerUUID,
                         ["time-joined"] = DateTime.Now.ToString("h:mm tt"),
                         ["whitelisted"] = this.playerManager.PlayerIsWhitelisted(name).ToString(),
                         ["op"]          = this.playerManager.PlayerIsOp(name).ToString()
                     };
                     Console.WriteLine(String.Format("Player {0} joined with IP {1} and UUID {2}", player_information["name"], player_information["ip"], player_information["uuid"]));
                     Add_Player(player_information);
                     players_list.Add(player_information["name"], player_information);
                     this.playerUUID = "";
                 }
                 else if (data.Contains("left the game"))
                 {
                     string name = e.Data.Split(' ')[2];
                     players_list.Remove(name);
                     Remove_Player(name);
                 }
                 if (data.Contains("Opped") || data.Contains("opped"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[line.Length - 1];
                     foreach (DataGridViewRow row in this.PlayersGridView.Rows)
                     {
                         if (row.Cells["Name"].Value.ToString().Equals(name))
                         {
                             row.Cells["OP"].Value = data.Contains("Opped") ? "True" : "False";
                             break;
                         }
                     }
                 }
                 else if (data.Contains("from the whitelist") || data.Contains("to the whitelist"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[3];
                     foreach (DataGridViewRow row in this.PlayersGridView.Rows)
                     {
                         if (row.Cells["Name"].Value.ToString().Equals(name))
                         {
                             row.Cells["Whitelisted"].Value = data.Contains("from the whitelist") ? "False" : "True";
                             break;
                         }
                     }
                 }
             }
             else
             {
                 ConsoleTextBox.AppendText(e.Data);
             }
             ConsoleTextBox.Select(ConsoleTextBox.TextLength, 0);
             ConsoleTextBox.ScrollToCaret();
         }
     }));
 }
Esempio n. 4
0
        private void ConsoleTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                //evaluate the expression
                // and go to another line
                int lp = ConsoleTextBox.Text.LastIndexOf(Prompt);

                string LastLine = Regex.Split(ConsoleTextBox.Text, Environment.NewLine).Last();


                try
                {
                    if (LastLine.StartsWith(Prompt))
                    {
                        var s = ConsoleTextBox.Text.Substring(lp).Substring(Prompt.Length);

                        ConsoleTextBox.Text += (Environment.NewLine);

                        if (!string.IsNullOrEmpty(s))
                        {
                            if (ConsoleLines.Count == 0)
                            {
                                ConsoleLines.Add(s);
                            }
                            else
                            {
                                if (ConsoleLines.Last() != s)
                                {
                                    //store in history only if the input string is not the same as latest string
                                    ConsoleLines.Add(s);
                                }
                            }
                        }

                        ConsoleLinesIndex = ConsoleLines.Count;

                        if (!string.IsNullOrEmpty(s))
                        {
                            var vv = SymbolicAlgebra.SymbolicVariable.Parse(s);

                            ConsoleTextBox.Text += "    " + vv.ToString();
                            ConsoleTextBox.Text += (Environment.NewLine);
                        }
                    }
                    else
                    {
                        ConsoleTextBox.Text += Environment.NewLine;
                    }
                }
                catch (Exception qse)
                {
                    //PrintError(qse);
                }
                finally
                {
                    ConsoleTextBox.Text += (Prompt);


                    //ConsoleTextBox.CaretIndex = ConsoleTextBox.Text.Length;
                    ConsoleTextBox.Select(ConsoleTextBox.Text.Length, 0);
                }
            }
        }