/// <summary> /// Finishing procedure. /// </summary> public void Finish(IRasterModule m) { // Called as UpdateAsync() finish routine. // Elapsed time in milliseconds. sw.Stop(); long elapsed = sw.ElapsedMilliseconds; // Optional output message. string message = DefaultRasterModule.UserBreak ? "User break!" : module.GetOutputMessage(0); form?.SetText(string.Format(CultureInfo.InvariantCulture, "Elapsed: {0:0.000}s{1}", 0.001 * elapsed, string.IsNullOrEmpty(message) ? "" : $", {message}")); DefaultRasterModule.UserBreak = false; form?.UpdateTooltip(); // Gui is already visible (if applicable). See Start() // !!! TODO: needs check ??? //module.GuiWindow = true; // Update result image. Bitmap oi = module.GetOutput(0); // Finish the job on the Form side (and discard this RecomputeTask eventually). form?.SetImage(oi); }
private void recomputeRequest(IRasterModule module) { if (module == currModuleSafe()) { recompute(false); } }
/// <summary> /// Called every time left mouse button is pressed WHILE Ctrl key is down /// and the current module has positive 'HasPixelUpdate'. /// </summary> /// <param name="x">Recomputed image coordinate in pixels.</param> /// <param name="y">Recomputed image coordinate in pixels.</param> private void recomputePixel( int x, int y) { if (running != null) { return; } IRasterModule module = currModule; if (module == null) { // Nothing to compute => set outputImage to null. setImage(ref outputImage, null); checkBoxResult.Checked = false; setSaveButton(); // Display input image. displayImage(); return; } running = new RecomputeTask(this, module); setRecomputeGui(true); running.Start(inputImage, textBoxParam.Text, x, y); }
private void updateParamFromModule(IRasterModule module) { if (module == currModule) { textBoxParam.Text = currModule.Param; } }
public HistogramForm(IRasterModule hModule) { module = hModule; InitializeComponent(); Show(); }
public HistogramHsvForm(IRasterModule hModule) { module = hModule; InitializeComponent(); this.FormClosed += HistogramForm_FormClosed; this.Resize += HistogramForm_Resize; this.Paint += HistogramForm_Paint; }
private void deactivateRequest(IRasterModule module) { if (module == currModuleSafe()) { int selectedModule = comboBoxModule.SelectedIndex; string moduleName = (string)comboBoxModule.Items[selectedModule]; deactivateModule(moduleName); } }
private void updateParamFromModule(IRasterModule module) { // MT-safe currentModule. IRasterModule cm = currModuleSafe(); if (module == cm) { textBoxParam.Text = cm.Param; } }
private void updateParamFromModule(IRasterModule module) { // MT-safe currentModule. IRasterModule cm = currModuleSafe(); if (module == cm) { SetParamText(module.Param); } }
private void buttonShowGUI_Click(object sender, EventArgs e) { // MT-safe currentModule. IRasterModule cm = currModuleSafe(); if (cm != null) { cm.GuiWindow = true; } }
private void pictureBoxMain_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { panAndZoom.OnKeyDown(e.KeyCode, ModifierKeys); // MT-safe currentModule. IRasterModule cm = currModuleSafe(); // Module's key handling. if (cm != null && cm.KeyDown != null) { cm.KeyDown(sender, new KeyEventArgs(e.KeyData)); } }
/// <summary> /// Catches mouse wheel movement for zoom in/out of image in picture box /// </summary> /// <param name="sender">Not needed</param> /// <param name="e">Needed for mouse wheel delta value and cursor location</param> private void pictureBoxMain_MouseWheel(object sender, MouseEventArgs e) { panAndZoom.OnMouseWheel(e, ModifierKeys); // MT-safe currentModule. IRasterModule cm = currModuleSafe(); // Module's mouse handling. if (cm != null && cm.MouseWheel != null) { cm.MouseWheel(sender, transformMouseEvent(e)); } }
private void deactivateModule(string moduleName) { // Deactivate the current module. currModule.GuiWindow = false; modules.Remove(moduleName); currModule = null; // Form elements. textBoxParam.Text = ""; tooltip = ""; buttonModule.Text = "Activate module"; buttonRecompute.Enabled = false; buttonBreak.Enabled = false; buttonShowGUI.Enabled = false; }
private void pictureBoxMain_MouseUp(object sender, MouseEventArgs e) { panAndZoom.OnMouseUp(out Cursor cursor); // MT-safe currentModule. IRasterModule cm = currModuleSafe(); // Module's mouse handling. if (cm != null && cm.MouseUp != null) { cm.MouseUp(sender, transformMouseEvent(e)); } Cursor = cursor; }
private void comboBoxModule_SelectedIndexChanged(object sender, EventArgs e) { int selectedModule = comboBoxModule.SelectedIndex; string moduleName = (string)comboBoxModule.Items[selectedModule]; lock (runLock) { // Backup data of the old module. if (currModule != null) { currModule.Param = textBoxParam.Text; } // Is the new selected module activated? bool activated = modules.ContainsKey(moduleName); if (activated) { // Switch data for the new module. currModule = modules[moduleName]; // Form. textBoxParam.Text = currModule.Param; UpdateTooltip(); buttonModule.Text = "Deactivate module"; currModule.GuiWindow = true; if (currModule.InputSlots > 0 && inputImage != null) { currModule.SetInput(inputImage, 0); } } else { currModule = null; // Form. textBoxParam.Text = ""; tooltip = ""; buttonModule.Text = "Activate module"; } buttonRecompute.Enabled = activated; buttonBreak.Enabled = false; } }
private void pictureBoxMain_MouseDown(object sender, MouseEventArgs e) { pictureBoxMain.Focus(); // MT-safe currentModule. IRasterModule cm = currModuleSafe(); bool isCtrl = (ModifierKeys & Keys.Control) > 0; bool isModule = cm != null; bool hasPixelUpdate = isModule && cm.HasPixelUpdate; bool leftButton = e.Button == MouseButtons.Left; Cursor cursor; if (hasPixelUpdate && isCtrl) { panAndZoom.OnMouseDown(e, recomputePixel, leftButton, ModifierKeys, out cursor); } else { panAndZoom.OnMouseDown(e, imageProbe, leftButton, ModifierKeys, out cursor); } // Warning for Ctrl+Mouse without currModule.HasPixelUpdate. if (isCtrl && isModule && !hasPixelUpdate) { SetText($"Current module '{ModuleRegistry.DecoratedModuleName(cm)}' has no PixelUpdate()"); } // Module's mouse handling. if (isModule && cm.MouseDown != null) { cm.MouseDown(sender, transformMouseEvent(e)); } if (cursor != null) { Cursor = cursor; } }
private void pictureBoxMain_MouseMove(object sender, MouseEventArgs e) { panAndZoom.OnMouseMove(e, imageProbe, e.Button == MouseButtons.Left, ModifierKeys, out Cursor cursor); // MT-safe currentModule. IRasterModule cm = currModuleSafe(); // Module's mouse handling. if (cm != null && cm.MouseMove != null) { cm.MouseMove(sender, transformMouseEvent(e)); } if (cursor != null) { Cursor = cursor; } }
private void buttonModule_Click(object sender, EventArgs e) { int selectedModule = comboBoxModule.SelectedIndex; string moduleName = (string)comboBoxModule.Items[selectedModule]; // Is the selected module activated? bool activated = modules.ContainsKey(moduleName); if (activated) { // Deactivate the current module. deactivateModule(moduleName); } else { lock (runLock) { // Activate the module. currModule = modules[moduleName] = ModuleRegistry.CreateModule(moduleName); // Notifications module -> main. currModule.UpdateRequest = recomputeRequest; currModule.ParamUpdated = updateParamFromModule; currModule.DeactivateRequest = deactivateRequest; // Form elements. textBoxParam.Text = currModule.Param; UpdateTooltip(); buttonModule.Text = "Deactivate module"; buttonShowGUI.Enabled = true; currModule.GuiWindow = true; if (currModule.InputSlots > 0 && inputImage != null) { currModule.SetInput(inputImage); } buttonRecompute.Enabled = true; buttonBreak.Enabled = false; } } }
public RoundedHistogramForm(IRasterModule hModule) { module = hModule; InitializeComponent(); }
/// <summary> /// Keep references to FormMain and the current module (to be sure). /// </summary> public RecomputeTask(FormMain f, IRasterModule m) { form = f; module = m; }
public FormHSV(IRasterModule hModule) { module = hModule; InitializeComponent(); }