IEnumerator ParseContentXMLFile(string path) { Debug.Log("Loading XML File: " + path); XElement doc = XElement.Load(path, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (ColorConfiguration == null) { ColorConfiguration = TileConfiguration <ColorContent> .GetFromRootElement(doc, "color"); } ColorConfiguration.AddSingleContentConfig(doc, null, MaterialColors); break; case "materialTextures": if (MaterialTextureConfiguration == null) { MaterialTextureConfiguration = TileConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture"); } MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, MaterialTextures); break; case "shapeTextures": if (ShapeTextureConfiguration == null) { ShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture"); } ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "terrainTextures": if (TerrainShapeTextureConfiguration == null) { TerrainShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "terrainTexture"); } TerrainShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) { TileMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh"); } TileMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "materialLayers": if (MaterialLayerConfiguration == null) { MaterialLayerConfiguration = TileConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer"); } MaterialLayerConfiguration.AddSingleContentConfig(doc); break; //case "buildingMeshes": // if (BuildingMeshConfiguration == null) // BuildingMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingMesh"); // BuildingMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); // break; //case "buildingShapeTextures": // if (BuildingShapeTextureConfiguration == null) // BuildingShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "buildingShapeTexture"); // BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); // break; case "growthMeshes": if (GrowthMeshConfiguration == null) { GrowthMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "growthMesh"); } GrowthMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "designationMeshes": if (DesignationMeshConfiguration == null) { DesignationMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "designationMesh"); } DesignationMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "collisionMeshes": if (CollisionMeshConfiguration == null) { CollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "collisionMesh"); } CollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; //case "buildingCollisionMeshes": // if (BuildingCollisionMeshConfiguration == null) // BuildingCollisionMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingCollisionMesh"); // BuildingCollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); // break; case "itemMeshes": if (ItemMeshConfiguration == null) { ItemMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "itemMesh"); } ItemMeshConfiguration.AddSingleContentConfig(doc, null); break; case "grassTextures": if (GrassTextureConfiguration == null) { GrassTextureConfiguration = TileConfiguration <GrassContent> .GetFromRootElement(doc, "grassTexture"); } GrassTextureConfiguration.AddSingleContentConfig(doc, new GrassContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage)); break; default: break; } doc = doc.NextNode as XElement; } yield return(null); }
bool ParseContentXMLFile(string path) { bool runningResult = true; XElement doc = XElement.Load(path, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (ColorConfiguration == null) { ColorConfiguration = TileConfiguration <ColorContent> .GetFromRootElement(doc, "color"); } ColorConfiguration.AddSingleContentConfig(doc, null, materialColors); break; case "materialTextures": if (MaterialTextureConfiguration == null) { MaterialTextureConfiguration = TileConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture"); } MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, materialTextures); break; case "shapeTextures": if (ShapeTextureConfiguration == null) { ShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture"); } ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) { TileMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh"); } TileMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "materialLayers": if (MaterialLayerConfiguration == null) { MaterialLayerConfiguration = TileConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer"); } MaterialLayerConfiguration.AddSingleContentConfig(doc); break; case "buildingMeshes": if (BuildingMeshConfiguration == null) { BuildingMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "buildingMesh"); } BuildingMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "buildingShapeTextures": if (BuildingShapeTextureConfiguration == null) { BuildingShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "buildingShapeTexture"); } BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "creatureMeshes": if (CreatureMeshConfiguration == null) { CreatureMeshConfiguration = CreatureConfiguration <MeshContent> .GetFromRootElement(doc, "creatureMesh"); } CreatureMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "growthMeshes": if (GrowthMeshConfiguration == null) { GrowthMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "growthMesh"); } GrowthMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "designationMeshes": if (DesignationMeshConfiguration == null) { DesignationMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "designationMesh"); } DesignationMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "collisionMeshes": if (CollisionMeshConfiguration == null) { CollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "collisionMesh"); } CollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "buildingCollisionMeshes": if (BuildingCollisionMeshConfiguration == null) { BuildingCollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "buildingCollisionMesh"); } BuildingCollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; default: break; } doc = doc.NextNode as XElement; } return(runningResult); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.Config); colors = ColorConversion.GetColorSetupFromXML(); var color = new Hsv { H = double.Parse(colors.TemperatureColor.LowColor.H), S = double.Parse(colors.TemperatureColor.LowColor.S), V = double.Parse(colors.TemperatureColor.LowColor.V) }.ToColor().ToAndroidColor(); btnLowTemp = (Button)FindViewById(Resource.Id.btnLowTemp); btnLowTemp.Click += btnLowTemp_Click; btnLowTemp.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.TemperatureColor.HighColor.H), S = double.Parse(colors.TemperatureColor.HighColor.S), V = double.Parse(colors.TemperatureColor.HighColor.V) }.ToColor().ToAndroidColor(); btnHighTemp = (Button)FindViewById(Resource.Id.btnHighTemp); btnHighTemp.Click += btnHighTemp_Click; btnHighTemp.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.HumidityColor.LowColor.H), S = double.Parse(colors.HumidityColor.LowColor.S), V = double.Parse(colors.HumidityColor.LowColor.V) }.ToColor().ToAndroidColor(); btnLowHumidity = (Button)FindViewById(Resource.Id.btnLowHumidity); btnLowHumidity.Click += btnLowHumidity_Click; btnLowHumidity.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.HumidityColor.HighColor.H), S = double.Parse(colors.HumidityColor.HighColor.S), V = double.Parse(colors.HumidityColor.HighColor.V) }.ToColor().ToAndroidColor(); btnHighHumidity = (Button)FindViewById(Resource.Id.btnHighHumidity); btnHighHumidity.Click += btnHighHumidity_Click; btnHighHumidity.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.ProximityColor.LowColor.H), S = double.Parse(colors.ProximityColor.LowColor.S), V = double.Parse(colors.ProximityColor.LowColor.V) }.ToColor().ToAndroidColor(); btnLowProximity = (Button)FindViewById(Resource.Id.btnLowProximity); btnLowProximity.Click += btnLowProximity_Click; btnLowProximity.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.ProximityColor.HighColor.H), S = double.Parse(colors.ProximityColor.HighColor.S), V = double.Parse(colors.ProximityColor.HighColor.V) }.ToColor().ToAndroidColor(); btnHighProximity = (Button)FindViewById(Resource.Id.btnHighProximity); btnHighProximity.Click += btnHighProximity_Click; btnHighProximity.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.HourColor.LowColor.H), S = double.Parse(colors.HourColor.LowColor.S), V = double.Parse(colors.HourColor.LowColor.V) }.ToColor().ToAndroidColor(); btnLowHour = (Button)FindViewById(Resource.Id.btnLowHour); btnLowHour.Click += btnLowHour_Click; btnLowHour.SetBackgroundColor(color); color = new Hsv { H = double.Parse(colors.HourColor.HighColor.H), S = double.Parse(colors.HourColor.HighColor.S), V = double.Parse(colors.HourColor.HighColor.V) }.ToColor().ToAndroidColor(); btnHighHour = (Button)FindViewById(Resource.Id.btnHighHour); btnHighHour.Click += btnHighHour_Click; btnHighHour.SetBackgroundColor(color); txtLowTemp = (EditText)FindViewById(Resource.Id.txtLowTempValue); txtHighTemp = (EditText)FindViewById(Resource.Id.txtHighTempValue); txtLowHumidity = (EditText)FindViewById(Resource.Id.txtLowHumidityValue); txtHighHumidity = (EditText)FindViewById(Resource.Id.txtHighHumidityValue); txtLowTemp.Text = colors.TemperatureColor.LowColor.Threshold; txtHighTemp.Text = colors.TemperatureColor.HighColor.Threshold; txtLowHumidity.Text = colors.HumidityColor.LowColor.Threshold; txtHighHumidity.Text = colors.HumidityColor.HighColor.Threshold; var textBackground = txtLowTemp.Background; if (textBackground is ColorDrawable) { defaultTextColor = (textBackground as ColorDrawable).Color; } txtLowTemp.FocusChange += UpdateValues; txtHighTemp.FocusChange += UpdateValues; txtLowHumidity.FocusChange += UpdateValues; txtHighHumidity.FocusChange += UpdateValues; imm = (InputMethodManager)GetSystemService(InputMethodService); var layout = (LinearLayout)FindViewById(Resource.Id.parentLayout); layout.Click += ConfigActivity_Click; layout.RequestFocus(); }
private bool IsSignificantChange(ColorConfiguration configuration) => _lastConfiguration == null || Math.Abs(configuration.Temperature - _lastConfiguration.Value.Temperature) > 15 || Math.Abs(configuration.Brightness - _lastConfiguration.Value.Brightness) > 0.01;
public IndexModel(ILogger <IndexModel> logger, IOptions <ColorConfigurationOptions> colorConfiguration) { _logger = logger; ColorConfiguration = colorConfiguration.Value.ColorConfiguration; }