HttpContent(Content content, string contentType, long? contentLength)
 {
     this.content = content;
     this.contentType = contentType;
     this.contentLength = contentLength;
     this.state = ContentState.Created;
 }
Beispiel #2
0
        /// <summary>Changes a state of an item to the new state.</summary>
        /// <param name="item">The item whose state is to be changed.</param>
        /// <param name="toState">The next state of the item.</param>
        public virtual void ChangeTo(ContentItem item, ContentState toState)
        {
            //if (item.State != toState)
            {
                var args = new StateChangedEventArgs(item, item.State);

                item.State = toState;
                switch (toState)
                {
                    case ContentState.Published:
                        // TODO check pre-condition: Published
                        item.Published = Utility.CurrentTime();
                        // TODO compare EnsurePublishedCommand handling of Publish Date in future

                        item.Expires = null;
                        break;

                    case ContentState.Unpublished:
                        // TODO check pre-condition: Published
                        item.Expires = Utility.CurrentTime().AddSeconds(-1);
                        break;

                    case ContentState.Draft:
                        item.Published = null; // was EnsureNotPublishedCommand
                        item.Expires = null;
                        break;
                }

                if (StateChanged != null)
                {
                    StateChanged(this, args);
                }
            }
        }
		public static List<ObjectComposer> AutoloadBatch(Scene scene, ContentState state, String name, bool hasPhysics = true)
		{
			List<ObjectComposer> returnedObjects = new List<ObjectComposer>();
			using (FileStream fs = new FileStream("Content/SceneData/" + level + "/" + name + ".csv", FileMode.Open))
			{
				using (StreamReader sr = new StreamReader(fs))
				{
					String[] generalData = sr.ReadLine().Split(';');
					String modelName = generalData[0];
					String diffuseMap = generalData[1];
					String normalMap = generalData[2];

					String line;
					while ((line = sr.ReadLine()) != null)
					{
						ObjectComposer newObjectComposer = ObjectComposer.Compose(scene, state);
							
						newObjectComposer.AutoLoad(line.Split(';'), name, hasPhysics)
                            .AppendMesh("SceneData/" + level + "/" + modelName)
							.AppendShader()
                            .AppendMaterialTextures("SceneData/" + level + "/" + diffuseMap.Split('.')[0], "SceneData/" + level + "/" + normalMap.Split('.')[0])
							.FinishAndAddToScene();

						returnedObjects.Add(newObjectComposer);
					}

				
				}
			}

			return returnedObjects;
		}
