private void InitializeResources() { Random random = new Random(); for (int i = 0; i < 15; i++) { Resources.Add(new Employees() { Name = nameCollection[i], Color = Color.FromRgb(random.Next(0, 255), random.Next(10, 255), random.Next(100, 255)), ID = i.ToString(), Image = i < 9 ? "Schedule_Resource" + i.ToString() + ".png" : null }); } for (int i = 0; i < 10; i++) { SelectedResources.Add(Resources[random.Next(Resources.Count)]); } }
private void InitializeResources() { Random random = new Random(); for (int i = 0; i < 15; i++) { Employees employees = new Employees(); employees.Name = nameCollection[i]; employees.Color = Color.FromRgb(random.Next(0, 255), random.Next(10, 255), random.Next(100, 255)); employees.ID = i.ToString(); if (i < 9) { if (employees.Name == "Brooklyn") { employees.Image = "People_Circle8.png"; } else if (employees.Name == "Sophia") { employees.Image = "People_Circle1.png"; } else if (employees.Name == "Stephen") { employees.Image = "People_Circle12.png"; } else if (employees.Name == "Zoey Addison") { employees.Image = "People_Circle2.png"; } else if (employees.Name == "Daniel") { employees.Image = "People_Circle14.png"; } else if (employees.Name == "Emilia") { employees.Image = "People_Circle3.png"; } else if (employees.Name == "Adeline Ruby") { employees.Image = "People_Circle4.png"; } else if (employees.Name == "James William") { employees.Image = "People_Circle5.png"; } else if (employees.Name == "Kinsley Elena") { employees.Image = "People_Circle6.png"; } } else { employees.Image = null; } Resources.Add(employees); } for (int i = 0; i < 10; i++) { SelectedResources.Add(Resources[random.Next(Resources.Count)]); } }
public override void Construct() { SourceResources = new List <ResourceAmount>(TradeEntity.Resources); var leftPanel = AddChild(new Widget()); leftPanel.AddChild(new Gum.Widget { Text = LeftHeader, Font = "outline-font", TextColor = new Vector4(1, 1, 1, 1), AutoLayout = AutoLayout.DockTop }); leftPanel.AddChild(new Gum.Widget { MinimumSize = new Point(0, 32), AutoLayout = AutoLayout.DockBottom, Font = "outline-font", TextColor = new Vector4(1, 1, 1, 1), Text = String.Format("${0}", TradeEntity.Money.ToString()), TextHorizontalAlign = ReverseColumnOrder ? HorizontalAlign.Left : HorizontalAlign.Right, TextVerticalAlign = VerticalAlign.Center }); var leftList = leftPanel.AddChild(new Gum.Widgets.WidgetListView { ItemHeight = 32, AutoLayout = AutoLayout.DockFill }) as Gum.Widgets.WidgetListView; var rightPanel = AddChild(new Widget()); rightPanel.AddChild(new Gum.Widget { Text = RightHeader, Font = "outline-font", TextColor = new Vector4(1, 1, 1, 1), AutoLayout = AutoLayout.DockTop }); MoneyField = rightPanel.AddChild(new MoneyEditor { MaximumValue = TradeEntity.Money, MinimumSize = new Point(0, 32), AutoLayout = AutoLayout.DockBottom, OnValueChanged = (sender) => Root.SafeCall(OnTotalSelectedChanged, this) }) as MoneyEditor; var rightList = rightPanel.AddChild(new Gum.Widgets.WidgetListView { ItemHeight = 32, AutoLayout = AutoLayout.DockFill }) as Gum.Widgets.WidgetListView; foreach (var resource in SourceResources) { var lineItem = CreateLineItem(resource); var lambdaResource = resource; lineItem.TriggerOnChildClick = true; lineItem.OnClick = (sender, args) => { if (lambdaResource.NumResources == 0) { return; } lambdaResource.NumResources -= 1; var existingEntry = SelectedResources.FirstOrDefault(r => r.ResourceType == lambdaResource.ResourceType); if (existingEntry == null) { existingEntry = new ResourceAmount(lambdaResource.ResourceType, 0); SelectedResources.Add(existingEntry); var rightLineItem = CreateLineItem(existingEntry); rightList.AddItem(rightLineItem); rightLineItem.TriggerOnChildClick = true; rightLineItem.OnClick = (_sender, _args) => { existingEntry.NumResources -= 1; if (existingEntry.NumResources == 0) { var index = SelectedResources.IndexOf(existingEntry); SelectedResources.RemoveAt(index); rightList.RemoveChild(rightList.GetChild(index + 1)); } UpdateRightColumn(rightList); var sourceEntry = SourceResources.FirstOrDefault( r => r.ResourceType == existingEntry.ResourceType); sourceEntry.NumResources += 1; UpdateLineItemText( leftList.GetChild(SourceResources.IndexOf(sourceEntry) + 1), sourceEntry); Root.SafeCall(OnTotalSelectedChanged, this); }; } existingEntry.NumResources += 1; UpdateRightColumn(rightList); UpdateLineItemText(lineItem, lambdaResource); Root.SafeCall(OnTotalSelectedChanged, this); }; leftList.AddItem(lineItem); } }