Пример #1
0
            readonly int m_PrefixLen           = 2 + 7 + 1;     // length of prefix in characters

            // Called once per sequence point to write Source lines.
            public void WriteSource()
            {
                string           path = m_seqPaths[m_index];;
                SourceViewerForm file = GetSourceFile(m_parent, path);

                // Now add text for this sequence point
                if (file != null)
                {
                    int lineStart = m_seqStartLines[m_index];
                    int lineEnd   = m_seqEndLines[m_index];

                    for (int j = lineStart; j <= lineEnd; j++)
                    {
                        // Need to count how many source lines we've injected so that we can adjust
                        // the il2row mapping accordingly.

                        if (j == 0xFeeFee)
                        {
                            m_writer.WriteLine("// !hidden!");
                            //m_writer.FormatLastRow(Color.DarkGreen);
                        }
                        else if (j > file.Count)
                        {
                            m_writer.WriteLine(String.Format(CultureInfo.InvariantCulture, m_lineFormatPrefix, j, "<out of range>"));
                            //m_writer.FormatLastRow(Color.DarkGreen);
                        }
                        else
                        {
                            // Write out: // line# :  <contents>
                            string t = String.Format(CultureInfo.InvariantCulture, m_lineFormatPrefix, j, file.GetLine(j));
                            m_writer.WriteLine(t);

                            // Handle format across multiple lines.
                            int columnStart = m_seqStartColumns[m_index] + m_PrefixLen;
                            int columnEnd   = m_seqEndColumns[m_index] + m_PrefixLen;

                            if (j > lineStart)
                            {
                                columnStart = m_PrefixLen + 1;
                            }
                            if (j < lineEnd)
                            {
                                columnEnd = t.Length + 1;
                            }


                            //m_writer.FormatLastRow(columnStart, columnEnd, Color.Green);
                            m_writer.FormatLastRow(columnStart, columnEnd, m_writer.Fonts.Emphasis, Color.Red);
                        }
                        //m_writer.FormatLastRow(Color.Green);
                    }
                }
                else
                {
                    // Source file not found.
                    m_writer.WriteLine("// File '" + path + "' missing. Line " + m_seqStartLines[m_index] + " to line " + m_seqEndLines[m_index]);
                    m_writer.FormatLastRow(Color.DarkGreen);
                }
            }
Пример #2
0
        // There's one SourceViewerForm instance for each source-file
        // Get the instance for the new source file.
        // Called on UI thread.
        public static SourceViewerForm GetSourceFile(MainForm parent, string path)
        {
            path = CommandBase.Shell.FileLocator.GetFileLocation(path);
            SourceViewerForm source = (SourceViewerForm)m_sourceList[path];

            if (source == null)
            {
                source = SourceViewerForm.Build(parent, path);
                if (source != null)
                {
                    AddSourceViewer(source);
                }
            }
            m_ActiveSourceFile = source;
            return(source);
        }
 // There's one SourceViewerForm instance for each source-file
 // Get the instance for the new source file.
 public static SourceViewerForm GetSourceFile(Form parent,string path)
 {
     String s = String.Intern(path);
     SourceViewerForm source = (SourceViewerForm) m_sourceList[path];
     if(source==null)
     {
         string realLocation = CommandBase.Shell.FileLocator.GetFileLocation(path);
         if(realLocation==null)
             return null;
         
         string fileLoc = String.Intern(realLocation);
         if(fileLoc==null)
             return null;
         
         ArrayList lines = LoadLinesFromFile(fileLoc);
         if(lines!=null)
             source = new SourceViewerForm(parent,path,lines);
     }
     return source;
 }