Esempio n. 1
0
        public ConsoleController(PingSender pingSender)
        {
            #region Lock console size
            IntPtr handle  = GetConsoleWindow();
            IntPtr sysMenu = GetSystemMenu(handle, false);

            if (handle != IntPtr.Zero)
            {
                //DeleteMenu(sysMenu, SC_CLOSE, MF_BYCOMMAND);//disable exit button
                DeleteMenu(sysMenu, SC_MINIMIZE, MF_BYCOMMAND);
                DeleteMenu(sysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
                DeleteMenu(sysMenu, SC_SIZE, MF_BYCOMMAND);
            }
            #endregion

            #region Console stuff
            Console.WindowWidth  = 50;
            Console.WindowHeight = 10;
            Console.SetBufferSize(50, 10);
            Console.SetWindowSize(50, 10);
            Console.CursorVisible = false;
            Console.Title         = "PingTools";
            var version = typeof(Program).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion;
            Console.WriteLine($"Ping Tools, version {version}");
            Console.WriteLine($".NET version {Environment.Version}");
            #endregion

            _pingSender        = pingSender;
            _lowLatencyMargin  = 50;
            _highLatencyMargin = 80;
        }
 public LogicController()
 {
     _pingSender        = new PingSender();
     _consoleController = new ConsoleController(_pingSender);
 }