Beispiel #4
0
 /// <summary>Changes a state of an item to the new state.</summary>
 /// <param name="item">The item whose state is to be changed.</param>
 /// <param name="toState">The next state of the item.</param>
 public virtual void ChangeTo(ContentItem item, ContentState toState)
 {
     var args = new StateChangedEventArgs(item, item.State);
     item.State = toState;
     if (StateChanged != null)
     {
         StateChanged(this, args);
     }
 }
		public static ObjectComposer Compose(Scene owner, ContentState state)
		{
			ObjectComposer composer = new ObjectComposer();

			composer.owner = owner;
			composer.currentObject = new GameObject(state);
			composer.state = state;

			return composer;
		}
	    public GameObject(ContentState state)
		{
			//worldMatrix = transform;
			this.Shader = new MaterialShader();
			this.Model = new ModelInstance();
			Model.ShaderProvider = null;

			Transform = Matrix.Identity;

			device = state.GraphicsDevice;
			effect = new BasicEffect(state.GraphicsDevice);
		}
        protected override void LoadContent(ContentState state)
        {
            MaterialManager.SetupMaterials(state);

            camera = new Camera3D(new Projection(0.6f, 0.1f, 10000f, state.GraphicsDevice.Viewport.AspectRatio));
            contentState = state;
            LoadLevel(3);



            base.LoadContent(state);
        }
		//Load content
		public void LoadContent(ContentState state)
		{
			//load and assign the texture:
			//Note the texture is assigned to the shader, not the visual element
			var texture = state.Load<Texture2D>(@"skyline");

			this.shader.DisplayTexture = texture;

			//The 2D element can adjust it's texture coordinates to make sure the texture
			//is exactly aligned to on screen pixels, however, to do this, the size of the
			//texture must be set (this is assuming the shader displays a texture!)
			this.element.SetTextureSize(texture.Width, texture.Height);
		}
        public void LoadLevel(ContentState state)
        {
            _instance = this;
            this.state = state;
            ObjectComposer.level = _level;
            List<ObjectComposer> allComposers = new List<ObjectComposer>();
            // Switch driven developement
            if (_level == 1)
            {
                AddObjects("FlatGround", state, allComposers);
                AddObjects("Sky", state, allComposers, false)[0].AppendMaterialLights(MaterialManager.InfiniteLight);
                AddObjects("Rock", state, allComposers);
                AddObjects("Stone", state, allComposers);
                AddObjects("StartStone", state, allComposers);
                AddObjects("HagravenSticks", state, allComposers);
                AddObjects("FalmerTotem", state, allComposers);
                AddObjects("Altar", state, allComposers);
                AddObjects("FlatGround", state, allComposers);
                AddObjects("MountainPeak", state, allComposers).ForEach(composer => composer.AppendMaterialLights(MaterialManager.BackgroundLights));
                AddObjects("MountainRidge", state, allComposers).ForEach(composer => composer.AppendMaterialLights(MaterialManager.BackgroundLights));
            }
            else if (_level == 2)
            {
                AddObjects("Altar", state, allComposers);
                AddObjects("StartStone", state, allComposers);
                AddObjects("RockBridge1", state, allComposers);
                AddObjects("RockBridge2", state, allComposers);
                AddObjects("RockBridge3", state, allComposers);
                AddObjects("RockBridge4", state, allComposers);
                AddObjects("StonePillar1", state, allComposers);
                AddObjects("StonePillar2", state, allComposers);
                AddObjects("StonePillar3", state, allComposers);
                AddObjects("Monster1a", state, allComposers);
                AddObjects("Monster1b", state, allComposers);
            }
            else if (_level == 3)
            {
                AddObjects("Altar", state, allComposers);
                AddObjects("StartStone", state, allComposers);
                AddObjects("FrozenMarshIceFloe1", state, allComposers);
                AddObjects("FrozenMarshIceFloe2", state, allComposers);
                AddObjects("Water", state, allComposers);
                AddObjects("Iceberg", state, allComposers);
                AddObjects("GlacierPillar1", state, allComposers);
            }

            SetParticles(state);
        }
