Esempio n. 1
0
        public void Run(UserConsole user)
        {
            Instance     = this;
            this.Console = user;

            this.NetworkManager = new ServerNetworkManager();
            this.NetworkManager.Start();

            this.UserManager           = new ChatUserManager();
            this.UserManager.Logined  += this.OnUserManagerLogined;
            this.UserManager.Logouted += this.OnUserManagerLogouted;

            this.TickThread = new Thread(this.Ticking);
            this.TickThread.Start();

            while (true)
            {
                var input = user.ReadInput().ToLowerInvariant();

                if (input.Equals("stop") == true)
                {
                    this.Stop();
                    return;
                }
            }
        }
Esempio n. 2
0
        public Gauss(int n, double[,] A)
        {
            this.n = n;
            this.A = A;

            UserConsole.PrintNumber("Порядок системы, n", n);
            UserConsole.PrintMatrix("Матрица системы, A", A, n);
        }
Esempio n. 3
0
        public static UserAbstract ParseArgs(string[] args, UserConsole defaultUser)
        {
            if (args.Length == 1)
            {
                return(new UserFile(args[0]));
            }

            return(defaultUser);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            UnitTest tester = new UnitTest();

            tester.Test();
            SockController controller = new SockController();
            UserConsole    console    = new UserConsole(controller);

            console.ConsoleEntry(args);
        }
Esempio n. 5
0
        public Gauss(int n, double[,] A, double[] b)
        {
            this.n = n;
            this.A = A;
            this.b = b;

            UserConsole.PrintNumber("Порядок системы, n", n);
            UserConsole.PrintMatrix("Матрица системы, A", A, n);
            UserConsole.PrintVector("Правая часть системы, b", b);
        }
Esempio n. 6
0
        public void Determenant()
        {
            double determenant = 1;

            for (int i = 0; i < n; i++)
            {
                determenant = A[i, i] * determenant;
            }
            UserConsole.PrintNumber("Определитель", determenant);
        }
Esempio n. 7
0
        /// <summary>
        /// Handler: Opens the terminal if the f12 key is pressed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.F12)
            {
                if (_console == null || _console.IsDisposed)
                {
                    _console = new UserConsole();
                }
                _console.Show();
                _console.BringToFront();
            }
        }
Esempio n. 8
0
        public void Verification()
        {
            var epsilon = new double[n];

            for (int i = 0; i < n; i++)
            {
                epsilon[i] = 0;
                for (int j = 0; j < n; j++)
                {
                    epsilon[i] = A[i, j] * result[j] + epsilon[i];
                }
                epsilon[i] = b[i] - epsilon[i];
            }
            UserConsole.PrintVector("Невязка", epsilon);
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            var user  = new UserConsole();
            var types = new Dictionary <int, object>();

            types[0] = new TcpTest.Clients.Client();
            types[1] = new TcpTest.Servers.Server();

            var input = user.QueryInput("Enter Type", types.Select(p => $"{p.Value.GetType().Name}"));
            var obj   = types[input];

            Console.CancelKeyPress += (sender, e) => ((dynamic)obj).Stop();

            ((dynamic)obj).Run(user);
        }
Esempio n. 10
0
 public void Triangle()
 {
     for (int i = 0; i < n; i++)
     {
         for (int j = i + 1; j < n; j++)
         {
             double koef = A[j, i] / A[i, i];
             for (int k = i; k < n; k++)
             {
                 A[j, k] = A[j, k] - A[i, k] * koef;
             }
         }
     }
     UserConsole.PrintMatrix("Треугольная матрица", A, n);
 }
        static async Task Main(string[] args)
        {
            UserConsole userConsole = new UserConsole();

            bool breakFlag = false;

            while (!breakFlag)
            {
                breakFlag = await userConsole.PrintMainMenu();

                //var subs = await subsMigrationService.ListAPIMSubscriptions();
                //await subsMigrationService.NormalizeAllSubscriptionsAsync();
                //breakFlag = true;
            }
        }
Esempio n. 12
0
        public static void Main(string[] args)
        {
            // Poor man DI
            IUserConsole        userConsole        = new UserConsole();
            IKnownLiterals      knownLiterals      = new KnownLiterals();
            IParametersResolver parametersResolver = new ParametersResolver(userConsole, knownLiterals);

            new VariableGroupCopier(parametersResolver,
                                    (a, t) => new VariableGroupVstsRepository(a, t, parametersResolver),
                                    () => new VariableGroupFileRepository(knownLiterals, parametersResolver)).Copy(args);

            if (parametersResolver.InteractiveMode)
            {
                userConsole.WaitAnyKey();
            }
        }
