Exemplo n.º 1
0
        public void CSV_file_is_read_correct()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Should().Contain(c => c.Message == "äöü" && c.Link == "http://das.ist.toll");
            result.Should().Contain(c => c.Message == "Hello World" && c.Link == "https://link.de");
        }
        public Lok.Unik.ModelCommon.Client.ContentLibrary ToCommonModel(ContentLibrary contentLibrary, ApplicationUser user, List <string> appIds)
        {
            //if (contentLibrary.ContentItems.Any())
            //{
            //    for (var i = 0; i < appIds.Count; i++)
            //    {
            //        contentLibrary.ContentItems.ElementAt(i).AssociateApp = new Guid(appIds[i]);
            //    }
            //}

            //var content = new Lok.Unik.ModelCommon.Client.ContentLibrary
            //{
            //    Id = contentLibrary.Id,
            //    Title = contentLibrary.Title,
            //    Description = contentLibrary.Description,
            //    CreationDate = DateTime.UtcNow,
            //    CreatorPrincipalId = user.PrincipalId,
            //    CreatorUserName = user.UserName,
            //    Files = ToCommonItems(contentLibrary.ContentItems, contentLibrary.Id, user),
            //    State = State.Enabled,
            //    BasePath = contentLibrary.BasePath
            //};

            //content.Tags.Add(new TagManager().AddDefault<Lok.Unik.ModelCommon.Client.ContentLibrary>(content.Title, content.Id.ToString()));

            //return content;
            return(new ContentLibrary());
        }
Exemplo n.º 3
0
    public void InitPanel(ContentLibrary library)
    {
        contentLibrary = library;
        currTileDB     = Globals.campaign.GetTileData();

        gameObject.SetActive(true);
    }
Exemplo n.º 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            //Create an empty texture and setup the Texture2D ContentLibrary
            empty_texture = new Texture2D(GraphicsDevice, 1, 1);
            empty_texture.SetData(new Color[] { new Color(255, 255, 255, 255) });
            textures = new ContentLibrary <Texture2D>(empty_texture, Content.Load <Texture2D>("missing_texture"));

            //Setup the AsepriteDocument ContentLibrary
            aseDocs = new ContentLibrary <AsepriteDocument>(Content.Load <AsepriteDocument>("empty_aseDoc"), Content.Load <AsepriteDocument>("missing_aseDoc"));

            //Setup the AsepriteDocument ContentLibrary
            fonts = new ContentLibrary <SpriteFont>(Content.Load <SpriteFont>("empty_font"), Content.Load <SpriteFont>("missing_font"));

            //TO-DO, Load Settings
            Settings.UIScale    = 1.0f;
            Settings.Resolution = new Point(1000, 600);
            ApplySettings();

            //start the game after the content is loaded.
            ChangeGameState("menu");

#if DEBUG
            Console.WriteLine("Debug mode: on");
#else
            Console.WriteLine("Debug mode: off");
#endif
        }
Exemplo n.º 5
0
 public Animation(string sheetName, int numFrames, TimeSpan frameTime)
 {
     //spriteSheet = new SpriteSheet(sheetName);
     spriteSheet      = ContentLibrary.GetSpriteSheet(sheetName);
     this.numFrames   = numFrames;
     currentFrame     = 0;
     this.frameTime   = frameTime;
     frameRunningTime = TimeSpan.Zero;
 }
