private void UpdateDisplay(CounterType counterType) { // get the display if it exists if (displays.TryGetValue(counterType, out CounterDisplay display)) { if (counterList.CounterMap.TryGetValue(counterType, out int amount)) { display.gameObject.SetActive(true); display.SetText(amount); // if a display exists and there is an amount for it then set the display to the amount } else { // A display exists but no amount so set the display to inactive display.SetText(0); display.gameObject.SetActive(false); UpdateDisplayLocations(); } } else { // no display exists so create a new one CounterDisplay newDisplay = Instantiate(counterDisplayPrefab, transform); displays.Add(counterType, newDisplay); newDisplay.SetBackgroundColor(Counters.GetData(counterType).FillColor); newDisplay.SetBorderColor(Counters.GetData(counterType).BorderColor); newDisplay.SetTextColor(Counters.GetData(counterType).BorderColor); newDisplay.SetText(counterList.AmountOf(counterType)); UpdateDisplayLocations(); } }
public void RemoveCounter(CounterDisplay d) { clist.Remove(d); graph_vbox.Remove(d); if (clist.Count == 0 && timeout_active) { timeout_active = false; GLib.Source.Remove(timeout_id); } }
void AddCounter(string cat, string counter, string instance) { CounterDisplay d = new CounterDisplay(this, cat, counter, instance); graph_vbox.PackStart(d, false, false, 6); clist.Add(d); //Console.WriteLine ("Added: {0}/{1}", cat, counter); if (!timeout_active) { timeout_id = GLib.Timeout.Add(timeout_ms, OnTimeout); timeout_active = true; } }
void AddCounter(string cat, string counter, string instance) { CounterDisplay d = new CounterDisplay (this, cat, counter, instance); graph_vbox.PackStart (d, false, false, 6); clist.Add (d); //Console.WriteLine ("Added: {0}/{1}", cat, counter); if (!timeout_active) { timeout_id = GLib.Timeout.Add (timeout_ms, OnTimeout); timeout_active = true; } }
public void RemoveCounter(CounterDisplay d) { clist.Remove (d); graph_vbox.Remove (d); if (clist.Count == 0 && timeout_active) { timeout_active = false; GLib.Source.Remove (timeout_id); } }