private Border CreateUnit(Unit unit) { UnitCounter counter = new UnitCounter(); //counter.lbl_unit_type.Content = unit.Symbol; counter.img_unit_size.Source = unit.Symbol; counter.img_unit_counter.Source = Images.IconQuestionmark; if (unit.Color != null) { counter.border_unit.Background = ColorHandler.ColorFromRGB(unit.Color); } counter.img_unit_counter.Source = unit.IconCounter; string tt = unit.Name + "\n"; if (unit.Owner != null) { tt += "Besitzer von " + unit.Owner.Name + "\n"; } if (unit.Commander != null) { tt += "Unter kontrolle von " + unit.Commander.Name; } counter.border_unit.ToolTip = tt; Border border = (Border)SubWindow.CopyFrom(counter.border_unit); unit.BorderParent = border; border.Tag = unit; border.MouseUp += UnitCounterClick; return(border); }
private void AddPerson(Person person) { img_person_picture.Source = person.Image; lbl_person_name.Content = person.Name; lbl_person_party.Content = "Parteilos"; if (person.Party != null) { lbl_person_party.Content = person.Party.Name; } lbl_person_age.Content = ""; lbl_person_this_to_him.Content = "-"; lbl_person_this_to_him.Foreground = Brushes.White; lbl_person_this_to_him.ToolTip = "Unsere Meinung über ihn"; lbl_person_him_to_this.Content = "-"; lbl_person_him_to_this.Foreground = Brushes.White; lbl_person_him_to_this.ToolTip = "Seine Meinung über uns"; if (Engine.CurrentPerson.Knows(person)) { double this_to_him = Engine.CurrentPerson.GetRelationTo(person); lbl_person_this_to_him.Content = this_to_him; if (this_to_him >= 0) { lbl_person_this_to_him.Foreground = Brushes.Green; lbl_person_this_to_him.Content = "+" + lbl_person_this_to_him.Content; } else { lbl_person_this_to_him.Foreground = Brushes.Red; } } if (person.Knows(Engine.CurrentPerson)) { double him_to_this = person.GetRelationTo(Engine.CurrentPerson); lbl_person_him_to_this.Content = him_to_this; if (him_to_this >= 0) { lbl_person_him_to_this.Foreground = Brushes.Green; lbl_person_him_to_this.Content = "+" + lbl_person_him_to_this.Content; } else { lbl_person_him_to_this.Foreground = Brushes.Red; } } Border border = (Border)SubWindow.CopyFrom(border_person_vorlage); border.MouseUp += person.PersonClick; panel_persons_list.Children.Add(border); }
private void AddParty(Party party, string from) { lbl_party_name.Content = party.Name; lbl_party_founder.Content = "<Unbekannt>"; if (party.Founder != null) { lbl_party_founder.Content = party.Founder.Name; } lbl_party_from.Content = from; lbl_party_members.Content = party.MemberCount + " Members"; lbl_party_politicians.Content = party.GetPossiblePersons().Length + " Politiker"; Border border = (Border)SubWindow.CopyFrom(border_party_vorlage); panel_party_list.Children.Add(border); }
private Border GetActionButton(string name, string color, BitmapImage icon, RoutedEventHandler handler) { Border border = (Border)SubWindow.CopyFrom(border_action_vorlage); border.Background = ColorHandler.ColorFromHex(color); Button btn = (Button)border.Child; btn.Click += handler; btn.Click += Update; StackPanel panel = (StackPanel)btn.Content; Image img = (Image)panel.Children[0]; img.Source = icon; Label lbl = (Label)panel.Children[1]; lbl.Content = name; return(border); }
private void LoadTabParlament() { if (Tile is Landscape) { tab_control.Items.Remove(tab_parlament); } img_parlament_header.Source = Images.IconTabParlament; img_parlament_bg.Source = Images.IconBackground2; Border vorlage = (Border)SubWindow.CopyFrom(border_parlament_vorlage); panel_parlament_head.Children.Clear(); border_parlament_vorlage = null; panel_parlament_body.Children.Clear(); lbl_government_person.Content = Tile.Persons.Count + " Personen"; if (Tile is City city) { if (city.Government == null) { return; } lbl_parlament_ruling_party.Content = city.Government.RulingParties[0].ShortName; lbl_government_last_election.Content = city.Government.LastElection.ToString(); lbl_government_next_election.Content = city.Government.NextElection.ToString(); lbl_government_party.Content = city.Government.RegisteredParties.Count + " Parteien"; if (city.Government.Cancelor != null) { Border canelor = (Border)SubWindow.CopyFrom(vorlage); Image img = (Image)((Button)(canelor.Child)).Content; img.Source = city.Government.Cancelor.Image; canelor.ToolTip = city.Government.Cancelor.Name + " (" + city.Government.Cancelor.Party.ShortName + ")"; panel_parlament_head.Children.Add(canelor); } if (city.Government.Seats.Count > 0) { int count = city.Government.Seats.Count; StackPanel hor_panel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; for (int i = 0; i < city.Government.Seats.Count; i++) { Border seat = (Border)SubWindow.CopyFrom(vorlage); Button btn = (Button)(seat.Child); btn.Click += city.Government.Seats[i].Person.PersonClick; Image img = (Image)btn.Content; img.Source = city.Government.Seats[i].Person.Image; seat.ToolTip = city.Government.Seats[i].Person.Name + " (" + city.Government.Seats[i].Party.ShortName + ")"; seat.Background = ColorHandler.ColorFromRGB(city.Government.Seats[i].Party.Color); hor_panel.Children.Add(seat); if (hor_panel.Children.Count == 12) { panel_parlament_body.Children.Add(hor_panel); hor_panel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; } } if (hor_panel.Children.Count != 0) { panel_parlament_body.Children.Add(hor_panel); } } } }
//- Update public void Update() { //- City Founding Grid parent = grid_center; parent.Children.Remove(gui_grid_special_city); parent.Children.Remove(gui_grid_special_landscape); parent.Children.Remove(gui_grid_special_founding); if (Tile is City city2) { parent.Children.Add(gui_grid_special_city); //- Unique Buildings.. Border building_border = (Border)SubWindow.CopyFrom(border_special_unique_building); panel_special_unique_buildings.Children.Clear(); lbl_special_unique_building_name.Content = ""; lbl_special_unique_building_desc.Text = ""; for (int i = 0; i < city2.UniqueBuildings.Length; i++) { Border border = (Border)SubWindow.CopyFrom(building_border); border.Tag = city2.UniqueBuildings[i]; Grid g = (Grid)border.Child; Button b = (Button)g.Children[0]; Image img = (Image)b.Content; img.Source = Images.IconEmptyBuilding; border.MouseEnter += BuildingHover; if (city2.UniqueBuildings[i] != null) { img.Source = city2.UniqueBuildings[i].Image; border.ToolTip = city2.UniqueBuildings[i].Name; } panel_special_unique_buildings.Children.Add(border); } //- Military Buildings.. Border military_border = (Border)SubWindow.CopyFrom(border_special_military_building); panel_special_military_buildings.Children.Clear(); for (int i = 0; i < city2.MilitaryBuildings.Length; i++) { Border border = (Border)SubWindow.CopyFrom(military_border); border.Tag = city2.MilitaryBuildings[i]; Border b = (Border)border.Child; Image img = (Image)b.Child; img.Source = Images.IconEmptyBuilding; border.MouseEnter += BuildingHover; if (city2.MilitaryBuildings[i] != null) { img.Source = city2.MilitaryBuildings[i].Image; border.ToolTip = city2.MilitaryBuildings[i].Name; } panel_special_military_buildings.Children.Add(border); } //- Government Building img_special_government_building.Source = Images.IconEmptyBuilding; img_special_government_building_icon.Source = null; lbl_special_government_building_name.Content = ""; lbl_special_government_building_type.Content = ""; if (city2.GovernmentBuilding != null) { img_special_government_building.Source = city2.GovernmentBuilding.Image; img_special_government_building_icon.Source = Images.IconBuilding; lbl_special_government_building_name.Content = city2.GovernmentBuilding.Name; lbl_special_government_building_type.Content = "Regierungsgebäude"; } progessbar_special_progress.Value = 100; } //- Upgrading if (Tile is Landscape && !Tile.Upgrading) { parent.Children.Add(gui_grid_special_landscape); } else if (Tile.MyProcess != null) { parent.Children.Add(gui_grid_special_founding); lbl_special_founding_duration.Content = Tile.MyProcess.RemainingRounds.Number; StackPanel panel = Tile.GetPropertyPanel(Modifiers.LocalCityFoundModifier); panel.Background = Brushes.Black; lbl_special_founding_duration.ToolTip = Tile.GetTooltip(Modifiers.LocalCityFoundModifier, Tile.BaseProcessRound, Tile.ProcessRound); lbl_special_founding_type.Content = "Stadt"; if (!(Engine.CurrentPerson == null || Engine.CurrentPerson == Tile.Founder)) { StackPanel p = (StackPanel)panel_special_founding_name.Parent; p.Children.Remove(panel_special_founding_name); } if (Tile.Founder != null) { lbl_special_founding_founder.Content = Tile.Founder.Name; } else { lbl_special_founding_founder.Content = "Keiner"; } txt_special_founding_cityname.Text = Tile.Name; progessbar_special_progress.Value = Tile.MyProcess.Status * 100; } Title = Tile.Name; if (Tile is City) { Title += " (Stadt)"; lbl_info_city_category.Content = "Stadt"; } if (Tile is Landscape) { Title += " (Lanschaft)"; lbl_info_city_category.Content = "Landschaft"; } //- Top if (Tile is City city && city.Government != null) { lbl_top_cancelor.Content = city.Government.Cancelor.Name; lbl_top_cancelor.ToolTip = "[" + city.Government.Cancelor.ID + "]"; lbl_top_ruling_party.Content = city.Government.RulingParties[0].ShortName; } //- Info lbl_info_owner.Content = Tile.Owner.Name; btn_info_owner.Click += OwnerClick; lbl_info_owner_owner.Content = Tile.Owner.Owner.Name; img_info_owner_owner.Source = Tile.Owner.Owner.Flag; btn_info_owner_owner.Click += OwnerOwnerClick; lbl_info_dichte.Content = Math.Round(Tile.Dichte, 1) + " Bev./km²"; lbl_info_culture.Content = Tile.Culture.Name; if (Tile.Founder != null) { lbl_info_founder.Content = Tile.Founder.Name; } if (Tile.Founder != null && Tile.Founder is Country) { lbl_info_founder.Content += " (Staat)"; } //- General lbl_general_citizen_count.Content = Tile.CitizenCount + " Citizens"; string line = "Citizen Ideology:\n"; for (int i = 0; i < Tile.CitizenCount; i++) { line += Tile.Citizens[i].Name + " => " + Tile.Citizens[i].Ideology.Name + "\n"; } lbl_general_citizen_count.ToolTip = line; lbl_general_citizen_amount.Content = TextHandler.ToFormatNumber(Tile.CitizenAmount) + " Bürger"; lbl_general_person_count.Content = Tile.Persons.Count + " Personen"; line = "Persons:\n"; for (int i = 0; i < Tile.Persons.Count; i++) { if (Tile.Persons[i].Ideology != null) { line += Tile.Persons[i].Name + " (" + Tile.Persons[i].Ideology.Name + ")"; } else { line += Tile.Persons[i].Name; } if (Tile.Persons[i] is Player) { line += " [Ist Spieler]"; } line += "\n"; } lbl_general_person_count.ToolTip = line; lbl_general_building_count.Content = Tile.BuildingCount + " Gebäude"; lbl_general_military_building_count.Content = Tile.MilitaryBuildingCount + " Gebäude"; lbl_general_building_processes_count.Content = Tile.BuildingProcesses + " Projekte"; //- Tabs LoadTabPerson(); }
public void OpenUnit(Unit unit) { CloseUnit(); Window.gui_grid.Children.Add(Window.gui_grid_unit_left); #region Parents Window.panel_unit_parents.Children.Clear(); Unit parent = unit.Parent; List <UIElement> parents = new List <UIElement>(); int c = 0; while (true) { if (parent == null) { break; } Window.btn_unit_parent.Content = parent.Name; Button btn = (Button)SubWindow.CopyFrom(Window.btn_unit_parent); btn.Click += ParentClick; btn.Tag = parent; parents.Add(btn); parent = parent.Parent; c++; } parents.Reverse(); foreach (UIElement element in parents) { Window.panel_unit_parents.Children.Add(element); } #endregion #region Top Window.img_unit_commander.Source = Images.IconPerson; Window.lbl_unit_commander.Content = "Kein Befehlshaber"; Window.img_unit_main_size.Source = unit.Symbol; Window.img_unit_main_counter.Source = unit.IconCounter; Window.lbl_unit_name.Content = unit.Name; Window.lbl_unit_amount.Content = unit.CurStrength; Window.proBar_unit_org.Maximum = unit.MaxOrganisation; Window.proBar_unit_org.Value = unit.CurOrganisation; Window.proBar_unit_org.ToolTip = unit.CurOrganisation + " / " + unit.MaxOrganisation; Window.proBar_unit_strenght.Maximum = unit.MaxStrength; Window.proBar_unit_strenght.Value = unit.CurStrength; Window.proBar_unit_strenght.ToolTip = unit.CurStrength + " / " + unit.MaxStrength; if (unit.Commander != null) { Window.img_unit_commander.Source = unit.Commander.Image; Window.img_unit_commander.Tag = unit.Commander; Window.lbl_unit_commander.Content = unit.Commander.Name; Window.lbl_unit_commander.Tag = unit.Commander; } #endregion #region Center Window.lbl_unit_location.Content = unit.Location.Name; Window.lbl_unit_location.Tag = unit.Location; if (unit.IsLinked) { Window.btn_unit_link.Content = "Link-Out"; } else { Window.btn_unit_link.Content = "Linkup"; } Window.btn_unit_link.Tag = unit; Window.btn_unit_link.IsEnabled = true; if (unit.Parent == null || unit.Parent.LocationID != unit.LocationID) { Window.btn_unit_link.IsEnabled = false; } //- Orders Window.lbl_unit_order.Content = "Kein Befehl"; if (unit.Orders.Count != 0) { Order order = unit.Orders[0]; Window.lbl_unit_order.Content = order.OrderText; Window.btn_unit_order_cancel.Tag = unit; } #endregion #region LocalUnits Window.panel_unit_localunits.Children.Clear(); Window.lbl_unit_localunit_count.Content = unit.LocalUnits.Count; foreach (Unit local_unit in unit.LocalUnits) { Window.img_localunit_counter.Source = local_unit.IconCounter; Window.img_localunit_size.Source = local_unit.Symbol; Window.lbl_localunit_name.Content = local_unit.Name; Window.lbl_localunit_size.Content = local_unit.CurStrength; Window.proBar_localunit_org.Maximum = local_unit.MaxOrganisation; Window.proBar_localunit_org.Value = local_unit.CurOrganisation; Window.proBar_localunit_strenght.Maximum = local_unit.MaxStrength; Window.proBar_localunit_strenght.Value = local_unit.CurStrength; Border sub = (Border)SubWindow.CopyFrom(Window.border_localunit_vorlage); HoverHandler.AddHover(sub); Window.panel_unit_localunits.Children.Add(sub); } #endregion #region SubUnits Window.panel_unit_subunits.Children.Clear(); Window.lbl_unit_subunit_count.Content = unit.SubUnits.Count; int subunits_amount = 0; foreach (Unit sub_unit in unit.SubUnits) { //- Mark other Units in Unit SubUnitBorders.Add(sub_unit); if (sub_unit.BorderParent != null) { sub_unit.BorderParent.Background = ColorHandler.ColorFromRGB("10-10-220"); } Window.img_subunit_counter.Source = sub_unit.IconCounter; Window.img_subunit_size.Source = sub_unit.Symbol; Window.lbl_subunit_name.Content = sub_unit.Name; Window.lbl_subunit_size.Content = sub_unit.CurStrength; Window.proBar_subunit_org.Maximum = sub_unit.MaxOrganisation; Window.proBar_subunit_org.Value = sub_unit.CurOrganisation; Window.proBar_subunit_strenght.Maximum = sub_unit.MaxStrength; Window.proBar_subunit_strenght.Value = sub_unit.CurStrength; Window.lbl_subunit_commander.Content = "Kein Befehlshaber"; if (sub_unit.Commander != null) { Window.lbl_subunit_commander.Content = sub_unit.Commander.Name; } subunits_amount += sub_unit.CurStrength; Border sub = (Border)SubWindow.CopyFrom(Window.border_unit_vorlage); sub.Tag = sub_unit; sub.MouseLeftButtonUp += SubUnitClick; HoverHandler.AddHover(sub); Window.panel_unit_subunits.Children.Add(sub); } Window.lbl_unit_subunit_amount.Content = subunits_amount; #endregion //- Parent if (unit.Parent != null && unit.Parent.BorderParent != null) { unit.Parent.BorderParent.Background = ColorHandler.ColorFromRGB("20-220-20"); SubUnitParten = unit.Parent; } }
private void LoadTiles() { panel_tiles.Children.Clear(); //btn_tile_vorlage_controller.Click += Click; foreach (Tile tile in Province.Tiles) { lbl_tile_vorlage_name.Content = "Umliegende Lanschaft von " + tile.Name; lbl_tile_vorlage_citizen_count.Content = tile.CitizenAmount; lbl_tile_vorlage_city_name.Content = tile.Name; lbl_tile_vorlage_tile_type.Content = "Landschaft"; if (tile is City) { lbl_tile_vorlage_tile_type.Content = "Stadt"; } img_tile_vorlage_icon.Source = tile.Icon; img_tile_vorlage_money_icon.Source = Images.IconMoney; panel_tile_vorlage_buildings.Children.Clear(); img_tile_vorlage_controller.Source = Images.FlagREB; //- OpenCountry //btn_tile_vorlage_controller.Tag = tile.CountryController; if (grid_title_vorlage.Children.Contains(panel_title_vorlage_government_info)) { grid_title_vorlage.Children.Remove(panel_title_vorlage_government_info); } if (tile is City city) { if (city.Government != null) { lbl_title_vorlage_person.Content = city.Government.Cancelor.Name; } else { lbl_title_vorlage_person.Content = "-"; } grid_title_vorlage.Children.Add(panel_title_vorlage_government_info); } if (tile.Controller is Country country) { img_tile_vorlage_controller.Source = country.Flag; } foreach (UniqueBuilding building in tile.UniqueBuildings) { if (building == null) { continue; } Border building_border = new Border(); building_border.Background = ColorHandler.ColorFromHex("7FACACAC"); building_border.BorderBrush = ColorHandler.ColorFromHex("FF4E555F"); building_border.BorderThickness = new Thickness(1); building_border.CornerRadius = new CornerRadius(5); building_border.Padding = new Thickness(2); building_border.HorizontalAlignment = HorizontalAlignment.Center; building_border.Margin = new Thickness(5, 0, 0, 0); building_border.Width = 22; Button btn_building = new Button(); btn_building.BorderBrush = null; btn_building.Margin = new Thickness(0); btn_building.Background = null; building_border.Child = btn_building; Image icon = new Image(); icon.Margin = new Thickness(-3); btn_building.Content = icon; icon.Source = Images.IconQuestionmark; if (building.Image != null) { icon.Source = building.Image; } panel_tile_vorlage_buildings.Children.Add(building_border); } Border outer_border = (Border)SubWindow.CopyFrom(border_tile_vorlage); Button btn = (Button)((Border)((StackPanel)((StackPanel)outer_border.Child).Children[0]).Children[((StackPanel)((StackPanel)outer_border.Child).Children[0]).Children.Count - 1]).Child; btn.Tag = tile.CountryController; btn.Click += Click; panel_tiles.Children.Add(outer_border); } }