//read the line into a list and then enrich the list containing IFCRELASSIGNS
        private void Open_Click(object sender, EventArgs e)
        {
            filename = TextBox_Filename.Text;
            IFClines = new List <IFCparser>();
            string  lines;
            Boolean flag = true;

            if (filename != null)
            {
                try
                {
                    if (System.IO.File.Exists(filename))
                    {
                        using (System.IO.StreamReader InputStream = new System.IO.StreamReader(filename))
                        {
                            while (InputStream.Peek() >= 0 && flag)
                            {
                                lines = null;
                                lines = InputStream.ReadLine();
                                if (string.Compare(lines, "DATA;", true) == 0)
                                {
                                    while ((InputStream.Peek() >= 0) && flag)
                                    {
                                        lines = null;
                                        lines = InputStream.ReadLine();
                                        if (!(string.Compare(lines, "ENDSEC;", true) == 0))
                                        {
                                            IFCparser component1 = new IFCparser(lines);
                                            IFClines.Add(component1);
                                        }
                                        else
                                        {
                                            flag = false;
                                        }
                                    }
                                }
                            }
                        }
                        Taskassignments = IFClines.EnrichIfCparser();
                    }
                    else
                    {
                        messageboxopen("File doesnt exist", "Invalid file");
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Failed to read the lines. {0}", exception.ToString());
                    throw;
                }
            }
            else
            {
                messageboxopen("You did not enter a file name. ", "No file Name Specified");
            }



            messageboxopen("end of file", "process complete");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="In"></param>
        /// <returns></returns>
        private static string ReadCommand(System.IO.StreamReader In)
        {
            var retval = "";

            while (In.Peek() != ';' && !In.EndOfStream)
            {
                while (In.Peek() == '\n' && !In.EndOfStream)
                {
                    In.Read();
                }

                if (In.Peek() != ';' && !In.EndOfStream)
                {
                    retval += (char)In.Read();
                }
            }

            while (In.Peek() == ';')
            {
                In.Read();
            }

            retval += ";";
            return(retval);
        }
Ejemplo n.º 3
0
        public bool cargaUsuarios(string direccion, ArbolBinario arbol_usuarios)//codigo basico para leer un archivo
        {
            bool todo_bien;

            System.IO.StreamReader archivo = new System.IO.StreamReader(direccion);
            string entrada = "";

            string[]        split;
            Objetos.Persona actual;
            try
            {
                if (archivo.Peek() > -1)
                {
                    entrada = archivo.ReadLine();//me como la primera linea porque por lo visto es una cabezera
                }
                while (archivo.Peek() > -1)
                {
                    entrada = archivo.ReadLine();
                    if (!string.IsNullOrEmpty(entrada))
                    {
                        split  = entrada.Split(',');
                        actual = new Objetos.Persona(split[1], split[2]);
                        actual.setConectado(split[3]);
                        arbol_usuarios.insertar(actual, split[0]);
                    }
                }
                todo_bien = true;
            }
            catch (Exception e)
            {
                todo_bien = false;
            }
            archivo.Close();
            return(todo_bien);
        }
Ejemplo n.º 4
0
        static string[] BlockFile(string file)
        {
            var tf = new System.IO.StreamReader(file, System.Text.Encoding.UTF8);
            var sb = new System.Text.StringBuilder();

            //System.Console.WriteLine("---");
            //Einlesen und Kommentare entfernen:
            while (!tf.EndOfStream)
            {
outerloop:
                char _c, _cc;

                _c = Char.ConvertFromUtf32(tf.Read()).ToCharArray()[0];
                if (_c == '(')
                {
                    _cc = Char.ConvertFromUtf32(tf.Peek()).ToCharArray()[0];
                    if (_cc == '*')
                    {
                        //Kommentar
                        tf.Read(); //*
                        while (!tf.EndOfStream)
                        {
                            _c = Char.ConvertFromUtf32(tf.Read()).ToCharArray()[0];
                            if (_c == '*')
                            {
                                _cc = Char.ConvertFromUtf32(tf.Peek()).ToCharArray()[0];
                                if (_cc == ')')
                                {
                                    tf.Read(); //*) komplett verarbeiten
                                    goto outerloop;
                                }
                            }
                        }
                    }
                    else
                    {
                        sb.Append(_c);
                    }
                }
                else if (_c == '\r' || _c == '\n')
                {
                    // ignore linebreaks
                }
                else
                {
                    // process non-comment-(
                    sb.Append(_c);
                }
                //System.Console.WriteLine(_c);
            }
            //System.Console.WriteLine("---");
            char splc = ';';

            return(sb.ToString().Split(splc));
        }
Ejemplo n.º 5
0
        private void ReadNumber(System.IO.StreamReader sr)
        {
            StringBuilder sb = new StringBuilder();
            int           i;

            if (sr.Peek() == '-')
            {
                sb.Append('-');
                sr.Read();
            }

            bool isFrontNumber = true;

            while ((i = sr.Peek()) >= 0)
            {
                char c = (char)i;
                if (isFrontNumber)
                {
                    if (c >= '0' && c <= '9')
                    {
                        if (sb.Length > 0 && sb[0] == '0')
                        {
                            throw new Exception("Parsing Object failed: Expected '.', got '" + c + "', Note: ASAP-JSON is not capable to parse eg. 0.1234e10");
                        }
                        sb.Append(c);
                    }
                    else if (c == '.')
                    {
                        sb.Append(c);
                        isFrontNumber = false;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if (c >= '0' && c <= '9')
                    {
                        sb.Append(c);
                    }
                    else if (c == 'e' || c == 'E' || c == '+' || c == '-')
                    {
                        throw new Exception("Parsing Object failed: Expected DIGIT, got '" + c + "', Note: ASAP-JSON is not capable to parse eg. 0.1234e10");
                    }
                    else
                    {
                        break;
                    }
                }
                sr.Read();
            }
            this.SetValue(double.Parse(sb.ToString(), System.Globalization.CultureInfo.InvariantCulture));
        }
Ejemplo n.º 6
0
            /// <summary>
            /// Reads characters from the reader until a specified delimiter is found. The delimiter character is NOT consumed from the reader.
            /// </summary>
            /// <param name="reader"></param>
            /// <param name="delimiter"></param>
            /// <returns></returns>
            protected static string readTillDelimiter(System.IO.StreamReader reader, params char[] delimiters)
            {
                StringBuilder b = new StringBuilder();
                char          c = (char)reader.Peek();

                while (!delimiters.Contains(c))
                {
                    b.Append(c);
                    reader.Read();
                    c = (char)reader.Peek();
                }
                return(b.ToString());
            }
Ejemplo n.º 7
0
        public report()
        {
            try
            {
                InitializeComponent();

                //Load the Scores

                System.IO.StreamReader scoreReader;


                scoreReader = new System.IO.StreamReader(path + @"\scores.txt");
                //Clear ScoreCard
                scoreCard.Text = "";
                int linecount = 0;

                while (scoreReader.Peek() != -1)
                {
                    //Read the content
                    scoreCard.Text += scoreReader.ReadLine() + "\r\n";
                    linecount++;
                }

                //Tune the scoreCard size

                scoreCard.Height = (int)((3 * linecount - 1) * scoreCard.Font.Size) + 50;
                scoreReader.Close();
                scoreReader.Dispose();
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }
Ejemplo n.º 8
0
        public static List <Graph.CompositeNode> ReadClusters(string filename)
        {
            System.IO.StreamReader     srClusters = new System.IO.StreamReader(filename);
            List <Graph.CompositeNode> clusters   = new List <Graph.CompositeNode>();

            while (srClusters.Peek() > 0)
            {
                string     content = srClusters.ReadLine();
                string[]   items   = content.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                string[]   nodes   = items[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string[]   labels  = items[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                List <int> node    = new List <int>();
                foreach (var n in nodes)
                {
                    node.Add(Convert.ToInt32(n));
                }
                List <int> label = new List <int>();
                foreach (var l in labels)
                {
                    label.Add(Convert.ToInt32(l));
                }
                List <int> modality = new List <int>();
                foreach (var m in modality)
                {
                    modality.Add(Convert.ToInt32(m));
                }
                clusters.Add(new Graph.CompositeNode(node, label, modality));
            }
            srClusters.Close();
            return(clusters);
        }
Ejemplo n.º 9
0
        public string LeggiQuery(Queries q)
        {
            if (!QueriesGiaLette.ContainsKey(q))
            {
                var z = "";

                using (var sr = new System.IO.StreamReader(System.IO.Path.Combine(RationesCurare.GB.DBW, QueriesToString(q))))
                {
                    while (sr.Peek() != -1)
                    {
                        z += sr.ReadLine() + Environment.NewLine;
                    }

                    sr.Close();
                }

                z = z.Replace("Datepart('d',", "strftime('%d',");
                z = z.Replace("Datepart('yyyy',", "strftime('%Y',");
                z = z.Replace("Format(m.data, 'yyyy')", "strftime('%Y',m.data)");
                z = z.Replace("Format(m.data, 'yyyy/mm')", "strftime('%Y/%m',m.data)");

                QueriesGiaLette.Add(q, z);
            }

            return(QueriesGiaLette[q]);
        }
Ejemplo n.º 10
0
        private void Login_Load(object sender, EventArgs e)
        {
            if (!System.IO.File.Exists("pass.dll"))
            {
                System.IO.File.Create("pass.dll");
            }
            else
            {
                System.IO.StreamReader sr = new System.IO.StreamReader("pass.dll", System.Text.Encoding.Default, true);

                //Si se trata de un fichero no vacio, inicializo antes los listados de funciones
                if (sr.Peek() != -1)
                {
                    // Leer una línea del ficheroFunciones
                    String s = sr.ReadLine();

                    if (String.IsNullOrEmpty(s) == false)
                    {
                        String[] vector     = s.Split(' ');
                        String   usuario    = vector[0];
                        String   contraseña = vector[1];
                        textBoxUsuario.Text        = usuario;
                        textBoxContraseña.Text     = contraseña;
                        contraseñaCheckBox.Checked = true;
                    }
                }

                sr.Close();
            }
        }
Ejemplo n.º 11
0
        private static void ReadLMKs(string fileName, string[] LMKAr)
        {
            int i = 0;

            LMKAr = new string[MAX_LMKS];

            try
            {
                using (System.IO.StreamReader SR = new System.IO.StreamReader(fileName))
                {
                    while (SR.Peek() > -1)
                    {
                        string s = SR.ReadLine();
                        if ((s != "") && (s.Trim().StartsWith(";")) == false)
                        {
                            if (Utility.IsHexString(s) == true)
                            {
                                if (s.Length == 32)
                                {
                                    LMKAr[i] = s;
                                    i       += 1;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Array.Clear(LMKAr, 0, MAX_LMKS);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        ///  Collect hidden system apps from file
        /// </summary>
        ///
        private void GetUWPSystem()
        {
            System.IO.StreamReader Database = null;

            try
            {   //Try to open the file
                Database = System.IO.File.OpenText("bloatbox.txt");
            }
            catch (System.IO.FileNotFoundException)                                     // bloatbox.txt does not exisits!?
            {
                System.IO.StreamWriter sw = System.IO.File.CreateText("bloatbox.txt");  // Create it!
                sw.Write(Resources.bloatbox);                                           // Populate it with built in preset
                sw.Close();

                Database = System.IO.File.OpenText("bloatbox.txt");
            }
            finally
            {
                if (Database.Peek() > 0)                                                // If exists and not empty!
                {
                    string buff;
                    while ((buff = Database.ReadLine()) != null)
                    {
                        _listSystemApps.Add(buff);
                    }
                }
                ;
                Database.Close();
            }
        }
Ejemplo n.º 13
0
        ERROR_CODE 코드_대분류하기(System.IO.StreamReader sr)
        {
            string     readLine;
            List <int> 패킷정의_시작위치_리스트 = new List <int>();

            while (sr.Peek() >= 0)
            {
                readLine = sr.ReadLine();

                if (string.IsNullOrEmpty(readLine))
                {
                    continue;
                }

                readLine = readLine.Trim();

                if (readLine.IndexOf("{") == 0 || readLine.IndexOf("};") == 0 || readLine.IndexOf("//") == 0)
                {
                    continue;
                }

                // 상수 데이터 분류
                if (readLine.IndexOf("const ") == 0)
                {
                    상수_정보만_분류(readLine);
                    continue;
                }

                // 헤더 파일 정보 분류
                if (readLine.IndexOf("#include") == 0)
                {
                    헤더파일_정보만_분류(readLine);
                    continue;
                }


                패킷정의데이터.Add(readLine);

                // 패킷 구조체 시작
                if (readLine.IndexOf("struct ") == 0)
                {
                    패킷정의_시작위치_리스트.Add(패킷정의데이터.Count() - 1);
                }
            }


            for (int i = 0; i < 패킷정의_시작위치_리스트.Count(); ++i)
            {
                if (i == (패킷정의_시작위치_리스트.Count() - 1))
                {
                    패킷정의_위치_리스트.Add(new Tuple <int, int>(패킷정의_시작위치_리스트[i], 패킷정의데이터.Count() - 1));
                }
                else
                {
                    패킷정의_위치_리스트.Add(new Tuple <int, int>(패킷정의_시작위치_리스트[i], 패킷정의_시작위치_리스트[i + 1] - 1));
                }
            }

            return(ERROR_CODE.NONE);
        }
Ejemplo n.º 14
0
        public static string GetSourceCode(string file, string path)
        {
            StringBuilder sbCode = new StringBuilder();

            // GRAPHITE_TODO Check if file exists.
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(path + file);
                string line;

                while (sr.Peek() != -1)
                {
                    line = sr.ReadLine();
                    sbCode.AppendLine(line);
                }

                sr.Close();
                sr.Dispose();
            }
            catch (Exception exp)
            {
                //
            }

            return sbCode.ToString();
        }
Ejemplo n.º 15
0
        public Resourcegroup addTemplate(string template_file)
        {
            System.IO.StreamReader streamReader = new System.IO.StreamReader(template_file);
            string template_text = "";
            int    i             = 0;

            do
            {
                if (i == 0)
                {
                    template_text = streamReader.ReadLine();
                }
                else
                {
                    template_text = template_text + "%n" + streamReader.ReadLine();
                }
                i += 1;
            }     while (streamReader.Peek() != -1);
            streamReader.Close();
            template_text = template_text.Replace("\\", "\\\\");
            template_text = template_text.Replace("\"", "\\\"");
            template_text = template_text.Replace("%n", "\\n");
            template_text = System.Text.RegularExpressions.Regex.Replace(template_text, @"\s+", " ");
            string        statment      = "{\"upload_template_xml\": {\"template_xml\": \"" + template_text + "\"}}";
            string        respond       = client.callServer(statment);
            Resourcegroup resourcegroup = jss.Deserialize <Resourcegroup>(respond);

            return(resourcegroup);
        }
Ejemplo n.º 16
0
        private void LoadZanimanje()
        {
            try
            {
                //kreiramo objekat StreamReader
                System.IO.StreamReader sr = new System.IO.StreamReader("zanimanje.txt");

                string ulaz;
                do //citamo dok god ima ulaza
                {
                    ulaz = sr.ReadLine();
                    //dodajemo samo ak red sadrzi bar jedna znak
                    if (ulaz != "")
                    {
                        this.cboZanimanje.Items.Add(ulaz);
                    }
                } while (sr.Peek() != -1);
                //Peek vraca -1 uklliko je kraj toka
                //zatvarmo tok
                sr.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Fajl zanimanje.txt nije nadjen!");
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Reads the class names.
        /// </summary>
        /// <returns>The class names.</returns>
        /// <param name="filename">Filename.</param>
        private List <string> readClassNames(string filename)
        {
            List <string> classNames = new List <string>();

            System.IO.StreamReader cReader = null;
            try
            {
                cReader = new System.IO.StreamReader(filename, System.Text.Encoding.Default);

                while (cReader.Peek() >= 0)
                {
                    string name = cReader.ReadLine();
                    classNames.Add(name);
                }
            }
            catch (System.Exception ex)
            {
                Debug.LogError(ex.Message);
                return(null);
            }
            finally
            {
                if (cReader != null)
                {
                    cReader.Close();
                }
            }

            return(classNames);
        }
Ejemplo n.º 18
0
        /// <summary> It adds the specified input text to the input queue of the work flow. After this method,
        /// you are allowed to get the analysis result by using one of the following methods:
        ///
        /// - getResultOfSentence() : to get the result for one sentence at the front of result queue
        /// - getResultOfDocument() : to get the entire result for all sentences
        ///
        /// If the input document is not small, getResultOfDocument() may show lower performance, and it
        /// could be better to call getResultOfSentence() repeatedly. You need to pay attention on this.
        ///
        /// </summary>
        /// <param name="document">- the path for the text file to be analyzed
        /// </param>
        /// <throws>  IOException </throws>
        public virtual void analyze(System.IO.FileInfo document)
        {
            System.IO.StreamReader br = new System.IO.StreamReader(document.FullName, System.Text.Encoding.UTF8);
            LinkedBlockingQueue <PlainSentence> queue = queuePhase1[0];

            if (queue == null)
            {
                return;
            }

            System.String line = null;
            int           i    = 0;

            while ((line = br.ReadLine()) != null)
            {
                if (br.Peek() != -1)
                {
                    queue.Add(new PlainSentence(0, i++, false, line.Trim()));
                }
                else
                {
                    queue.Add(new PlainSentence(0, i++, true, line.Trim()));
                    break;
                }
            }

            br.Close();

            if (!isThreadMode)
            {
                analyzeInSingleThread();
            }
        }
Ejemplo n.º 19
0
        // Returns source code of a demo file
        public static string GetSourceCode(string suffix, bool dicFiles, int intActiveIndex, string path, Graphite.Internal.Config config)
        {
            string strFileName = "default";
            if (dicFiles == false)
            {
                int intMenuItemActive = intActiveIndex;
                strFileName = config.Type(intMenuItemActive);
            }

            string strRoot = HttpContext.Current.Server.MapPath(path) + "\\";
            StringBuilder sbCode = new StringBuilder();

            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(strRoot + strFileName + suffix);
                string line;

                while (sr.Peek() != -1)
                {
                    line = sr.ReadLine();
                    sbCode.AppendLine(line);
                }

                sr.Close();
                sr.Dispose();
            }
            catch (Exception exp)
            {
                //
            }
            return sbCode.ToString();
        }
Ejemplo n.º 20
0
        public void InitializeConnection()
        {
            string FILE_NAME = "";
            string myServer  = "";
            string myPort    = "";
            string myDB      = "";
            string myUID     = "";
            string myPW      = "";
            string cn        = "";

            FILE_NAME = "Conn.cn";
            if (System.IO.File.Exists(FILE_NAME) == true)
            {
                System.IO.StreamReader objReader = new System.IO.StreamReader(FILE_NAME);
                string   line;
                string[] row;
                do
                {
                    line = objReader.ReadLine();
                    if (line == "")
                    {
                        break;
                    }
                    if (line[0] == '#')
                    {
                        continue;
                    }

                    row = line.Split(':');
                    if (row[0] == "Server")
                    {
                        myServer = row[1];
                    }
                    else if (row[0] == "port")
                    {
                        myPort = row[1];
                    }
                    else if (row[0] == "Database")
                    {
                        myDB = row[1];
                    }
                    else if (row[0] == "Uid")
                    {
                        myUID = row[1];
                    }
                    else if (row[0] == "Pwd")
                    {
                        myPW = row[1];
                    }
                } while (objReader.Peek() != -1);



                cn = "Server = " + myServer + "; " + "Port = " + myPort + "; " + "Database = " + myDB + "; " + "Uid = " + myUID + "; " + "Pwd = " + myPW + "; ";
                objReader.Close();
            }

            objConnection.ConnectionString = cn;
            objCommand.CommandTimeout      = 0;
        }
Ejemplo n.º 21
0
        private int GetNumberOfPsPages(string fileName)
        {
            var count = 0;

            try
            {
                using (var fs = _file.OpenRead(fileName))
                    using (var sr = new System.IO.StreamReader(fs.StreamInstance))
                    {
                        while (sr.Peek() >= 0)
                        {
                            var readLine = sr.ReadLine();
                            if (readLine != null && readLine.Contains("%%Page:"))
                            {
                                count++;
                            }
                        }
                    }
            }
            catch
            {
                Logger.Warn("Error while retrieving page count. Set value to 1.");
            }

            return(count == 0 ? 1 : count);
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            //Lecture du fichier
            string file_name = "../../../file.txt";
            string textLine  = "";

            if (System.IO.File.Exists(file_name) == true)
            {
                System.IO.StreamReader objReader;
                objReader = new System.IO.StreamReader(file_name);

                do
                {
                    textLine = textLine + objReader.ReadLine();
                } while (objReader.Peek() != -1);
            }
            else
            {
                Console.WriteLine("Fichier introuvable!");
                Console.ReadLine();
            }

            //Lance l'analyse du code
            Console.WriteLine(new AnalSyn(new AnalLex(textLine)).Analyse());
            Console.ReadLine();
        }
Ejemplo n.º 23
0
 private void mostrar()
 {
     try
     {
         //Declaramos una variable auxiliar.
         string linea;
         //Limpiamos nuestro label.
         lbMostrar.Text = "";
         //Usamos nuestro objeto para leer el txt.
         using (leerArchivo = new System.IO.StreamReader(ruta))
         {
             //Usamos el while hasta que no encentre mas lienas.
             while (leerArchivo.Peek() > -1)
             {
                 //Todo lo escrito en las lineas las guardamos en nuestra variable.
                 linea = leerArchivo.ReadLine();
                 //Comprovamos que la variable tenga algun valor.
                 if (!String.IsNullOrEmpty(linea))
                 {
                     //Lo imprimimos en nuestro label.
                     lbMostrar.Text += linea + "\n";
                 }
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error", "Ha ocurrido un error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 24
0
        private void generar()
        {
            try
            {
                personas.Clear();

                using (leerArchivo = new System.IO.StreamReader(ruta))
                {
                    while (leerArchivo.Peek() > -1)
                    {
                        string linea = leerArchivo.ReadLine();
                        if (!String.IsNullOrEmpty(linea))
                        {
                            //Lo que contiene el archivo que lo abrimos en modo lectura lo guardamos en una lista.
                            personas.Add(linea);
                        }
                    }
                }
                //Generamos numero random.
                auxiliar = random.Next(0, personas.Count);
                //Lo imprimimos.
                lbMostrar.Text = personas[auxiliar];
            }
            catch (Exception)
            {
                MessageBox.Show("Error", "Introduca solo texto.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 25
0
 private void load_clicks_Click(object sender, EventArgs e)
 {
     textBoxTree.Clear();
     textBoxBypass.Clear();
     textBoxSearch.Clear();
     try
     {
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             osinka = new Tree.TreeNode();// создать новое дерево
             textBoxTree.Clear();
             using (var file = new System.IO.StreamReader(openFileDialog1.FileName))
             {
                 while (file.Peek() >= 0)
                 {
                     string currentElement = file.ReadLine();
                     if (currentElement != null)
                     {
                         osinka.Add(int.Parse(currentElement));
                     }
                 }
             }
             string results = "";
             osinka.Output(ref results);
             textBoxTree.Text = results;
         }
     }
     catch
     {
         MessageBox.Show("Ошибка ввода", "Графы",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Question);
     }
 }
Ejemplo n.º 26
0
        private void loadWords()
        {
            string path = System.IO.Directory.GetCurrentDirectory();
            string wordsFileDirectory = path + "\\words.txt";

            if (System.IO.File.Exists(wordsFileDirectory) && new System.IO.FileInfo(wordsFileDirectory).Length != 0)
            {
                System.IO.StreamReader wordsLoader = new System.IO.StreamReader(wordsFileDirectory);
                int i = 0;
                while (wordsLoader.Peek() != -1)
                {
                    Words.Insert(i, wordsLoader.ReadLine());
                    i++;
                }
                wordsLoader.Close();
            }
            else if (!System.IO.File.Exists(wordsFileDirectory))
            {
                MessageBox.Show("Words file was not found! We'll create one for you, already loaded with 5 words!");
                createWordsFile();
            }
            else if (new System.IO.FileInfo(wordsFileDirectory).Length == 0)
            {
                MessageBox.Show("Words file was found but is empty, we'll put some words for you!");
                createWordsFile();
            }
        }
Ejemplo n.º 27
0
        private void b_Loadfile_Click(object sender, EventArgs e)
        {
            oFD1.Multiselect = false;
            oFD1.Title       = "Choose File to open";
            while (!System.IO.File.Exists(oFD1.FileName))
            {
                oFD1.ShowDialog();
            }
            System.IO.StreamReader sr = new System.IO.StreamReader(oFD1.FileName);
            int row = 0;

            while (row < 8 && sr.Peek() != -1)
            {
                string zeile = sr.ReadLine();
                if (!string.IsNullOrEmpty(zeile))
                {
                    string[] values = zeile.Split(' ');
                    if (values.Count() == 11)
                    {
                        int steps = 0;
                        for (int i = 0; i < 9; i++)
                        {
                            if (i == 3 || i == 6)
                            {
                                steps++;
                            }
                            Werte[row, i] = Convert.ToInt32(values[i + steps]);
                        }
                        row++;
                    }
                }
            }
            Show_werte();
        }
Ejemplo n.º 28
0
        static void insertCountries()
        {
            MySqlCommand cmd = new MySqlCommand("INSERT INTO `climate`.`countries` (`abbreviation`,`name`) VALUES (@abbrev,@name);", conn);

            conn.Open();
            System.IO.StreamReader countries = new System.IO.StreamReader("Y:\\country-list.txt");
            System.IO.StreamWriter csvCountries = new System.IO.StreamWriter("Y:\\country-list.csv");

            Console.WriteLine(countries.ReadLine());
            Console.WriteLine(countries.ReadLine());

            while (countries.Peek() > 0)
            {
                string line = countries.ReadLine();
                string[] strings = line.Split(new string[] { "          " }, StringSplitOptions.RemoveEmptyEntries);
                //string[] strings = line.Split(new char[] { ' ' }, 12);
                Console.WriteLine(strings[0] + "," + strings[1]);
                csvCountries.WriteLine(strings[0] + "," + strings[1]);
                cmd.Parameters.AddWithValue("abbrev", strings[0]);
                cmd.Parameters.AddWithValue("name", strings[1]);

                cmd.ExecuteScalar();
                cmd.Parameters.Clear();
            }

            conn.Close();
            csvCountries.Close();
            countries.Close();
        }
Ejemplo n.º 29
0
        private void Form2_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            string fileRow;

            string[] fileDataField;



            string csvPath = "P:\\Normy.par";

            if (System.IO.File.Exists(csvPath))
            {
                System.IO.StreamReader fileReader = new System.IO.StreamReader(csvPath, false);


                //Reading Data
                while (fileReader.Peek() != -1)
                {
                    fileRow       = fileReader.ReadLine();
                    fileDataField = fileRow.Split(',');
                    dataGridView1.Rows.Add(fileDataField);
                }
                fileReader.Dispose();
                fileReader.Close();
            }
        }
Ejemplo n.º 30
0
        public void Save()
        {
            var path     = System.IO.Path.GetTempPath();
            var filePath = System.IO.Path.Combine(path, "deepends.dgml");

            this.graph.Save(filePath);

            bool found  = false;
            var  reader = new System.IO.StreamReader(filePath);
            var  writer = new System.IO.StreamWriter(this.options["graph"]);

            while (reader.Peek() >= 0)
            {
                var line = reader.ReadLine();
                if (!found)
                {
                    if (line.Contains("<Nodes>"))
                    {
                        found = true;
                        writer.WriteLine("  <Paths>");
                        writer.WriteLine(string.Format("    <Path Id=\"Source\" Value=\"{0}\"/>", this.sourcePath));
                        writer.WriteLine("  </Paths>");
                    }
                }

                writer.WriteLine(line);
            }

            writer.Close();
            reader.Close();
        }
Ejemplo n.º 31
0
        static Regex lineSimpleApply = CreateRegex(@"^Ext.apply\(\s*(?<name>({id}\.)?{idx})(\.prototype)?.*"); // e.g. Ext.apply(Dextop.common, {

        #endregion Fields

        #region Methods

        public override void ProcessFile(String filePath, Dictionary<String, LocalizableEntity> map)
        {
            ClasslikeEntity jsObject = null;
            System.IO.TextReader reader = new System.IO.StreamReader(filePath, Encoding.UTF8);
            //Logger.LogFormat("Processing file {0}", filePath);
            try
            {
                while (reader.Peek() > 0)
                {
                    String line = reader.ReadLine();
                    ClasslikeEntity o = ProcessExtendLine(filePath, line);
                    if (o != null)
                        jsObject = o;

                    else if (jsObject != null) {
                        LocalizableEntity prop = ProcessPropertyLine(jsObject, line);
                        if (prop != null && !map.ContainsKey(prop.FullEntityPath))
                            map.Add(prop.FullEntityPath, prop);
                    }
                }
                Logger.LogFormat("Processing file {0} - Success", filePath);
            }
            catch (Exception ex)
            {
                Logger.LogFormat("Processing file {0} - Error", filePath);
                throw ex;
            }
            finally
            {
                reader.Close();
            }
        }
Ejemplo n.º 32
0
        private void LoadData()
        {
            string path     = "MoneyData.csv";           // 入力ファイル名
            string delimStr = ",";                       // 区切り文字

            char[]   delimiter = delimStr.ToCharArray(); // 区切り文字をまとめる
            string[] strData;                            // 分解後の文字の入れ物
            string   strLine;                            // 1行分のデータ
            bool     fileExists = System.IO.File.Exists(path);

            if (fileExists)
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(
                    path,
                    System.Text.Encoding.Default);
                while (sr.Peek() >= 0)
                {
                    strLine = sr.ReadLine();
                    strData = strLine.Split(delimiter);
                    moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
                        DateTime.Parse(strData[0]),
                        strData[1],
                        strData[2],
                        int.Parse(strData[3]),
                        strData[4]);
                }
                sr.Close();
            }
        }
Ejemplo n.º 33
0
 public Graph(string path)
 {
     using (var reader = new System.IO.StreamReader(path, Encoding.GetEncoding("shift_jis")))
     {
         double tmp;
         var    nodes = reader.ReadLine().Split(',');
         foreach (var item in nodes)
         {
             if (double.TryParse(item, out tmp))
             {
                 var n = Node.NewNode(tmp);
                 nodeList.Add(n);
             }
         }
         while (reader.Peek() > -1)
         {
             var link = reader.ReadLine().Split(',');
             var l    = new Link()
             {
                 From   = nodeList.Single(x => x.ID == int.Parse(link[0])),
                 To     = nodeList.Single(x => x.ID == int.Parse(link[1])),
                 Weight = double.Parse(link[2])
             };
             linkList.Add(l);
         }
     }
 }
Ejemplo n.º 34
0
        public string[][] read()
        {
            List <csvData> csv_list = new List <csvData>();

            System.IO.StreamReader cReader = (
                new System.IO.StreamReader(filePath_, System.Text.Encoding.GetEncoding("shift_jis")));


            while (cReader.Peek() >= 0)
            {
                // ファイルを 1 行ずつ読み込む
                string stBuffer = cReader.ReadLine();
                stBuffer.Trim();
                if (null == stBuffer || stBuffer.Equals(""))
                {
                    continue;
                }
                if (stBuffer[0].Equals("#") || stBuffer[0].Equals("#"))
                {
                    continue;
                }
                // 読み込んだものを追加で格納する
                csv_list.Add(new csvData(stBuffer.Split(',')));
            }
            //string[][] csv_data = new string[csv_list.Count][];
            List <string[]> csv_data = new List <string[]>();

            foreach (var s in csv_list)
            {
                csv_data.Add(s.read());
            }

            cReader.Close();
            return(csv_data.ToArray());
        }
Ejemplo n.º 35
0
        private void fetchDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Collections.Generic.List<string> SYMBOLS = new System.Collections.Generic.List<string>();
            try
            {
                string path = null;
                string dest = null;
                using (System.IO.StreamReader SR = new System.IO.StreamReader(String.Concat(System.IO.Directory.GetCurrentDirectory(), "\\tickers.txt")))
                    {
                        while (SR.Peek() > 0)
                        {
                            SYMBOLS.Add(SR.ReadLine());
                        }
                        SR.Close();
                    }

                WebClient Client = new WebClient();

                foreach (string ticker in SYMBOLS)
                {
                    //MessageBox.Show(ticker);

                    // Format
                    // Date Open High Low Close Volume AdjClose
                    int[] DateVals = GetLatest(ticker);

                    // foreach ticker get data
                    //  http://real-chart.finance.yahoo.com/table.csv?s=AAPL&a=11&b=12&c=1980&d=06&e=6&f=2014&g=d&ignore=.csv

                    // Date testing with 7/29/2014
                    path = "http://real-chart.finance.yahoo.com/table.csv?s=" + ticker + "&a=" + DateVals[0].ToString() + "&b=" + DateVals[1] + "&c=" + DateVals[2] + "&d=06&e=29&f=2014&g=d&ignore=.csv";

                    //MessageBox.Show(path);

                    dest = System.IO.Directory.GetCurrentDirectory() + "\\temp\\test.csv";
                    // Download data into data set then add to file?
                    Client.DownloadFile(path, dest);

                    using (System.IO.StreamReader SR = new System.IO.StreamReader(dest))
                    {
                        while (SR.Peek() > 0)
                        {
                            MessageBox.Show(SR.ReadLine());
                        }
                        SR.Close();
                    }

                }
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Reading \'Tickers.txt\' failed: \n\n" + err.ToString());
            }
        }
Ejemplo n.º 36
0
        static void insertStations()
        {
            MySqlCommand cmd = new MySqlCommand("INSERT INTO `climate`.`stations` (`USAF`,`WBAN`,`station`,`country`,`FIPS`,`state`,`call`,`latitude`,`longitude`,`elevation`) "
                + "VALUES (@usaf,@wban,@station,@country,@fips,@state,@call,@lat,@lon,@elev);", conn);

            conn.Open();
            System.IO.StreamReader stations = new System.IO.StreamReader("Y:\\ish-history.csv");

            Console.WriteLine(stations.ReadLine());

            while (stations.Peek() > 0)
            {
                string line = stations.ReadLine();
                string[] strings = line.Split(new char[] { ',' }, 12);
                for(int i = 0; i<10; i++)
                {
                    strings[i] = strings[i].Replace("\"", string.Empty);
                }

                int c = Convert.ToInt32(strings[0]);
                if (c > 61240)
                {
                    //Console.WriteLine(strings[0] + "," + strings[1]+","+strings[2]+","+strings[3]+","+strings[4]+","+strings[5]+","+strings[6]+","+strings[7]+","+strings[8]+","+strings[9]);

                    cmd.Parameters.AddWithValue("usaf", strings[0]);
                    cmd.Parameters.AddWithValue("wban", strings[1]);
                    cmd.Parameters.AddWithValue("station", strings[2]);
                    cmd.Parameters.AddWithValue("country", strings[3]);
                    cmd.Parameters.AddWithValue("fips", strings[4]);
                    cmd.Parameters.AddWithValue("state", strings[5]);
                    cmd.Parameters.AddWithValue("call", strings[6]);
                    cmd.Parameters.AddWithValue("lat", strings[7]);
                    cmd.Parameters.AddWithValue("lon", strings[8]);
                    cmd.Parameters.AddWithValue("elev", strings[9]);

                    try
                    {
                        cmd.ExecuteScalar();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    cmd.Parameters.Clear();
                }
                Console.WriteLine(strings[0]);
            }

            conn.Close();
            stations.Close();
        }
Ejemplo n.º 37
0
        public static XMLDocument Parse(System.IO.Stream ins, XMLListener l)
        {
            StringBuilder sbr = new StringBuilder();
            try
            {
                int i = 0;
                while (ins.Length == 0)
                {
                    i++;
                    try
                    {
                        Thread.Sleep(100L);
                    }
                    catch
                    {
                    }
                    if (i <= 100)
                    {
                        continue;
                    }
                    throw new System.Exception("Parser: InputStream timed out !");
                }
                using (System.IO.StreamReader reader = new System.IO.StreamReader(ins, System.Text.Encoding.UTF8))
                {
                    while (reader.Peek() > -1)
                    {
                        sbr.Append(reader.ReadLine());
                        sbr.Append("\n");
                    }
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }

            }
            catch (System.Exception ex)
            {
                Log.Exception(ex);
            }
            finally
            {
                if (ins != null)
                {
                    ins.Close();
                    ins = null;
                }
            }
            return new XMLParser().ParseText(sbr.ToString(), l);
        }
Ejemplo n.º 38
0
 private void LoadBMSFile()
 {
     IsLoading = true;
     System.IO.StreamReader sr
         = new System.IO.StreamReader(Path, System.Text.Encoding.Default);
     string result = string.Empty;
     while(sr.Peek() >= 0)
     {
         string buffer = sr.ReadLine();
         System.Console.WriteLine(buffer);
         result += buffer + System.Environment.NewLine;
     }
     sr.Close();
 }
Ejemplo n.º 39
0
 public void LoadSettings()
 {
     s_file = new System.IO.FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\settings.dat", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
     using (System.IO.StreamReader sR = new System.IO.StreamReader(s_file))
     {
         while (sR.Peek() != -1)
         {
             string s = sR.ReadLine();
             if (s != null)
                 s_settings.Add(s.Substring(0, s.IndexOf(":", StringComparison.Ordinal)), s.Substring(s.IndexOf(":", StringComparison.Ordinal) + 1));
         }
     }
     s_file = new System.IO.FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\settings.dat", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
 }
        public ActionResult Upload(HttpPostedFileBase upload, BulkUpload model)
        {
            string info = "";
            try {
                // Check if the user has entered application ids
                if (model.Applications.Trim().Length > 0)
                {
                    string[] appications = model.Applications.Split(';');

                    string[] securityRoles = model.SecurityRoles.Split(';');

                    string[] permissionGroups = model.PermissionGroups.Split(';');

                    var file = new System.IO.StreamReader(upload.InputStream);

                    while (file.Peek() >= 0)
                    {
                        string line = file.ReadLine();

                        string[] fields = line.Split(',');

                        var bulkUser = new BulkUser();

                        bulkUser.Title = fields[0];
                        bulkUser.GivenName = fields[1];
                        bulkUser.MiddleName = fields[2];
                        bulkUser.Surname = fields[3];
                        bulkUser.Email = fields[4];
                        bulkUser.Password = fields[5];

                        // call to creat user

                    // call 

                    }
                }
                else
                {
                    // No Application entered
                    info = "No Application Ids entered.";
                }
            }
            catch (Exception exp)
            {
                info = exp.Message;
            }

            return View();
        }
Ejemplo n.º 41
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            String file_name = "\\test.txt"; // provides the location for our file name in this case its test.txt
            String textLine = ""; // creates a textLine of string text
            ArrayList findSubroutine = new ArrayList(); // Only saves the  subroutines

            file_name = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + file_name; // gets my specific object txt location
            System.IO.StreamReader objReader; // System.IO.StreamReader creates an objReader which ill use later in the program.
            objReader = new System.IO.StreamReader(file_name);
            ArrayList location = new ArrayList();

            string[] insructions = {"NOP", "MULS","ADD","SUB","LDI","AND","OR","RJMP","SLEEP","TST"};
            string[] opcodes = {"0000000000000000","00000010","000011","000110","1110","001000","001010","1100","1001010110001000","001000"};

            string test = ""; // created to test if we are able to attach opcodes from function together *which was successful*

            for (int i = 0; i < opcodes.Length; i++)
            {
                if (opcodes[i].Count() < 16)
                {
                    MessageBox.Show("This mother f****r has less than 16 characters " + i);
                    test = getOp(opcodes[i], "something", "somethingelse");
                }
            }

            MessageBox.Show(test);

            int x = 1;
            while (objReader.Peek() != -1)
            {
                textLine = objReader.ReadLine() + "\r\n"; //reads this line by line
                if (textLine.Contains(":"))
                {
                    findSubroutine.Add(textLine);
                    location.Add(x);
                }
                x++;
            }

            //code just for testing location and subroutine.
            for (int i = 0; i < findSubroutine.Count; i++)
            {
                //MessageBox.Show(findSubroutine[i].ToString());
                //MessageBox.Show(location[i].ToString());
            }
            objReader.Close();
        }
Ejemplo n.º 42
0
        public static string GetCodeBehind(string ascxSource, string cssClass, string path, Graphite.Internal.Config config, int activeIndex)
        {
            string strCode = "";

            // Get URL to Codebehind
            string strCodeBehindURL = "";
            int intCodeFileStart = ascxSource.IndexOf("CodeFile=", StringComparison.OrdinalIgnoreCase);
            int intIgnoreCodeFile = ascxSource.IndexOf("<!-- Graphite: Ignore Codefile -->", StringComparison.OrdinalIgnoreCase);
            int intStartQuote = ascxSource.IndexOf("\"", intCodeFileStart);
            int intEndQuote = ascxSource.IndexOf("\"", (intStartQuote + 1));
            if (intStartQuote >= 0)
            {
                strCodeBehindURL = ascxSource.Substring((intStartQuote + 1), (intEndQuote - intStartQuote - 1));
            }

            string strRoot = HttpContext.Current.Server.MapPath(path) + "\\";

            if (intIgnoreCodeFile >= 0)
            {
                // Get Codebehind code
                try
                {
                    StringBuilder sbCode = new StringBuilder();
                    System.IO.StreamReader sr = new System.IO.StreamReader(strRoot + strCodeBehindURL);

                    while (sr.Peek() != -1)
                    {
                        string line = sr.ReadLine();
                        sbCode.AppendLine(line);
                    }
                    sr.Close();
                    sr.Dispose();

                    strCode = sbCode.ToString();

                    // Insert class into private variable _strRootClass
                    int rootClassStart = strCode.IndexOf("_strRootClass", StringComparison.OrdinalIgnoreCase);
                    int rootClassValueStart = strCode.IndexOf("\"\"", rootClassStart);
                    strCode = strCode.Insert(rootClassValueStart + 1, config.CssClass(activeIndex));
                }
                catch (Exception exp)
                {
                    // No Codebehind available
                }
            }
            return strCode;
        }
Ejemplo n.º 43
0
        public Boolean csvToHTML()
        {
            String outputfile;
            if (this.InputFilePath == null)
            {
                return false;
            }
            else
            {
                outputfile = getRawOutputFilePath()+"_output.html";
            }

            System.IO.StreamReader sr = new
              System.IO.StreamReader("..\\..\\gpssample.html");
            System.IO.StreamReader srcsv = new System.IO.StreamReader(InputFilePath);
            System.IO.StreamWriter sw = new System.IO.StreamWriter(outputfile);

            String str = sr.ReadLine();
            //内容を一行ずつ読み込む
            while (sr.Peek() > -1)
            {
                sw.WriteLine(str);
                if (str.IndexOf("StartArray()") != -1)
                {
                    //ヘッダー行
                    String strcsv = srcsv.ReadLine();
                    //内容1行目
                    strcsv = srcsv.ReadLine();
                    long i = 0;
                    while (strcsv != null)
                    {
                        String[] contents = strcsv.Split(',');
                        sw.WriteLine("patharray[" + i
                                + "] = new google.maps.LatLng(" + contents[1]
                                + "," + contents[2] + ");");
                        i++;
                        strcsv = srcsv.ReadLine();
                    }
                }
                str = sr.ReadLine();
            }
            //閉じる
            sw.Close();
            srcsv.Close();
            sr.Close();
            return true;
        }
Ejemplo n.º 44
0
        public Form2()
        {
            InitializeComponent();

            List<string> set = new List<string>();
            using (var sr = new System.IO.StreamReader("config.ini"))
            {
                while (sr.Peek() >= 0)
                    set.Add(sr.ReadLine());
            }
            textBox1.Text = set[0];
            textBox2.Text = set[1];
            textBox3.Text = set[2];
            textBox4.Text = set[3];
            textBox5.Text = set[4];
            textBox3.Text = Decode(textBox3.Text);
        }
Ejemplo n.º 45
0
        private void btOk_Click(object sender, EventArgs e)
        {
            webBrowser.Navigate("http://hipoqih.com");
            this.Refresh();

            string st_Texto = null;

            string st_url = "http://hipoqih.com/leerposicion.php?iduser="******"utf-8");
            System.IO.StreamReader sr = new System.IO.StreamReader(recibir, encode);
            // leer el estreamer
            while (sr.Peek() >= 0)
            {
                st_Texto += sr.ReadLine();
            }
            resul.Close();
            //ahora interpreta la cadena
            // que viene asi:
            // echo'latitud','longitud'
            string st_lat = "";
            string st_lon = "";
            int i_a;
            //coge el contenido devuelto por hipoqih y lo parsea
            if (st_Texto != null)
            {
                i_a = st_Texto.IndexOf(",");
                if (i_a > 0)
                {
                    st_lat = st_Texto.Substring(0, i_a);
                    st_lon = st_Texto.Substring(i_a + 1, st_Texto.Length - i_a - 1);
                }
            }
            // lo pinto en referencias
            plugin_hipoqih.hipoqih.frmPreferencias.txLat.Text = st_lat;
            plugin_hipoqih.hipoqih.frmPreferencias.txLon.Text = st_lon;
            this.Close();
        }
Ejemplo n.º 46
0
 public void loadFromCSV(string filename)
 {
     if (!System.IO.File.Exists(filename))
         return;
     if (!(System.IO.Path.GetExtension(filename).Equals(".csv")))
         return;
     using (System.IO.StreamReader sr = new System.IO.StreamReader(filename))
     {
         this.DataSource = null;
         this.Clear();
         string[] tmp = sr.ReadLine().Split(';');
         this.ColumnCount=tmp.Length;
         for (int i = 0; i < tmp.Length; i++)
             this.Columns[i].HeaderCell.Value = tmp[i];
         while (sr.Peek() > -1)
             this.Rows.Add(sr.ReadLine().Split(';'));
     }
     if (!checkGridIsCorrect())
         Clear();
 }
Ejemplo n.º 47
0
        /// <summary>
        /// Load pairs of keys and values from file
        /// </summary>
        /// <param name="filepath">Path and name of file.</param>
        /// <returns></returns>
        public bool Load(string filepath)
        {
            using (System.IO.StreamReader sr = new System.IO.StreamReader(filepath))
            {

                int linecounter = 0;

                while(true)
                {
                    string line = sr.ReadLine();
                    linecounter++;

                    if(line == null)
                        return true;

                    while (sr.Peek() == '\t')
                    {
                        line += sr.ReadLine().Remove(0,1);
                        linecounter++;
                    }

                    if(line.Length == 0)
                        continue;

                    if(line[0] == '#') //skip comments
                        continue;

                    string key, val;
                    int index = line.IndexOf('='); //look for first "="
                    if (index == -1)
                        throw new System.Exception(string.Format("Corrupted line #{2} ('{1}') in file {0} (can not find '=' symbol)",filepath,line,linecounter));

                    key = line.Substring(0, index);
                    val = line.Substring(index + 1);
                    System.Diagnostics.Debug.WriteLine(string.Format("{0} = {1}", key, val));

                    ht[key.Trim()] = val.Trim();
                }
            }
        }
Ejemplo n.º 48
0
        private void button_load_computers_file_Click(object sender, EventArgs e)
        {
            OpenFileDialog load_file = new OpenFileDialog();

            load_file.Filter = "All Files (*.*)|*.*";
            load_file.FilterIndex = 1;

            load_file.Multiselect = false;
            bool user_clicked_ok = (load_file.ShowDialog() == DialogResult.OK);

            if (user_clicked_ok == true)
            {
                System.IO.Stream fileStream = load_file.OpenFile();

                try
                {
                    int lines = 0;
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
                    {
                        while (reader.Peek() >= 0)
                        {
                            crawler.computer_list.Add(reader.ReadLine());
                            lines++;
                        }
                    }
                    crawler.computer_list_file = load_file.FileName;
                    update_computer_file_textbox();

                    System.Diagnostics.Debug.WriteLine($"Loaded file {load_file.FileName}. Contains {lines} lines.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Could not open file {load_file.SafeFileName}. Please choose a different file.\nException:\n{ex}", "CrawlerInfo", MessageBoxButtons.OK);
                }
                finally
                {
                    fileStream.Close();
                }
            }
        }
Ejemplo n.º 49
0
        public IniResourceService(string file_ini)
        {
            string Key_Cache = "App.IniResourceService." + HL.Lib.Global.Security.MD5(file_ini);
            object obj = HL.Core.Web.Cache.GetValue(Key_Cache);
            if (obj != null)
                listResource = (Dictionary<string, string>)obj;
            else
            {
                listResource = new Dictionary<string,string>();
                if (System.IO.File.Exists(file_ini))
                {
                    System.IO.StreamReader _StreamReader = new System.IO.StreamReader(file_ini);
                    while (_StreamReader.Peek() != -1)
                    {
                        string s = _StreamReader.ReadLine();

                        if (s == null)
                            continue;

                        s = s.Trim();
                        if (s == string.Empty || s.StartsWith("//"))
                            continue;

                        int index = s.IndexOf('=');
                        if (index == -1)
                            continue;

                        string key = s.Substring(0, index).Trim();
                        string value = s.Substring(index + 1).Trim();

                        listResource[key] = value;
                    }
                    _StreamReader.Close();
                }
                HL.Core.Web.Cache.SetValue(Key_Cache, listResource);
            }
        }
Ejemplo n.º 50
0
        public void ReadEvaluation()
        {
            string evaluationFile = System.IO.Directory.GetCurrentDirectory() + "\\eval.txt";
            if (System.IO.File.Exists(evaluationFile))
            {
                try
                {
                    System.IO.StreamReader fileReader = new System.IO.StreamReader(evaluationFile, true);

                    lblStatus.Text = "Reading Evaluation file.";
                    txtEvaluation.Text = "";
                    while (fileReader.Peek() != -1)
                    {
                        txtEvaluation.Text = fileReader.ReadLine() + "\r\n" + txtEvaluation.Text;
                    }
                    fileReader.Dispose();
                    fileReader.Close();

                    txtEvaluation.SelectionStart = txtEvaluation.Text.Length - 1;
                }
                finally
                {
                    lblStatus.Text = "Completed. Read evaluations in the Evaluation tab.";
                }
            }
            else
            {
                MessageBox.Show("Couldn't find evaluation file.");
            }
        }
Ejemplo n.º 51
0
        public ScriptRunner(string filename)
        {
            this.filename = filename;
            this.global = new Dictionary<string, dynamic>();
            this.function = DefaultFunction.GetDefaultFunctions();
            this.system_command = DefaultFunction.GetDefaultCommand();
            this.constant_value = new Dictionary<string, dynamic>();
            this.literal_checker = DefaultFunction.GetDefaultLiteralChecker();
            var lis = new List<string>();
            using (var stream = new System.IO.StreamReader(filename))
            {
                while (stream.Peek() >= 0)
                {
                    lis.Add(stream.ReadLine());
                }
            }
            var trees = lis.Select((t, index) => new Tree(t, index, filename) as TokenTree);
            
            int i = 0;
            foreach (var v in trees)
            {
                ++i;
                var tree = v.GetTree();
                if (tree.Count == 0)
                    continue;
                var top = tree.First().GetToken() ?? Utility.Throw(new InnerException(tree.First().GetData().ExceptionMessage("invalid command")));
                SFunction func;
                if (system_command.TryGetValue(top, out func))
                {
                    int l = func.ArgumentLength;

                    if (l == -1)
                    {
                        var d = new List<dynamic>();
                        int u = 0;
                        foreach (var e in tree.Skip(1))
                        {
                            var expr = Expression.MakeExpression(tree.Skip(++u).First(), this, new NullFunction(), e.GetData());
                            var k = expr.StaticEval(this);
                            if (k != null)
                                throw new InnerException(e.GetData().ExceptionMessage("this expression is not constant."));
                            d.Add(k);
                        }
                        func.Call(d.ToArray(), this, tree[0].GetData());
                    }
                    else
                    {
                        if (tree.Count() <= func.ArgumentLength)
                            throw new InnerException(top.GetData().ExceptionMessage(string.Format("too few arguments to function '{0}'", func.Name)));
                        var d = new List<dynamic>();
                        for (int m = 0; m < func.ArgumentLength - 1; ++m)
                        {
                            var tu = tree[m + 1];
                            var expr = Expression.MakeExpression(tu, this, new NullFunction(), tu.GetData());
                            var k = expr.StaticEval(this);
                            if (k != null)
                                throw new InnerException(tree[m + 1].GetData().ExceptionMessage("this expression is not constant."));
                            d.Add(k);
                        }
                        var t = tree.Skip(func.ArgumentLength);
                        d.Add(Expression.MakeExpression(t, this, new NullFunction(), t.First().GetData()));
                        func.Call(d.ToArray(), this, tree[0].GetData());
                    }
                }

                if (top == "const")
                {
                    if (tree.Count < 3)
                        throw new InnerException(tree.First().GetData().ExceptionMessage("too few argument to 'const'"));
                    var name = tree.Skip(1).First().GetToken() ?? Utility.Throw(new InnerException(tree.Skip(1).First().GetData().ExceptionMessage("invalid constant value name"))) as string;
                    if (this.constant_value.ContainsKey(name))
                        throw new InnerException(tree.First().GetData().ExceptionMessage(string.Format("constant value '{0}' has been defined", name)));
                    var val = Expression.MakeExpression(tree.Skip(2), this, new NullFunction(), tree.First().GetData()).StaticEval(this);
                }
                if (top == "def")
                {
                    if (tree.Count == 1)
                        throw new InnerException(tree[0].GetData().ExceptionMessage("too few argument to 'def'"));
                    var name = tree[1].GetToken() ?? Utility.Throw(new InnerException(tree[1].GetData().ExceptionMessage("invalid function name")));
                    var cas = new List<string>();
                    foreach (var u in tree.Skip(2))
                    {
                        cas.Add(u.GetToken() ?? Utility.Throw(new InnerException(u.GetData().ExceptionMessage("invalid argument name"))));
                    }
                    this.function.Add(name, new UserDefinedFunction(name, cas, trees.Skip(i), this));
                }
                if (top == "async")
                {
                    if (tree.Count == 1)
                        throw new InnerException(tree[0].GetData().ExceptionMessage("too few argument to 'def'"));
                    var name = tree[1].GetToken() ?? Utility.Throw(new InnerException(tree[1].GetData().ExceptionMessage("invalid function name")));
                    var cas = new List<string>();
                    foreach (var u in tree.Skip(2))
                    {
                        cas.Add(u.GetToken() ?? Utility.Throw(new InnerException(u.GetData().ExceptionMessage("invalid argument name"))));
                    }
                    this.function.Add(name, new UserDefineCoRoutine(name, cas, trees.Skip(i), this));
                }
            }
        }
Ejemplo n.º 52
0
        public void Start(Settings settings)
        {
            foreach (string f in System.IO.Directory.GetFiles(Environment.CurrentDirectory, "*.*", System.IO.SearchOption.TopDirectoryOnly))
            {
                if (f.Contains("."))
                {
                    if (f.Substring(f.LastIndexOf(".", StringComparison.Ordinal)) == ".old")
                    {
                        System.IO.File.Delete(f);
                    }
                }

            }
            Dictionary<string, string> versions = new Dictionary<string, string>();
            foreach (sString f in System.IO.Directory.GetFiles(Environment.CurrentDirectory, "*.*", System.IO.SearchOption.TopDirectoryOnly))
            {
                settings.AddSetting("v_" + f.SubString(f.LastIndexOf("\\") + 1), "1.0.0", false);
            }
            foreach (string key in settings.GetKeys())
            {
                if (key.StartsWith("v_"))
                {
                    string fname = key.Substring(2);
                    if (versions.ContainsKey(fname) == false)
                    {
                        versions.Add(fname, settings.GetSetting(key));
                    }
                }
            }
            try
            {
                System.Net.WebClient wc = new System.Net.WebClient();
                if (System.IO.File.Exists(Environment.CurrentDirectory + "\\files.updt"))
                {
                    System.IO.File.Delete(Environment.CurrentDirectory + "\\files.updt");
                }
                wc.DownloadFile("http://repo.smgi.me/" + Assembly.GetExecutingAssembly().GetName().Name + "/files.updt", Environment.CurrentDirectory + "\\files.updt");
                using (System.IO.StreamReader sR = new System.IO.StreamReader(Environment.CurrentDirectory + "\\files.updt"))
                {
                    while (sR.Peek() != -1)
                    {
                        //Example /asdf.exe:\asdf.exe:1.0.1
                        sString line = sR.ReadLine();
                        if (line != null)
                        {
                            string onlinepath = line.SubString(0, line.nthDexOf(":", 0));
                            sString localpath = line.SubString(line.nthDexOf(":", 0) + 1, line.nthDexOf(":", 1));
                            string version = line.SubString(line.nthDexOf(":", 1) + 1);
                            string name = localpath.SubString(localpath.LastIndexOf("\\") + 1);
                            if (versions.ContainsKey(name) == false)
                            {
                                wc.DownloadFile("http://repo.smgi.me/" + Assembly.GetExecutingAssembly().GetName().Name + onlinepath, Environment.CurrentDirectory + localpath);
                                settings.AddSetting("v_" + name, version);
                                if (updateReady != null)
                                    updateReady(null, new EventArgs());
                            }
                            else
                            {
                                if (version != versions[name])
                                {
                                    if (System.IO.File.Exists(Environment.CurrentDirectory + localpath + ".old"))
                                    {
                                        System.IO.File.Delete(Environment.CurrentDirectory + localpath + ".old");
                                    }
                                    System.IO.File.Move(Environment.CurrentDirectory + localpath, Environment.CurrentDirectory + localpath + ".old");
                                    wc.DownloadFile("http://repo.smgi.me/" + Assembly.GetExecutingAssembly().GetName().Name + onlinepath, Environment.CurrentDirectory + localpath);
                                    settings.AddSetting("v_" + name, version);
                                    if (updateReady != null)
                                        updateReady(null, new EventArgs());
                                }
                            }
                        }
                    }
                }
            }
            catch { }
            if (System.IO.File.Exists(Environment.CurrentDirectory + "\\files.updt"))
            {
                System.IO.File.Delete(Environment.CurrentDirectory + "\\files.updt");
            }
            settings.Save();
        }
Ejemplo n.º 53
0
        //-------------------------------
        // Open the selected log
        //-------------------------------
        private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Lst1.View = View.Details;
            Lst1.FullRowSelect = true;
            Lst1.GridLines = true;
            Lst1.LabelEdit = false;
            Lst1.Items.Clear();
            string fic = Localpath + "\\" + cmb1.SelectedItem.ToString();
            dynamic Data = null;
            bool Heading = false;
            bool AmmoStat = true;
            System.IO.StreamReader sr = new System.IO.StreamReader(fic);
            Heading = true;
            Cleardata();

            while (!(sr.Peek() == -1))
            {
                Data = Strings.Split(sr.ReadLine(), ";");

                if (Heading)
                {
                    Heading = false;

                }
                else
                {
                    ListViewItem item = new ListViewItem("");
                    if (Data[6] == "")
                    {
                        AmmoStat = false;
                    }

                    var _with3 = item;
                    _with3.SubItems.Add(Data[0]);
                    _with3.SubItems.Add(Data[1]);
                    _with3.SubItems.Add(Data[2]);
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[3]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[3]) / Convert.ToDouble(Data[2]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[4]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[4]) / Convert.ToDouble(Data[2]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[5]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[5]) / Convert.ToDouble(Data[2]), "###,###,##0"));
                    _with3.SubItems.Add(Strings.Format((Convert.ToDouble(Data[3]) + Convert.ToDouble(Data[4])) / Convert.ToDouble(Data[2]), "###,###,##0"));
                    if (AmmoStat)
                    {
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[6]), "###,###,##0"));
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[7]), "###,###,##0"));
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble(Data[8]), "###,###,##0"));
                    }
                    else
                    {
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble("0"), "###,###,##0"));
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble("0"), "###,###,##0"));
                        _with3.SubItems.Add(Strings.Format(Convert.ToDouble("0"), "###,###,##0"));
                    }
                    AmmoStat = true;

                    _with3.SubItems.Add(Data[9]);
                    _with3.SubItems.Add(Data[10]);
                    _with3.SubItems.Add(Data[11]);
                    _with3.SubItems.Add(Data[12]);
                    _with3.SubItems.Add(Data[13]);
                    _with3.SubItems.Add(Data[14]);

                    Lst1.Items.Add(item);

                }
            }
            sr.Close();
            Preload();
            StatsMision();
        }