Exemplo n.º 6
0
        public void Tweet()
        {
            var token            = Token.ReadFromFile(CredentialsFilename);
            var contents         = ContentLibrary.ReadFromJsonFile(ContentLibraryFilename);
            var contentFinder    = new ContentFinder(contents);
            var contentToPublish = contentFinder.GetNextContent();
            var response         = Tweet(contentToPublish, token);

            ContentLibrary.SaveAsJsonFile(contents, ContentLibraryFilename);

            Console.WriteLine($"Id of tweet is: {response.IdStr}");
        }
        public void CreateLibrary(ContentLibrary contentLibrary, ApplicationUser user, List <System.Web.HttpPostedFileBase> fileBases, List <string> appIds)
        {
            //var cf = Catalog.Factory.Resolve<IConfig>();
            //var containerFileShare = cf[ComServerConfiguration.DistributedFileShare];
            //var contentContainerPath = cf[ContentFileStorage.ContentFilesContainer];
            //var containerLibPath = cf[ContentFileStorage.ContentLibrariesContainer];

            //var containerHost = Path.Combine(containerFileShare, contentContainerPath);
            //var directory = Path.Combine(containerHost, containerLibPath);

            //contentLibrary.Id = Guid.NewGuid();
            //contentLibrary.BasePath = directory;

            //foreach (var file in fileBases.Where(file => file.ContentLength != 0))
            //{
            //    if (contentLibrary.ContentItems == null)
            //        contentLibrary.ContentItems = new Collection<ContentItem>();

            //    contentLibrary.ContentItems.Add(new ContentItem
            //    {
            //        Id = Guid.NewGuid(),
            //        CreatorPrincipalId = user.PrincipalId,
            //        Title = file.FileName,
            //        Path = directory,

            //    });

            //}

            //using (var cntx = ContextRegistry.NamedContextsFor(this.GetType()))
            //{
            //    using (var session = DocumentStoreLocator.ContextualResolve())
            //    {
            //        session.Store(ToCommonModel(contentLibrary, user, appIds));
            //        session.SaveChanges();
            //        _log.InfoFormat("{0} Library has been Created", contentLibrary.Title);
            //    }
            //}

            //for (var i = 0; i < contentLibrary.ContentItems.Count; i++)
            //{
            //    var flh = new FileStorageHelper();
            //    byte[] fileData;
            //    var objId = string.Format("{0}.zip", contentLibrary.ContentItems.ElementAt(i).Id);

            //    using (var binaryReader = new BinaryReader(fileBases[i].InputStream))
            //        fileData = binaryReader.ReadBytes(fileBases[i].ContentLength);

            //    flh.SaveData(containerLibPath, objId, fileData);
            //    _log.InfoFormat("{0} library has been stored at '{1}'", objId, directory);
            //}
        }
Exemplo n.º 8
0
        public void GetListTest1()
        {
            ContentLibrary    target    = new ContentLibrary(); // TODO: Initialize to an appropriate value
            long              siteId    = 7512913955264234783;  // TODO: Initialize to an appropriate value
            string            @where    = string.Empty;         // TODO: Initialize to an appropriate value
            string            sortField = string.Empty;         // TODO: Initialize to an appropriate value
            IList <awContent> expected  = null;                 // TODO: Initialize to an appropriate value
            IList <awContent> actual;

            actual = target.GetList(siteId, @where, sortField);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a GameScreen which handles gameplay
        /// </summary>
        public GameScreen(ScreenHandler screenHandler)
            : base(screenHandler)
        {
            // ---------- Create ContentLibrary ----------
            _contentLibrary = new ContentLibrary(Content);

            // ---------- Create GameLevel ----------
            _gameLevel = new GameLevel(this, "poopies");
            //_gameLevel = new GameLevel(this, 40, 40, 1);

            // ---------- Create GameInterface ----------
            _gameInterface = new GameInterface(this);
        }
        public void CreateLibrary(ContentLibrary contentLibrary, ApplicationUser user, List <string> appIds)
        {
            using (var cntx = ContextRegistry.NamedContextsFor(this.GetType()))
            {
                using (var session = DocumentStoreLocator.ContextualResolve())
                {
                    contentLibrary.Id = Guid.NewGuid();

                    session.Store(ToCommonModel(contentLibrary, user, appIds));
                    session.SaveChanges();

                    _log.InfoFormat("{0} Library has been Stored sucessfully", contentLibrary.Title);
                }
            }
        }
Exemplo n.º 11
0
        private ContentLibraryViewModel ContentToViewModel(ContentLibrary content, bool gridView)
        {
            var result = new ContentLibraryViewModel
            {
                ContentType     = content.ContentType.ToString(),
                Status          = content.Status,
                Id              = content.Id,
                Created         = content.Created?.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") ?? "",
                Featured        = content.Featured,
                Precis          = content.Precis,
                ImageUrl        = MakeImageUrl(content.ImageUrl, gridView),
                Title           = content.Title,
                Url             = content.Url,
                ContentTypeText = content.ContentType.ToString(),
                StatusText      = content.Status.ToString()
            };

            return(result);
        }
Exemplo n.º 12
0
        public DeferredColoredChunkRenderer(EngineConfiguration config, ContentLibrary contentLibrary, GraphicsDevice device, CameraManager cameraManager, IChunkManager chunkManager)
        {
            _device = device;
            _sb     = new SpriteBatch(_device);

            _halfPixel = new Vector2(0.5f / _device.PresentationParameters.BackBufferWidth, 0.5f / _device.PresentationParameters.BackBufferHeight);

            _quadRenderer = new QuadRenderer(_device);

            _clearEffect            = new ClearEffect(contentLibrary.ClearEffect);
            _renderGBufferEffect    = new RenderGBufferColorEffect(contentLibrary.RenderGBufferColorEffect);
            _renderCombineEffect    = new RenderCombineEffect(contentLibrary.RenderCombineEffect);
            _directionalLightEffect = new DirectionalLightEffect(contentLibrary.DirectionalLightEffect);
            _pointLightEffect       = new PointLightEffect(contentLibrary.PointLightEffect);
            _ssaoEffect             = new SSAOEffect(contentLibrary.SSAOEffect);

            _camManager = cameraManager;
            _chunks     = chunkManager;

            _debugOptions = ChunkRendererDebugOptions.NONE;

            basicEffect = contentLibrary.BasicEffect;

            _uiFontTiny = contentLibrary.UIFontTiny;

            _albedoTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
            _lightTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _normalTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _depthTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8);

            _randomMap = new Texture2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight);
            CreateRandomNormalTexture(_randomMap);

            _debugRasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.None, FillMode = Microsoft.Xna.Framework.Graphics.FillMode.WireFrame
            };
            _rasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.CullCounterClockwiseFace
            };
        }
Exemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        Globals.currState = GameState.Base;

        SaveStateBase stat = (SaveStateBase)(SaveLoadManager.LoadFile(FilePath.CurrentSaveFilePath));

        campaign = stat.campaign;

        contentContainer = campaign.contentLibrary;

        baseUI.campaign = campaign;

        baseMap = Globals.campaign.GetMapDataContainer().mapDB.GetCopy(stat.baseID);

        atlas = Resources.Load <SpriteAtlas>(FilePath.TileSetAtlas);

        PrintBoard();

        inputFSM = new InputFSM(new BlockUserInputState());
    }
        public void EditLibrary(ContentLibrary contentLibrary)
        {
            using (var cntx = ContextRegistry.NamedContextsFor(this.GetType()))
            {
                using (var session = DocumentStoreLocator.ContextualResolve())
                {
                    var libs = from q in session.Query <Lok.Unik.ModelCommon.Client.ContentLibrary>() select q;

                    var lib = libs.ToArray().FirstOrDefault(x => x.Id == contentLibrary.Id);

                    if (lib != null)
                    {
                        lib.Title       = contentLibrary.Title;
                        lib.Description = contentLibrary.Description;
                        // lib.State = (State)Enum.Parse(typeof(State), contentLibrary.State);
                        //..
                        _log.InfoFormat("{0} Library has been updated", lib.Title);
                        session.SaveChanges();
                    }
                }
            }
        }
 public DualContourDeferredColoredChunkSystem(GraphicsDevice device, ContentLibrary contentLibrary, IChunkManager chunkManager, CameraManager cameraManager, World world, ITerrainGradientFunction densityGradientFunction, float minimumSolidDensity)
 {
     _builder  = new DualContourChunkBuilder(device, world, densityGradientFunction, minimumSolidDensity);
     _renderer = new DeferredColoredChunkRenderer(world.EngineConfiguration, contentLibrary, device, cameraManager, chunkManager);
 }
        public void AddItemPackage(ContentLibrary library, List <System.Web.HttpPostedFileBase> tempFiles, List <string> associateAppWithFile, ApplicationUser user)
        {
            //var cf = Catalog.Factory.Resolve<IConfig>();
            //var containerFileShare = cf[ComServerConfiguration.DistributedFileShare];
            //var contentContainerPath = cf[ContentFileStorage.ContentFilesContainer];
            //var containerLibPath = cf[ContentFileStorage.ContentLibrariesContainer];

            //var containerHost = Path.Combine(containerFileShare, contentContainerPath);
            //var directory = Path.Combine(containerHost, containerLibPath);

            //library.BasePath = directory;

            //foreach (var file in tempFiles.Where(file => file.ContentLength != 0))
            //{
            //    if (library.ContentItems == null)
            //        library.ContentItems = new Collection<ContentItem>();

            //    library.ContentItems.Add(new ContentItem
            //    {
            //        Id = Guid.NewGuid(),
            //        Title = file.FileName,
            //        Path = directory,
            //        CreatorPrincipalId = library.CreatorPrincipalId,
            //        LibraryId = library.Id.ToString()
            //    });

            //}

            //for (var i = 0; i < associateAppWithFile.Count; i++)
            //    library.ContentItems.ElementAt(i).AssociateApp = new Guid(associateAppWithFile[i]);

            //using (var cntx = ContextRegistry.NamedContextsFor(this.GetType()))
            //{
            //    using (var session = DocumentStoreLocator.ContextualResolve())
            //    {
            //        var query =
            //            (from libs in session.Query<Lok.Unik.ModelCommon.Client.ContentLibrary>() select libs)
            //            .ToArray()
            //            .FirstOrDefault(x => x.Id == library.Id);

            //        if (query != null)
            //        {
            //            query.BasePath = library.BasePath;

            //            var commomItems = ToCommonItems(library.ContentItems, query.Id, user);

            //            foreach (var contentItem in commomItems)
            //            {
            //                query.Files.Add(contentItem);
            //                _log.InfoFormat("Adding {0} Item into '{1}' Library", contentItem.Title, query.Title);
            //            }

            //        }

            //        session.SaveChanges();
            //    }
            //}

            //for (var i = 0; i < library.ContentItems.Count; i++)
            //{
            //    var flh = new FileStorageHelper();
            //    byte[] fileData;
            //    var objId = string.Format("{0}.zip", library.ContentItems.ElementAt(i).Id);

            //    using (var binaryReader = new BinaryReader(tempFiles[i].InputStream))
            //        fileData = binaryReader.ReadBytes(tempFiles[i].ContentLength);

            //    flh.SaveData(containerLibPath, objId, fileData);

            //    _log.InfoFormat("Storing {0} into '{1}'", objId, directory);
            //}

            //_log.InfoFormat("Storing Success");
        }
