Esempio n. 1
0
 public MainWindowPresenter(RevisionManager revisionManager)
 {
     _revisionManager = revisionManager;
     _db = _revisionManager.Database;
     FixMissingInfo();
     PopulateListData();
 }
Esempio n. 2
0
        public async Task ExecutesCorrectly()
        {
            var fs          = new MockFileSystem();
            var api         = new MockAPIConnector(fs);
            var revisionMgr = new RevisionManager(new ConfigFile("C:\\SFM"), fs);
            var ids         = new List <int>()
            {
                1337
            };
            var installationPresenter = new InstallationPresenter(api, fs, revisionMgr, ids);

            /* Create fake revision to download */
            fs.CreateDirectory("C:\\tmp");
            fs.CreateDirectory("C:\\tmp\\models");
            fs.CreateFile("C:\\tmp\\models\\model.ext");
            fs.CreateDirectory("C:\\tmp\\materials");
            fs.CreateFile("C:\\tmp\\materials\\material.ext");
            var revision = Revision.CreateTemporaryRevisionFromFolder(1337, "C:\\tmp", fs);

            api.AddRevision("C:\\tmp", revision);

            await installationPresenter.Execute();

            Assert.IsTrue(revisionMgr.VerifyInstalled(revision, null));
        }
Esempio n. 3
0
        private bool StartInstallation(int id)
        {
            /* force refresh */
            _revMgr = new RevisionManager(_config.Read(), WindowsFileSystem.Instance);

            if (_revMgr.IsInstalled(id))
            {
                var msg = MessageBox.Show("This revision is already installed. Do you want to uninstall?",
                                          "PonySFM", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (msg == MessageBoxResult.Yes)
                {
                    var list = new List <int>()
                    {
                        id
                    };
                    new Deinstallation.DeinstallationWindow(_revMgr, list, true).ShowDialog();
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                var ids = new List <int>()
                {
                    id
                };
                new Installation.InstallationWindow(ids, _revMgr, true).ShowDialog();
            }

            PonySFM_Workshop.Main.MainWindow.Instance.RefreshListData();

            return(true);
        }
Esempio n. 4
0
        public void CreatesDirectory()
        {
            var configFile      = new ConfigFile(Dir);
            var fs              = new MockFileSystem();
            var revisionManager = new RevisionManager(configFile, fs);

            Assert.IsTrue(fs.DirectoryExists(Dir));
        }
Esempio n. 5
0
 public ModPage(RevisionManager revisionManager, Revision revision)
 {
     _revisionManager = revisionManager;
     _revision        = revision;
     _presenter       = new ModPagePresenter(revision);
     _presenter.View  = this;
     InitializeComponent();
 }
 public VerificationWindow(List <int> ids, RevisionManager revisionManager)
 {
     _presenter = new VerificationPresenter(revisionManager, ids)
     {
         View = this
     };
     _revisionManager = revisionManager;
     InitializeComponent();
 }
Esempio n. 7
0
 public VerificationPresenter(RevisionManager revisionManager, List <int> ids)
 {
     _revisionManager = revisionManager;
     _ids             = ids;
     foreach (var id in _ids)
     {
         _uninstallProgress[id] = 0;
     }
 }
Esempio n. 8
0
 public DeinstallationWindow(RevisionManager revisionManager, List <int> ids, bool closeOnFinish = false)
 {
     _presenter = new DeinstallationPresenter(revisionManager, ids)
     {
         View = this
     };
     _closeOnFinish = closeOnFinish;
     InitializeComponent();
 }
        public InstallationWindow(List <int> ids, RevisionManager revisionMgr, bool closeOnFinish = false)
        {
            _presenter      = new InstallationPresenter(PonySFMAPIConnector.Instance, WindowsFileSystem.Instance, revisionMgr, ids);
            _presenter.View = this;
            _closeOnFinish  = closeOnFinish;

            _presenter.OnFileExists += OnFileExistsTriggered;

            InitializeComponent();
        }
Esempio n. 10
0
 public MainPage(MainWindow window, ConfigFile configFile, RevisionManager revisionManager)
 {
     _window          = window;
     _configFile      = configFile;
     _revisionManager = revisionManager;
     _sfmDirParser    = new SFMDirectoryParser(_configFile.SfmDirectoryPath, WindowsFileSystem.Instance);
     _presenter       = new MainWindowPresenter(revisionManager);
     _presenter.View  = this;
     InitializeComponent();
 }
Esempio n. 11
0
 public InstallationPresenter(IApiConnector api, IFileSystem fs, RevisionManager revisionMgr, List <int> ids)
 {
     _api         = api;
     _fs          = fs;
     _revisionMgr = revisionMgr;
     _ids         = ids;
     _progress    = 0;
     _progresses.Add(ProgressState.Download, 0);
     _progresses.Add(ProgressState.Extraction, 0);
     _progresses.Add(ProgressState.Installation, 0);
 }
Esempio n. 12
0
        public async Task InstallsRevisionCorrectly()
        {
            var configFile      = new ConfigFile(Dir);
            var fs              = new MockFileSystem();
            var revisionManager = new RevisionManager(configFile, fs);

            Util.CreateSFMDirectory(fs);
            var revision = Util.CreateFakeTempRevision(fs);

            await revisionManager.InstallRevision(revision, "C:\\tmp", null);

            Assert.IsTrue(revisionManager.VerifyInstalled(revision, null));
        }
Esempio n. 13
0
        public void InitialisePages()
        {
            var config       = new ConfigHandler(ModManager.ConfigFileLocation, WindowsFileSystem.Instance);
            var configFile   = config.Read();
            var revMgr       = new RevisionManager(configFile, WindowsFileSystem.Instance);
            var sfmDirParser = new SFMDirectoryParser(configFile.SfmDirectoryPath, WindowsFileSystem.Instance);

            _sfmDirParser = sfmDirParser;
            _configFile   = configFile;

            _pages["MainPage"]     = new MainPage(Instance, configFile, revMgr);
            _pages["SettingsPage"] = new SettingsPage(config);
            _pages["LicensesPage"] = new Licenses.LicensesPage();
            _pages["AboutPage"]    = new About.AboutPage(revMgr.Database);

            Instance.SetPage("MainPage");
        }
Esempio n. 14
0
        public MainWindow(int userID)
        {
            InitializeComponent();

            _instance = new RevisionManager();

            _userId = userID;

            // populate information
            SetCurrentUserInformation();
            PopulateProjectInfo();
            GetRevisionsFromProjectID(_projectID);
            GetAllTasksFromRevisionAndPopulate();
            PopulateComboBoxUrgency();
            PopulateComboBoxProgress();
            PopulateProjectsDependOnUser();
        }
        public void Setup()
        {
            // instantiate
            _revisionManager = new RevisionManager();

            // Create User and Project Test Data
            using (var db = new MonokayuDbContext())
            {
                // create user and project to test
                db.Add(new User2()
                {
                    firstName = "PersonNameTest", lastName = "PersonLastNameTest", securityLevel = 0, password = "******"
                });
                db.Add(new Project2()
                {
                    projectName = "ProjectNameForTesting"
                });

                db.SaveChanges();
            }

            // Set global variables
            using (var db = new MonokayuDbContext())
            {
                // locate data and obtain ids
                var userID    = db.Users2.Where(u => u.firstName == "PersonNameTest").Where(c => c.lastName == "PersonLastNameTest").FirstOrDefault().UserID;
                var projectID = db.Projects2.Where(p => p.projectName == "ProjectNameForTesting").FirstOrDefault().ProjectID;

                // assign users to project using joining table
                db.Add(new UserProject()
                {
                    userID = userID, projectID = projectID
                });

                _userIdToTest    = userID;
                _projectIdToTest = projectID;
                db.SaveChanges();
            }

            //using (var db = new MonokayuDbContext())
            //{
            //    db.Add(new Revision() { ProjectID = _projectIdToTest, deadline = DateTime.Now });
            //    db.SaveChanges();
            //}
        }
        public async Task ExecutesCorrectly()
        {
            var configFile      = new ConfigFile("C:\\SFM");
            var fs              = new MockFileSystem();
            var revisionManager = new RevisionManager(configFile, fs);

            fs.CreateDirectory("C:\\SFM");
            fs.CreateDirectory("C:\\SFM\\ponysfm");

            fs.CreateDirectory("C:\\tmp");
            fs.CreateDirectory("C:\\tmp\\models");
            fs.CreateFile("C:\\tmp\\models\\pony.vtf");

            fs.CreateDirectory("C:\\tmp\\materials");
            fs.CreateFile("C:\\tmp\\materials\\pony.vmt");

            var files = new List <RevisionFileEntry>
            {
                RevisionFileEntry.FromFile("C:\\tmp\\models\\pony.vtf", fs),
                RevisionFileEntry.FromFile("C:\\tmp\\materials\\pony.vmt", fs)
            };

            var revision = new Revision(1, files);

            await revisionManager.InstallRevision(revision, "C:\\tmp", null);

            Assert.IsTrue(revisionManager.VerifyInstalled(revision, null));

            var list = new List <int> {
                1
            };

            var deinstallationPresenter = new DeinstallationPresenter(revisionManager, list);

            await deinstallationPresenter.Execute();

            Assert.IsFalse(revisionManager.VerifyInstalled(revision, null));

            foreach (var file in revision.Files)
            {
                Assert.IsFalse(fs.FileExists(file.Path));
            }
        }
Esempio n. 17
0
        public async Task UninstallsRevisionCorrectly()
        {
            var configFile      = new ConfigFile(Dir);
            var fs              = new MockFileSystem();
            var revisionManager = new RevisionManager(configFile, fs);

            Util.CreateSFMDirectory(fs);
            var revision = Util.CreateFakeTempRevision(fs);

            await revisionManager.InstallRevision(revision, "C:\\tmp", null);

            Assert.IsTrue(revisionManager.VerifyInstalled(revision, null));

            await revisionManager.UninstallRevision(revision.ID, null);

            Assert.IsFalse(revisionManager.VerifyInstalled(revision, null));

            foreach (var file in revision.Files)
            {
                Assert.IsFalse(fs.FileExists(file.Path));
            }
        }
Esempio n. 18
0
 public DeinstallationPresenter(RevisionManager revisionManager, List <int> uninstallList)
 {
     _revisionManager = revisionManager;
     _uninstallList   = uninstallList;
 }
Esempio n. 19
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ModManager.CreateFolders();

#if !DEBUG
            if (!UriProtocolExists())
            {
                InstallUriProtocol();
            }
#endif
            bool mutexCreated;
            // The string can be anything, but re-producing the same GUID would be quite a thing.
            _appMutex = new Mutex(true, MainMutexName, out mutexCreated);

            if (mutexCreated)
            {
                Logger.Open();
                StartPipeThread();
            }

            _config = new ConfigHandler(ModManager.ConfigFileLocation, WindowsFileSystem.Instance);
            if (_config.Exists())
            {
                _revMgr = new RevisionManager(_config.Read(), WindowsFileSystem.Instance);

                if (e.Args.Length == 1)
                {
                    var uri = e.Args[0];
                    uri = uri.TrimStart("ponysfm://".ToCharArray());
                    uri = uri.TrimEnd('/');
                    var id = Convert.ToInt32(uri);

                    if (mutexCreated)
                    {
                        StartInstallation(id);
                        return;
                    }
                    else
                    {
                        SendPipeString(id.ToString());
                    }
                }

                if (mutexCreated)
                {
                    PonySFM_Workshop.Main.MainWindow.Instance.InitialisePages();
                    PonySFM_Workshop.Main.MainWindow.Instance.Show();
                }
                else
                {
                    SendPipeString("BringToFront");
                }
            }
            else // Installation mode
            {
                var w = Setup.SetupWindow.Instance;
                w.SetPage(new Setup.Greeting.SetupGreeting());
                w.Show();
            }

            /* Immediately shut down if in client mode */
            if (!mutexCreated)
            {
                Shutdown();
            }
        }