public GroupCalculationProgressDialog(IGraph graph, GroupsCheckedList chkList, ShowMetricCalculateResult oShowMetricCalculateResult) { InitializeComponent(); m_oGroupsCheckedList = chkList; m_oGroupCalculatorManager = new GroupCalculatorManager(); m_ograph = graph; m_oGroupCalculatorManager.CalculationProgressChanged += new ProgressChangedEventHandler(Manager_ProgressChanged); m_oGroupCalculatorManager.CalculationCompleted += new RunWorkerCompletedEventHandler(Manager_WorksCompleted); m_oShowMetricCalculateResult = oShowMetricCalculateResult; m_oGroupCalculatorManager.attach(m_oShowMetricCalculateResult); }
/* Create calculator accoring to the input checkedlist and pass to BackgroundWorker */ public void calculateMetricsAsync(IGraph graph, GroupsCheckedList checkedlist) { if (m_oBackgroundWorker != null && m_oBackgroundWorker.IsBusy) { /* throw new InvalidOperationException(String.Format( "{0}:{1}: An asynchronous operation is already in progress." , this.ClassName, MethodName )); * */ } CalculateGroupsAsyncArgs args = new CalculateGroupsAsyncArgs(); // add analyzer to this object and pass to BackgroundWorker args.Analyzers = new LinkedList<AnalyzerBase>(); args.Graph = graph; if (checkedlist.Fan_Motif == true) { args.Analyzers.AddLast(new FanMotifDetector()); } if (checkedlist.Dconnector_Motif == true && checkedlist.dMininum > 4 && checkedlist.dMaximum < 9999 && checkedlist.dMininum < checkedlist.dMaximum) { args.Analyzers.AddLast(new DConnectorMotifDetector(checkedlist.dMininum, checkedlist.dMaximum)); } if (checkedlist.WakitaTsurumi_Cluster == true) { args.Analyzers.AddLast(new WakitaTsurumiClusterDetector());} // create a new BackgroundWorker m_oBackgroundWorker = new BackgroundWorker(); m_oBackgroundWorker.WorkerReportsProgress = true; m_oBackgroundWorker.WorkerSupportsCancellation = true; m_oBackgroundWorker.DoWork += new DoWorkEventHandler(BackgroundWorker_DoWork); m_oBackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged); m_oBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker_RunWorkerCompleted); m_oBackgroundWorker.RunWorkerAsync(args); }
private void btnOK_Click(object sender, EventArgs e) { /* TO DO: * logic to set GroupsCheckedList and pass it to * * */ chklist = new GroupsCheckedList(); if (radDConnectorMotif.Checked) { chklist.Dconnector_Motif = true; chklist.dMaximum = Convert.ToInt32(numericUpDown2.Value); chklist.dMininum = Convert.ToInt32(numericUpDown1.Value); } else if (radFanMotif.Checked) chklist.Fan_Motif = true; else chklist.WakitaTsurumi_Cluster = true; GroupCalculationProgressDialog gp = new GroupCalculationProgressDialog(m_oGraph, chklist, m_oShowMetricCalculateResult); if (gp.ShowDialog() == DialogResult.OK) { DialogResult = DialogResult.OK; m_oResultDataTableObservableBase = m_oShowMetricCalculateResult.m_oDataTableObservableBase; gp.Close(); } }