/// <summary> /// Refreshes the data in the gridview when a change is made to one of the view options /// </summary> /// <param name="sender">The sending object</param> /// <param name="e">The event arguments</param> private void OnUpdateData(object sender, EventArgs e) { // The process of initially setting up the view will trigger the event early. // This statement catches early triggers to prevent errors/needless computation if (view.Filter == null) { return; } // Look for the data source var store = table.FindInScope <IDataStore>(); DataTable input = store.Reader.GetData(view.LedgerName); // Don't try to update if data source isn't found if (input == null) { return; } // Update filters if the filter button was pressed //if (sender is Gtk.Button btn) { UpdateFilter(input, btn.Name); } // The timescale is the number of significant characters when grouping based on date, // i.e. you only need to look at 4 characters when determining what year it is int timeScaleCharacters = 0; if (view.TimeScale == "Daily") { timeScaleCharacters = 10; } else if (view.TimeScale == "Monthly") { timeScaleCharacters = 7; } else if (view.TimeScale == "Yearly") { timeScaleCharacters = 4; } // Find the data and generate the table with it var columns = FindColumns(input, timeScaleCharacters); var rows = FindRows(input, columns, timeScaleCharacters); GenerateTable(rows, columns); }
/// <summary> /// Looks through the simulation for resource ledgers and adds /// them as options to the ledger box /// </summary> /// <param name="table">The table model in the simulation</param> public void SetLedgers(PivotTable table) { // Find a CLEMFolder CLEMFolder folder = table.FindInScope <CLEMFolder>(); // Look for ledgers inside the CLEMFolder foreach (var child in folder.Children) { if (child.GetType() != typeof(ReportResourceLedger)) { continue; } ReportResourceLedger ledger = child as ReportResourceLedger; LedgerViewBox.AddText(ledger.Name); } // Set the active ledger option if (LedgerViewBox.ID < 0) { LedgerViewBox.ID = 0; } }