Example #1
0
        private static void Init()
        {
            var player = map.Actors.Single(a => a is Player) as Player;

            var mapConsole     = new MapConsole(game, true, new AStarPathFinder());
            var logConsole     = new LogConsole();
            var messageConsole = new MessageConsole();
            var statusConsole  = new StatusConsole(player);
            var menuConsole    = new MenuConsole(Width, Height);

            var inventory = new InventoryConsole(player);

            var keyboardHandler = new KeyboardHandler(mapConsole, logConsole, messageConsole, player, inventory, menuConsole, game, () => StartGame(rnd));

            var mainConsole = new MainConsole(mapConsole, logConsole, messageConsole, statusConsole, keyboardHandler, inventory);

            mainConsole.Children.Add(mapConsole);
            mainConsole.Children.Add(logConsole);
            mainConsole.Children.Add(messageConsole);
            mainConsole.Children.Add(statusConsole);
            mainConsole.Children.Add(inventory);
            mainConsole.Children.Add(menuConsole);

            SadConsole.Game.Instance.Screen = mainConsole;
        }
Example #2
0
        public ConsoleWindow()
        {
            InitializeComponent();
            App.Console = MainConsole;

            // Registering commands
            CommandRegistrar.AutoRegisterCommands("KBS2.Console.Commands");

            // Console logic

            MainConsole.SendCommand += (sender, args) =>
            {
                var input = args.Command;

                try
                {
                    var output = CommandHandler.HandleInput(input);
                    if (output == null)
                    {
                        return;
                    }
                    MainConsole.Print(output);
                }
                catch (CommandException exception)
                {
                    MainConsole.Print(exception.Message, Colors.Red);
                }
            };
        }
Example #3
0
        // read console input and act
        private void readConsoleInput(string mT)
        {
            string mainText = mT;

            // basic help information and all available commands
            #region available commands
            if (mainText.ToLower().Trim() == "/help".ToString().ToLower().Trim())
            {
                MainConsole.AppendText("\nList of available commands:");
                MainConsole.AppendText("\n/help ability {ability name}");
                MainConsole.CaretPosition = MainConsole.CaretPosition.DocumentEnd;
            }
            #endregion

            // help for all abilities
            #region all abilities
            else if (mainText.ToLower().Trim() == "/help ability adaptability".ToString().ToLower().Trim())
            {
                //adaptabilityInfo();
            }
            #endregion

            // unrecognized command information
            else
            {
                MainConsole.AppendText("\nUnrecognized command. Use /help to see a list of available commands.");
                MainConsole.CaretPosition = MainConsole.CaretPosition.DocumentEnd;
            }
        }
Example #4
0
        public Screen(int width, int height)
        {
            MainConsole    = new MainConsole(width - MENU_WIDTH - 1, height - MESSAGES_HEIGHT);
            MessageConsole = new MessageConsole(1, height - MESSAGES_HEIGHT + 1, width, MESSAGES_HEIGHT);
            MenuConsole    = new MenuConsole(width - MENU_WIDTH, 1, MENU_WIDTH + 1, height - MESSAGES_HEIGHT + 1);

            StartScreen = new StartScreen(width + 2, height + 2);
        }
Example #5
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            MainConsole.Clear();
            //MainConsole.Print(30, 20, "@", RLColor.White);

            if (currentState != null)
            {
                currentState.Render(MainConsole);
            }

            MainConsole.Draw();
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Core"/> class.
        /// </summary>
        public Core()
        {
            _applications = new List <IApplication>();
            _mainConsole  = new MainConsole(SendMessage);
            DateTime now = DateTime.Now;

            _mainConsole.UpdateUpSince(now);
            _upTime = new Timer(UpdateUpTime, now, 0, 1000);
            //_refreshPings = new Timer(RefreshPings, null, 500, 5000);

            Message.SendMessage = SendMessage;
            Logger.LoggerInstance.LoggingRequested += _mainConsole.Log;
            Logger.LoggerInstance.IsNoisy           = true;
        }