Exemplo n.º 17
0
        public void ImportContent()
        {
            var contents = ContentLibrary.ImportFromCsvFile(CsvFilename);

            ContentLibrary.SaveAsJsonFile(contents, ContentLibraryFilename);
        }
Exemplo n.º 18
0
        public void Importing_from_CSV_file_sets_the_ids_on_each_content()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Should().NotContain(c => string.IsNullOrEmpty(c.Id));
        }
Exemplo n.º 19
0
        public void Ids_are_unique()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Select(c => c.Id).Should().OnlyHaveUniqueItems();
        }
Exemplo n.º 20
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            contentLibrary = new ContentLibrary();
            contentLibrary.Load(GraphicsDevice, Content);

            basicEffect = new BasicEffect(GraphicsDevice);

            _space = new Space();
            _space.ForceUpdater.Gravity = MathConverter.Convert(new Vector3(0, -9.81f, 0));

            font = Content.Load <SpriteFont>("Arial");

            _fpsCounter = new FPSCounter(this, font);
            _fpsCounter.LoadContent();

            camManager = new CameraManager();
            camManager.AddCamera("player", cam);
            camManager.MainCameraName = "player";

            simplexDensityFunction = new SimplexDensityFunction(0.01f, 0.1f);

            EngineConfiguration config = new EngineConfiguration();

            config.ChunkWidth  = 16;
            config.ChunkHeight = 16;
            config.ChunkLength = 16;

            config.CPULightingEnabled = true;

            config.RenderDistance = 5;

            int worldChunkHeight = 8;

            SphereDensityFunction   sdf  = new SphereDensityFunction(new Vector3(8, 8, 8), 7.5f);
            SineWaveDensityFunction swdf = new SineWaveDensityFunction(5, 10, 0.25f);

            DualContourIslandChunkGenerator icg = new DualContourIslandChunkGenerator(worldChunkHeight * config.ChunkHeight, new SimplexNoiseGenerator(Environment.TickCount));
            DualContourFlatLandGenerator    flg = new DualContourFlatLandGenerator();

            DensityChunkGenerator dcg = new DensityChunkGenerator(swdf);
            DebuggerGenerator     dg  = new DebuggerGenerator();

            IChunkGenerator          generator;
            ITerrainGradientFunction grad;

            generator = icg;
            grad      = icg;

            _world                    = new World(config, camManager);
            _chunkManager             = new StaticThreadedChunkManager(config, _world, 5, worldChunkHeight, 5);
            _chunkManager.ChunkSystem = new DualContourColoredChunkSystem(GraphicsDevice, contentLibrary, _chunkManager, camManager, _world, grad, 0.0f);
            _chunkManager.ChunkSystem.Builder.MeshBuilt += new MeshBuildEventHandler(BuildPhysicsMesh);
            _chunkManager.ChunkGenerator = generator;
            _chunkManager.LightManager   = new FloodfillLightManager(_chunkManager, config, worldChunkHeight);

            _world.ChunkManager = _chunkManager;

            _chunkManager.GenerateChunks();
            _chunkManager.BuildAllChunks();
        }
