private void listErrors_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (listErrors.SelectedIndex >= 0)
     {
         CompilerErrorWrapper errw = listErrors.SelectedItem as CompilerErrorWrapper;
         if (errw != null)
         {
             txtCode.Highlight(errw.CompilerError.Line - lineOffset, errw.CompilerError.Column);
         }
         toolTips.SetToolTip(listErrors, listErrors.SelectedItem.ToString());
     }
 }
        private bool Build(bool toDll)
        {
            bool retVal = false;

            listErrors.Items.Clear();
            try
            {
                string prepend2 = " : base(\"" + txtScriptName.Text + "\", null) {}";
                if (toDll)
                {
                    string oldargs = param.CompilerOptions;

                    Uri    location = new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase);
                    string fullPath = Uri.UnescapeDataString(System.IO.Path.GetDirectoryName(location.AbsolutePath));

                    fullPath = Path.Combine(fullPath, "Effects");
                    fullPath = Path.Combine(fullPath, txtScriptName.Text);
                    fullPath = Path.ChangeExtension(fullPath, ".dll");

                    param.CompilerOptions = param.CompilerOptions + " /debug- /target:library /out:\"" + fullPath + "\"";
                    cscp.CompileAssemblyFromSource(param, prepend + prepend2 + txtCode.Text + append);

                    param.CompilerOptions = oldargs;
                }
                else
                {
                    userScriptObject = null;
                    result           = cscp.CompileAssemblyFromSource(param, prepend + prepend2 + txtCode.Text + append);
                }

                if (result.Errors.HasErrors)
                {
                    foreach (CompilerError err in result.Errors)
                    {
                        CompilerErrorWrapper cew = new CompilerErrorWrapper();
                        cew.CompilerError = err;
                        listErrors.Items.Add(cew);
                    }
                }
                else if (!toDll)
                {
                    userAssembly = result.CompiledAssembly;

                    foreach (Type type in userAssembly.GetTypes())
                    {
                        if (type.IsSubclassOf(typeof(Effect)) && !type.IsAbstract)
                        {
                            userScriptObject = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
                        }
                    }
                    retVal = (userScriptObject != null);
                }
                else
                {
                    retVal = true;
                }
            }
            catch (Exception exc)
            {
                userScriptObject = null;
                listErrors.Items.Add("Internal Error: " + exc.ToString());
            }
            if (!toDll)
            {
                FinishTokenUpdate();
            }
            return(retVal);
        }
        private bool Build(bool toDll)
        {
            bool retVal = false;
            listErrors.Items.Clear();
            try
            {
                string prepend2 = " : base(\"" + txtScriptName.Text + "\", null) {}";
                if (toDll)
                {
                    string oldargs = param.CompilerOptions;

                    Uri location = new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase);
                    string fullPath = Uri.UnescapeDataString(System.IO.Path.GetDirectoryName(location.AbsolutePath));

                    fullPath = Path.Combine(fullPath, "Effects");
                    fullPath = Path.Combine(fullPath, txtScriptName.Text);
                    fullPath = Path.ChangeExtension(fullPath, ".dll");

                    param.CompilerOptions = param.CompilerOptions + " /debug- /target:library /out:\"" + fullPath + "\"";
                    cscp.CompileAssemblyFromSource(param, prepend + prepend2 + txtCode.Text + append);

                    param.CompilerOptions = oldargs;

                }
                else
                {
                    userScriptObject = null;
                    result = cscp.CompileAssemblyFromSource(param, prepend + prepend2 + txtCode.Text + append);
                }

                if (result.Errors.HasErrors)
                {
                    foreach (CompilerError err in result.Errors)
                    {
                        CompilerErrorWrapper cew = new CompilerErrorWrapper();
                        cew.CompilerError = err;
                        listErrors.Items.Add(cew);
                    }
                }
                else if (!toDll)
                {
                    userAssembly = result.CompiledAssembly;

                    foreach (Type type in userAssembly.GetTypes())
                    {
                        if (type.IsSubclassOf(typeof(Effect)) && !type.IsAbstract)
                        {
                            userScriptObject = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
                        }
                    }
                    retVal = (userScriptObject != null);
                }
                else
                {
                    retVal = true;
                }
            }
            catch (Exception exc)
            {
                userScriptObject = null;
                listErrors.Items.Add("Internal Error: " + exc.ToString());
            }
            if (!toDll)
            {
                FinishTokenUpdate();
            }
            return retVal;
        }