Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            bool showWelcome = false;

            try
            {
                //Open connection to the server
                service.Open();

                ((ICommunicationObject)service).Faulted += new EventHandler(delegate
                {
                    MessageBox.Show("Service faulted!");
                });

                showWelcome = true;
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Main Window - Exception: {0}", e.Message);
                showWelcome = false;
            }

            if (showWelcome)
            {
                string email = Properties.Settings.Default.email;
                string pass  = Properties.Settings.Default.password;

                WelcomePage welcome;
                if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(pass))
                {
                    welcome = new WelcomePage(service);
                }
                else
                {
                    LoginData loginData = new LoginData();

                    loginData.EmailAddress = email;
                    loginData.Password     = pass;

                    LoginResult result = service.UserLogin(loginData);

                    if (result.Status == OperationStatus.Success)
                    {
                        welcome = new WelcomePage(service, result.NickName, email);
                    }
                    else
                    {
                        welcome = new WelcomePage(service);
                    }
                }

                mainFrame.NavigationService.Navigate(welcome);
            }
            else
            {
                string    message   = "Failed to connect to server!" + Environment.NewLine + "Try to connect later.";
                ErrorPage errorPage = new ErrorPage(message);
                mainFrame.NavigationService.Navigate(errorPage);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Back to the Welcome page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backButton_Click(object sender, RoutedEventArgs e)
        {
            WelcomePage welcome = new WelcomePage(service);

            NavigationService.Navigate(welcome);
        }