示例#1
0
文件: FormMain.cs 项目: Woprok/grcis
        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;
            }
        }
示例#2
0
文件: FormMain.cs 项目: Woprok/grcis
        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;
                }
            }
        }
示例#3
0
文件: FormMain.cs 项目: Woprok/grcis
            /// <summary>
            /// Starts the module.Update()/PixelUpdate() + support.
            /// </summary>
            public void Start(Bitmap inImage, string newParam, int x = -1, int y = -1)
            {
                // Set input.
                if (module.InputSlots > 0)
                {
                    module.SetInput(inImage, 0);
                }

                // Update Param string?
                if (newParam != null)
                {
                    module.Param = newParam;
                }

                // Show the optional GUI for the module.
                // !!! TODO: needs check ???
                module.GuiWindow = true;

                // Reset the break system.
                DefaultRasterModule.UserBreak = false;

                // Measure the recompute time.
                sw = new Stopwatch();
                sw.Start();

                // Recompute.
                if (x >= 0 &&
                    y >= 0)
                {
                    module.PixelUpdateAsync(x, y, Finish);
                }
                else
                {
                    module.UpdateAsync(Finish);
                }
            }