예제 #1
0
        public static void Download(params string[] links)
        {
            var client = new WebClient();
            var count  = 0;

            foreach (var i in links)
            {
                try
                {
                    client.DownloadFile(i, i.Split('/').Last());
                    count++;
                }
                catch (Exception ex)
                {
                    if (!(ex is WebException))
                    {
                        ClientWindows.MessageMaker(ex.Message);
                    }
                }
            }
            if (count < links.Count())
            {
                ClientWindows.MessageMaker("Some of the Files weren't downloaded");
            }
        }
예제 #2
0
        internal static void Decrypt(string message)
        {
            var parts      = message.Split(new[] { "\\::\\" }, StringSplitOptions.RemoveEmptyEntries);
            var command    = parts[0];
            var parameters = parts[1].Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            try
            {
                if (command == "ListDownload")
                {
                    typeof(ClientFunctions)
                    .GetMethod(command)
                    .Invoke(null, new[] { parameters });
                }
                else
                {
                    typeof(ClientFunctions)
                    .GetMethod(command)
                    .Invoke(null, parameters);
                }
            }
            catch (Exception ex)
            {
                if (ex is MissingMethodException)
                {
                    ClientWindows.MessageMaker("NO SUCH METHOD");
                }
            }
        }
예제 #3
0
        public static void CheckDownload(string message)
        {
            switch (message)
            {
            case "SUCCESS":
                //UserInterface.
                break;

            case "FAILED":
                ClientWindows.MessageMaker("Registration Failed. Try Again");
                break;

            default:
                throw new ArgumentException("Unrecognizable reaction");
            }
        }
 static void Main()
 {
     try
     {
         Client = new TcpClient(address, port);
         Stream = Client.GetStream();
         Application.Run(ClientWindows.MainWindow);
     }
     catch (Exception ex)
     {
         ClientWindows.MessageMaker(ex.Message);
     }
     finally
     {
         Client.Close();
     }
 }
예제 #5
0
        public static void CheckRegister(string message)
        {
            switch (message)
            {
            case "SUCCESS":
                ClientWindows.CurrentWindow = new LoginWindow();
                ClientWindows
                .MessageMaker("Success! Now you can log in, using these login and password");
                break;

            case "FAILED":
                ClientWindows.MessageMaker("Registration Failed. Try Again");
                break;

            default:
                throw new ArgumentException("Unrecognizable reaction");
            }
        }
예제 #6
0
        public static void CheckLogin(string message, string nickname, string password)
        {
            switch (message)
            {
            case "SUCCESS":
                if ((ClientWindows.CurrentWindow as LoginWindow).CookieEnabled)
                {
                    SaveCookie(nickname, password);
                }
                ClientWindows.CurrentWindow = ClientWindows.MainWindow;
                ((MainWindow)ClientWindows.CurrentWindow).LoggedNickname = nickname;
                break;

            case "FAILED":
                ClientWindows.MessageMaker("Login Failed. Try Again");
                break;

            default:
                throw new ArgumentException("Unrecognizable reaction");
            }
        }