Пример #1
0
        private void LeaseBook()
        {
            Action redo = () =>
            {
                SelectedBook.LeasedTo = Session.Current.LoggedInUser;

                LeaseCommand.RaiseCanExecuteChanged();
                OnPropertyChanged("SelectedBook");
                BookList.Refresh();
            };
            Action undo = () =>
            {
                SelectedBook.LeasedTo = string.Empty;

                LeaseCommand.RaiseCanExecuteChanged();
                OnPropertyChanged("SelectedBook");
                BookList.Refresh();
            };

            history.AddAndExecute(new RevertableCommand(redo, undo));
            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();

            ClientLogger.Log($"{Session.Current.LoggedInUser} leased book {selectedBook.BookName}", Common.LogLevel.Info);
        }
Пример #2
0
        private void CreateUser(object param)
        {
            PasswordBox pw = param as PasswordBox;

            if (!ValidateUserData(pw.Password == null ? string.Empty : pw.Password))
            {
                return;
            }

            if (!Session.Current.LibraryProxy.CreateUser(UsernameTextBox, pw.Password, FirstNameTextBox, LastNameTextBox))
            {
                ErrorText = "User already exists.";
                return;
            }

            ClientLogger.Log("Admin has created a new user with username " + UsernameTextBox, Common.LogLevel.Debug);

            UsernameTextBox  = string.Empty;
            FirstNameTextBox = string.Empty;
            LastNameTextBox  = string.Empty;
            pw.Password      = string.Empty;
            ErrorText        = string.Empty;
            OnPropertyChanged("UsernameTextBox");
            OnPropertyChanged("FirstNameTextBox");
            OnPropertyChanged("LastNameTextBox");
        }
Пример #3
0
        private void SendMissingOptionalRequirements(ClientLogger logger)
        {
            bool bWMPExists = false;
            bool bQTExists  = false;

            CheckOptionalRequirements(ref bWMPExists, ref bQTExists);

            if (!bWMPExists)
            {
                logger.Log("FinalInstallMissing_WMP");
            }

            if (!bQTExists)
            {
                logger.Log("FinalInstallMissing_QT");
            }
        }