Esempio n. 13
0
        public void Calculate()
        {
            result = new double[n];

            for (int i = n - 1; i >= 0; i--)
            {
                result[i] = b[i];
                for (int j = i + 1; j < n; j++)
                {
                    result[i] = result[i] - A[i, j] * result[j];
                }
                result[i] = result[i] / A[i, i];
            }

            UserConsole.PrintVector("Решение СЛАУ", result);
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            var user       = new UserConsole();
            var createUser = ParseArgs(args, user);

            var(api, userKey) = Create(createUser);

            user.SendMessage("API Key = " + api.APIKey);
            user.SendMessage("User Key = " + userKey);

            var tests = new Dictionary <string, TestDelegate>();

            tests["psate"]  = TestPaste;
            tests["list"]   = TestList;
            tests["delete"] = TestDelete;
            tests["user"]   = TestUser;
            tests["raw"]    = TestRaw;

            while (true)
            {
                try
                {
                    user.SendMessage();
                    user.SendMessage();
                    var testQuery = user.QueryInput("Enter Test", tests, pair => pair.Key, true);

                    if (testQuery.Breaked == true)
                    {
                        continue;
                    }

                    var test = testQuery.Value.Value;
                    test(user, api, userKey);
                }
                catch (UserInputReturnException)
                {
                }
                catch (Exception e)
                {
                    user.SendMessage(string.Concat(e));
                }
            }
        }
Esempio n. 15
0
        public static void Main(string[] args)
        {
            var user          = new UserConsole();
            var authUser      = args.Length > 0 ? new UserFile(args[0]) : (UserAbstract)user;
            var clientId      = authUser.ReadInput("Client-Id");
            var redirectURI   = authUser.ReadInput("Redirect-URI");
            var nickName      = authUser.ReadInput("Nickname").ToLowerInvariant();
            var authorization = Auth(clientId, redirectURI);

            using (var client = new TwitchChatClient())
            {
                client.Type     = ProtocolType.WebSocket;
                client.Security = ProtocolSecurity.Default;
                client.OAuth    = authorization.AccessToken;
                client.Nick     = nickName;
                client.Capabilities.Add(KnownCapabilities.Commands);
                client.Capabilities.Add(KnownCapabilities.Membership);
                client.Capabilities.Add(KnownCapabilities.Tags);
                client.Connect();

                new Thread(() =>
                {
                    while (true)
                    {
                        var input   = user.ReadInput();
                        var message = new IRCMessage();
                        message.Parse(input);

                        client.Send(message);
                    }
                }).Start();

                var program = new Program(user, client);
                program.Run();
            }
        }
Esempio n. 16
0
 public BrokenConsole(UserConsole console, int[] failureSchedule)
 {
     this.failureSchedule = failureSchedule;
     this.console         = console;
 }
 public UserConsoleTests()
 {
     this.sut = new UserConsole();
 }
Esempio n. 18
0
 public abstract void Run(UserConsole userConsole, Storage storage);
Esempio n. 19
0
 public void Invoke(User user)
 {
     UserConsole.WriteLine(_massage, _color);
     user.Health -= (_damage - user.Armor);
 }
Esempio n. 20
0
        public void Run(UserConsole user)
        {
            Instance     = this;
            this.Console = user;

            var tcpClient = new TcpClient();

            tcpClient.NoDelay = true;
            tcpClient.Connect(new IPEndPoint(IPAddress.Parse("124.58.147.98"), 1653));

            var client = new NetworkManager(tcpClient);

            new Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        client.ReadPackets();

                        if (client.CloseMessage != null)
                        {
                            user.SendMessage($"Network Closed : {client.CloseMessage}");
                            return;
                        }
                        else
                        {
                            client.Tick();
                            Thread.Sleep(10);
                        }
                    }
                }
                catch (Exception e)
                {
                    user.SendMessage(e.ToString());
                }
            }).Start();


            try
            {
                var loginToken  = Guid.NewGuid().ToString();
                var displayName = user.ReadInput("Enter DisplayName");
                client.SendPacket(new PacketLoginRequest()
                {
                    LoginToken = loginToken, DisplayName = displayName
                });

                while (true)
                {
                    var line = user.ReadInput();
                    client.SendPacket(new PacketChat()
                    {
                        Message = line
                    });
                }
            }
            catch (Exception e)
            {
                user.SendMessage(e.ToString());
            }
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            UserConsole userConsole = new UserConsole();

            userConsole.TakeInput();
        }