Beispiel #10
0
        public void LoadContent(ContentState state)
        {
            this.texture = state.Load<Texture2D>("skydome/cloudMap");
            this.model.ModelData = state.Load<ModelData>("skydome/dome");

            MaterialShader material = new MaterialShader();

            material.SpecularColour = new Vector3(1, 1, 1);
            material.DiffuseColour = new Vector3(0.6f, 0.6f, 0.6f);
            material.SpecularPower = 64;

            MaterialTextures textures = new MaterialTextures();
            textures.TextureMap = state.Load<Texture2D>("skydome/cloudMap");
            textures.TextureMapSampler = TextureSamplerState.AnisotropicHighFiltering;
            textures.EmissiveTextureMapSampler = TextureSamplerState.AnisotropicHighFiltering;
            textures.NormalMapSampler = TextureSamplerState.AnisotropicHighFiltering;

            material.Textures = textures;

            this.shader = material;
        }
		public static void SetupMaterials(ContentState state)
		{
			var lightDirection1 = new Vector3(-0.5265408f,-0.5735765f ,-0.6275069f);
			var lightDirection2 = new Vector3(0.7198464f ,0.3420201f, 0.6040227f);
			var lightDirection3 = new Vector3(0.4545195f,-0.7660444f,0.4545195f);

			var lightColor1 = new Vector3(1.0f, 0.9607844f, 0.8078432f);
			var lightColor2 = new Vector3(0.9647059f,0.8607844f,0.6078432f);
			var lightColor3 = new Vector3(0.3231373f ,0.3607844f ,0.3937255f);

			Lights.AmbientLightColour = new Vector3(0.05333332f ,0.09882354f ,0.1819608f);
            BasicLights.Add(Lights.CreateDirectionalLight(lightDirection1, lightColor1));
            BasicLights.Add(Lights.CreateDirectionalLight(lightDirection2, lightColor2));
            BasicLights.Add(Lights.CreateDirectionalLight(lightDirection3, lightColor3));

			BackgroundLights.AmbientLightColour = Vector3.One * 0.8f;
			BackgroundLights.CreateDirectionalLight(lightDirection1, lightColor1 * 0.8f);
			BackgroundLights.CreateDirectionalLight(lightDirection2, lightColor2 * 0.8f);
			BackgroundLights.CreateDirectionalLight(lightDirection3, lightColor3 * 0.8f);

			InfiniteLight.AmbientLightColour = Vector3.One * 3;
		}
        public HandController(Camera camera, Scene scene, ContentState state)
        {
            this.camera = camera;

            hand = ObjectComposer.Compose(scene, state)
                .AppendName("hand")
                .AppendMesh("hand")
                .AppendMaterialTextures("hand_map", "hand_map")
                .AppendWorld(Vector3.Zero,Vector3.Zero, Vector3.One * 0.02f)
                .AppendDummyCollider()
                .FinishAndAddToScene();

            int animationIndex = hand.Model.GetAnimationController().AnimationIndex("Take 001");
            hand.Model.GetAnimationController().PlayLoopingAnimation(animationIndex);

            bonesController = new HandAnimator(hand.Model.ModelData);
            hand.BoneModifier = bonesController;

            curseParticles = new ParticleSystem(state.Application.UpdateManager);
            TestScene._instance.AddDrawable(new BillboardParticles3D(curseParticles));
            curseParticles.ParticleSystemData = TestScene._instance.state.Load<ParticleSystemData>("Particles/Spark");
            curseParticlesTriger = curseParticles.GetTriggerByName("burst");

        }
        public SearchTag_ContentViewModel(Content content)
        {
            if (content != null)
            {
                if (content.AuthorId.HasValue)
                {
                    AuthorName   = content.Author.FullName;
                    AuthorId     = content.AuthorId;
                    AuthorAvatar = ImageService.GetImageUrl <User>(content.Author.Avatar);
                }

                if (content.GroupId.HasValue)
                {
                    GroupUrl  = content.Group.Url;
                    GroupName = content.Group.Name;
                    GroupLogo = content.Group.Logo;
                }

                ContentState = (ContentState)content.State;

                Url     = content.GetUrl();
                Title   = content.Title;
                Summary = TextHelper.CleanTags(content.Text);
                if (Summary.Length > 200)
                {
                    Summary = Summary.Substring(0, 200) + "...";
                }

                if (content is Post)
                {
                    if (content.GroupId.HasValue)
                    {
                        ContentClass = "group";
                        ContentType  = ContentViewType.GroupPost;
                    }
                    else
                    {
                        ContentClass = "user";
                        ContentType  = ContentViewType.UserPost;
                    }

                    ContentClass += " post";
                }
                else if (content is Petition)
                {
                    if (content.GroupId.HasValue)
                    {
                        ContentClass = "group";
                        ContentType  = ContentViewType.GroupPetition;
                    }
                    else
                    {
                        ContentClass = "user";
                        ContentType  = ContentViewType.UserPetition;
                    }

                    ContentClass += " petition";
                }
                else if (content is Poll)
                {
                    ContentClass = "poll";
                    ContentType  = ContentViewType.Poll;
                }
                else if (content is Election)
                {
                    ContentClass = "election";
                    ContentType  = ContentViewType.Election;
                }
            }
        }
        private void SetSpecialEffects(ContentState state, IEnumerable<GameObject> allElements)
        {
            if (_level == 1)
            {
            }
            else if (_level == 2)
            {
                foreach (var element in allElements)
                {
                    element.Shader.FogState = new MaterialFogState();
                    element.Shader.FogState.FogColour = new Vector3(0, 0, 0);
                    element.Shader.FogState.FogEnabled = true;
                    element.Shader.FogState.FogNearDistance = 200f;
                    element.Shader.FogState.FogFarDistance = 400f;

                    if (element.Name == "Monster1a")
                    {
                        element.onCollision = (self, player, direction) =>
                                                  {
                                                      self.justCollided = 100;
                                                      self.Model.GetAnimationController().PlayAnimation(0);
                                                      player.PhysicsEntity.ApplyImpulse(player.PhysicsEntity.Position, -direction * 1000);
                                                  };
                    }
                    if (element.Name == "Monster1a" || element.Name == "Monster1b")
                    {
                        element.PhysicsEntity.CollisionInformation.CollisionRules.Group = bulletEnemyCollisionGroup;
                    }
                }
            }
        }
        public void WriteTo(Stream stream)
        {
            ThrowIfDisposedOrConsumed();

            if (this.state == ContentState.Buffered)
            {
                stream.Write(this.buffer, 0, this.buffer.Length);
                return;
            }

            this.state = ContentState.ConsumedWrite;
            this.content.WriteTo(stream, this.contentLength);
        }
