Esempio n. 1
0
        private ArrayList SplitGiorniODT(string s)
        {
            string[]  Lines      = s.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
            string    tempGiorno = "";
            string    l;
            ArrayList SplitG = new ArrayList();

            foreach (string CurLine in Lines)
            {
                l = CurLine.Trim();
                if (èInizioGiornoSettimana(l) || èInizioDomenica(l))
                {
                    if (tempGiorno.Length > 0)
                    {
                        SplitG.Add(tempGiorno);
                    }
                    NumGiorni++;
                    tempGiorno = l + Environment.NewLine;
                }
                else
                {
                    tempGiorno += l + Environment.NewLine;
                }
            }
            SplitG.Add(tempGiorno);
            NumGiorni++;
            return(SplitG);
        }
Esempio n. 2
0
        private ArrayList SplitGiorni(Story s)
        {
            Story     tempGiorno = new Story();
            string    l;
            ArrayList SplitG = new ArrayList();

            foreach (StoryLine CurLine in StoryText.Lines)
            {
                l = CurLine.getText().Trim();
                if (èInizioGiornoSettimana(l) || èInizioDomenica(l))
                {
                    if (tempGiorno.Lines.Count > 0)
                    {
                        SplitG.Add(tempGiorno);
                    }
                    NumGiorni++;
                    tempGiorno = new Story();
                    tempGiorno.Lines.Add(CurLine);
                }
                else
                {
                    tempGiorno.Lines.Add(CurLine);
                }
            }
            SplitG.Add(tempGiorno);
            NumGiorni++;
            return(SplitG);
        }
