예제 #1
0
        public void Build()
        {
            lock (this)
            {
                if (currentScript == null)
                {
                    loadBtn.PerformClick();
                }

                if (currentScript == null)
                {
                    MessageBox.Show("Please load some script file first.", "CS-Script");
                }
                else
                {
                    OutputPanel outputPanel = Plugin.ShowOutputPanel();

                    outputPanel.ShowBuildOutput();
                    outputPanel.BuildOutput.Clear();
                    outputPanel.BuildOutput.WriteLine("------ Build started: Script: " + Path.GetFileNameWithoutExtension(currentScript) + " ------");

                    try
                    {
                        if (!CurrentDocumentBelongsToProject())
                        {
                            EditItem(currentScript);
                        }

                        Npp.SaveDocuments(GetProjectDocuments());

                        CSScriptHelper.Build(currentScript);

                        outputPanel.BuildOutput.WriteLine(null)
                        .WriteLine("========== Build: succeeded ==========")
                        .SetCaretAtStart();
                    }
                    catch (Exception ex)
                    {
                        outputPanel.ShowBuildOutput()
                        .WriteLine(null)
                        .WriteLine(ex.Message)
                        .WriteLine("========== Build: Failed ==========")
                        .SetCaretAtStart();
                    }
                }
            }
        }
예제 #2
0
        void deployBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (currentScript == null)
                {
                    LoadCurrentDoc();
                }

                if (currentScript != null) //may not necessarily be loaded successfully

                {
                    using (var dialog = new DeploymentInput())
                        if (DialogResult.OK == dialog.ShowDialog())
                        {
                            EditItem(currentScript);

                            Npp.SaveDocuments(GetProjectDocuments());

                            string selectedTargetVersion = dialog.SelectedVersion.Version;
                            string path = CSScriptHelper.Isolate(currentScript, dialog.AsScript, selectedTargetVersion, dialog.AsWindowApp);

                            if (path != null)
                            {
                                string pluginClrVersion = "v" + Environment.Version.ToString();

                                if (dialog.AsScript && !pluginClrVersion.StartsWith(selectedTargetVersion)) //selectedTargetVersion may not include the build number
                                {
                                    MessageBox.Show("Distribution package targets CLR version, which is different from the default version.\r\nPlease verify that the script is compatible with the selected CLR version.", "CS-Script");
                                }

                                Process.Start("explorer.exe", path);
                            }
                        }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "CS-Script");
            }
        }
예제 #3
0
        void Run(bool asExternal)
        {
            if (currentScript == null)
            {
                loadBtn.PerformClick();
            }

            if (currentScript == null)
            {
                MessageBox.Show("Please load some script file first.", "CS-Script");
            }
            else
            {
                try
                {
                    if (!CurrentDocumentBelongsToProject())
                    {
                        EditItem(currentScript);
                    }

                    Npp.SaveDocuments(GetProjectDocuments());


                    if (asExternal)
                    {
                        try
                        {
                            CSScriptHelper.ExecuteAsynch(currentScript);
                        }
                        catch (Exception e)
                        {
                            Plugin.ShowOutputPanel()
                            .ShowBuildOutput()
                            .WriteLine(e.Message)
                            .SetCaretAtStart();
                        }
                    }
                    else
                    {
                        OutputPanel outputPanel = Plugin.ShowOutputPanel();

                        outputPanel.AttachDebuger();
                        outputPanel.ClearAllDefaultOutputs();

                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                outputPanel.ShowDebugOutput();
                                if (Config.Instance.InterceptConsole)
                                {
                                    CSScriptHelper.Execute(currentScript, OnRunStart, OnConsoleOutChar);
                                }
                                else
                                {
                                    CSScriptHelper.Execute(currentScript, OnRunStart);
                                }
                            }
                            catch (Exception e)
                            {
                                outputPanel.ShowBuildOutput()
                                .WriteLine(e.Message)
                                .SetCaretAtStart();
                            }
                            finally
                            {
                                this.InUiThread(() =>
                                {
                                    Plugin.RunningScript = null;
                                    RefreshControls();
                                    Npp.GrabFocus();
                                });
                            }
                        });
                    }
                }
                catch (Exception ex)
                {
                    Plugin.ShowOutputPanel()
                    .ShowBuildOutput()
                    .WriteLine(ex.Message)
                    .SetCaretAtStart();
                }
            }
        }