public HomeScreen( IApplicationManager applicationManager, IEventService eventService, IApplicationService appService, List <ApplicationInstanceVisual> applicationInstances) : base() { this.applications = applicationInstances; this.applicationDashboard = appService.Kernel.Get <ApplicationDashboard>( new ConstructorArgument("applications", applicationInstances)); eventService.RegisterKeyboardCallback(Id, new KeyPressCallbackEventArgs(Keyboard.Key.Left), applicationDashboard.LeftKeyPressed); eventService.RegisterKeyboardCallback(Id, new KeyPressCallbackEventArgs(Keyboard.Key.Right), applicationDashboard.RightKeyPressed); eventService.RegisterMouseClickCallback(Id, new MouseClickCallbackEventArgs(Mouse.Button.Left), applicationDashboard.OnMouseClick); eventService.RegisterMouseWheelScrollCallback(Id, applicationDashboard.OnMouseWheelMove); eventService.RegisterKeyboardCallback( Id, new KeyPressCallbackEventArgs(Keyboard.Key.Enter), (_) => applicationManager.SetActiveApplication(selectedApplication)); }
private ApplicationDefinition CreateApplicationDefinition(List <Reference> references, IEnumerable <PackageFile> files) { var defaultEnvironments = DefaultEnvironments.Select( e => ( TargetEnvironment )Enum.Parse(typeof(TargetEnvironment), e)); var scripts = files.Where(f => f.Environment != TargetEnvironment.None); var specifiedEnvironments = scripts.Where(f => f.Environment != TargetEnvironment.All).Select(f => f.Environment).Distinct(); specifiedEnvironments = specifiedEnvironments.Union(defaultEnvironments); Guid = Guid.Replace("{", "").Replace("}", ""); ApplicationDefinition appdef = new ApplicationDefinition { Name = ApplicationName, Guid = Guid, Version = ApplicationVersion, Description = Description, Publisher = Publisher, Copyright = Copyright, RequiredMFilesVersion = MFilesVersion, EnabledByDefault = EnabledByDefault, Optional = Optional, MasterApplicationGuid = MasterApplicationGuid, Platforms = Platforms.Select(platformName => new Platform(platformName)).ToList() }; // Create the module elements. foreach (var env in specifiedEnvironments) { var module = new ApplicationModule { Environment = env.ToString().ToLower() }; appdef.Modules.Add(module); // Add the bootstrap scripts. module.Files.Add(new ApplicationFile { Name = "_package_start.js" }); // Add javascript files from the references. foreach (var r in references) { var referencedScripts = r.GetScriptsForEnvironment(env); foreach (var script in referencedScripts) { var file = new ApplicationFile { Name = r.PackageName + "/" + script }; module.Files.Add(file); } } // Add the application's own javascript files. var environmentScripts = scripts.Where(s => s.Environment == TargetEnvironment.All || s.Environment == env); foreach (var script in environmentScripts) { var file = new ApplicationFile { Name = script.PathInProject }; module.Files.Add(file); } module.Files.Add(new ApplicationFile { Name = "_package_end.js" }); } foreach (var db in files.Where(f => f.IsDashboard)) { var dashboard = new ApplicationDashboard { Id = Path.GetFileNameWithoutExtension(db.PathInProject), Content = db.PathInProject }; appdef.Dashboards.Add(dashboard); } foreach (var r in references) { foreach (var db in r.GetDashboards()) { var dashboard = new ApplicationDashboard { Id = db.Key, Content = r.PackageName + "/" + db.Value }; appdef.Dashboards.Add(dashboard); } } return(appdef); }