Пример #4
0
 public void LogNotMetPrerequisites(ClientLogger logger)
 {
     foreach (InstallationPrerequisite prerequisite in _prerequisites)
     {
         if (prerequisite.PrerequisiteStatus == PrerequisiteStatus.DoesNotExist)
         {
             logger.Log(prerequisite.LogMessage);
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Attempt to set the display mode to the desired resolution.  Itterates through the display
        /// capabilities of the default graphics adapter to determine if the graphics adapter supports the
        /// requested resolution.  If so, the resolution is set and the function returns true.  If not,
        /// no change is made and the function returns false.
        /// </summary>
        /// <param name="iWidth">Desired screen width.</param>
        /// <param name="iHeight">Desired screen height.</param>
        /// <param name="bFullScreen">True if you wish to go to Full Screen, false for Windowed Mode.</param>
        public bool InitGraphicsMode(int iWidth, int iHeight, bool bFullScreen, bool doICare)
        {
            IsChanged = false;
            // If we aren't using a full screen mode, the height and width of the window can
            // be set to anything equal to or smaller than the actual screen size.
            if (bFullScreen == false)
            {
                if ((iWidth <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width) &&
                    (iHeight <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height) || doICare)
                {
                    WindowSizeX = iWidth;
                    WindowSizeY = iWidth;
                    _graphics.PreferredBackBufferWidth  = iWidth;
                    _graphics.PreferredBackBufferHeight = iHeight;
                    Fullscreen             = bFullScreen;
                    _graphics.IsFullScreen = bFullScreen;
                    _graphics.ApplyChanges();

                    ClientLogger.Log(Log_Type.INFO,
                                     "Initialized Graphics in Windowed Mode at " + iWidth + "x" + iHeight + " resolution.");
                    return(true);
                }
            }
            else
            {
                // If we are using full screen mode, we should check to make sure that the display
                // adapter can handle the video mode we are trying to set.  To do this, we will
                // iterate thorugh the display modes supported by the adapter and check them against
                // the mode we want to set.
                foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
                {
                    // Check the width and height of each mode against the passed values
                    if ((dm.Width == iWidth) && (dm.Height == iHeight))
                    {
                        // The mode is supported, so set the buffer formats, apply changes and return
                        WindowSizeX = iWidth;
                        WindowSizeY = iWidth;
                        _graphics.PreferredBackBufferWidth  = iWidth;
                        _graphics.PreferredBackBufferHeight = iHeight;
                        Fullscreen             = bFullScreen;
                        _graphics.IsFullScreen = bFullScreen;
                        _graphics.ApplyChanges();

                        ClientLogger.Log(Log_Type.INFO,
                                         "Initialized Graphics in Fullscreen Mode at " + iWidth + "x" + iHeight +
                                         " resolution.");
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #6
0
        private void DeleteBook()
        {
            if (Session.Current.LibraryProxy.DeleteBook(selectedBook.BookName))
            {
                ClientLogger.Log($"Book {selectedBook.BookName} deleted successfully.", Common.LogLevel.Info);
            }
            else
            {
                ClientLogger.Log($"Book {selectedBook.BookName} could not be deleted.", Common.LogLevel.Error);
            }

            RefreshList();
        }
Пример #7
0
        public WindowsMain(ClientEnvironmentType environment)
        {
            _environment = environment;

            //ProtobufMappingSetup.Setup();

            ClientLogger.init(); // Initializes logger
            ClientLogger.Log(Log_Type.INFO, "Game Initialized");
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _LoginConfig = new LoginConfig();

            this.Exiting += Main_Exiting;
        }
Пример #8
0
        private void NewBook()
        {
            var win             = new View.NewBookWindow();
            NewBookViewModel vm = (NewBookViewModel)win.DataContext;

            win.ShowDialog();

            if (Session.Current.LibraryProxy.CreateBook(vm.BookName, vm.Author, int.Parse(vm.PublicationYear)))
            {
                ClientLogger.Log($"Book {vm.BookName} successfully created.", Common.LogLevel.Info);
            }
            else
            {
                ClientLogger.Log($"Book {vm.BookName} could not be created.", Common.LogLevel.Error);
            }

            RefreshList();
        }
Пример #9
0
        private void UpdateShipPosition(PositionUpdateData posUpdate)
        {
            var s = _clientShipManager.GetShip(posUpdate.TargetId);

            if (s == null)
            {
                ClientLogger.Log(Log_Type.ERROR, "RECIEVED POSITION UPDATE FOR A SHIP THAT WAS NOT IN THE SHIPLIST");
                return;
            }
#if DEBUG
            if (_clientShipManager.PlayerShip != null && s.Id == _clientShipManager.PlayerShip.Id)
            {
                ConsoleManager.WriteLine("Error: Received position update for player ship!", ConsoleMessageType.Error);
            }
#endif

            _clientShipManager.HandlePositionUpdate(posUpdate);

            s.Shields.CurrentShields = (int)posUpdate.CurrentShields;
            s.CurrentHealth          = (int)posUpdate.CurrentHealth;
            s.Thrusting = posUpdate.Thrusting;
        }
Пример #10
0
        private void EditBook()
        {
            var win             = new View.NewBookWindow();
            NewBookViewModel vm = (NewBookViewModel)win.DataContext;

            vm.BookName        = selectedBook.BookName;
            vm.Author          = selectedBook.Author.AuthorName;
            vm.PublicationYear = selectedBook.PublicationYear.ToString();

            win.ShowDialog();

            if (Session.Current.LibraryProxy.EditBook(selectedBook.BookName, vm.BookName, vm.Author, int.Parse(vm.PublicationYear)))
            {
                ClientLogger.Log($"Book {vm.BookName} successfully edited.", Common.LogLevel.Info);
            }
            else
            {
                ClientLogger.Log($"Book {vm.BookName} could not be edited.", Common.LogLevel.Error);
            }

            RefreshList();
        }
Пример #11
0
        private void Login(object parameter)
        {
            PasswordBox pass = parameter as PasswordBox;

            LogInInfo loginInfo;

            using (var c = new WaitCursor())
            {
                loginInfo = Session.Current.LibraryProxy.LogIn(Username, pass.Password);
            }

            if (loginInfo == LogInInfo.Sucess)
            {
                Session.Current.LoggedInUser = Username;

                MainWindow mw = new MainWindow();
                mw.Show();

                Application.Current.MainWindow.Close();
                Application.Current.MainWindow = mw;

                ClientLogger.Log("Successfully logged in.", Common.LogLevel.Info);
            }
            else
            {
                if (loginInfo == LogInInfo.WrongUserOrPass)
                {
                    ErrorText = "Username or password is incorrect.";
                }
                else
                {
                    ErrorText = "Account already connected.";
                }

                ClientLogger.Log("Unsuccessful login attempt.", Common.LogLevel.Error);
            }
        }
Пример #12
0
 private void DuplicateBook(Book b)
 {
     ClientLogger.Log($"Book {b.BookName} duplicated.", Common.LogLevel.Info);
     Session.Current.LibraryProxy.DuplicateBook(b);
     RefreshList();
 }
Пример #13
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var settings = new SettingsManager();

            // Changes size of GameWindow.
            // Todo: Clean this up.
            var m = new RenderingMath(_graphics);

            m.InitGraphicsMode(
                SettingsManager.GameWidth,
                SettingsManager.GameHeight,
                SettingsManager.Fullscreen,
                true
                );

            var bloom = new BloomComponent(Content, _spriteBatch);

            _bloomSettingsIndex = (_bloomSettingsIndex + 1)
                                  % BloomSettings.PresetSettings.Length;

            bloom.Settings = BloomSettings.PresetSettings[6];

            ClientLogger.Log(Log_Type.INFO, "Assets Loaded");

            #region Autofac (disabled, couldn't get it to work, sorry Free!)

            /*
             *
             *
             * //HudManager.Initialize(Content, spriteBatch, GraphicsDevice); // Just Chatbox and Radar
             *
             * //_UI.OnDocumentCompleted += OnDocumentCompleted;
             *
             * // Included so that it forces the assemblies to load into AutoFac
             * var whatever = typeof(MainManager);
             * var whatever2 = typeof(GameStateManager);
             * var whatever3 = typeof(GlobalGameWebLayer);
             * var whatever4 = typeof(PlanetStateManager);
             *
             * // Todo: Gut this in favor of reactive flow.
             * var _bus = BusSetup.StartWith<Conservative>()
             *                 .Apply<FlexibleSubscribeAdapter>(a => a.ByInterface(typeof(IHandle<>)))
             *                 .Construct();
             *
             * // Create your builder.
             * var builder = new ContainerBuilder();
             *
             *
             * builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies())
             *  .Where(p =>
             *      (p.Name.Contains("Manager") || p.Name.Contains("Factory") || p.Name.Contains("Service") || p.Name.Contains("WebLayer")) &&
             *      p.Name != "PhysicsManager")
             *  .InstancePerLifetimeScope();
             *
             * builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies())
             *  .Where(p => p.Name.Contains("Manager") || p.Name.Contains("Factory") || p.Name.Contains("Service") || p.Name.Contains("WebLayer"))
             *  .AsSelf()
             *  .AsImplementedInterfaces()
             *  .InstancePerLifetimeScope();
             *
             * //builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies())
             * //    .Where(p => p is IGameState)
             * //    .SingleInstance();
             *
             *
             * //Configure single instances, overriding .InstancePerDependency
             * builder.RegisterType<MainNetworkingManager>().SingleInstance();
             * builder.RegisterType<NetworkingService>().SingleInstance();
             * builder.RegisterType<ClientManager>().SingleInstance();
             * builder.RegisterType<MessageService>().SingleInstance();
             * builder.RegisterType<PlayerShipManager>().SingleInstance();//PlayerShip is currently only sent on login
             * builder.RegisterType<KeyboardManager>().SingleInstance();
             * builder.RegisterType<textDrawingService>().SingleInstance();
             *
             *
             *
             *
             * builder.RegisterInstance<LoginConfig>(new LoginConfig()).SingleInstance();
             *
             * var uiPath = Directory.GetCurrentDirectory();
             *
             * switch (_environment)
             * {
             *  case ClientEnvironmentType.Development:
             *      builder.RegisterInstance<IClientWebViewConfig>(new DebugClientWebViewConfig()).SingleInstance();
             *      break;
             *
             *  default:
             *      throw new Exception("You should add a production config, yo!");
             * }
             *
             * // XNA classes
             * builder.RegisterInstance<SpriteBatch>(_spriteBatch).SingleInstance();
             * builder.RegisterInstance<GraphicsDeviceManager>(_graphics).SingleInstance();
             * builder.RegisterInstance<GraphicsDevice>(_graphics.GraphicsDevice).SingleInstance();
             * builder.RegisterInstance<ContentManager>(Content).SingleInstance();
             * builder.RegisterInstance<SettingsManager>(settings).SingleInstance();
             * builder.RegisterInstance<Game>(this).SingleInstance();
             * builder.RegisterInstance<GameWindow>(GameWindow).SingleInstance();
             *
             * builder.RegisterInstance<Random>(new Random(8)).SingleInstance();
             * builder.RegisterInstance<BloomComponent>(bloom).SingleInstance();
             * builder.RegisterInstance<IBus>(_bus).SingleInstance();
             * builder.RegisterInstance<WindowsMain>(this).SingleInstance();
             * builder.RegisterInstance<IClientLogger>(new FakeLogger()).SingleInstance();
             *
             * builder.RegisterType<MainManager>().AsSelf();
             *
             * //builder.RegisterType<PlanetStateManager>().SingleInstance();
             * //builder.RegisterType<SpaceStateManager>().SingleInstance();
             * //builder.RegisterType<PortStateManager>().SingleInstance();
             * //builder.RegisterType<LoginStateManager>().SingleInstance();
             * object scope1 = new object();
             *
             *
             * builder.RegisterType<PhysicsManager>().InstancePerLifetimeScope();
             *
             *
             * _container = builder.Build();
             *
             *
             *
             *
             * List<GameStateType> PlayableGameStateScopes = new List<GameStateType> { GameStateType.Planet, GameStateType.Space, GameStateType.Port };
             *
             *
             * ContainerBuilder b1 = new ContainerBuilder();
             *
             * PlanetStateManager planetsm;
             * using(var scope = _container.BeginLifetimeScope("scope1"))
             * {
             *  //var physm = scope.Resolve<PhysicsManager>();
             *  //builder.RegisterInstance<PhysicsManager>(physm).AsSelf().SingleInstance();
             *  planetsm = scope.Resolve<PlanetStateManager>();
             * }
             * b1.RegisterInstance<PlanetStateManager>(planetsm).SingleInstance();
             *
             * SpaceStateManager spacesm;
             * using (var scope = _container.BeginLifetimeScope("scope2"))
             * {
             *  spacesm = scope.Resolve<SpaceStateManager>();
             * }
             * b1.RegisterInstance<SpaceStateManager>(spacesm).SingleInstance().ExternallyOwned();
             *
             * PortStateManager portsm;
             * using (var scope = _container.BeginLifetimeScope("scope3"))
             * {
             *  portsm = scope.Resolve<PortStateManager>();
             * }
             * b1.RegisterInstance<PortStateManager>(portsm).SingleInstance();
             *
             *
             *
             * b1.Update(_container);
             *
             * //var container2 = b1.Build();
             * using (var scope = _container.BeginLifetimeScope("scope4"))
             * {
             *  _mainManager = _container.Resolve<MainManager>();
             *  //_container.Resolve<GameStateNetworkingManager>();
             * }
             *
             */

            #endregion

            _mainManager = _manualBuild();
        }
Пример #14
0
 private void SaveAccountChanges()
 {
     Session.Current.LibraryProxy.EditUserInfo(Session.Current.LoggedInUser, FirstNameTextBox, LastNameTextBox);
     ClientLogger.Log($"Account {Session.Current.LoggedInUser} successfully edited.", Common.LogLevel.Info);
 }