Example #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var buttonParam = new ButtonParamWf("labelText", "buttonText", (o, args) => { Console.WriteLine("Button clicked"); });
            var fileParam   = new CheckedFileParamWf("test", (s, control) =>
            {
                if (!string.IsNullOrWhiteSpace(s))
                {
                    control.selectButton.BackColor = Color.Aqua;
                    control.ToolTip.SetToolTip(control.selectButton, "good job!");
                }
            });
            var    processing = new PluginInterop.Python.MatrixProcessing();
            string err        = "";
            var    parameters = processing.GetParameters(null, ref err);
            var    form       = new ParameterForm(new Parameters(buttonParam, fileParam), "test", "test help", "help output", new List <string>());

            form.Load += (sender, args) =>
            {
                var form2 = new ParameterForm(parameters, "python", "asdf", "asdfsdf", new List <string>());
                form2.Show();
            };
            Application.Run(form);
        }
Example #2
0
        protected override FileParam ExecutableParam()
        {
            Action <string, CheckedFileParamControl> checkFileName = (s, control) =>
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    return;
                }
                if (Utils.CheckPythonInstallation(s))
                {
                    control.selectButton.BackColor = Color.LimeGreen;
                    control.ToolTip.SetToolTip(control.selectButton, "Python installation was found");
                }
                else
                {
                    control.selectButton.BackColor = Color.Red;
                    control.ToolTip.SetToolTip(control.selectButton, "A valid Python installation was not found. Make sure to select a Python installation with perseuspy installed");
                };
            };
            var fileParam = new CheckedFileParamWf(InterpreterLabel, checkFileName)
            {
                Filter = InterpreterFilter
            };
            string path;

            if (TryFindExecutable(out path))
            {
                fileParam.Value = path;
            }
            return(fileParam);
        }
Example #3
0
        /// <summary>
        /// Try to find R executable and show green light if found.
        /// </summary>
        public static FileParam CreateCheckedFileParam(string interpreterLabel, string interpreterFilter, Python.Utils.TryFindExecutableDelegate tryFindExecutable)
        {
            void CheckFileName(string s, CheckedFileParamControl control)
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    return;
                }
                if (CheckRInstallation(s))
                {
                    control.selectButton.BackColor = Color.LimeGreen;
                    control.ToolTip.SetToolTip(control.selectButton, "R installation was found");
                }
                else
                {
                    control.selectButton.BackColor = Color.Red;
                    control.ToolTip.SetToolTip(control.selectButton, "A valid R installation was not found. Make sure to select a R installation with 'PerseusR' installed");
                }
            }

            var fileParam = new CheckedFileParamWf(interpreterLabel, CheckFileName)
            {
                Filter = interpreterFilter
            };

            if (tryFindExecutable(out string path))
            {
                fileParam.Value = path;
            }
            return(fileParam);
        }
Example #4
0
        /// <summary>
        /// Create a checked file param which changes color if the python installation passes <see cref="CheckPythonInstallation"/>.
        /// </summary>
        /// <param name="interpreterLabel"></param>
        /// <param name="interpreterFilter"></param>
        /// <param name="tryFindExecutable"></param>
        /// <param name="packages">Passed directly to python.exe -e</param>
        /// <returns></returns>
        public static FileParam CreateCheckedFileParam(string interpreterLabel, string interpreterFilter, TryFindExecutableDelegate tryFindExecutable,
                                                       string[] packages)
        {
            Action <string, CheckedFileParamControl> checkFileName = (s, control) =>
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    return;
                }
                if (CheckPythonInstallation(s, packages))
                {
                    control.selectButton.BackColor = Color.LimeGreen;
                    control.ToolTip.SetToolTip(control.selectButton, "Python installation was found");
                }
                else
                {
                    control.selectButton.BackColor = Color.Red;
                    control.ToolTip.SetToolTip(control.selectButton,
                                               "A valid Python installation was not found.\n" +
                                               "Could not import one or more packages:\n" +
                                               string.Join(", ", packages));
                }
                ;
            };
            var fileParam = new CheckedFileParamWf(interpreterLabel, checkFileName)
            {
                Filter = interpreterFilter
            };
            string path;

            if (tryFindExecutable(out path))
            {
                fileParam.Value = path;
            }
            return(fileParam);
        }