public NodeElement(ProductionNode node, ProductionGraphViewer parent) : base(parent) { Width = 100; Height = 90; DisplayedNode = node; if (DisplayedNode.GetType() == typeof(ConsumerNode)) { backgroundColour = supplyColour; } else if (DisplayedNode.GetType() == typeof(SupplyNode)) { backgroundColour = consumerColour; } else { backgroundColour = recipeColour; } backgroundBrush = new SolidBrush(backgroundColour); foreach (Item item in node.Inputs) { ItemTab newTab = new ItemTab(item, LinkType.Input, Parent); SubElements.Add(newTab); inputTabs.Add(newTab); } foreach (Item item in node.Outputs) { ItemTab newTab = new ItemTab(item, LinkType.Output, Parent); SubElements.Add(newTab); outputTabs.Add(newTab); } if (DisplayedNode is RecipeNode || DisplayedNode is SupplyNode) { assemblerBox = new AssemblerBox(Parent); SubElements.Add(assemblerBox); assemblerBox.Height = assemblerBox.Width = 50; } centreFormat.Alignment = centreFormat.LineAlignment = StringAlignment.Center; }
public NodeElement(ProductionNode node, ProductionGraphViewer parent) : base(parent) { Width = 100; Height = 90; DisplayedNode = node; Color backgroundColour = missingColour; Color textColour = darkTextColour; if (DisplayedNode is ConsumerNode) { backgroundColour = outputColour; if (((ConsumerNode)DisplayedNode).ConsumedItem.IsMissingItem) { backgroundColour = missingColour; } } else if (DisplayedNode is SupplyNode) { backgroundColour = supplyColour; if (((SupplyNode)DisplayedNode).SuppliedItem.IsMissingItem) { backgroundColour = missingColour; } } else if (DisplayedNode is RecipeNode) { backgroundColour = recipeColour; if (((RecipeNode)DisplayedNode).BaseRecipe.IsMissingRecipe) { backgroundColour = missingColour; } } else if (DisplayedNode is PassthroughNode) { backgroundColour = passthroughColour; if (((PassthroughNode)DisplayedNode).PassedItem.IsMissingItem) { backgroundColour = missingColour; } } else { Trace.Fail("No branch for node: " + DisplayedNode.ToString()); } backgroundBrush = new SolidBrush(backgroundColour); textBrush = new SolidBrush(textColour); foreach (Item item in node.Inputs) { ItemTab newTab = new ItemTab(item, LinkType.Input, Parent); SubElements.Add(newTab); inputTabs.Add(newTab); } foreach (Item item in node.Outputs) { ItemTab newTab = new ItemTab(item, LinkType.Output, Parent); SubElements.Add(newTab); outputTabs.Add(newTab); } if (DisplayedNode is RecipeNode || DisplayedNode is SupplyNode) { assemblerBox = new AssemblerBox(Parent); SubElements.Add(assemblerBox); assemblerBox.Height = assemblerBox.Width = 50; } centreFormat.Alignment = centreFormat.LineAlignment = StringAlignment.Center; }