Esempio n. 22
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 23
0
        /// <summary>
        /// Handler: Opens the terminal if the f12 key is pressed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            ConsoleInterface nullOutput = new ConsoleInterface();

            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
            case Keys.D0:
            case Keys.NumPad0:
                InvisibleInputText += "0";
                break;

            case Keys.D1:
            case Keys.NumPad1:
                InvisibleInputText += "1";
                break;

            case Keys.D2:
            case Keys.NumPad2:
                InvisibleInputText += "2";
                break;

            case Keys.D3:
            case Keys.NumPad3:
                InvisibleInputText += "3";
                break;

            case Keys.D4:
            case Keys.NumPad4:
                InvisibleInputText += "4";
                break;

            case Keys.D5:
            case Keys.NumPad5:
                InvisibleInputText += "5";
                break;

            case Keys.D6:
            case Keys.NumPad6:
                InvisibleInputText += "6";
                break;

            case Keys.D7:
            case Keys.NumPad7:
                InvisibleInputText += "7";
                break;

            case Keys.D8:
            case Keys.NumPad8:
                InvisibleInputText += "8";
                break;

            case Keys.D9:
            case Keys.NumPad9:
                InvisibleInputText += "9";
                break;

            case Keys.Delete:
                if (e.Shift)
                {
                    Globals.PrimaryTimer.InFreeMode = !Globals.PrimaryTimer.InFreeMode;
                }
                else
                {
                    Globals.PrimaryTimer.Target = DateTime.Now;
                }

                return;

            case Keys.Pause:
                Command.GetByType <Freeze>().Execute(new string[0], nullOutput);
                return;

            case Keys.PageUp:
                Globals.PrimaryTimer.Target = Globals.PrimaryTimer.Target.AddDays(1.0);
                return;

            case Keys.PageDown:
                Globals.PrimaryTimer.Target = Globals.PrimaryTimer.Target.AddDays(-1.0);
                return;

            case Keys.Insert:
                Globals.PrimaryTimer.StopAtZero = !Globals.PrimaryTimer.StopAtZero;
                MessageBox.Show(Globals.PrimaryTimer.StopAtZero ? "End Mode: Stop" : "End Mode: Continue");
                return;

            case Keys.Return:
                Globals.SwapTimers();
                return;

            case Keys.F1:
                MessageBox.Show(string.Join(Environment.NewLine,
                                            "F1: Help",
                                            "F10: Collapse/Uncollapse",
                                            "F11: Translucency Mode",
                                            "F12: Console",
                                            "Del: Reset to zero",
                                            "Shift + Del: Idle Mode",
                                            "Enter: Swap Primary/Secondary Timer",
                                            "Ins: Change end mode",
                                            "Pause: Freeze/Unfreeze",
                                            "0930: Set target to 09:30 (Must be in 24h format)",
                                            "Shift + 0930: Set countdown to 9 minutes and 30 seconds",
                                            "Alt + 0930: Set countdown to 9 hours and 30 minutes",
                                            "Page Up: Add 1 day to target",
                                            "Page Dn: Subtract 1 day from to target"
                                            ), "Keyboard Shortcuts");
                return;

            case Keys.F11:
                ToggleWindowTranslucencyMode();
                break;

            case Keys.F10:
                const int COLLAPSE_HEIGHT = 90;

                if (tabs.SelectedIndex == 4)
                {
                    int lastHeigh = Height;
                    tabs.SelectedIndex = 0;
                    Top -= (Height - lastHeigh);

                    //Found this solution on stack
                    tabs.Appearance = TabAppearance.Normal;
                    tabs.ItemSize   = new Size(30, 18);
                }
                else
                {
                    tabs.SelectedIndex = 4;
                    Top   += (Height - COLLAPSE_HEIGHT);
                    Height = COLLAPSE_HEIGHT;

                    tabs.Appearance = TabAppearance.FlatButtons;
                    tabs.ItemSize   = new Size(0, 1);
                }


                break;

            case Keys.F12:
                if (_console == null || _console.IsDisposed)
                {
                    _console = new UserConsole();
                }

                _console.Show();
                _console.BringToFront();
                return;
            }

            if (InvisibleInputText.Length == 4)
            {
                int a = int.Parse(InvisibleInputText.Substring(0, 2), NumberStyles.Integer, CultureInfo.InvariantCulture);
                int b = int.Parse(InvisibleInputText.Substring(2, 2), NumberStyles.Integer, CultureInfo.InvariantCulture);

                //Duration
                if (e.Shift || e.Alt)
                {
                    int hour;
                    int minute;
                    int second;

                    if (e.Alt)
                    {
                        hour   = a;
                        minute = b;
                        second = 0;
                    }
                    else
                    {
                        hour   = 0;
                        minute = a;
                        second = b;
                    }

                    TimeSpan newTarget = new TimeSpan(hour, minute, second);
                    Globals.PrimaryTimer.Target     = DateTime.Now + newTarget;
                    Globals.PrimaryTimer.InFreeMode = false;
                }

                //Target
                else
                {
                    int hour   = a;
                    int minute = b;

                    if (hour < 24 && minute < 60)
                    {
                        Globals.PrimaryTimer.Target     = DateTime.Today.AddHours(hour).AddMinutes(minute);
                        Globals.PrimaryTimer.InFreeMode = false;
                    }
                }

                LastInvisibileInputTextUpdateTime = default;
                InvisibleInputText = "";
            }
            else
            {
                LastInvisibileInputTextUpdateTime = DateTime.Now;
            }
        }