Esempio n. 3
0
 static void Main(string[] args)
 {
     if (args.Length == 2)
     {
         string arg1 = args[0].ToLower();
         string arg2 = args[1].ToLower();
         using (WebClient W = new WebClient())
         {
             W.DownloadFile("ftp://ftp.univ.kiev.ua/pub/linux/centos/build/rpmcompare5.pl.txt", @"C:\Users\maksy\OneDrive\Документы\2.2 курс\Petrovich\rpmcompare5.pl.txt");
         }
         using (StreamReader sr = new StreamReader(File.OpenRead(@"C:\Users\maksy\OneDrive\Документы\2.2 курс\Petrovich\rpmcompare5.pl.txt")))
         {
             using (StreamWriter sw = new StreamWriter(File.Open(@"C:\Users\maksy\OneDrive\Документы\2.2 курс\Petrovich\RpmCompare-LIGHT.txt", FileMode.Create)))
             {
                 string   CurLine;
                 string[] split;
                 int      counter;
                 bool     cheker1;
                 bool     cheker2;
                 string   ls;
                 while (!sr.EndOfStream)
                 {
                     cheker1 = false;
                     cheker2 = false;
                     counter = 0;
                     CurLine = sr.ReadLine();
                     split   = CurLine.Split(new String[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries);
                     foreach (string s in split)
                     {
                         ls = s.ToLower();
                         if (ls.Contains(arg1) || (counter == 0 && ls.StartsWith("#")))
                         {
                             cheker1 = true;
                         }
                         else if (ls.Contains("="))
                         {
                             cheker2 = true;
                         }
                         counter++;
                     }
                     if (cheker1)
                     {
                     }
                     else if (cheker2)
                     {
                         sw.WriteLine(arg2);
                     }
                     else
                     {
                         sw.WriteLine(CurLine);
                     }
                 }
             }
         }
     }
     else
     {
         Console.WriteLine("SYNTAX: SysProga1.exe <Arg1> <Arg2>");
     }
 }
Esempio n. 4
0
        public static void LoadConfig()
        {
            if (File.Exists("IRCStatistician.conf"))
            {
                AppLog.WriteLine(1, "STATUS", "Loading configuration from IRCStatistician.conf");
                string       CurLine;
                StreamReader ConfigFile = new StreamReader("IRCStatistician.conf");
                while ((CurLine = ConfigFile.ReadLine()) != null)
                {
                    if (CurLine.Substring(0, 1) != "#")
                    {
                        string[] CurLineSplit = CurLine.Split(new char[1] {
                            '='
                        }, 2);
                        AppLog.WriteLine(4, "CONFIG", "Configuration Option: " + CurLineSplit[0] + " = " + CurLineSplit[1]);
                        switch (CurLineSplit[0].ToLower())
                        {
                        case "sqlserverhost":
                            m_SQLServerHost = CurLineSplit[1];
                            break;

                        case "sqlserverport":
                            m_SQLServerPort = Convert.ToInt32(CurLineSplit[1]);
                            break;

                        case "sqlusername":
                            m_SQLUsername = CurLineSplit[1];
                            break;

                        case "sqlpassword":
                            m_SQLPassword = CurLineSplit[1];
                            break;

                        case "sqldatabase":
                            m_SQLDatabase = CurLineSplit[1];
                            break;

                        case "sqltableprefix":
                            m_SQLTablePrefix = CurLineSplit[1];
                            break;

                        case "resolution":
                            m_Resolution = Convert.ToInt32(CurLineSplit[1]);
                            break;

                        default:
                            AppLog.WriteLine(1, "ERROR", "Unknown Configuration Option: " + CurLineSplit[0] + " = " + CurLineSplit[1]);
                            break;
                        }
                    }
                }
            }
            else
            {
                AppLog.WriteLine(1, "ERROR", "No Configuration File Found. Did you copy IRCStatistician.sample.conf and change the settings?");
            }
        }
 /// <summary>
 /// Saves the document to disk.
 /// </summary>
 /// <param name="Name">The path to a file that the document will be written to.</param>
 public void SaveToFile(string Name)
 {
     using (StreamWriter Writer = new StreamWriter(File.Open(Name, FileMode.Create, FileAccess.Write, FileShare.Read)))
     {
         foreach (DocumentLine CurLine in mLines)
         {
             Writer.Write(CurLine.ToString());
         }
     }
 }
Esempio n. 6
0
 private void OnPictureBoxMouseDown(object sender, MouseEventArgs e)
 {
     // Avoid context menu clicks
     if (e.Button != MouseButtons.Left)
     {
         return;
     }
     // Needed for KeyPanning as well as PAN
     PanStart = e.Location;
     // Don't do mouse down operation while key panning
     if (KeyPanning)
     {
         return;
     }
     if (ActiveMode == Mode.PAN)
     {
         // Do nothing for now
     }
     else if (ActiveMode == Mode.EDIT)
     {
         bool resLine = hitTestLine(e.Location);
         Debug.WriteLine("OnPictureBoxMouseDown: EDIT: resLine="
                         + resLine);
         if (Control.ModifierKeys == Keys.Alt)
         {
             if (HitPoint != null)
             {
                 HitPoint.Line.Points.RemoveAt(HitPoint.Index);
                 redrawLines();
             }
         }
         else if (Control.ModifierKeys == Keys.Shift)
         {
             if (HitLine != null)
             {
                 addPoint(e.Location);
                 redrawLines();
             }
         }
         redrawOverlay();
     }
     else if (ActiveMode == Mode.NORMAL)
     {
         if (CurLine != null && e.Button == MouseButtons.Left)
         {
             CurLine.addPoint(imagePoint(e.Location));
             redrawLines();
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Deletes the current line.
 /// </summary>
 public void deleteLastPoint()
 {
     if (LinesImage == null)
     {
         return;
     }
     if (CurLine == null)
     {
         Utils.errMsg("There is no current line active");
         return;
     }
     CurLine.deleteLastPoint();
     redrawLines();
 }
        public void ProcessLog(string Data)
        {
            TextReader LogTextReader = new StringReader(Data);
            string     CurLine;
            int        i          = 0;
            DateTime   StartOfDay = DateTime.MinValue;
            DateTime   Timestamp  = DateTime.MinValue;

            while ((CurLine = LogTextReader.ReadLine()) != null)
            {
                if (CurLine.Substring(0, 1) == "#")
                {
                    if (CurLine.Substring(0, 15) == "# Opened (UTC):")
                    {
                        string DayStr = CurLine.Substring(16);
                        StartOfDay = Convert.ToDateTime(DayStr.Substring(0, DayStr.IndexOf(' ')));
                    }
                    // Is a comment
                }
                else
                {
                    string TimeNum = CurLine.Substring(0, CurLine.IndexOf(' '));
                    Timestamp = StartOfDay.AddMilliseconds(Convert.ToDouble(TimeNum));
                    // The will return the number of whole Config.Resolution chunks that have passed since Jan 1 2014.
                    uint TimeframeID = (uint)(((Timestamp - new DateTime(2014, 1, 1)).TotalSeconds) / Config.Resolution);
                    CurLine = CurLine.Substring(TimeNum.Length + 1);
                    if (CurLine.Substring(0, 1) == ":")
                    {
                        CurLine = CurLine.Substring(1);
                        string[] ParameterSplit = CurLine.Split(" ".ToCharArray(), 3, StringSplitOptions.RemoveEmptyEntries);
                        Sender   Sender         = IRCFunctions.ParseSender(ParameterSplit[0]);
                        string   Command        = ParameterSplit[1];
                        string   Parameters     = ParameterSplit[2];
                        Network.Parse(Timestamp, TimeframeID, Sender, Command, Parameters);
                    }
                    else if (CurLine.Substring(0, 4) == "PING")
                    {
                        // Do anything here?
                    }
                    else
                    {
                        AppLog.WriteLine(5, "DEBUG", "Unknown Line Format: " + CurLine);
                    }
                }
                i++;
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please supply input file");
                return;
            }

            StreamReader InputFile   = new StreamReader(args[0]);
            StreamWriter OutputFile1 = new StreamWriter(@"Output1.txt");
            StreamWriter OutputFile2 = new StreamWriter(@"Output2.txt");

            string CurLine;

            while ((CurLine = InputFile.ReadLine()) != null)
            {
                string[] b = { "a", "a" };
                if (CurLine.Contains(':'))
                {
                    b = CurLine.Split(':');
                }
                else if (CurLine.Contains(';'))
                {
                    b = CurLine.Split(';');
                }
                try
                {
                    OutputFile1.WriteLine(b[1]);
                    OutputFile2.WriteLine(b[0]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(CurLine);
                    Console.WriteLine(ex);
                }
            }
            OutputFile1.Close();
            OutputFile2.Close();
            InputFile.Close();

            Console.WriteLine("Done Splitting!");
            Console.ReadKey();
        }
        /// <summary>
        /// Creates a new document by filtering out the lines of the current document using the supplied filter function.
        /// </summary>
        /// <param name="Filter">The function that will filter the lines out of the current document.</param>
        /// <param name="Data">User supplied data that may control filtering.</param>
        /// <returns>A new document containing filtered lines from the current document.</returns>
        public OutputWindowDocument CreateFilteredDocument(OutputWindowDocumentFilterDelegate Filter, object Data)
        {
            if (Filter == null)
            {
                throw new ArgumentNullException("Filter");
            }

            OutputWindowDocument NewDoc = new OutputWindowDocument();

            NewDoc.mLines.Capacity = mLines.Capacity;
            DocumentLine LastLine = null;

            foreach (DocumentLine CurLine in mLines)
            {
                if (!Filter(new ReadOnlyDocumentLine(CurLine), Data))
                {
                    DocumentLine NewLine = (DocumentLine)CurLine.Clone();
                    NewDoc.mLines.Add(NewLine);

                    int LineLength = GetLineLength(NewLine);

                    if (LineLength > NewDoc.mLongestLineLength)
                    {
                        NewDoc.mLongestLineLength = LineLength;
                    }

                    LastLine = NewLine;
                }
            }

            // If the last line is a full line we need to append an empty line because the empty line has been filtered out
            if (LastLine != null && LastLine.ToString().EndsWith(Environment.NewLine))
            {
                NewDoc.mLines.Add(new DocumentLine());
            }

            return(NewDoc);
        }
        /// <summary>
        /// Appends text of the specified color to the document.
        /// </summary>
        /// <param name="TxtColor">The color of the text to be appended</param>
        /// <param name="Txt">The text to be appended</param>
        public void AppendText(Color?TxtColor, string Txt)
        {
            if (Txt.Length == 0)
            {
                return;
            }

            DocumentLine CurLine;
            int          CurLineLength = 0;

            if (mLines.Count == 0)
            {
                CurLine = new DocumentLine();
                mLines.Add(CurLine);
            }
            else
            {
                CurLine = mLines[mLines.Count - 1];
            }

            char LastChar = (char)0;

            // Break the Text in to multiple lines
            String[] Lines = System.Text.RegularExpressions.Regex.Split(Txt, "\r\n");
            foreach (String Line in Lines)
            {
                // Skip empty lines
                if (Line.Length == 0)
                {
                    continue;
                }
                // Put back the \r\n
                String ThisLine  = Line + "\r\n";
                Color? CurrColor = TxtColor;
                // Check for keywords
                if (ThisLine.Contains("Error"))
                {
                    CurrColor = Color.Red;
                }
                else if (ThisLine.Contains("Warning"))
                {
                    CurrColor = Color.Orange;
                }
                // Append the line
                foreach (char CurChar in ThisLine)
                {
                    if (CurChar == '\n' && LastChar != '\r')
                    {
                        CurLine.Append(CurrColor, '\r');
                    }

                    // replace tabs with 4 spaces
                    if (CurChar == '\t')
                    {
                        CurLine.Append(CurrColor, "    ");
                    }
                    else
                    {
                        CurLine.Append(CurrColor, CurChar);
                    }

                    if (CurChar == '\n')
                    {
                        // only count displayable characters (cut \r\n)
                        CurLineLength = CurLine.Length - 2;

                        if (CurLineLength > mLongestLineLength)
                        {
                            mLongestLineLength = CurLineLength;
                        }

                        // This isn't required but it enables readonly optimizations
                        CurLine.FinishBuilding();

                        // A full line has been created so trigger the line added event
                        OnLineAdded(new OutputWindowDocumentLineAddedEventArgs(mLines.Count - 1, new ReadOnlyDocumentLine(CurLine)));

                        // Then begin our new line
                        CurLine = new DocumentLine();
                        mLines.Add(CurLine);
                    }

                    LastChar = CurChar;
                }
            }

            // NOTE: This line hasn't been terminated yet so we don't have to account for \r\n at the end
            CurLineLength = CurLine.Length;

            if (CurLineLength > mLongestLineLength)
            {
                mLongestLineLength = CurLineLength;
            }

            OnModified(new EventArgs());
        }
Esempio n. 12
0
    //-----------------------------------------------------------
    //	запись Tsv-текста в файл
    public bool    SaveToFile(string FileName)
    {
        int    I;
        bool   ContainsEmpty;
        string CurLine;

        string[] Columns;
        if (FileName == null)
        {
            return(false);
        }
        if ((Tsv == null) || (Tsv.Length == 0))
        {
            return(false);
        }
        string[] Lines = Tsv.ToString().Split(CCommon.Chr(13));
        if (Lines == null)
        {
            return(false);
        }
        if (Lines.Length == 0)
        {
            return(false);
        }
        bool        Result     = false;
        CTextWriter TextWriter = new   CTextWriter();

        if (!TextWriter.Create(FileName, CAbc.CHARSET_WINDOWS))
        {
            return(false);
        }

        for (I = 0; I < Lines.Length; I++)
        {
            Result  = true;
            CurLine = Lines[I].Replace(CAbc.BIG_UKR_I, "I").Replace(CAbc.SMALL_UKR_I, "i").Trim();
            if (CurLine.Trim().Length == 0)
            {
                continue;
            }
            ContainsEmpty = true;
            Columns       = CurLine.Split(CCommon.Chr(9));
            if (Columns == null)
            {
                ContainsEmpty = true;                                           // есть пустые ячейки ?
            }
            else if (Columns.Length < 2)
            {
                ContainsEmpty = true;
            }
            else
            {
                foreach (string Item in Columns)
                {
                    if (Item.Trim().Length != 0)
                    {
                        ContainsEmpty = false;
                    }
                }
            }
            if (!ContainsEmpty)
            {
                if (!TextWriter.Add(CurLine + CAbc.CRLF))
                {
                    Result = false;
                }
            }
        }
        TextWriter.Close();
        return(Result);
    }
Esempio n. 13
0
        private string PutTagOnDay(string s)
        {
            string[] Lines = s.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
            //MessageBox.Show("linee:" + Convert.ToString(Lines.GetLength(0)));
            try
            {
                string l;

                foreach (string CurLine in Lines)
                {
                    lineNum++;
                    l = CurLine.Trim();
                    switch (sec)
                    {
                    //sezione GIORNO
                    case (int)Section.giorno:
                    {
                        switch (prog)
                        {
                        //inizio
                        case 0:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }

                            //GIORNO da lun a sab
                            if (èInizioGiornoSettimana(l))
                            {
                                addInizioGiornoSettimana(l);
                            }
                            //GIORNO domenica
                            else if (èInizioDomenica(l))
                            {
                                addInizioDomenica(l);
                            }
                            else
                            {
                                addProblem("manca giorno");
                            }
                            sTemp = "";
                            break;
                        }

                        //GIORNO
                        case 1:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            //aggiungo santi --> tutti sulla stessa riga
                            addOutPQ("#02", l);
                            prog  = 2;
                            sTemp = "";
                            break;
                        }

                        //NOME SANTI
                        case 2:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }
                            //controllo se la stringa è lunga --> allora è la storia dei santi
                            if (l.Length > 90)
                            {
                                //l = AggiungiTagNomeSanti(l, dicPQTag[giornoCorrente]["#02"]);
                                addOutPQ("#03", l);
                                prog = 3;
                            }
                            else
                            {
                                if (èGiornataMondiale(l))
                                {
                                    addGiornataMondiale(l);
                                }
                                else
                                {
                                    //suppongo sia festività
                                    addOutPQ("#04", l);
                                    prog = 4;
                                }
                            }

                            break;
                        }

                        //VITA SANTI
                        case 3:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            if (èGiornataMondiale(l))
                            {
                                addGiornataMondiale(l);
                            }
                            else
                            {
                                //suppongo sia festività
                                addOutPQ("#04", l);
                                prog = 4;
                            }
                            break;
                        }

                        // FESTA RELIGIOSA IMPORTANTE
                        case 4:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            if (èGiornataMondiale(l))
                            {
                                addGiornataMondiale(l);
                            }
                            else
                            {
                                addProblem("parte non riconosciuta");
                            }
                            break;
                        }

                        // GIORNATA MONDIALE
                        case 5:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            //suppongo sia testo altra festa
                            addOutPQ("#06", l);
                            //vado comunque avanti
                            prog = 6;
                            break;
                        }

                        // TESTO ALTRA FESTA
                        case 6:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            //se arrivo qui è un problema ... non ho trovato la prma lettura
                            addProblem("manca prima lettura");
                            sec  = Section.primaLettura;
                            prog = 1;
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    //PRIMA O seconda LETTURA o vangelo
                    case Section.vangelo:
                    case Section.primaLettura:
                    case Section.secondalettura:
                    case Section.vangeloOppure:
                    case Section.primaLetturaOppure:
                    case Section.secondaLetturaOppure:
                    {
                        switch (prog)
                        {
                        case -1:
                        {
                            // quando so che deve iniziare una lettura o vangelo ma non ho ancora trovato niente
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l) || èInizioVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, sec);
                                break;
                            }
                            else if (èAntifonaVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, sec);
                                break;
                            }
                            else
                            {
                                sTemp += l;
                                addProblem("manca titolo e rif lettura");
                            }
                            break;
                        }

                        //titolo e riferimenti
                        case 1:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            AddTestoLettura(l);
                            break;
                        }

                        case 3:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            AddCommentoLettura(l);
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    //SALMO
                    case Section.salmo:
                    {
                        switch (prog)
                        {
                        //titolo e riferimenti
                        case 0:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add1AntifonaSalmo(l);
                            break;
                        }

                        case 1:
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, 6);
                                sTemp = "";
                                break;
                            }
                            if (èoppure(l))
                            {
                                Add1OppureSalmo(l);
                            }
                            else
                            {
                                if (sTemp.Length > 0)
                                {
                                    sTemp += Environment.NewLine + l;
                                }
                                else
                                {
                                    sTemp += l;
                                }
                            }
                            break;
                        }

                        case 2:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add2AntifonaSalmo(l);
                            break;
                        }

                        case 3:
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, 6);
                                sTemp = "";
                                break;
                            }
                            if (èoppure(l))
                            {
                                Add2OppureSalmo(l);
                            }
                            else
                            {
                                if (sTemp.Length > 0)
                                {
                                    sTemp += Environment.NewLine + l;
                                }
                                else
                                {
                                    sTemp += l;
                                }
                            }
                            break;
                        }

                        case 4:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add3AntifonaSalmo(l);
                            break;
                        }

                        case 5:
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                        case 10:             //'A' su rtf
                        case 11:             //'B'  su rtf
                        case 12:             //'C'  su rtf
                        case 13:             //'D'  su rtf
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                if (sTemp.Length > 0)
                                {
                                    AddStrofaSalmo(sTemp, prog + 1);
                                    sTemp = "";
                                }
                                addInizioLetturaOVangelo(l, Section.secondalettura);
                                break;
                            }

                            if (èAntifonaVangelo(l))
                            {
                                if (sTemp.Length > 0)
                                {
                                    AddStrofaSalmo(sTemp, prog + 1);
                                    sTemp = "";
                                }
                                AddInizioPrimaAntifonaVangelo(l);
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, prog + 1);
                                sTemp = "";
                                break;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    case Section.antifonaVangelo:
                    {
                        switch (prog)
                        {
                        case 0:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                addOutPQ("#41", sTemp);
                                sTemp = "";
                                addOutPQ("#42", l);
                                //sec = Section.vangelo;
                                //prog = -1;
                                prog = 2;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        case 2:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èoppure(l))
                            {
                                AddOppureAntifonaVangelo(l);
                            }
                            else if (èInizioVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, Section.vangelo);
                            }
                            break;
                        }

                        case 3:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                AddInizioSecondaAntifonaVangelo(l);
                            }
                            else
                            {
                                addProblem("manca seconda antifona vangelo");
                            }
                            break;
                        }

                        case 4:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                addOutPQ("#45", sTemp);
                                sTemp = "";
                                addOutPQ("#46", l);
                                sec  = Section.vangelo;
                                prog = -1;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    default:
                    {
                        addProblem("default .. non gestito!");
                        break;
                    }
                    }
                }
                //aggiungo commento al vangelo
                if (sTemp.Length > 0)
                {
                    addOutPQ("#" + (int)sec + "4", sTemp);
                    sTemp = "";
                }
            }
            catch (System.Exception ex)
            {
                addProblem("eccezione: " + ex.Message);
            }

            return(outPQTag);
        }
