void BuildingPanelIcon_OnMouseOver(object sender, ButtonEventArgs e) { BuildingIcon icon = ((BuildingIcon)sender); tooltip.YRelative = icon.YRelative + 45; tooltip.Text = icon.TooltipText; tooltip.IsVisible = true; }
public void ClearSelectedIcon() { if (selectedIcon != null) { selectedIcon.Unselect(); selectedIcon = null; Map.HideSlots(); } }
void icon_OnRelease(object sender, ButtonEventArgs e) { BuildingIcon icon = (BuildingIcon)sender; if (!icon.IsSelected) { if (selectedIcon != null) { selectedIcon.Unselect(); } icon.Select(); selectedIcon = icon; RefreshBuildings(icon.BuildingType); Map.DisplaySlots(((BuildingIcon)sender).BuildingType); } else { ClearSelectedIcon(); } }
private void CreateIcons() { iconPositions = new List <Point>(6); iconPositions.Add(new Point(26, 68)); iconPositions.Add(new Point(99, 68)); iconPositions.Add(new Point(26, 133)); iconPositions.Add(new Point(99, 133)); iconPositions.Add(new Point(26, 199)); iconPositions.Add(new Point(99, 199)); #region Energy energyIcons = new List <BuildingIcon>(); BuildingIcon icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyGeo); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyNuclear); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergySolar); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergySolid); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyWind); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); for (int i = 0; i < energyIcons.Count; i++) { energyIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); energyIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Education educationIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationSchool); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationHighSchool); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationUniversity); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); for (int i = 0; i < educationIcons.Count; i++) { educationIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); educationIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Food foodIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodAnimalFarm); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodCropFarm); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodOrchard); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodFarmedFisherie); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); for (int i = 0; i < foodIcons.Count; i++) { foodIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); foodIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Population populationIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationVillage); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationTown); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationCity); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationMetropolis); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); for (int i = 0; i < populationIcons.Count; i++) { populationIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); populationIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Health healthIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Health, Construction.HealthHospital); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); healthIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Health, Construction.HealthClinic); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); healthIcons.Add(icon); for (int i = 0; i < healthIcons.Count; i++) { healthIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); healthIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Environment environmentIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentNursery); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentRecycling); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentWaterPurification); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); for (int i = 0; i < environmentIcons.Count; i++) { environmentIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); environmentIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Economy economyIcons = new List <BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyFactory); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyMine); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomySawMill); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyOilWell); icon.OnRelease += new EventHandler <ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); for (int i = 0; i < economyIcons.Count; i++) { economyIcons[i].OnMouseOver += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); economyIcons[i].OnMouseLeave += new EventHandler <ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion }
void icon_OnRelease(object sender, ButtonEventArgs e) { BuildingIcon icon = (BuildingIcon)sender; if (!icon.IsSelected) { if (selectedIcon != null) selectedIcon.Unselect(); icon.Select(); selectedIcon = icon; RefreshBuildings(icon.BuildingType); Map.DisplaySlots(((BuildingIcon)sender).BuildingType); } else { ClearSelectedIcon(); } }
private void CreateIcons() { iconPositions = new List<Point>(6); iconPositions.Add(new Point(26, 68)); iconPositions.Add(new Point(99, 68)); iconPositions.Add(new Point(26, 133)); iconPositions.Add(new Point(99, 133)); iconPositions.Add(new Point(26, 199)); iconPositions.Add(new Point(99, 199)); #region Energy energyIcons = new List<BuildingIcon>(); BuildingIcon icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyGeo); icon.OnRelease+=new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyNuclear); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergySolar); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergySolid); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Energy, Construction.EnergyWind); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); energyIcons.Add(icon); for (int i = 0; i < energyIcons.Count; i++) { energyIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); energyIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Education educationIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationSchool); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationHighSchool); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Education, Construction.EducationUniversity); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); educationIcons.Add(icon); for (int i = 0; i < educationIcons.Count; i++) { educationIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); educationIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Food foodIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodAnimalFarm); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodCropFarm); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodOrchard); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Food, Construction.FoodFarmedFisherie); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); foodIcons.Add(icon); for (int i = 0; i < foodIcons.Count; i++) { foodIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); foodIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Population populationIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationVillage); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationTown); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationCity); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Population, Construction.PopulationMetropolis); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); populationIcons.Add(icon); for (int i = 0; i < populationIcons.Count; i++) { populationIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); populationIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Health healthIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Health, Construction.HealthHospital); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); healthIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Health, Construction.HealthClinic); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); healthIcons.Add(icon); for (int i = 0; i < healthIcons.Count; i++) { healthIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); healthIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Environment environmentIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentNursery); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentRecycling); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Environment, Construction.EnvironmentWaterPurification); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); environmentIcons.Add(icon); for (int i = 0; i < environmentIcons.Count; i++) { environmentIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); environmentIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion #region Economy economyIcons = new List<BuildingIcon>(); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyFactory); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyMine); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomySawMill); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); icon = new BuildingIcon(this.Game, ConstructionType.Economy, Construction.EconomyOilWell); icon.OnRelease += new EventHandler<ButtonEventArgs>(icon_OnRelease); icon.Visible = false; icon.Enabled = false; AddChild(icon); economyIcons.Add(icon); for (int i = 0; i < economyIcons.Count; i++) { economyIcons[i].OnMouseOver += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseOver); economyIcons[i].OnMouseLeave += new EventHandler<ButtonEventArgs>(BuildingPanelIcon_OnMouseLeave); } #endregion }