Ejemplo n.º 54
0
        public bool LoadSettingsFile()
        {
            if (System.IO.File.Exists(settingsFile))
            {
                try
                {
                    System.IO.StreamReader fileReader = new System.IO.StreamReader(settingsFile, false);

                    bool writeSettingsAfter = true;

                    lblStatus.Text = "Reading settings file.";
                    int lineNumber = 0;
                    //Reading Data
                    while (fileReader.Peek() != -1)
                    {
                        string fileRow = fileReader.ReadLine();
                        string[] fileDataField = fileRow.Split('=');

                        if (fileDataField.Length > 0)
                        {
                            if (fileDataField[0] == "tradingStrategyExecutable")
                            {
                                if (fileDataField[1].Substring(fileDataField[1].Length - 3, 3) == "jar")
                                {
                                    executableURL = fileDataField[1];
                                }
                            }
                            else if (fileDataField[0] == "argumentsFile")
                            {
                                if (fileDataField[1].Substring(fileDataField[1].Length - 3, 3) == "txt")
                                {
                                    executableArguments = fileDataField[1];
                                }
                            }
                            else if (fileDataField[0] == "evaluatorExecutable")
                            {
                                if (fileDataField[1].Substring(fileDataField[1].Length - 3, 3) == "jar")
                                {
                                    evaluatorURL = fileDataField[1];
                                }
                            }
                            else if (fileDataField[0] == "inputCSVFile")
                            {
                                inputFileURL = fileDataField[1];
                                inputFileName = inputFileURL.Split('/')[inputFileURL.Split('/').Length - 1];
                            }
                            else if (fileDataField[0] == "threshold")
                            {
                                threshold = fileDataField[1];
                                txtVal_Threshold.Text = threshold;
                            }
                            else if (fileDataField[0] == "window")
                            {
                                window = fileDataField[1];
                                txtVal_Window.Text = window;
                            }
                            else if (fileDataField[0] == "importOnStart")
                            {
                                importOnStart = fileDataField[1] == "True";
                                chkAutoImport.Checked = importOnStart;
                            }
                            else if (fileDataField[0] == "version")
                            {
                                if (Convert.ToDouble(version) > Convert.ToDouble(fileDataField[1]))
                                {
                                    version = fileDataField[1];
                                    writeSettingsAfter = true;
                                }
                                else
                                {
                                    writeSettingsAfter = false;
                                }
                            }
                        }
                        lineNumber++;
                    }
                    fileReader.Dispose();
                    fileReader.Close();

                    evaluatorURL = System.IO.Directory.GetCurrentDirectory() + "\\Evaluator.jar";

                    if (writeSettingsAfter)
                    {
                        WriteSettingsFile();
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 55
0
        void ReadUpdateCSV(DataGridView dataInput, string csvPath, bool firstRowIsHeader)
        {
            try
            {
                dataInput.Rows.Clear();
                dataInput.Columns.Clear();
                System.IO.StreamReader fileReader = new System.IO.StreamReader(csvPath, false);

                //Reading Data
                while (fileReader.Peek() != -1)
                {
                    string fileRow = fileReader.ReadLine();
                    string[] fileDataField = fileRow.Split(',');

                    int i = 0;
                    while (dataInput.Columns.Count < fileDataField.Length)
                    {
                        dataInput.Columns.Add(fileDataField[i], fileDataField[i]);
                        if (firstRowIsHeader)
                        {
                            i++;
                        }
                    }
                    if (i == 0) // skipping first line which is header
                    {
                        dataInput.Rows.Add(fileDataField);
                    }
                }
                fileReader.Dispose();
                fileReader.Close();
                lblStatus.Text = "Loaded CSV = " + System.IO.Path.GetFileName(csvPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Couldn't read CSV: " + ex.Message);
            }
        }
Ejemplo n.º 56
0
        private int[] GetLatest(string Symbol)
        {
            string[] tempMonDayYear = new string[3];
            int[] MonDayYear = new int[3];
            string Latest = null;
            char[] delimiters = {'/', ' '};

            try
            {
            string path = @System.IO.Directory.GetCurrentDirectory() + "\\Data\\" + Symbol + "\\" + Symbol + ".csv";
            using (System.IO.StreamReader Sr = new System.IO.StreamReader(@path))
                    {
                        while (Sr.Peek() > 0)
                        {
                            Latest = Sr.ReadLine();
                            //MessageBox.Show(Latest);
                        }
                        Sr.Close();
                        tempMonDayYear = Latest.Split(delimiters);
                        tempMonDayYear[2] = tempMonDayYear[2].Substring(0, 4);
                        MonDayYear[0] = Convert.ToInt32(tempMonDayYear[0]) - 1;
                        MonDayYear[1] = Convert.ToInt16(tempMonDayYear[1]);
                        MonDayYear[2] = Convert.ToInt16(tempMonDayYear[2]);
                    }
            }
            catch (Exception err)
            {
                MessageBox.Show("Error reading " + Symbol + ".csv in " + Symbol + ": \n\n" + err.ToString());
            }
                return MonDayYear;
        }
Ejemplo n.º 57
0
        public static List<LogData> GetZLOGTXTLogList(string filePath)
        {
            List<LogData> loglist = new List<LogData>();
            System.IO.StreamReader sr = new System.IO.StreamReader(filePath, System.Text.Encoding.Default);
            string[] splits;
            string[] columns = new string[11]{
                "mon", "day", "time", "callsign", "sent",
                "rcvd", "multi", "MHz", "mode", "pts", "memo"
            };

            try {
                for(int i = 0;sr.Peek() >= 0;i++) {
                    string str = sr.ReadLine();
                    if(i == 0) {
                        splits = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        if (splits.Count() != 11) return null;
                        for(int j = 0;j < 11;j++) {
                            if(splits[j] != columns[j]) return null;
                        }
                    } else {
                        splits = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                        if(splits.Count() == 0) break;
                        int mon = int.Parse(splits[0]);
                        int day = int.Parse(splits[1]);
                        int time = int.Parse(splits[2]);
                        int hour = time / 100;
                        int min = (time - hour * 100) % 100;
                        DateTime dt = new DateTime(DateTime.Now.Year, mon, day, hour, min, 0);
                        string callsign = splits[3];
                        string scn = splits[4];
                        string rcn = splits[5];
                        int modeno = 8;
                        if(!Regex.IsMatch(splits[modeno], @"[A-Z]+")) {
                            modeno--;
                        }
                        string freq = splits[modeno - 1];
                        string mode = splits[modeno];
                        int pts = int.Parse(splits[modeno + 1]);
                        string ope = "";
                        string rem = "";
                        if (Regex.IsMatch(str, @"(%%.*%%)")) {
                            var m = Regex.Match(str, @"(%%.*%%)(.*)");
                            ope = m.Groups[1].Value;
                            rem = m.Groups[2].Value;
                        } else {
                            for(int ii = modeno + 2;ii < splits.Length; ii++) {
                                rem += splits[ii] + " ";
                            }
                        }
                        loglist.Add(new LogData() {
                            Date = dt, Callsign = callsign, SentCn = scn,
                            ReceivedCn = rcn, Freq = freq + "MHz",
                            Mode = mode, Operator = ope,
                            Point = pts,
                            Rem = rem, IsFinded = false, IsSearched = false,
                        });
                    }
                }
            } catch(Exception e) {
                MessageBox.Show("ログファイル読み込みエラー\r\n" + e.Message, "通知");
                return null;
            }

            sr.Close();

            return loglist;
        }
 private void readFavBtn_Click(object sender, RoutedEventArgs e)
 {
     if (loadResultIndex >= loadNameList.Count) loadResultIndex = 0;
     System.IO.DirectoryInfo dirinfo = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory() + @"\settings\Favorites");
     System.IO.FileInfo[] finfo = dirinfo.GetFiles();
     int fileCount = finfo.Length;
     List<string> loadList = new List<string>();
     for (int i = 0; i < fileCount; i++)
     {
         if (System.Text.RegularExpressions.Regex.IsMatch(finfo[i].Name, @"Summon_.+\.ini"))
         {
             loadList.Add(finfo[i].Name);
         }
     }
     loadNameList = loadList;
     if (loadNameList.Count > 0)
     {
         if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\settings\Favorites\" + loadNameList[loadResultIndex]))
         {
             List<string> txt = new List<string>();
             using (System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.Directory.GetCurrentDirectory() + @"\settings\Favorites\" + loadNameList[loadResultIndex], System.Text.Encoding.UTF8))
             {
                 int lineCount = 0;
                 while (sr.Peek() > 0)
                 {
                     lineCount++;
                     string temp = sr.ReadLine();
                     txt.Add(temp);
                 }
             }
             string[] readFavStr = txt[0].Split('|');
             //version
             int tempFavFileVersion = int.Parse(readFavStr[0]);
             if (tempFavFileVersion < FavFileVersion) this.ShowMessageAsync("", FloatFavouriteFileVersionOld, MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = FloatConfirm, NegativeButtonText = FloatCancel });
             //api
             globalPotionString = readFavStr[1].Replace("|", "[MCH_SPLIT]");
             globalAttrString = readFavStr[2].Replace("|", "[MCH_SPLIT]");
             //spawner
             tabSpawnerShowType.SelectedIndex = int.Parse(readFavStr[3]);
             tabSpawnerHasName.IsChecked = bool.Parse(readFavStr[4]);
             tabSpawnerName.Text = readFavStr[5].Replace("|", "[MCH_SPLIT");
             tabSpawnerHasItemNL.IsChecked = bool.Parse(readFavStr[6]);
             tabSpawnerSpawnCount.Value = int.Parse(readFavStr[7]);
             tabSpawnerSpawnRange.Value = int.Parse(readFavStr[8]);
             tabSpawnerRequiredPlayerRange.Value = int.Parse(readFavStr[9]);
             tabSpawnerDelay.Value = int.Parse(readFavStr[10]);
             tabSpawnerMinSpawnDelay.Value = int.Parse(readFavStr[11]);
             tabSpawnerMaxSpawnDelay.Value = int.Parse(readFavStr[12]);
             tabSpawnerMaxNearbyEntities.Value = int.Parse(readFavStr[13]);
             tabSpawnerAddToInv.IsChecked = bool.Parse(readFavStr[14]);
             tabSpawnerAddToMap.IsChecked = bool.Parse(readFavStr[15]);
             tabSpawnerX.Value = int.Parse(readFavStr[16]);
             tabSpawnerY.Value = int.Parse(readFavStr[17]);
             tabSpawnerZ.Value = int.Parse(readFavStr[18]);
             //sumos
             tabSumosType.SelectedIndex = int.Parse(readFavStr[19]);
             tabSumosHasPotion.IsChecked = bool.Parse(readFavStr[20]);
             tabSumosHasMetaData.IsChecked = bool.Parse(readFavStr[21]);
             tabSumosNoAI.IsChecked = bool.Parse(readFavStr[22]);
             tabSumosInvulnerable.IsChecked = bool.Parse(readFavStr[23]);
             tabSumosSilent.IsChecked = bool.Parse(readFavStr[24]);
             tabSumosBaby.IsChecked = bool.Parse(readFavStr[25]);
             tabSumosHasName.IsChecked = bool.Parse(readFavStr[26]);
             tabSumosName.Text = readFavStr[27].Replace("|", "[MCH_SPLIT");
             tabSumosNameVisible.IsChecked = bool.Parse(readFavStr[28]);
             tabSumosNowHealthCheck.IsChecked = bool.Parse(readFavStr[29]);
             tabSumosNowHealth.Value = int.Parse(readFavStr[30]);
             tabSumosLHand.SelectedIndex = int.Parse(readFavStr[31]);
             tabSumosNumLHand.Value = int.Parse(readFavStr[32]);
             globalSumosLHand = readFavStr[33].Replace("|", "[MCH_SPLIT");
             tabSumosHand.SelectedIndex = int.Parse(readFavStr[34]);
             tabSumosNumHand.Value = int.Parse(readFavStr[35]);
             globalSumosHand = readFavStr[36].Replace("|", "[MCH_SPLIT");
             tabSumosBoot.SelectedIndex = int.Parse(readFavStr[37]);
             tabSumosNumBoot.Value = int.Parse(readFavStr[38]);
             globalSumosBoot = readFavStr[39].Replace("|", "[MCH_SPLIT");
             tabSumosLeg.SelectedIndex = int.Parse(readFavStr[40]);
             tabSumosNumLeg.Value = int.Parse(readFavStr[41]);
             globalSumosLeg = readFavStr[42].Replace("|", "[MCH_SPLIT");
             tabSumosChest.SelectedIndex = int.Parse(readFavStr[43]);
             tabSumosNumChest.Value = int.Parse(readFavStr[44]);
             globalSumosChest = readFavStr[45].Replace("|", "[MCH_SPLIT");
             tabSumosHead.SelectedIndex = int.Parse(readFavStr[46]);
             tabSumosNumHead.Value = int.Parse(readFavStr[47]);
             globalSumosHead = readFavStr[48].Replace("|", "[MCH_SPLIT");
             tabSumosHasHeadID.IsChecked = bool.Parse(readFavStr[49]);
             tabSumosHeadID.Text = readFavStr[50].Replace("|", "[MCH_SPLIT");
             tabSumosLeftHand.IsChecked = bool.Parse(readFavStr[51]);
             tabSumosGlowing.IsChecked = bool.Parse(readFavStr[52]);
             tabSumosFireCheck.IsChecked = bool.Parse(readFavStr[53]);
             tabSumosFireNum.Value = int.Parse(readFavStr[54]);
             tabSumosPersistenceRequired.IsChecked = bool.Parse(readFavStr[55]);
             tabSumosElytra.IsChecked = bool.Parse(readFavStr[56]);
             tabSumosTagsCheck.IsChecked = bool.Parse(readFavStr[57]);
             tabSumosTags.Text = readFavStr[58].Replace("|", "[MCH_SPLIT").Replace("\r\n", "[MCH_ENTER");
             tabSumosArmorNogravity.IsChecked = bool.Parse(readFavStr[59]);
             tabSumosTeamCheck.IsChecked = bool.Parse(readFavStr[60]);
             tabSumosTeam.Text = readFavStr[61].Replace("|", "[MCH_SPLIT");
             tabSumosDropchance.IsChecked = bool.Parse(readFavStr[62]);
             tabSumosDCHand.Value = float.Parse(readFavStr[63]);
             tabSumosDCChest.Value = float.Parse(readFavStr[64]);
             tabSumosDCBoot.Value = float.Parse(readFavStr[65]);
             tabSumosDCHead.Value = float.Parse(readFavStr[66]);
             tabSumosDCLeg.Value = float.Parse(readFavStr[67]);
             tabSumosDCLHand.Value = float.Parse(readFavStr[68]);
             tabSumosMotionCheck.IsChecked = bool.Parse(readFavStr[69]);
             tabSumosMotionX.Value = float.Parse(readFavStr[70]);
             tabSumosMotionY.Value = float.Parse(readFavStr[71]);
             tabSumosMotionZ.Value = float.Parse(readFavStr[72]);
             tabSumosDirection.IsChecked = bool.Parse(readFavStr[73]);
             tabSumosDirectionX.Value = float.Parse(readFavStr[74]);
             tabSumosDirectionY.Value = float.Parse(readFavStr[75]);
             tabSumosEUUID.Text = readFavStr[76].Replace("|", "[MCH_SPLIT");
             tabSumosEWoolColor.SelectedIndex = int.Parse(readFavStr[77]);
             tabSumosEdamage.Value = int.Parse(readFavStr[78]);
             tabSumosEOwner.Text = readFavStr[79].Replace("|", "[MCH_SPLIT");
             tabSumosEZombieType.Value = int.Parse(readFavStr[80]);
             tabSumosEExplosionRadius.Value = int.Parse(readFavStr[81]);
             tabSumosEDragon.Value = int.Parse(readFavStr[82]);
             tabSumosESize.Value = int.Parse(readFavStr[83]);
             tabSumosEShulkerPeek.Value = int.Parse(readFavStr[84]);
             tabSumosEpickup.Value = int.Parse(readFavStr[85]);
             tabSumosEThrower.Text = readFavStr[86].Replace("|", "[MCH_SPLIT");
             tabSumosEFuse.Value = int.Parse(readFavStr[87]);
             tabSumosEExplosionPower.Value = int.Parse(readFavStr[88]);
             tabSumosECatType.Value = int.Parse(readFavStr[89]);
             tabSumosERabbitType.Value = int.Parse(readFavStr[90]);
             tabSumosEInvul.Value = int.Parse(readFavStr[91]);
             tabSumosEExp.Value = int.Parse(readFavStr[92]);
             tabSumosEPowered.IsChecked = bool.Parse(readFavStr[93]);
             tabSumosEAtkByEnderman.IsChecked = bool.Parse(readFavStr[94]);
             tabSumosECanBreakDoor.IsChecked = bool.Parse(readFavStr[95]);
             tabSumosESheared.IsChecked = bool.Parse(readFavStr[96]);
             tabSumosEElder.IsChecked = bool.Parse(readFavStr[97]);
             tabSumosESaddle.IsChecked = bool.Parse(readFavStr[98]);
             tabSumosEAngry.IsChecked = bool.Parse(readFavStr[99]);
             tabSumosEPlayerCreated.IsChecked = bool.Parse(readFavStr[100]);
             tabSumosEDuration.Value = float.Parse(readFavStr[101]);
             tabSumosERadius.Value = float.Parse(readFavStr[102]);
             globalParticleSel = int.Parse(readFavStr[103]);
             globalParticlePara1 = int.Parse(readFavStr[104]);
             globalParticlePara2 = int.Parse(readFavStr[105]);
             globalParticleColor = readFavStr[106];
             //summon item
             tabSummonItem.SelectedIndex = int.Parse(readFavStr[107]);
             tabSummonCount.Value = int.Parse(readFavStr[108]);
             tabSummonMeta.Value = int.Parse(readFavStr[109]);
             tabSummonHasEnchant.IsChecked = bool.Parse(readFavStr[110]);
             tabSummonHasNL.IsChecked = bool.Parse(readFavStr[111]);
             tabSummonHasAttr.IsChecked = bool.Parse(readFavStr[112]);
             tabSummonUnbreaking.IsChecked = bool.Parse(readFavStr[113]);
             tabSummonHide.SelectedIndex = int.Parse(readFavStr[114]);
             tabSummonPickupdelayCheck.IsChecked = bool.Parse(readFavStr[115]);
             tabSummonPickupdelay.Value = int.Parse(readFavStr[116]);
             tabSummonAgeCheck.IsChecked = bool.Parse(readFavStr[117]);
             tabSummonAge.Value = int.Parse(readFavStr[118]);
             //armorstand
             tabSumosArmorCheck.IsChecked = bool.Parse(readFavStr[119]);
             tabSumosMarker.IsChecked = bool.Parse(readFavStr[120]);
             tabSumosArmorHeadX.Value = int.Parse(readFavStr[121]);
             tabSumosArmorHeadY.Value = int.Parse(readFavStr[122]);
             tabSumosArmorHeadZ.Value = int.Parse(readFavStr[123]);
             tabSumosArmorBodyX.Value = int.Parse(readFavStr[124]);
             tabSumosArmorBodyY.Value = int.Parse(readFavStr[125]);
             tabSumosArmorBodyZ.Value = int.Parse(readFavStr[126]);
             tabSumosArmorLArmX.Value = int.Parse(readFavStr[127]);
             tabSumosArmorLArmY.Value = int.Parse(readFavStr[128]);
             tabSumosArmorLArmZ.Value = int.Parse(readFavStr[129]);
             tabSumosArmorRArmX.Value = int.Parse(readFavStr[130]);
             tabSumosArmorRArmY.Value = int.Parse(readFavStr[131]);
             tabSumosArmorRArmZ.Value = int.Parse(readFavStr[132]);
             tabSumosArmorLLegX.Value = int.Parse(readFavStr[133]);
             tabSumosArmorLLegY.Value = int.Parse(readFavStr[134]);
             tabSumosArmorLLegZ.Value = int.Parse(readFavStr[135]);
             tabSumosArmorRLegX.Value = int.Parse(readFavStr[136]);
             tabSumosArmorRLegY.Value = int.Parse(readFavStr[137]);
             tabSumosArmorRLegZ.Value = int.Parse(readFavStr[138]);
             tabSumosArmorRotationCheck.IsChecked = bool.Parse(readFavStr[139]);
             tabSumosArmorRotationX.Value = int.Parse(readFavStr[140]);
             tabSumosArmorRotationY.Value = int.Parse(readFavStr[141]);
             tabSumosArmorRotationZ.Value = int.Parse(readFavStr[142]);
             tabSumosArmorShowarmor.IsChecked = bool.Parse(readFavStr[143]);
             tabSumosArmorNochestplate.IsChecked = bool.Parse(readFavStr[144]);
             tabSumosArmorCant.IsChecked = bool.Parse(readFavStr[145]);
             //horse
             HorseTypeHorse.IsChecked = bool.Parse(readFavStr[146]);
             HorseTypeDonkey.IsChecked = bool.Parse(readFavStr[147]);
             HorseTypeMule.IsChecked = bool.Parse(readFavStr[148]);
             HorseTypeZombie.IsChecked = bool.Parse(readFavStr[149]);
             HorseTypeSkeleton.IsChecked = bool.Parse(readFavStr[150]);
             HorseHasChest.IsChecked = bool.Parse(readFavStr[151]);
             HorseTamedUUID.Text = readFavStr[152].Replace("|", "[MCH_SPLIT");
             HorseVariantValue.Value = int.Parse(readFavStr[153]);
             HorseTemper.Value = int.Parse(readFavStr[154]);
             HorseSkeletonTrapTime.Value = int.Parse(readFavStr[155]);
             HorseTamed.IsChecked = bool.Parse(readFavStr[156]);
             HorseSkeletonTrap.IsChecked = bool.Parse(readFavStr[157]);
             HorseSaddle.IsChecked = bool.Parse(readFavStr[158]);
             HorseChestList[-6] = readFavStr[159].Replace("|", "[MCH_SPLIT");
             HorseChestList[-5] = readFavStr[160].Replace("|", "[MCH_SPLIT");
             HorseChestList[-4] = readFavStr[161].Replace("|", "[MCH_SPLIT");
             HorseChestList[-3] = readFavStr[162].Replace("|", "[MCH_SPLIT");
             HorseChestList[-2] = readFavStr[163].Replace("|", "[MCH_SPLIT");
             HorseChestList[-1] = readFavStr[164].Replace("|", "[MCH_SPLIT");
             HorseChestList[0] = readFavStr[165].Replace("|", "[MCH_SPLIT");
             HorseChestList[1] = readFavStr[166].Replace("|", "[MCH_SPLIT");
             HorseChestList[2] = readFavStr[167].Replace("|", "[MCH_SPLIT");
             HorseChestList[3] = readFavStr[168].Replace("|", "[MCH_SPLIT");
             HorseChestList[4] = readFavStr[169].Replace("|", "[MCH_SPLIT");
             HorseChestList[5] = readFavStr[170].Replace("|", "[MCH_SPLIT");
             HorseChestList[6] = readFavStr[171].Replace("|", "[MCH_SPLIT");
             HorseChestList[7] = readFavStr[172].Replace("|", "[MCH_SPLIT");
             HorseChestList[8] = readFavStr[173].Replace("|", "[MCH_SPLIT");
             HorseChestList[9] = readFavStr[174].Replace("|", "[MCH_SPLIT");
             HorseChestList[10] = readFavStr[175].Replace("|", "[MCH_SPLIT");
             //FallingSands
             FallingSandItemSel.SelectedIndex = int.Parse(readFavStr[176]);
             FallingSandMeta.Value = int.Parse(readFavStr[177]);
             FallingSandLifeTime.Value = int.Parse(readFavStr[178]);
             FallingSandIsDrop.IsChecked = bool.Parse(readFavStr[179]);
             FallingSandIsDamage.IsChecked = bool.Parse(readFavStr[180]);
             FallingSandMaxDamage.Value = int.Parse(readFavStr[181]);
             FallingSandDamageCount.Value = int.Parse(readFavStr[182]);
             //ItemFrame
             FrameCoCheck.IsChecked = bool.Parse(readFavStr[183]);
             FrameX.Value = int.Parse(readFavStr[184]);
             FrameY.Value = int.Parse(readFavStr[185]);
             FrameZ.Value = int.Parse(readFavStr[186]);
             FrameFacing.Value = int.Parse(readFavStr[187]);
             FrameDropChance.Value = int.Parse(readFavStr[188]);
             FrameRouteCount.Value = int.Parse(readFavStr[189]);
             FrameHasItem.IsChecked = bool.Parse(readFavStr[190]);
             globalFrameItem[-6] = readFavStr[191];
             globalFrameItem[-5] = readFavStr[192];
             globalFrameItem[-4] = readFavStr[193];
             globalFrameItem[-3] = readFavStr[194];
             //
             this.ShowMessageAsync("", "已读取:" + loadNameList[loadResultIndex], MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = FloatConfirm, NegativeButtonText = FloatCancel, AnimateShow = false, AnimateHide = false });
         }
         loadResultIndex++;
     }
     else
     {
         this.ShowMessageAsync(FloatErrorTitle, FloatSaveFileCantFind, MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = FloatConfirm, NegativeButtonText = FloatCancel });
     }
 }
Ejemplo n.º 59
0
        public void ReadLog()
        {
            if (System.IO.File.Exists(settingsFile))
            {
                try
                {
                    System.IO.StreamReader fileReader = new System.IO.StreamReader(System.IO.Path.GetDirectoryName(executableURL) + "\\MomentumStrategyModule.log", true);

                    lblStatus.Text = "Reading log file.";

                    while (fileReader.Peek() != -1)
                    {
                        txtLog.Text = fileReader.ReadLine() + "\r\n" + txtLog.Text;
                    }
                    fileReader.Dispose();
                    fileReader.Close();

                    txtLog.SelectionStart = txtLog.Text.Length - 1;
                }
                finally
                {
                    lblStatus.Text = "Completed. Read logs in the Log tab.";
                }
            }
        }
Ejemplo n.º 60
0
 private void loadFormats()
 {
     if (formats == null)
     {
         formats = new System.Collections.ArrayList();
         try
         {
             //logger.debug("Starting loading Formats...");
             //UPGRADE_TODO: The differences in the expected value  of parameters for constructor 'java.io.BufferedReader.BufferedReader'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
             //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
             //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.getResourceAsStream' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassLoader'"
             //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassgetClassLoader'"
             System.IO.StreamReader reader = new System.IO.StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenCDKSharp." + IO_FORMATS_LIST));//new System.IO.StreamReader(this.GetType().getClassLoader().getResourceAsStream(IO_FORMATS_LIST), System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(this.GetType().getClassLoader().getResourceAsStream(IO_FORMATS_LIST), System.Text.Encoding.Default).CurrentEncoding);
             int formatCount = 0;
             while (reader.Peek() != -1)
             {
                 // load them one by one
                 System.String formatName = reader.ReadLine();
                 formatCount++;
                 try
                 {
                     //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassLoader'"
                     //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassgetClassLoader'"
                     ObjectHandle handle = System.Activator.CreateInstance("NuGenCDKSharp", formatName);
                     IResourceFormat format = (IResourceFormat)handle.Unwrap();//System.Activator.CreateInstance(//this.GetType().getClassLoader().loadClass(formatName));
                     if (format is IChemFormat)
                     {
                         formats.Add(format);
                         //logger.info("Loaded IChemFormat: " + format.GetType().FullName);
                     }
                 }
                 //UPGRADE_NOTE: Exception 'java.lang.ClassNotFoundException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                 catch (System.Exception exception)
                 {
                     //logger.error("Could not find this IResourceFormat: ", formatName);
                     //logger.debug(exception);
                 }
                 //catch (System.Exception exception)
                 //{
                 //    //logger.error("Could not load this IResourceFormat: ", formatName);
                 //    //logger.debug(exception);
                 //}
             }
             //logger.info("Number of loaded formats used in detection: ", formatCount);
         }
         catch (System.Exception exception)
         {
             //logger.error("Could not load this io format list: ", IO_FORMATS_LIST);
             //logger.debug(exception);
         }
     }
 }