示例#1
0
文件: Main.cs 项目: youj33ns/launcher
        private void timer1_Tick(object sender, EventArgs e)
        {
            SampQuery api = new SampQuery(User.ip, 7777, 'i');

            var response       = api.read();
            var online_players = response["players"];
            var maxplayers     = response["maxplayers"];

            this.label1.Text = online_players + "/" + maxplayers;
        }
示例#2
0
文件: Main.cs 项目: youj33ns/launcher
        public Main()
        {
            InitializeComponent();

            //запускаем1 раз

            SampQuery api = new SampQuery(User.ip, 7777, 'i');

            var response       = api.read();
            var online_players = response["players"];
            var maxplayers     = response["maxplayers"];

            this.label1.Text = online_players + "/" + maxplayers;
            //потом обновляем в таймере


            timer          = new DispatcherTimer();
            timer.Tick    += new EventHandler(timer1_Tick);
            timer.Interval = new TimeSpan(0, 0, 0, 0, 10000);
            timer.Start();

            Animator.Start();
            UserSave Usave = new UserSave();

            try
            {
                using (StreamReader sw = new StreamReader(Directory.GetCurrentDirectory() + "/set.json"))
                {
                    string json = sw.ReadToEnd();
                    Usave         = JsonConvert.DeserializeObject <UserSave>(json);
                    User.nickname = Usave.nickname;
                    User.path     = Usave.path;
                    sw.Close();
                }
                this.Input_Login.TextInput = User.nickname;
            }
            catch
            {
            }
        }