public HierarchicalOptimalGrid() { grid = new ColorableGrid(); WrapControl(grid); Name = "Imai Iri Hierarchical - Graph Weights"; Priority = 4; VisualizableState = RunState.OutputAvailable; grid.PreviewKeyDown += HandlePreviewKeyDown; grid.KeyDown += HandleArrowKeys; grid.Paint += DrawInfo; BeforeStateReachedHandler = run => { Visible = false; }; AfterStateReachedHandler = run => { Visible = true; this.run = run; currentLevel = 1; DrawGrid(); }; }
private void LoadDefaultConfiguration() { //default input if (controller.Inputs.Count == 0) { controller.Inputs.Add(new TIn()); } //default run if (controller.Runs.Count == 0) { if (controller.Algorithms.Count > 0 && controller.Inputs.Count > 0) { var run = new AlgorithmRun <TIn, TOut>(controller.Algorithms[0], controller.Inputs[0]); controller.Runs.Add(run); } } controller.Runs.ToList().ForEach(AddRunToTable); //updating controls appropriately when data is updated controller.Inputs.ListChanged += (o, e) => InputsUpdated(); controller.Algorithms.ListChanged += (o, e) => AlgorithmsUpdated(); AlgorithmsUpdated(); InputsUpdated(); //redrawing controls when some name is updated controller.Inputs.ItemNameChanged += (o, s) => RedrawControls(); controller.Algorithms.ItemNameChanged += (o, s) => RedrawControls(); controller.Runs.ItemNameChanged += (o, s) => RedrawControls(); //force loading currently selected data inputComboBox_SelectedIndexChanged(null, null); algorithmComboBox_SelectedIndexChanged(null, null); }
public MSSGridExplorer() { grid = new ColorableGrid(); WrapControl(grid); Name = "Colored Grid"; Priority = 1; VisualizableState = RunState.OutputAvailable; grid.PreviewKeyDown += HandlePreviewKeyDown; grid.KeyDown += HandleArrowKeys; grid.Paint += DrawInfo; BeforeStateReachedHandler = run => { Visible = false; }; AfterStateReachedHandler = run => { Visible = true; this.run = run; currentLevel = 1; DrawGrid(); }; }
public void AfterOutputAvailable(AlgorithmRun <MSInput, MSOutput> run) { this.run = run; output = run.Output; Visible = true; currentLevel = 1; LookAtTrajectory(output.GetTrajectoryAtLevel(currentLevel)); }
private void RemoveRun(AlgorithmRun <TIn, TOut> run) { var row = workloadTable.Rows .Cast <DataGridViewRow>().ToList() .Find(r => (AlgorithmRun <TIn, TOut>)r.Cells["workloadTableRunColumn"].Value == run); workloadTable.Rows.Remove(row); controller.Runs.Remove(run); }
public static AlgorithmRunInfo CreateFrom(AlgorithmRun run) { return(new AlgorithmRunInfo() { Info = run.Alg.ToInfo(), Mask = run.Context.Mask.Jaggedize_DC(), RandomSeed = run.Context.R.Seed }); }
private void addRunButton_Click(object sender, EventArgs e) { var input = controller.Inputs[0]; var algo = controller.Algorithms[0]; var run = new AlgorithmRun <TIn, TOut>(algo, input); controller.Runs.Add(run); AddRunToTable(run); }
public void AfterOutputAvailable(AlgorithmRun <MSInput, MSOutput> run) { Visible = true; this.run = run; var trajectory = output.GetTrajectoryAtLevel(1); trajectoryGMap.LookAtTrajectory(trajectory); FitLevelToDesiredDetail(); }
public void AfterOutputAvailable(AlgorithmRun <MSInput, MSOutput> run) { Visible = true; this.run = run; currentLevel = 1; var trajectory = output.GetTrajectoryAtLevel(currentLevel); trajectoryGMap.DrawSingleTrajectory(trajectory); trajectoryGMap.LookAtTrajectory(trajectory); }
protected void AddStateReachedHandler(AlgorithmRun <TIn, TOut> run, RunState state, Action <AlgorithmRun <TIn, TOut> > handler) { //wrap the handler RunStateChangedHandler <TIn, TOut> act = (r, s) => { if (s == state) { handler(r); } }; run.StateChanged += act; stateChangedHandlers[run].Add(act); }
private void AddRunToTable(AlgorithmRun <TIn, TOut> run) { var rowIndex = workloadTable.Rows.Add(run, run.Input, run.Algorithm, run.NumIterations); var row = workloadTable.Rows[rowIndex]; row.ReadOnly = run.State != RunState.Idle; var multCell = row.Cells["workloadTableAmountColumn"]; var foreColor = Color.FromArgb(255, 40, 40, 40); multCell.Style.ForeColor = foreColor; multCell.Style.SelectionForeColor = foreColor; RunStateChangedHandler <TIn, TOut> stateChanged = (r, state) => { Color color = multCell.Style.BackColor; switch (state) { case RunState.Idle: color = Color.IndianRed; break; case RunState.Started: color = Color.Yellow; break; case RunState.OutputAvailable: color = Color.GreenYellow; break; case RunState.Finished: color = Color.LimeGreen; break; } multCell.Style.BackColor = color; multCell.Style.SelectionBackColor = color; RunsUpdated(); }; stateChanged(run, run.State); run.StateChanged += stateChanged; }
public void AfterStarted(AlgorithmRun <TIn, TOut> run) { var newWorker = new BackgroundWorker { WorkerSupportsCancellation = true }; newWorker.DoWork += (o, e) => { var buffer = new StringBuffer(); while (run.Output == null) { Thread.Sleep(500); } var output = run.Output; this.InvokeIfRequired(() => { output.LogBuffers.Add(buffer); richTextBox.Text = output.LogString; Visible = true; }); while (!newWorker.CancellationPending) { this.InvokeIfRequired(() => { AppendLoggedOutput(buffer.Flush()); }); Thread.Sleep(500); } output.LogBuffers.Remove(buffer); }; logPollingWorker?.CancelAsync(); newWorker.RunWorkerAsync(); logPollingWorker = newWorker; }
public void BeforeOutputAvailable(AlgorithmRun <MSInput, MSOutput> run) { Visible = false; }
public void BeforeStarted(AlgorithmRun <TIn, TOut> run) { Visible = false; }
public static AlgorithmRunInfo ToInfo(this AlgorithmRun run) { return(AlgorithmRunInfo.CreateFrom(run)); }