Exemplo n.º 1
0
        private void lvErrors_DoubleClick(object sender, System.EventArgs e)
        {
            if (this.lvErrors.SelectedItems.Count == 0)
            {
                return;
            }

            if (this.lvErrors.SelectedItems[0].Tag == null)
            {
                return;
            }

            CProject.File file = (CProject.File) this.lvErrors.SelectedItems[0].Tag;

            string[] linesplit = this.lvErrors.SelectedItems[0].SubItems[2].Text.Replace(" ", "").Split('/');
            int      line_num  = Convert.ToInt32(linesplit[0]);

            g.Main.OpenFile(file, line_num - 1, false);

            // Set focus on the editor
            g.Main.GetActiveEditor().txtEditor.Select();
            g.Main.GetActiveEditor().txtEditor.Focus();

            // Select the column in question
            int fileoffset = g.Main.GetActiveEditor().txtEditor.Document.PositionToOffset(new ActiproSoftware.SyntaxEditor.Position(line_num - 1, Convert.ToInt32(linesplit[1]) - 1));

            g.Main.GetActiveEditor().txtEditor.SelectedView.Selection.SelectRange(fileoffset, 0);
        }
Exemplo n.º 2
0
        public static void SetFile(CWFile File)
        {
            AssertOpenProject("SetFile");
            AssertValidFile(File, "SetFile");

            CProject.File actfile = GetFile(File);

            actfile.FileIcon        = File.file_icon;
            actfile.isDirty         = File.is_dirty;
            actfile.isForcedReload  = File.is_forced_reload;
            actfile.isForeign       = File.is_foreign;
            actfile.isPendingReload = File.is_pending_reload;
            actfile.RelativePath    = File.relative_path;
            actfile.SimpleName      = File.simple_name;

            if (File.parent_dir != null)
            {
                AssertValidDirectory(File.parent_dir, "SetFile__SetDirectoryOnFile");
                actfile.ParentDir = GetDir(File.parent_dir);
            }
            else
            {
                actfile.ParentDir = null;
            }
        }