Example #7
0
 private void ConnectButton_Click(object sender, EventArgs e) //Connect to server
 {
     if (Regex.IsMatch(IP_TextBox.Text, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b") && !connected)
     {
         client = new TcpClient();
         IPEndPoint IP_End = new IPEndPoint(IPAddress.Parse(IP_TextBox.Text), int.Parse(Port_TextBox.Text));
         try
         {
             client.Connect(IP_End);
             if (client.Connected)
             {
                 connected = true;
                 MainConsole.AppendText("Connected \n");
                 STW           = new StreamWriter(client.GetStream());
                 STR           = new StreamReader(client.GetStream());
                 STW.AutoFlush = true;
                 backgroundWorker1.RunWorkerAsync();
             }
         }
         catch (Exception exc)
         {
             backgroundWorker1.CancelAsync();
             MessageBox.Show(exc.Message.ToString());
         }
     }
     else
     {
         if (connected)
         {
             MessageBox.Show("Already connected");
         }
         else
         {
             MessageBox.Show("Wrong IP Address");
         }
     }
 }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxEmail.Text.Length == 0)
            {
                errormessage.Text = "Enter an email.";
                textBoxEmail.Focus();
            }
            else if (!textBoxEmail.Text.Equals("1") && (!Regex.IsMatch(textBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")))
            {
                errormessage.Text = "Enter a valid email.";
                textBoxEmail.Select(0, textBoxEmail.Text.Length);
                textBoxEmail.Focus();

            }
            else if ((comboBoxDatabase.SelectedValue as ListBoxItem) == null)
            {
                errormessage.Text = "Select database from provided list";
            }
            else
            {
                // Save global variables with connection string to database selected from combo for future nhibernate use when initiation session
                if ((comboBoxDatabase.SelectedValue as ListBoxItem).Content.ToString().Equals("mydb"))
                {
                    Application.Current.Properties["HOSTNAME"] = "localhost";
                    Application.Current.Properties["DBSID"] = "mydb";
                    Application.Current.Properties["DBUSER"] = "******";
                    Application.Current.Properties["DBPASSWORD"] = "******";
                }
                else if ((comboBoxDatabase.SelectedValue as ListBoxItem).Content.ToString().Equals("mydbTest"))
                {
                    Application.Current.Properties["HOSTNAME"] = "localhost";
                    Application.Current.Properties["DBSID"] = "mydbTest";
                    Application.Current.Properties["DBUSER"] = "******";
                    Application.Current.Properties["DBPASSWORD"] = "******";
                }

                string email = textBoxEmail.Text;
                string password = passwordBox1.Password;
                UserIdentity userInstance = new UserIdentity();

                bool isUserAuthenticated = nhibernategateway.ValidateUserCredentials(email,password, out userInstance);

                if (isUserAuthenticated)
                {
                    Application.Current.Properties["LoggedUserID"] = userInstance.id.ToString();
                    Application.Current.Properties["LoggedUserEmail"] = userInstance.email.ToString();

                    MainConsole myMainWindow = new MainConsole();
                    System.Windows.Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                    System.Windows.Application.Current.MainWindow = myMainWindow;

                    myMainWindow.Show();
                    Close();
                }
                else
                {
                    errormessage.Text = "Please enter existing Email/Password.";
                }
            }
        }
 public MainController()
 {
     mainConsole = new MainConsole();
 }
Example #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            InputWord.Text = InputWord.Text.Replace("\n", "");

            MainConsole.Clear();

            MainConsole.AppendText("Старт\n");
            MainConsole.Select(0, 5);
            MainConsole.SelectionFont = new Font(MainConsole.Font.FontFamily, this.Font.Size, FontStyle.Bold);

            string word = InputWord.Text;
            List <Tuple <string, string> > list = new List <Tuple <string, string> >();


            for (int i = 1; i <= number_of_enter; ++i)
            {
                string enter = (panel.Controls.Find("In" + i, true)[0] as TextBox).Text;
                string exit  = (panel.Controls.Find("Out" + i, true)[0] as TextBox).Text;

                list.Add(new Tuple <string, string>(enter, exit));
            }

            MainConsole.AppendText("Слово: " + word + "\n");
            MainConsole.Select(6, 6);
            MainConsole.SelectionFont = new Font(MainConsole.Font.FontFamily, this.Font.Size, FontStyle.Bold);

            while (true)
            {
                bool exit = true;

                for (int i = 0; i < number_of_enter; ++i)
                {
                    if (list[i].Item1 == "")
                    {
                        word = list[i].Item2 + word;

                        MainConsole.AppendText("Подстановка " + (i + 1) + ":  " + word + "\n");
                        MainConsole.Select(MainConsole.Text.Length - word.Length - 17, 13);
                        MainConsole.SelectionFont = new Font(MainConsole.Font.FontFamily, this.Font.Size, FontStyle.Bold);

                        exit = (panel.Controls.Find("End" + (i + 1), true)[0] as CheckBox).Checked;
                        break;
                    }

                    int index = word.IndexOf(list[i].Item1);

                    if (index != -1)
                    {
                        word = word.Remove(index, list[i].Item1.Length);
                        word = word.Insert(index, list[i].Item2);

                        MainConsole.AppendText("Подстановка " + (i + 1) + ":  " + word + "\n");
                        MainConsole.Select(MainConsole.Text.Length - word.Length - 17, 13);
                        MainConsole.SelectionFont = new Font(MainConsole.Font.FontFamily, this.Font.Size, FontStyle.Bold);

                        exit = (panel.Controls.Find("End" + (i + 1), true)[0] as CheckBox).Checked;
                        break;
                    }
                }

                if (exit)
                {
                    MainConsole.AppendText("Стоп: " + word + "\n");
                    MainConsole.Select(MainConsole.Text.Length - word.Length - 8, 6);
                    MainConsole.SelectionFont = new Font(MainConsole.Font.FontFamily, this.Font.Size, FontStyle.Bold);
                    break;
                }
            }
        }
 public Warehouse()
 {
     _products         = new List <Product>();
     _warehouseConsole = new MainConsole(_products);
 }
 /// <summary>
 /// The main method.
 /// </summary>
 /// <param name="args">The command line arguments.</param>
 public static void Main(string[] args)
 {
     var mainMenu = new MainConsole();
     mainMenu.Run();
 }
Example #13
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (client.Connected)
            {
                try
                {
                    received_text = STR.ReadLine();

                    //haslo
                    if (received_text == "250 User Ok")
                    {
                        STW.WriteLine("pass " + password);
                    }

                    if (received_text == "250 Pass Ok")
                    {
                        logged_in = true;
                    }


                    if (received_text == "250 Ok")
                    {
                        STW.WriteLine("rcpt to: " + "<" + to + ">");
                    }

                    if (received_text == "250 Accepted")
                    {
                        STW.WriteLine("data");
                    }

                    if (received_text == ("354 Ok Send data"))
                    {
                        STW.WriteLine("From: " + SenderTextBox.Text);
                        STW.WriteLine("To: " + ReceiverTextBox.Text);
                        STW.WriteLine("Subject: " + SubjectTextBox.Text);
                        STW.WriteLine(DataTextBox.Text);
                        if (!has_file)
                        {
                            STW.WriteLine(".");
                            STW.WriteLine("No files");
                        }
                        else
                        {
                            STW.WriteLine(".");
                            STW.WriteLine("Size " + fileBytes.Length.ToString());
                        }
                    }

                    if (received_text == "250 Size Ok")
                    {
                        STW.WriteLine("FileName " + fileName);
                    }

                    if (received_text == "250 Ready")
                    {
                        sending_file = true;

                        if (sending_file)
                        {
                            this.MainConsole.Invoke(new MethodInvoker(delegate() { MainConsole.AppendText(received_text + "\n"); }));
                            received_text = "";
                            var        stream = client.GetStream();
                            FileStream fs     = new FileStream(filePath, FileMode.Open);

                            //bufferCount = Convert.ToInt32(Math.Ceiling((double)fs.Length / (double)bufferSize));

                            //teraz niepotrzebne
                            //for (int i = 0; i < bufferCount; i++)

                            buffer = new byte[bufferSize];
                            int size = fs.Read(buffer, 0, bufferSize);

                            client.Client.Send(fileBytes, fileSize, SocketFlags.Partial);


                            fs.Close();
                            sending_file = false;
                        }
                    }



                    this.MainConsole.Invoke(new MethodInvoker(delegate() { MainConsole.AppendText(received_text + "\n"); }));
                    if (!helo)
                    {
                        STW.WriteLine("helo " + clientIP);
                        helo = true;
                    }

                    received_text = "";
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message.ToString());
                }
            }
        }
Example #14
0
        public static void Main(string[] args)
        {
            MainConsole consola = new MainConsole();

            consola.Main();
        }