Beispiel #16
0
 public static Parameter State(ContentState expectedState)
 {
     return Parameter.Equal("State", expectedState);
 }
        public void LoadIntoBuffer()
        {
            ThrowIfDisposedOrConsumed();

            if (state == ContentState.Buffered)
            {
                return;
            }
            this.state = ContentState.Buffered;
            Debug.Assert(buffer == null);
            var temp = content.ReadAsBytes(this.contentLength);
            this.buffer = temp;
            this.contentLength = temp.Length;
        }
 public Stream ReadAsStream()
 {
     ThrowIfDisposedOrConsumed();
     if (state == ContentState.Buffered)
     {
         return CreateReadOnlyMemoryStream(this.buffer);
     }
     this.state = ContentState.ConsumedRead;
     return content.ReadAsStream();
 }
Beispiel #19
0
        public void AddingVersion_OfUnpublishedItem_SetsStateOfVersion_AccordingTo_PreviousOrNot(bool isPrevious, ContentState expectedState)
        {
            PersistableItem master = CreateOneItem <PersistableItem>(0, "root", null);

            master.State = ContentState.Unpublished;
            persister.Save(master);

            var version1 = versioner.AddVersion(master, asPreviousVersion: isPrevious);

            version1.State.ShouldBe(expectedState);
        }
Beispiel #20
0
		public void PubliclyAvailable_is_determined_by_current_nonpublished_page(ContentState state, bool expectedAvailability)
		{
			var path = new PathData { CurrentItem = item, CurrentPage = new Items.PageItem { State = state } };

			path.IsPubliclyAvailable.ShouldBe(expectedAvailability);
		}
Beispiel #21
0
 public static Parameter State(ContentState expectedState)
 {
     return(Parameter.Equal("State", expectedState));
 }
 public UpdateContentStateCommand(StateChanger changer, ContentState toState)
 {
     this.changer = changer;
     this.toState = toState;
 }
Beispiel #23
0
 public void Change(string title, string slug, ContentType contentType, string content, ContentState state)
 {
     this.Title       = title;
     this.Slug        = slug;
     this.ContentType = contentType;
     this.Content     = content;
     this.State       = state;
 }
Beispiel #24
0
 public Topic(Guid aggregateId, string title, string slug, ICollection <ContentChannels> channels, ContentType contentType, string content, ContentState state) : base(aggregateId, channels, title, slug, contentType, content, state)
 {
     this.Title       = title;
     this.Slug        = slug;
     this.ContentType = contentType;
     this.Content     = content;
     this.State       = state;
 }
