private void RegisteMsg()
 {
     WeakReferenceMessenger.Default.Register <object, string>(
         this,
         MsgToken.Create(nameof(TodayToDoViewModel), nameof(TodayToDoView), "HideWindow"),
         (r, m) => {
         this.Hide();
     });
     WeakReferenceMessenger.Default.Register <object, string>(
         this,
         MsgToken.Create(nameof(TodayToDoViewModel), nameof(TodayToDoView), "ShowWindow"),
         (r, m) => {
         if (!this.IsActive)
         {
             this.Hide();
         }
         this.Show();
     });
     WeakReferenceMessenger.Default.Register <object, string>(
         this,
         MsgToken.Create(nameof(TodayToDoViewModel), nameof(TodayToDoView), "CloseWindow"),
         (r, m) => {
         this.Close();
     });
 }
        private void InitBinding()
        {
            InitBindingWindow();

            InitBindingCloseBtn();
            InitBindingTopMostBtn();
            InitBindingTodayTaskLB();

            WeakReferenceMessenger.Default.Register <object, string>(
                this,
                MsgToken.Create(nameof(TomatoClockViewModel), nameof(TodayToDoViewModel), "ShowTodayToDoWindow"),
                (r, m) =>
            {
                ApplyTheme(Ioc.Default.GetService <ITomatoClockThemeService>().CurrentTheme);
                WeakReferenceMessenger.Default.Send(
                    new object(),
                    MsgToken.Create(nameof(TodayToDoViewModel), nameof(TodayToDoView), "ShowWindow"));
            });
            WeakReferenceMessenger.Default.Register <object, string>(
                this,
                MsgToken.Global("Close"),
                (r, m) => {
                WeakReferenceMessenger.Default.Send(
                    new object(),
                    MsgToken.Create(nameof(TodayToDoViewModel), nameof(TodayToDoView), "CloseWindow"));
            });
        }
示例#3
0
        public static async Task Main()
        {
            FConsole.WriteLine("Host: ");
            ServerHostname       = Console.ReadLine().Trim();
            Client.OnConnected  += Connected;
            Client.OnPacket     += PacketRouter.Handle;
            Client.OnDisconnect += Disconnected;
            Client.ConnectAsync(ServerHostname, ServerPort);

            while (true)
            {
                var msg = Console.ReadLine();

                switch (msg)
                {
                case "login":
                    Client.Send(MsgLogin.Create("asd", "asdasd", true, MsgLoginType.Login));
                    break;

                case "ping":
                    var array  = new byte[MsgBench.MAX_ARRAY_LENGTH];
                    var random = new Random();
                    for (var i = 0; i < array.Length; i++)
                    {
                        array[i] = (byte)random.Next(0, 255);
                    }
                    Stopwatch.Start();
                    for (var i = 0; i < 1000; i++)
                    {
                        var msgBench = MsgBench.Create(array, false);
                        Client.Send(msgBench);
                    }
                    break;

                case "send":
                    var user = (User)Client.StateObject;
                    FConsole.WriteLine("Requesting Token...");
                    user.Send(MsgToken.Create("transcoder", 0, true));
                    while (!user.Tokens.ContainsKey(0))
                    {
                        Thread.Sleep(1);
                    }
                    FConsole.WriteLine("Uploading... using " + user.Tokens[0]);
                    Stopwatch.Start();
                    await user.SendFile(@"/home/alumni/transcoder", 0);

                    Stopwatch.Stop();
                    FConsole.WriteLine($"Done. {Stopwatch.Elapsed.TotalSeconds.ToString("##.##")}");
                    break;
                }
            }
        }
示例#4
0
        private void RegisteMsg()
        {
            WeakReferenceMessenger.Default.Register <object, string>(
                this,
                MsgToken.Create(nameof(TomatoClockViewModel), nameof(TomatoClockView), "MinimizeWindow"),
                (r, m) => {
                this.Hide();
            });

            WeakReferenceMessenger.Default.Register <object, string>(
                this,
                MsgToken.Create(nameof(TomatoClockViewModel), nameof(TomatoClockView), "CloseWindow"),
                (r, m) => {
                this.Close();
            });
        }
示例#5
0
        public static void Process(User user, byte[] packet)
        {
            var msgToken = (MsgToken)packet;
            var path     = msgToken.GetToken;

            string token;

            if (!user.Tokens.ContainsKey(path))
            {
                token = Guid.NewGuid().ToString().Replace("-", "");
                user.Tokens.Add(path, token);
            }
            else
            {
                token = user.Tokens[path];
            }

            FConsole.WriteLine("Token Created: " + token + " for: " + path);

            msgToken = MsgToken.Create(token, 0, true);
            user.Send(msgToken);
        }