Example #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");
            }
        }
Example #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");
                }
            }
        }
Example #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();
     }
 }
Example #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");
            }
        }
Example #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");
            }
        }