private Vector2 DisplayByType(Drawing drawing, Vector2 position, List <string> types) { int count = 0; float height = itemSize; float width = 3 * itemSize; int limit = GetLimit(drawing); string colorDefault = DisplayLcd.program.MyProperty.Get("color", "default"); int limitDefault = DisplayLcd.program.MyProperty.GetInt("Limit", "default"); foreach (string type in types) { foreach (KeyValuePair <string, Item> entry in item_list.OrderByDescending(entry => entry.Value.Amount).Where(entry => entry.Value.Type == type)) { Item item = entry.Value; Vector2 position2 = position + new Vector2(width * (count / limit), (cellSpacing + height) * (count - (count / limit) * limit)); // Icon Color color = DisplayLcd.program.MyProperty.GetColor("color", item.Name, colorDefault); int limitBar = DisplayLcd.program.MyProperty.GetInt("Limit", item.Name, limitDefault); //DisplayIcon(drawing, item, position2, width); StyleIcon style = new StyleIcon() { path = item.Icon, Width = width, Height = height, Color = color }; int variance = 2; //DisplayLcd.program.drawingSurface.WriteText($"variance:{entry.Key}?{last_amount.ContainsKey(entry.Key)}\n", true); if (last_amount.ContainsKey(entry.Key)) { if (last_amount[entry.Key] < item.Amount) { variance = 1; } if (last_amount[entry.Key] > item.Amount) { variance = 3; } } else { variance = 1; } drawing.DrawGaugeIcon(position2, item.Name, item.Amount, limitBar, style, variance); count++; } } if (item_list.Count > limit) { return(position + new Vector2(0, (cellSpacing + height) * limit)); } return(position + new Vector2(0, (cellSpacing + height) * item_list.Count)); }
public void DrawGaugeIcon(Vector2 position, string name, double amount, int limit, StyleIcon style_icon, int variance = 0) { Vector2 position2 = position + new Vector2(style_icon.Padding.X, style_icon.Padding.Y); // cadre info //AddForm(position2, SpriteForm.SquareSimple, style_icon.Width, style_icon.Height, new Color(40, 40, 40, 128)); float width = (style_icon.Width - 3 * style_icon.Margin.X) / 3; float fontTitle = Math.Max(0.3f, (float)Math.Round(0.5f * (style_icon.Height / 80f), 1)); float fontQuantity = Math.Max(0.5f, (float)Math.Round(1f * (style_icon.Height / 80f), 1)); // Icon AddSprite(new MySprite() { Type = SpriteType.TEXTURE, Data = style_icon.path, Size = new Vector2(width, width), Color = style_icon.Color, Position = position2 + new Vector2(0, width / 2) }); StyleGauge style = new StyleGauge() { Orientation = SpriteOrientation.Horizontal, Fullscreen = false, Width = width * 2, Height = width / 3, Padding = new StylePadding(0), RotationOrScale = Math.Max(0.3f, (float)Math.Round(0.6f * (style_icon.Height / 80f), 1)) }; DrawGauge(position2 + new Vector2(width + style_icon.Margin.X, style_icon.Height / 2), (float)amount, limit, style); // Element Name icon = new MySprite() { Type = SpriteType.TEXT, Data = name, Size = new Vector2(width, width), Color = Color.DimGray, Position = position2 + new Vector2(style_icon.Margin.X, -8), RotationOrScale = fontTitle, FontId = Font, Alignment = TextAlignment.LEFT }; AddSprite(icon); // Quantity icon = new MySprite() { Type = SpriteType.TEXT, Data = Util.GetKiloFormat(amount), Size = new Vector2(width, width), Color = Color.LightGray, Position = position2 + new Vector2(width + style_icon.Margin.X, style_icon.Margin.Y), RotationOrScale = fontQuantity, FontId = Font }; AddSprite(icon); float symbolSize = 20f; if (variance == 1) { AddSprite(new MySprite() { Type = SpriteType.TEXTURE, Data = SpriteForm.Triangle.ToString(), Size = new Vector2(symbolSize, symbolSize), Color = new Color(0, 100, 0, 255), Position = position2 + new Vector2(3 * width - 25, symbolSize - style_icon.Margin.Y), RotationOrScale = 0 }); } if (variance == 3) { AddSprite(new MySprite() { Type = SpriteType.TEXTURE, Data = SpriteForm.Triangle.ToString(), Size = new Vector2(symbolSize, symbolSize), Color = new Color(100, 0, 0, 255), Position = position2 + new Vector2(3 * width - 25, symbolSize + style_icon.Margin.Y), RotationOrScale = (float)Math.PI }); } }