Beispiel #25
0
 public void SetContentState(ContentState state)
 {
     quizConfig.quizState = state;
 }
        private async Task <LoadMoreItemsResult> LoadMore()
        {
            try
            {
                HasMoreDownItems = false;
                ContentState     = ContentState.Loading;

                uint         tempCount   = 0;
                bool         tempHasMore = false;
                ContentState tempState   = ContentState.None;

                foreach (var group in this)
                {
                    if (group.HasMoreItems || group.ContentState == ContentState.Error)
                    {
                        var result = await group.LoadMore();

                        tempCount += result.Count;

                        if (group.HasMoreItems)
                        {
                            tempHasMore = true;
                        }

                        if ((byte)tempState < (int)group.ContentState)
                        {
                            tempState = group.ContentState;
                        }
                    }

                    if (tempState == ContentState.Error)
                    {
                        HasMoreDownItems = false;
                        ContentState     = ContentState.Error;
                        return(new LoadMoreItemsResult()
                        {
                            Count = tempCount
                        });
                    }
                    else if (tempCount >= 50)
                    {
                        HasMoreDownItems = tempHasMore;
                        ContentState     = ContentState.Normal;
                        return(new LoadMoreItemsResult()
                        {
                            Count = tempCount
                        });
                    }
                }

                ContentState     = tempState;
                HasMoreDownItems = tempHasMore;
                return(new LoadMoreItemsResult()
                {
                    Count = tempCount
                });
            }
            catch (Exception)
            {
                HasMoreDownItems = false;
                ContentState     = ContentState.Error;
                return(new LoadMoreItemsResult()
                {
                    Count = 0
                });
            }
        }
Beispiel #27
0
 protected AbstractContent(Guid aggregateId, ICollection <ContentChannels> channels, string title, string slug, ContentType contentType, string content, ContentState state) : base(aggregateId)
 {
     this.Channels    = channels;
     this.Title       = title;
     this.Slug        = slug;
     this.ContentType = contentType;
     this.Content     = content;
     this.State       = state;
 }
Beispiel #28
0
 /// <summary>Serves as a hashcode for the specified type</summary>
 public override int GetHashCode()
 {
     return(SafeGetHashCode(Path) ^ Revision.GetHashCode() ^ ContentState.GetHashCode());
 }
Beispiel #29
0
 public static bool IsLoading(this ContentState state)
 {
     return(state == ContentState.Loading);
 }
        public void Dispose()
        {
            if (this.state == ContentState.Disposed)
            {
                return;
            }
            this.state = ContentState.Disposed;

            this.content.Close();
            this.content = null;
            this.buffer = null;
        }
Beispiel #31
0
 public static bool IsLoaded(this ContentState state)
 {
     return(state == ContentState.Normal || state == ContentState.NoData);
 }
 public byte[] ReadAsByteArray()
 {
     ThrowIfDisposedOrConsumed();
     if (this.state == ContentState.Buffered)
     {
         return this.buffer;
     }
     this.state = ContentState.ConsumedRead;
     return this.content.ReadAsBytes(this.contentLength);
 }
Beispiel #33
0
 public static bool IsError(this ContentState state)
 {
     return(state == ContentState.Error);
 }
        public void ThenTheContentCalledShouldBeInTheState(string contentName, string stateName)
        {
            ContentState actual = this.scenarioContext.Get <ContentState>(contentName);

            Assert.AreEqual(stateName, actual.StateName);
        }
			void IContentOwner.LoadContent(ContentState state)
			{
				white = MakeTexture(Color.White, state);
				normal = MakeTexture(new Color(127,127,255), state);
				black = MakeTexture(Color.Black, state);
			}
