private void SaveButton_Click(object sender, EventArgs e) { if (graphList == null || graphList.XenObject == null) { return; } designedGraph.DisplayName = GraphNameTextBox.Text; if (isNew) { graphList.AddGraph(designedGraph); } else { graphList.ReplaceGraphAt(graphList.SelectedGraphIndex, designedGraph); } List <DataSourceItem> dataSources = new List <DataSourceItem>(); foreach (DataGridViewRow row in dataGridView.Rows) { DataSourceItem dsi = ((DataSourceGridViewRow)row).Dsi; if (dsi.ColorChanged) { Palette.SetCustomColor(Palette.GetUuid(dsi.DataSource.name_label, graphList.XenObject), dsi.Color); } dataSources.Add(dsi); } graphList.SaveGraphs(dataSources); }