Exemple #1
0
 private static void errorMessage(IErrorMessagesPresenter errorPresenter, ErrorMessageSeverity ems, string module, string message)
 {
     if (errorPresenter != null)
     {
         errorPresenter.ErrorMessage(ems, module, message);
     }
 }
        public void Show(string ipAddress, int port, int leaguesID, int roundsID, IProfileRepository profileRepository, IErrorMessagesPresenter errorPresenter, IConnectionRelayer connectionRelayer, IGameMatch gameMatch)
        {
            if (connectionDialog != null)
            {
                connectionDialog.Close();
            }

            connectionDialog = new ConnectionDialog(ipAddress, port, leaguesID, roundsID,
                    ProfileRepository.Instance, consolePane, this, null);
            connectionDialog.Owner = this;
            connectionDialog.Closing += new System.ComponentModel.CancelEventHandler(modalWindow_Closing);
            connectionDialog.Show();
        }
        public InitConnection(int leaguesID, int roundsID, IProfileRepository profileRepository, 
            IErrorMessagesPresenter errorPresenter, IConnectionRelayer connectionRelayer,
            IGameMatch gameMatch)
        {
            InitializeComponent();
            this.DataContext = this;
            IpAddress = "Automatic";
            this.leaguesID = leaguesID;
            this.roundsID = roundsID;
            this.profile = profileRepository;
            this.errorPresenter = errorPresenter;
            this.connectionRelayer = connectionRelayer;
            this.gameMatch = gameMatch;

            auth = new Authentication(profileRepository.Username, profileRepository.IPAddress);
        }
        public ConnectionDialog(string ipAddress, int port, int leaguesID, int roundsID, 
            IProfileRepository profileRepository, IErrorMessagesPresenter errorPresenter, 
            IConnectionRelayer connectionRelayer, IGameMatch gameMatch)
        {
            InitializeComponent();
            this.DataContext = this;
            this.leaguesID = leaguesID;
            this.roundsID = roundsID;
            this.profile = profileRepository;
            this.errorPresenter = errorPresenter;
            this.connectionRelayer = connectionRelayer;
            this.port = port;
            this.ipAddress = ipAddress;
            this.gameMatch = gameMatch;
            endTheThread = 0;

            auth = new Authentication(profileRepository.Username, profileRepository.IPAddress);
        }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="request">i.e., "/remote/GetInitLeagues/"</param>
        /// <returns>Response of the server</returns>
        public static string GetRequestOnServer(string request, IProfileRepository profile, string module, IErrorMessagesPresenter errorPresenter)
        {
            if (profile == null) throw new UninitializedException("Server name was not initialized.");

            LastError = "";
            string output;

            if (profile.Server == String.Empty)
            {
                output = "error";
                LastError = "User is not logged in.";
                errorMessage(errorPresenter, ErrorMessageSeverity.Low, module, "User is not logged in. Please log in and click on 'Refresh'");
            }
            else
            {

                string url = profile.Server.TrimEnd(new char[] { '/' }) + request;

                try
                {
                    output = HttpReq.GetRequest(url, "");
                }
                catch (WebException e)
                {
                    output = "error";
                    LastError = "Error in communication with the server. Please try again in a while.";
                    errorMessage(errorPresenter, ErrorMessageSeverity.Medium, module, "Error in communication with the server. Additional information: " + e.Message);
                }
                catch (Exception e)
                {
                    output = "error";
                    LastError = "Unknown error occured. Please try again in a while.";
                    errorMessage(errorPresenter, ErrorMessageSeverity.High, module, "Unknown error in communication with the server. Additional information: " + e.Message);
                }

            }

            return output;
        }
 public void Initialize(IErrorMessagesPresenter errorPresenter,
     IProfileRepository profileRepository, IConnectionRelayer connectionRelayer,
     IConnectionDialogPresenter connectionDialogPresenter)
 {
     this.profile = profileRepository;
     this.profileRepository = profileRepository;
     this.errorPresenter = errorPresenter;
     this.connectionRelayer = connectionRelayer;
     this.connectionDialogPresenter = connectionDialogPresenter;
     this.Refresh();
 }
Exemple #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path">Absolute path to the directory with solvers</param>
        /// <param name="parentWindow">We need to display dialogs and the dialogs need to be bound to a window; main window reference is expected</param>
        public void Initialize(ISolverProvider solverProvider, Window parentWindow, 
            IErrorMessagesPresenter errorPresenter, IUserInquirer userInquirer, IGameServerCommunication gameServerCommunication)
        {
            this.errorPresenter = errorPresenter;
            this.gameServerCommunication = gameServerCommunication;
            this.userInquirer = userInquirer;
            this.solverProvider = solverProvider;
            solversManager = new SolversManager(solverProvider, parentWindow);
            // Register callback
            solversManager.RegisterStatusChangeCallback(solverStatusChange);
            SolversList = new ObservableCollection<string>(solversManager.Solvers); // we want to notify
            CurrentSolver = solversManager.CurrentSolver;

            solverPainter = solverProvider as ISolverPainter;

            if (solverPainter == null)
            {
                throw new Exception("Reference `solverProvider' should also implement ISolverPainter.");
            }
        }