Beispiel #36
0
 public void LoadContent(ContentState state)
 {
     this.model.ModelData = state.Load<ModelData>(filename);
 }
        private void SetParticles(ContentState state)
        {
            if (_level == 2)
            {
                ParticleSystem particles = new ParticleSystem(state.Application.UpdateManager);
                followingParticles.Add(particles);
                drawToScreen.Add(new BillboardParticles3D(particles));
                particles.ParticleSystemData = state.Load<ParticleSystemData>("Particles/Mist");
            }
            if (_level == 3)
            {
                ParticleSystem particles = new ParticleSystem(state.Application.UpdateManager);

                followingParticles.Add(particles);

                ParticleDrawer3D fogDrawer = new BillboardParticles3D(particles);
                ParticleDrawer3D snowDrawer = new VelocityBillboardParticles3D(particles, false, 0.1f);
                
                drawToScreen.Add(fogDrawer);
                drawToScreen.Add(snowDrawer);

                particles.ParticleSystemData = state.Load<ParticleSystemData>("Particles/Snow");

                fogDrawer.SetParticleTypeDrawMask("fog", true);
                fogDrawer.SetParticleTypeDrawMask("snow", false);

                snowDrawer.SetParticleTypeDrawMask("fog", false);
                snowDrawer.SetParticleTypeDrawMask("snow", true);

                
            }
            else if (_level == 2)
            {
            }
        }
		protected override void LoadContent(ContentState state)
		{
			statOverlay.Font = state.Load<SpriteFont>("Arial");
		}
		public void LoadContent(ContentState state)
		{
			//load the model data into the model instance
			model.ModelData = state.Load<Xen.Ex.Graphics.Content.ModelData>(@"tiny_4anim");
		}
        private List<ObjectComposer> AddObjects(String name, ContentState state, List<ObjectComposer> allcomposers, bool physics = true)
        {
            var composers = ObjectComposer.AutoloadBatch(this, state, name, physics);
            allcomposers.AddRange(composers);

            allObjects = allcomposers.Select(c => c.Finish()).ToList();
            SetSpecialEffects(state, allObjects);

            return composers;
        }
		public void LoadContent(ContentState state)
		{
			text.Font = state.Load<SpriteFont>("CourierNew");
		}
Beispiel #42
0
 /// <summary>Filters items returning those of the given state.</summary>
 /// <param name="state">The state to return.</param>
 /// <returns>A filter that filters on content state.</returns>
 public ItemFilter State(ContentState state)
 {
     return(new DelegateFilter(ci => (ci.State & state) == state));
 }
Beispiel #43
0
        public static void CanCreateDraft(CreateContentDraft command, ISchemaEntity schema, ContentState content)
        {
            Guard.NotNull(command);

            if (schema.SchemaDef.IsSingleton)
            {
                throw new DomainException("Singleton content cannot be updated.");
            }

            if (content.Status != Status.Published)
            {
                throw new DomainException("You can only create a new version when the content is published.");
            }
        }
 public StateChangedEventArgs(ContentItem item, ContentState previousState)
     : base(item)
 {
     PreviousState = previousState;
 }
Beispiel #45
0
        public static void CanDeleteDraft(DeleteContentDraft command, ISchemaEntity schema, ContentState content)
        {
            Guard.NotNull(command);

            if (schema.SchemaDef.IsSingleton)
            {
                throw new DomainException("Singleton content cannot be updated.");
            }

            if (content.NewStatus == null)
            {
                throw new DomainException("There is nothing to delete.");
            }
        }
		protected override void LoadContent(ContentState state)
		{
			backgroundParticles.ParticleSystemData = state.Load<ParticleSystemData>("Particles/XboxMenu");
			helperText.Font = state.Load<SpriteFont>("Arial");
			logo.Texture = state.Load<Texture2D>("xen");
		}
 /// <summary>
 /// Инициализирует новый экземпляр класса с заданной информации о состоянии коллекции.
 /// </summary>
 /// <param name="state">Информация о состоянии.</param>
 internal StateChangedEventArgs(ContentState state)
 {
     State = state;
 }
		void IContentOwner.LoadContent(ContentState state)
		{
			if (IsDisposed)
				return;

			GraphicsDevice device = state;

			if (texture != null &&
				texture.GraphicsDevice != device)
			{
				if (cloneOf == null)
				{
					texture.Dispose();
				}
				texture = null;
			}

			Warm(state);
		}
Beispiel #49
0
 /// <summary>
 /// Turns off the content and resets it to the default state.
 /// </summary>
 public void Clear()
 {
     StopAllAsyncCoroutines();
     this.TurnOff(false);
     this.State = ContentState.Unknown;
 }
			private Texture2D MakeTexture(Color colour, ContentState state)
			{
				Color[] colours = new Color[]
				{
					colour,colour,colour,colour
				};

				Texture2D texture = new Texture2D(state, 2, 2, false, SurfaceFormat.Color);
				texture.SetData(colours);
				return texture;
			}
Beispiel #51
0
 public StateFilter(ContentState requiredState)
 {
     this.requiredState = requiredState;
 }