Esempio n. 14
0
        private void LoadData(String Filename)
        {
            String CurLine;                                         // 存讀取器抓到的字串
            int    Section = 0;                                     // 設定變數存狀態,預設為0

            String[] Piecewise;                                     // 存字串陣列

            StreamReader TaskCSV = new StreamReader(Filename);      // 用資料流讀取器抓資料

            //-------讀檔,要做檢查跳出的判斷式-------//
            while ((CurLine = TaskCSV.ReadLine()) != null)
            {
                int fileEnd = 0;
                if (CurLine.ToUpper().Contains("DATA_TIME"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                //if (CurLine.ToUpper().Contains("NUM1"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                {
                    Section = 1;                                    // Section = 1,這行要跳過
                }
                else if (CurLine.ToUpper().Contains("0"))
                {
                    Section = 2;                                   // Section = 2,數值資料的部分
                }

                switch (Section)
                {
                case 1:
                    Piecewise    = CurLine.Trim().Split(',');
                    ItemsNumbers = Piecewise.Length;
                    break;

                case 2:
                    Piecewise = CurLine.Trim().Split(',');
                    //------判斷是否讀到空字串了------------//
                    if (Piecewise[0] == "" || Piecewise[0] == string.Empty || Piecewise[0] == null)
                    {
                        fileEnd = 1;
                        break;
                    }
                    else     //解析字串內容並存進矩陣
                    {
                        for (int j = 0; j < ItemsNumbers; j++)
                        {
                            //------把各項數值放進對應的List裡------//
                            if (j == 0)
                            {
                                Index.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 1)
                            {
                                DataTime.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 5)
                            {
                                Gap.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 6)
                            {
                                Feed.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 7)
                            {
                                Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 8)
                            {
                                WaterR.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            //else if (j == 9) Label3.Add(Convert.ToDouble(Piecewise[j]));
                            else if (j == 10)
                            {
                                Label4.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 11)
                            {
                                Label5.Add(Convert.ToDouble(Piecewise[j]));
                            }

                            /*
                             * if (j == 0) Gap.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 1) Feed.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 2) Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 3) WaterR.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 4) Label5.Add(Convert.ToDouble(Piecewise[j]));
                             */
                        }
                    }
                    break;
                }
                if (fileEnd == 1)
                {
                    break;
                }
            }
        }
Esempio n. 15
0
        private void RunModel()
        {
            string CurLine;

            string[] Fields;
            int      Frame  = 0;
            string   Delims = " ";

            char[] FieldDelims = Delims.ToCharArray();
            bool   Once        = true;

            btnRun.Enabled       = false;
            btnStop.Enabled      = true;
            udFrameCount.Enabled = false;
            menuModelRun.Enabled = false;

            mRunning         = false;
            sbTextPanel.Text = "Running";
            Log("Starting simulation");
            Log("Current path is: " + Directory.GetCurrentDirectory());

            Log("Module directory: \"" + ModuleDirectory + "\"");
            Log("Input directory: \"" + InputDirectory + "\"");
            Log("Output directory: \"" + OutputDirectory + "\"");
            Log("Model configuration: \"" + DiagramFile + "\"");
            Log("Module parameters: \"" + ParameterFile + "\"");
            Log("Beginning simulation\n");
            while (true)
            {
                CurLine = mExecutionProcess.StandardOutput.ReadLine();
                if ((CurLine != null) && (CurLine.IndexOf("Error") > 0))
                {
                    Log(CurLine);
                }
                else
                {
                    if ((CurLine != null) && (CurLine.StartsWith("  Starting Frame ")))
                    {
                        Fields            = CurLine.Split(FieldDelims);
                        Frame             = Int32.Parse(Fields[Fields.Length - 1]);
                        progressBar.Value = Frame;
                        sbTextPanel.Text  = "Running: Frame " + Frame.ToString() + "/" + mFrameCount.Value.ToString();
                    }
                }
                if (Frame < 2)
                {
                    Log(CurLine);
                }
                else
                {
                    if (Once)
                    {
                        Once = false;
                        Log("Simulation running, please wait");
                    }
                }
                if (mExecutionProcess.HasExited)
                {
                    break;
                }
            }
            progressBar.Value   = progressBar.Maximum;
            progressBar.Visible = false;
            if (mExecutionProcess.ExitCode != 0)
            {
                Log("Simulation completed with errors");
            }
            else
            {
                Log("Simulation complete");
            }
            Log("Ready");

            btnRun.Enabled       = true;
            btnStop.Enabled      = false;
            btnAbort.Enabled     = false;
            udFrameCount.Enabled = true;
            UpdateStatusDisplay();
            udFrameCount.Focus();
            mRunning             = false;
            menuModelRun.Enabled = true;
            if (RunningFromCommandLineInput)
            {
                Application.Exit();
            }
        }