Exemplo n.º 3
0
        public Hashtable MakeObjectListing(string code, CProject.File filedecl, Hashtable ht)
        {
            // Construct listing of objects and their functions
            Regex rx = new Regex(@"(^(\s*///\s*(.*?)\n){0,5})?^\s*\bfunction\b\s*(\b[A-Z_][A-Z0-9_]*\b)::(\b[A-Z][A-Z0-9]*\b)\s*\((.*?)\)", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            //Hashtable ht = new Hashtable();

            foreach (Match mt in rx.Matches(code))
            {
                CProject.TokenObject tokobj;
                if (ht.ContainsKey(mt.Groups[4].Value.ToLower()))
                {
                    tokobj = (CProject.TokenObject)ht[mt.Groups[4].Value.ToLower()];
                }
                else
                {
                    tokobj            = new CProject.TokenObject();
                    tokobj.ObjectName = mt.Groups[4].Value;
                    tokobj.isInternal = false;
                    ht.Add(mt.Groups[4].Value.ToLower(), tokobj);
                }

                if (!tokobj.ObjectFunctions.ContainsKey(mt.Groups[5].Value.ToLower()))
                {
                    // Create a function definition if none exists already
                    CProject.TokenObject.ObjectDescr objdescr = new CProject.TokenObject.ObjectDescr();
                    objdescr.FuncName   = mt.Groups[5].Value;
                    objdescr.FuncOffset = mt.Groups[5].Index;
                    objdescr.FuncFile   = filedecl;

                    // Set description
                    string descr = mt.Groups[1].Value.Replace("///", "").Replace("\t", "").Replace("\r", "").TrimStart('\n');
                    foreach (string line in descr.Split('\n'))
                    {
                        if (line.Trim() == "")
                        {
                            continue;
                        }

                        objdescr.FuncDescr += line.Trim() + "<br />";
                    }

                    // Grab all the function parameters by splitting it at the comma
                    // and stick them in the appropriate array
                    if (mt.Groups[4].Value != "")
                    {
                        objdescr.FuncParams = mt.Groups[6].Value.Replace(" ", "").Split(',');
                    }
                    else
                    {
                        objdescr.FuncParams = null;
                    }

                    // Add it to the hashtable
                    tokobj.ObjectFunctions.Add(mt.Groups[5].Value.ToLower(), objdescr);
                }
            }

            return(MakeObjectDeclarations(code, filedecl, ht));;
        }
Exemplo n.º 4
0
        public static int[] DebugGetBreakpoints(CWFile File)
        {
            AssertOpenProject("DebugGetBreakpoints");
            AssertValidFile(File, "DebugGetBreakpoints");

            CProject.File file = GetFile(File);

            // Go through the breakpoints
            ArrayList breakpoints = new ArrayList();

            foreach (CProject.Breakpoint bp in g.Project.ProjectBreaks)
            {
                if (bp.file == file)
                {
                    breakpoints.Add(bp.LineNumber);
                }
            }

            // Turn it into an array
            int[] output = new int[breakpoints.Count];

            for (int i = 0; i < breakpoints.Count; i++)
            {
                output[i] = (int)breakpoints[i];
            }

            return(output);
        }
Exemplo n.º 5
0
        public static void DebugDelBreakpoint(CWFile File, int line)
        {
            AssertOpenProject("DebugDelBreakpoint");
            AssertValidFile(File, "DebugDelBreakpoint");

            CProject.File file = GetFile(File);

            // Find the breakpoint
            foreach (CProject.Breakpoint bp in g.Project.ProjectBreaks)
            {
                if (bp.file == file && bp.LineNumber == line)
                {
                    g.Project.ProjectBreaks.Remove(bp);
                    break;
                }
            }

            // Update the breakpoints if the file is open
            UCEditor editor = GetEditor(file);

            if (editor != null)
            {
                editor.BreakpointRender();
            }
        }
Exemplo n.º 6
0
        public static void AddIndicatorIcon(CWFile File, string IndicatorName, int line, Image marginIcon)
        {
            if (g.Project == null)
            {
                throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan");
            }

            CProject.File file = GetFile(File);

            if (file == null)
            {
                throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan");
            }

            // Check to see if the file is open
            UCEditor editor = GetEditor(file);

            if (editor == null)
            {
                throw new PluginException("File specified is not open", "AddIndicatorSpan");
            }

            // Add the indicator
            editor.txtEditor.Document.Indicators.Add(
                new CIndicators.CustomIconIndicator(IndicatorName, marginIcon), line);
        }
Exemplo n.º 7
0
        public static void AddIndicatorSpan(CWFile File, string IndicatorName, int startoffset, int endoffset, Image marginIcon, Color lineForeColor, Color lineBackColor, bool Bold, bool Italic, bool Underline)
        {
            if (g.Project == null)
            {
                throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan");
            }

            CProject.File file = GetFile(File);

            if (file == null)
            {
                throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan");
            }

            // Check to see if the file is open
            UCEditor editor = GetEditor(file);

            if (editor == null)
            {
                throw new PluginException("File specified is not open", "AddIndicatorSpan");
            }

            // Finally, add the indicator
            editor.txtEditor.Document.Indicators.Add(
                new CIndicators.CustomIndicator(IndicatorName, marginIcon, lineForeColor, lineBackColor, Bold, Italic, Underline),
                startoffset, (endoffset - startoffset));
        }
Exemplo n.º 8
0
            public void RemoveFileRefs(CProject.File file)
            {
                Monitor.Enter(ObjectFunctions);
                Monitor.Enter(ObjectProperties);

                Hashtable _temp_ht = (Hashtable)ObjectFunctions.Clone();

                IDictionaryEnumerator enumer = _temp_ht.GetEnumerator();

                while (enumer.MoveNext())
                {
                    if (((ObjectDescr)enumer.Value).FuncFile.Equals(file))
                    {
                        ObjectFunctions.Remove(enumer.Key);
                    }
                }


                if ((ObjectFileDecl != null) && ObjectFileDecl.Equals(file))
                {
                    ObjectFileDecl   = null;
                    ObjectDeclOffset = -1;
                }

                Monitor.Exit(ObjectFunctions);
                Monitor.Exit(ObjectProperties);
            }
Exemplo n.º 9
0
 public Breakpoint(CProject.File file, int LineNumber, int PassCount)
 {
     this.file       = file;
     this.LineNumber = LineNumber;
     this.Enabled    = true;
     this.PassCount  = PassCount;
 }
Exemplo n.º 10
0
 public Breakpoint(CProject.File file, int LineNumber, int PassCount, string Conditional)
 {
     this.file        = file;
     this.LineNumber  = LineNumber;
     this.Enabled     = true;
     this.PassCount   = PassCount;
     this.Conditional = Conditional;
 }
Exemplo n.º 11
0
        public void RemoveObjectsInFile(CProject.File file)
        {
            g.LogDebug("CPROJECT::RemoveObjectsInFile: Enter - " + file.RelativePath);

            foreach (CProject.TokenObject tokobj in this.TokenObjList.Values)
            {
                tokobj.RemoveFileRefs(file);
            }
        }
Exemplo n.º 12
0
        public Hashtable MakeObjectListingFromFile(string filename, CProject.File file, Hashtable ht)
        {
            try {
                StreamReader reader        = new StreamReader(filename);
                string       file_contents = reader.ReadToEnd();

                reader.Close();

                return(this.MakeObjectListing(file_contents, file, ht));
            } catch /*(Exception exc)*/ { /*System.Windows.Forms.MessageBox.Show(exc.Message);*/ return(ht); };
        }
Exemplo n.º 13
0
        public int FindToken(string word, string prevtok, out CProject.File out_file)
        {
            out_file = null;

            // Find it in the file listing first
            foreach (CProject.File file in g.Project.FileList)
            {
                if (file.TokenList.ContainsKey(word.ToLower()))
                {
                    // Got it!
                    out_file = file;
                    return(((CProject.TokenKey)file.TokenList[word.ToLower()]).LineNumber);
                }
            }

            // Now search active objects, seeing if this is an object
            // we can jump to.
            if (g.Project.TokenObjList.ContainsKey(word.ToLower()))
            {
                // Yes, it appears this is a valid object...
                CProject.TokenObject tokobj = (CProject.TokenObject)g.Project.TokenObjList[word.ToLower()];
                if (tokobj.ObjectFileDecl != null)
                {
                    out_file = tokobj.ObjectFileDecl;
                    return(tokobj.ObjectDeclOffset);
                }
                else
                {
                    return(-1);
                }
            }


            // Check to see if the *previous* token wasn't an object...
            // ... which would mean that the *current* token is a function
            // definition inside an object
            if (g.Project.TokenObjList.ContainsKey(prevtok.ToLower()))
            {
                // Yes, it appears this is so... see if the thingy is a valid function
                CProject.TokenObject tokobj = (CProject.TokenObject)g.Project.TokenObjList[prevtok.ToLower()];

                if (!tokobj.ObjectFunctions.ContainsKey(word.ToLower()))
                {
                    return(-1);
                }

                // Retrieve the function file information
                CProject.TokenObject.ObjectDescr func = (CProject.TokenObject.ObjectDescr)tokobj.ObjectFunctions[word.ToLower()];
                out_file = func.FuncFile;
                return(func.FuncOffset);
            }

            return(-1);
        }
Exemplo n.º 14
0
        public static CWObjects IntellicodeObjectsInFile(CWFile File)
        {
            AssertOpenProject("IntellicodeObjectsInProject");
            AssertValidFile(File, "IntellicodeObjectsInProject");

            CProject.File file = GetFile(File);

            CWObjects objout = new CWObjects(File, new ArrayList());

            foreach (CProject.TokenKey tok in file.TokenList.Values)
            {
                objout.objects.Add(new CWObjects.CWObject(
                                       CWObjectType.DefinedFunction,
                                       "",
                                       tok.FuncName,
                                       String.Join(", ", tok.FuncParams),
                                       tok.FuncDescr,
                                       tok.LineNumber));
            }

            foreach (CProject.TokenObject tokobj in g.Project.TokenObjList.Values)
            {
                if (tokobj.ObjectFileDecl != file)
                {
                    continue;
                }

                objout.objects.Add(new CWObjects.CWObject(
                                       CWObjectType.DefinedClass,
                                       tokobj.ObjectType,
                                       tokobj.ObjectName,
                                       "",
                                       "",
                                       tokobj.ObjectDeclOffset));

                foreach (CProject.TokenObject.ObjectDescr objdescr in tokobj.ObjectFunctions)
                {
                    if (objdescr.FuncFile != file)
                    {
                        continue;
                    }

                    objout.objects.Add(new CWObjects.CWObject(
                                           CWObjectType.DefinedClassFunction,
                                           tokobj.ObjectName,
                                           objdescr.FuncName,
                                           String.Join(", ", objdescr.FuncParams),
                                           objdescr.FuncDescr,
                                           objdescr.FuncOffset));
                }
            }

            return(objout);
        }
Exemplo n.º 15
0
 public void RemoveAtLine(CProject.File file, int LineNum)
 {
     foreach (Breakpoint brk in this.List)
     {
         if (brk.file == file && brk.LineNumber == LineNum)
         {
             Remove(brk);
             return;
         }
     }
 }
Exemplo n.º 16
0
        private void lvFind_DoubleClick(object sender, System.EventArgs e)
        {
            if (this.lvFind.SelectedItems.Count == 0)
            {
                return;
            }

            CProject.File file = (CProject.File) this.lvFind.SelectedItems[0].Tag;
            int           line = Convert.ToInt32(this.lvFind.SelectedItems[0].SubItems[1].Text);

            g.Main.OpenFile(file, line, false);
        }
Exemplo n.º 17
0
            public Breakpoint this[CProject.File file, int LineNum] {
                get {
                    foreach (Breakpoint brk in this.List)
                    {
                        if (brk.file == file && brk.LineNumber == LineNum)
                        {
                            return(brk);
                        }
                    }

                    return(null);
                }
            }
Exemplo n.º 18
0
        private static void AssertOpenFile(CWFile file, string caller)
        {
            CProject.File actfile = GetFile(file);

            if (actfile == null)
            {
                throw new PluginException("Invalid file handle.", caller);
            }

            if (GetEditor(actfile) == null)
            {
                throw new PluginException("File not open", caller);
            }
        }
Exemplo n.º 19
0
        public static void RemoveIndicator(CWFile File, string IndicatorName, int line)
        {
            if (g.Project == null)
            {
                throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan");
            }

            CProject.File file = GetFile(File);

            if (file == null)
            {
                throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan");
            }

            // Check to see if the file is open
            UCEditor editor = GetEditor(file);

            if (editor == null)
            {
                throw new PluginException("File specified is not open", "AddIndicatorSpan");
            }

            // Remove the indicator
            ArrayList toremove = new ArrayList();

            foreach (ActiproSoftware.SyntaxEditor.Indicator ind in editor.txtEditor.Document.Indicators)
            {
                if (ind is CIndicators.CustomIconIndicator)
                {
                    if (line == -1)
                    {
                        toremove.Add(ind);
                    }
                    else if ((ind as CIndicators.CustomIconIndicator).LineIndex == line)
                    {
                        toremove.Add(ind);
                    }
                }
                else if (ind is CIndicators.CustomIndicator)
                {
                    toremove.Add(ind);
                }
            }

            foreach (ActiproSoftware.SyntaxEditor.Indicator ind in toremove)
            {
                editor.txtEditor.Document.Indicators.Remove(ind);
            }
        }
Exemplo n.º 20
0
        private Hashtable MakeObjectDeclarations(string code, CProject.File file, Hashtable curlist)
        {
            // Private function for enumerating all object declarations
            // which are declared like "new TypeOfObject(ObjectName) { }" ...
            // Skip objects that don't have a name.

            /*Regex rx = new Regex(@"^\s*\bnew\b\s*(\b[A-Z][A-Z0-9]*\b)\s*\((\b[A-Z_][A-Z0-9_]*\b)\)(\s*\n)?" +
             *      @"(" +
             *      @"(?<inner>" +
             *      @"(?>" +
             *      @"\{(?<LEVEL>)" +
             *      @"|" +
             *      @"\};(?<-LEVEL>)" +
             *      @"|" +
             *      @"(?!\{|\};)." +
             *      @")*" +
             *      @"(?(LEVEL)(?!))" +
             *      @"))?"
             *      , RegexOptions.IgnoreCase | RegexOptions.Multiline);*/

            Regex rx = new Regex(@"^\s*\bnew\b\s*(\b[A-Z][A-Z0-9]*\b)\s*\((\b[A-Z_][A-Z0-9_]*\b)\)(\s*\n)?", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            foreach (Match mt in rx.Matches(code))
            {
                // Enumerate each match and try to compare it to an active object

                //System.Windows.Forms.MessageBox.Show(mt.Groups["inner"].Value.ToLower());

                CProject.TokenObject tokobj;
                if (curlist.ContainsKey(mt.Groups[2].Value.ToLower()))
                {
                    tokobj = (CProject.TokenObject)curlist[mt.Groups[2].Value.ToLower()];
                }
                else
                {
                    tokobj            = new CProject.TokenObject();
                    tokobj.ObjectName = mt.Groups[2].Value;
                    tokobj.isInternal = false;
                    curlist.Add(mt.Groups[2].Value.ToLower(), tokobj);
                }

                tokobj.ObjectType       = mt.Groups[1].Value;
                tokobj.ObjectFileDecl   = file;
                tokobj.ObjectDeclOffset = mt.Groups[2].Index;
            }

            return(curlist);
        }
Exemplo n.º 21
0
        public static CWFile AddFile(string filepath, CWDirectory parent)
        {
            AssertOpenProject("AddFile");

            if (parent != null)
            {
                AssertValidDirectory(parent, "AddFile__CheckParent");
            }

            if (!File.Exists(filepath))
            {
                throw new PluginException(filepath + " does not exist.", "AddFile");
            }

            CProject.File newfile = g.Main.AddExistingFile(filepath, ((parent == null) ? null : GetDir(parent)));
            return(newfile.ToCWFile());
        }
Exemplo n.º 22
0
        private static UCEditor GetEditor(CProject.File File)
        {
            if (File == null)
            {
                return(null);
            }

            foreach (PrimaryTab <UCEditor> editor in g.Editors)
            {
                if (editor.Control.g_curFile == File)
                {
                    return(editor.Control);
                }
            }

            return(null);
        }
Exemplo n.º 23
0
        public static void DebugAddBreakpoint(CWFile File, int line, int pass_count, bool clear_after_hit, string conditional)
        {
            AssertOpenProject("DebugAddBreakpoint");
            AssertValidFile(File, "DebugAddBreakpoint");

            CProject.File file = GetFile(File);

            // Create a new instance of the breakpoint
            CProject.Breakpoint bp = new CProject.Breakpoint(file, line, pass_count, ((conditional == "") ? "true" : conditional));

            if (clear_after_hit == true)
            {
                throw new PluginException("NotImplemented: clear_after_hit cannot equal true.  The enhanced telnetdebugger does not support this attribute yet.", "DebugAddBreakpoint");
            }

            // Add the breakpoint
            g.Project.ProjectBreaks.Add(bp);
        }
Exemplo n.º 24
0
        public frmProperties(CProject proj, CProject.File file, int proptype)
        {
            //
            // Required for Windows Form Designer support
            //

            if (proptype == 0)
                this.file = file;
            else
                this.proj = proj;

            this.proptype = proptype;

            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
Exemplo n.º 25
0
        public frmProperties(CProject proj, CProject.File file, int proptype)
        {
            //
            // Required for Windows Form Designer support
            //


            if (proptype == 0)
            {
                this.file = file;
            }
            else
            {
                this.proj = proj;
            }

            this.proptype = proptype;

            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
Exemplo n.º 26
0
 public bool HasBreakpointAt(CProject.File file, int LineNum)
 {
     return(HasIdentical(new CProject.Breakpoint(file, LineNum)));
 }
Exemplo n.º 27
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            // If we have a filename and a template selected, we're gold
            if (txtSaveTo.Text.Trim() == "") {
                MessageBox.Show("Please select a filename to save your file as.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            } else if (lvTemplates.SelectedItems.Count == 0) {
                MessageBox.Show("Please select a template to create the new file from", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Construct a relative path
            string fileRelativePath = CProject.PathGetRelative(txtSaveTo.Text, g.Project.ProjectPath);

            if (fileRelativePath == "")
                fileRelativePath = txtSaveTo.Text;

            // Check if the file already exists in the project
            if (g.Project.FileList.ContainsFile(fileRelativePath)) {
                // If it's open, close it
                g.Main.CloseFile(g.Project.FileList.GetFile(fileRelativePath), false, false);

                // Remove it from the file list
                g.Project.FileList.Remove(g.Project.FileList.GetFile(fileRelativePath));
            }

            // Open the template file
            StreamReader templateFile = new StreamReader(lvTemplates.SelectedItems[0].Tag.ToString().Split('|')[1]);

            // Chop off the first line by doing some backasswards string manipulation
            string template = templateFile.ReadToEnd().Split(new string[] { "\r\n" }, 2, StringSplitOptions.None)[1];
            templateFile.Close();

            // Write the template
            template = template.Replace("{{PROJECT_NAME}}", g.Project.ProjectName);
            template = template.Replace("{{FILE_RELATIVE_PATH}}", fileRelativePath);
            template = template.Replace("{{FILE_ABSOLUTE_PATH}}", txtSaveTo.Text);
            template = template.Replace("{{SYSUSER}}", Environment.UserName);
            template = template.Replace("{{SYSMACHINE}}", Environment.MachineName);
            template = template.Replace("{{CW_VERSION}}", Application.ProductVersion);
            template = template.Replace("{{DATE}}", DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString());

            // Create the destination file and write the template
            StreamWriter destinationFile = new StreamWriter(txtSaveTo.Text);
            destinationFile.Write(template);
            destinationFile.Close();

            // Create a file
            CProject.File newFile = new CProject.File(Path.GetFileName(txtSaveTo.Text), fileRelativePath, false, false, _parentDir);
            newFile.isDirty = true;

            // Add to the file list
            g.Project.FileList.Add(newFile);

            // Make the project dirty
            frmMain.stc_bIsProjectDirty = true;

            // Open the file and re-init the left bar
            g.Main.OpenFile(newFile, 0, false);
            g.Main.InitProject();

            this.Close();
        }
Exemplo n.º 28
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            // If we have a filename and a template selected, we're gold
            if (txtSaveTo.Text.Trim() == "")
            {
                MessageBox.Show("Please select a filename to save your file as.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else if (lvTemplates.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a template to create the new file from", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Construct a relative path
            string fileRelativePath = CProject.PathGetRelative(txtSaveTo.Text, g.Project.ProjectPath);

            if (fileRelativePath == "")
            {
                fileRelativePath = txtSaveTo.Text;
            }

            // Check if the file already exists in the project
            if (g.Project.FileList.ContainsFile(fileRelativePath))
            {
                // If it's open, close it
                g.Main.CloseFile(g.Project.FileList.GetFile(fileRelativePath), false, false);

                // Remove it from the file list
                g.Project.FileList.Remove(g.Project.FileList.GetFile(fileRelativePath));
            }

            // Open the template file
            StreamReader templateFile = new StreamReader(lvTemplates.SelectedItems[0].Tag.ToString().Split('|')[1]);

            // Chop off the first line by doing some backasswards string manipulation
            string template = templateFile.ReadToEnd().Split(new string[] { "\r\n" }, 2, StringSplitOptions.None)[1];

            templateFile.Close();

            // Write the template
            template = template.Replace("{{PROJECT_NAME}}", g.Project.ProjectName);
            template = template.Replace("{{FILE_RELATIVE_PATH}}", fileRelativePath);
            template = template.Replace("{{FILE_ABSOLUTE_PATH}}", txtSaveTo.Text);
            template = template.Replace("{{SYSUSER}}", Environment.UserName);
            template = template.Replace("{{SYSMACHINE}}", Environment.MachineName);
            template = template.Replace("{{CW_VERSION}}", Application.ProductVersion);
            template = template.Replace("{{DATE}}", DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString());

            // Create the destination file and write the template
            StreamWriter destinationFile = new StreamWriter(txtSaveTo.Text);

            destinationFile.Write(template);
            destinationFile.Close();

            // Create a file
            CProject.File newFile = new CProject.File(Path.GetFileName(txtSaveTo.Text), fileRelativePath, false, false, _parentDir);
            newFile.isDirty = true;

            // Add to the file list
            g.Project.FileList.Add(newFile);

            // Make the project dirty
            frmMain.stc_bIsProjectDirty = true;

            // Open the file and re-init the left bar
            g.Main.OpenFile(newFile, 0, false);
            g.Main.InitProject();

            this.Close();
        }
Exemplo n.º 29
0
            public void RemoveFileRefs(CProject.File file)
            {
                Monitor.Enter(ObjectFunctions);
                Monitor.Enter(ObjectProperties);

                Hashtable _temp_ht = (Hashtable)ObjectFunctions.Clone();

                IDictionaryEnumerator enumer = _temp_ht.GetEnumerator();

                while(enumer.MoveNext()) {
                    if (((ObjectDescr)enumer.Value).FuncFile.Equals(file))
                        ObjectFunctions.Remove(enumer.Key);
                }

                if ((ObjectFileDecl != null) && ObjectFileDecl.Equals(file)) {
                    ObjectFileDecl = null;
                    ObjectDeclOffset = -1;
                }

                Monitor.Exit(ObjectFunctions);
                Monitor.Exit(ObjectProperties);
            }
Exemplo n.º 30
0
        public UCEditor(CProject.File file, bool isSaved)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.g_curFile = file;
            this.isSaved = isSaved;

            if (!file.isText) {
                this._DropDownMake = new _dDropdownMake(DropdownMake);
                g.Config.LoadColorData(txtEditor);
            } else {
                // Disable completion for text files
                bDisableAllCompletion = true;
                bDisableAdvancedCompletion = true;
                cboCurFileFuncs.Visible = false;
            }

            // If we're a foreign file, disable "advanced" completion,
            // (so basically, anything not engine-function)
            if (file.isForeign) {
                bDisableAdvancedCompletion = true;
                cboCurFileFuncs.Visible = false;
            }

            //this.Owner = g.Main;

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
Exemplo n.º 31
0
        public CProject.File PromptForSave()
        {
            SaveFileDialog save = new SaveFileDialog();

            save.Title = "Save File As";
            save.OverwritePrompt = true;
            save.InitialDirectory = g.Project.ProjectPath;
            save.ValidateNames = true;
            save.CheckPathExists = true;
            save.Filter = "TorqueScript Files (*.cs)|*.cs|User Interface Scripts (*.gui)|*.gui|netMercs TorqueScript Files (*.ns)|*.ns|All Files (*.*)|*.*";

            DialogResult result = save.ShowDialog(this);

            if (result == DialogResult.Cancel) {
                return null;
            }

            string full_file = save.FileName;

            try {
                txtEditor.Document.SaveFile(full_file, LineEndStyle.CarriageReturnNewline);
            } catch (Exception exc) {
                MessageBox.Show("An error occurred while attempting to save your file:\n\n" + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return null;
            }

            txtEditor.Document.Modified = false;
            getrelpath:

            string relative_path = CProject.PathGetRelative(full_file, g.Project.ProjectPath);
            string filename = Path.GetFileName(full_file);

            if (relative_path == "") {
                result = MessageBox.Show(this, "Fatal: Failed to retrieve relative path to saved file.", "Critical Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);

                if (result == DialogResult.Abort)
                    return null;
                else if (result == DialogResult.Retry)
                    goto getrelpath;
                else if (result == DialogResult.Ignore)
                    MessageBox.Show(this, "Ignoring error.  Please note, project definitions may become corrupt.", "Ignore", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            CProject.File file = new CProject.File(filename, relative_path, null);
            g.Project.FileList.Add(file);
            g.Main.InitProject();

            this.g_curFile = file;
            this.Text = filename;
            this.isDirty = false;
            this.isSaved = true;
            this._ParentTab.Title = filename;
            this._ParentTab.ToolTip = relative_path;

            g.Main.InitExplorer();

            return file;
        }
Exemplo n.º 32
0
 public Breakpoint(CProject.File file, int LineNumber)
 {
     this.file       = file;
     this.LineNumber = LineNumber;
     this.Enabled    = true;
 }