private void UpdateDataSources(List <DataSourceItem> datasources) { foreach (DataSourceItem dsi in datasources) { bool found = false; foreach (DesignedGraph graph in Graphs) { found = graph.DataSources.Contains(dsi); if (found) { if (!Palette.HasCustomColour(dsi.Uuid)) { dsi.ColorChanged = true; Palette.SetCustomColor(dsi.Uuid, dsi.Color); } break; } } if (!dsi.DataSource.standard && dsi.DataSource.name_label != "avg_cpu") { dsi.Enabled = found; } } }
private List <DataSourceItem> GetGraphsDataSources() { List <DataSourceItem> dataSources = new List <DataSourceItem>(); foreach (DesignedGraph designedGraph in Graphs) { foreach (DataSourceItem dsi in designedGraph.DataSources) { string datasourceName = dsi.GetDataSource(); if (datasourceName == "memory_total_kib" || datasourceName == "memory") { continue; } if (!Palette.HasCustomColour(dsi.Uuid)) { dsi.DataSource.name_label = datasourceName; dsi.ColorChanged = true; Palette.SetCustomColor(dsi.Uuid, dsi.Color); dataSources.Add(dsi); } } } if (dataSources.Count > 0) { return(dataSources); } return(null); }
/// <summary> /// Random Thread /// </summary> void pool_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "gui_config") { Dictionary <string, string> gui_config = Helpers.GetGuiConfig((IXenObject)sender); string uuid = Helpers.GetUuid(XenObject); foreach (string key in gui_config.Keys) { if (!Palette.OtherConfigUUIDRegex.IsMatch(key) || !key.Contains(uuid)) { continue; } string value = gui_config[key]; int argb; if (!Int32.TryParse(value, out argb)) { continue; } string[] strs = key.Split('.'); // just set the color, we dont care what it is Palette.SetCustomColor(Palette.GetUuid(strs[strs.Length - 1], XenObject), Color.FromArgb(argb)); } OnArchivesUpdated(); } }