Exemplo n.º 21
0
 private void OnDestroy()
 {
     Destroy(ms_instance);
     ms_instance = null;
 }
Exemplo n.º 22
0
        public void Should_all_be_unpublished()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Should().NotContain(c => c.IsPublished);
        }
Exemplo n.º 23
0
        public ActionResult Create(ContentLibraryAddModel model)
        {
            ProcessImageUpload imageData = new ProcessImageUpload
            {
                PostedFile = model.UploadedFile,
            };

            if (!imageData.CheckImageOk())
            {
                ModelState.AddModelError("UploadedFile", imageData.Error);
                return(View(model));
            }

            if (imageData.Empty && !ModelState.IsValid)
            {
                return(View(model));
            }

            //NOTE: model.sendDateTime will be in local time. We need it in the timezone the user has selected
            var correctDateTime = model.AvailableFromDate;

            if (correctDateTime.HasValue)
            {
                var timezone = System.TimeZoneInfo.FindSystemTimeZoneById(model.TimeZone);
                var newDate  = System.TimeZoneInfo.ConvertTimeToUtc(model.AvailableFromDate.Value, timezone);

                correctDateTime = newDate;
            }

            var record = new ContentLibrary
            {
                Featured          = model.Featured,
                Title             = model.Title,
                Precis            = model.Precis,
                Url               = model.Url,
                Status            = ContentStatus.AwaitingDate,
                ContentType       = model.ContentType,
                Created           = DateTime.UtcNow,
                AvailableFromDate = model.AvailableFromDate != null? correctDateTime : DateTime.UtcNow,
                TimeZone          = model.TimeZone
            };

            try
            {
                Db.ContentLibraries.Add(record);
                Db.SaveChanges();
                if (!imageData.Empty && imageData.PostedFileSaveAndResize(Server.MapPath(AppSettings.ContentLibraryImagePath), "item" + record.Id))
                {
                    record.ImageUrl = imageData.SavedName;
                    Db.SaveChanges();
                }
            }
            catch (Exception)
            {
                return(View(model));
            }

            if (!ModelState.IsValid || !imageData.Empty)
            {
                return(RedirectToAction("Edit", new { id = record.Id }));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 24
0
        public void Should_not_have_published_ids()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Should().NotContain(c => !string.IsNullOrEmpty(c.PublishedId));
        }
Exemplo n.º 25
0
 private ContentLibraryViewModel ContentToGridViewModel(ContentLibrary content)
 {
     return(ContentToViewModel(content, true));
 }
Exemplo n.º 26
0
        public void Should_not_have_published_timestamps()
        {
            var result = ContentLibrary.ImportFromCsvFile("content\\Tweets.csv");

            result.Should().NotContain(c => c.PublishedAt != new DateTime());
        }