using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using TradeIdeas.TIProGUI; namespace TIProPerformanceMonitorExtension { public partial class ChartMonitorControl: UserControl { private BindingList _chartsList = new BindingList(); public ChartMonitorControl() { InitializeComponent(); LoadCharts(); lstCharts.DataSource = _chartsList; lstCharts.DisplayMember = "name"; } private void LoadCharts() { // find all charts and add them to the list _chartsList.Clear(); foreach (Charts chart in Application.OpenForms.OfType().Where(x => !x.IsDisposed).ToList()) { AddChart(new ChartListItem { name = chart.Text, chart = chart }); } } private void AddChart(ChartListItem chartItem) { // RVHTODO - add onDispose event handler to remove from the list _chartsList.Add(chartItem); } private void RemoveChart(ChartListItem chartItem) { // RVHTODO - remove onDispose event handler before removing from the list _chartsList.Remove(chartItem); } private void btnRefresh_Click(object sender, EventArgs e) { LoadCharts(); } private void lstCharts_SelectedIndexChanged(object sender, EventArgs e) { } } public class ChartListItem { private Charts _chart; public string name { get; set; } public Charts chart { get { return _chart; } set { _chart = value; _chart.TextChanged += chart_TextChanged; } } private void chart_TextChanged(object sender, EventArgs e) { name = ((Form)sender).Text; } } }