static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            IService        server          = new ServerProxy("127.0.0.1", 55555);
            AppController   appController   = new AppController(server);
            LoginController loginController = new LoginController(server);
            LoginWindow     login           = new LoginWindow(loginController);
            AppWindow       mainWindow      = new AppWindow(appController);

            appController.set(loginController, login, mainWindow);
            loginController.set(appController, login, mainWindow);
            Application.Run(login);
        }
        public void SetUp(bool openedByAnotherWindow)
        {
            try
            {
                Client.ClientUtils.SetupServerConnection(); //Set connection to WCF Server

                ClientUtils.clientDetails = new ClientDetails();

                if (openedByAnotherWindow) //Open after 'SignedOut' button pressed - From SharingFilesWindow
                {
                    InitializeComponent();
                }
                else //Application opened from client computer
                {
                    InitializeComponent();
                    Hide();

                    //Get user details (from Config file or from GUI)
                    if (File.Exists(Consts.CONFIGURATION_FILE_NAME)) //Configurations file exist - Get details from file
                    {
                        try
                        {
                            ClientUtils.clientDetails = ClientUtils.GetDetailsFromConfigurationFile();
                            //Details get from configuration file - Try Sign In
                            ClientUtils.SignIn();
                            //Sign In success - Move to SharingFilesWindow
                            AppWindow appWindow = new AppWindow();
                            appWindow.Show();
                            Close();
                        }
                        catch (Exception ex) //Error occured - Get details from user
                        {
                            Show();
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }
                    else //Configuration file not exist - Get details from user
                    {
                        Show();
                    }
                }
            }
            catch (Exception)
            {
                ClientUtils.SignOut();
                Close();
            }
        }
        // On submit button try to connect user
        private async void submitButton_Click(object sender, RoutedEventArgs e)
        {
            this.startLoading();
            this.user = new User()
            {
                username = usernameTextBox.Text,
                password = passwordTextBox.Password
            };

            Message request = new Message()
            {
                application = this.application,
                operation   = "authentication",
                user        = user
            };

            Response response = await proxy.DispatcherAsync(request);

            Console.WriteLine("Operation " + request.operation + " --- " + response.status);

            if (response.status == "SUCCESS")
            {
                stopLoading();
                User connectedUser = response.user;
                Console.WriteLine("User info : ");
                Console.WriteLine("Username : "******"Password : "******"Token : " + connectedUser.token);
                Console.WriteLine("LastConnection : " + connectedUser.lastConnection);
                Console.WriteLine("TokenExpiration : " + connectedUser.tokenExpiration);

                this.appWindow         = new AppWindow();
                App.Current.MainWindow = this.appWindow;
                this.appWindow.setUser(connectedUser);
                this.appWindow.setAppInfo(this.application);
                // Close auth window
                this.Close();

                // Open main window
                this.appWindow.Show();
            }
            else
            {
                stopLoading();
                MessageBox.Show("Error : Wrong username or password please try again");
            }
        }
 private void signInButton_Click(object sender, RoutedEventArgs e)
 {
     ClientUtils.clientDetails.Username = UsernameTextBox.Text;
     ClientUtils.clientDetails.Password = PasswordTextBox.Text;
     ClientUtils.clientDetails.IP       = ClientUtils.GetIpLocalAddress();
     ClientUtils.clientDetails.Port     = int.Parse(Consts.CLIENT_PORT);
     try
     {
         ClientUtils.SetConfigurationFile();
         ClientUtils.SignIn();
         //Signed In successfully - Show AppWindow
         AppWindow appWindow = new AppWindow();
         appWindow.Show();
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #5
0
 public void set(LoginController loginController, LoginWindow loginWindow, AppWindow appWindow)
 {
     this.loginController = loginController;
     this.loginWindow     = loginWindow;
     this.appWindow       = appWindow;
 }