Ejemplo n.º 1
0
        void compilarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Checker ch = new Checker();

            RTB.SelectAll();
            RTB.SelectionColor = Color.Red;
            RTB.Select(0, 0);

            Pbar.Minimum = 0;
            Pbar.Maximum = 20;
            Pbar.Step    = 1;
            Pbar.Value   = 0;

            int aux = 0;

            for (int i = 0; i < 40; i++)
            {
                //si la palabra existe busca hasta donde se encuentra la ultima palabra
                while (aux < RTB.Text.LastIndexOf(ch.findWord(i)))
                {
                    //busca la palabra y la selecciona desde un caracter espesificado (aux) hasta el final del texto
                    RTB.Find(ch.findWord(i), aux, RTB.Text.Length, RichTextBoxFinds.None);
                    //cambia el color a... verde agua?
                    RTB.SelectionColor = Color.Aqua;
                    //busca la palabra a partir de una posision indicada y guarda la posicion +1 para buscar la siguiente
                    aux = RTB.Text.IndexOf(ch.findWord(i), aux) + 1;
                }
                Pbar.PerformStep();
                //resetea la posicion
                aux = 0;
            }
        }
Ejemplo n.º 2
0
        public static void SelectNextMatched()
        {
            RTB.Focus();
            if (_matches.Length == 0)
            {
                return;
            }
            PositionInMatches p = CursorBetweenMatches();

            if (p.NextMatchedNumber >= _matches.Length)
            {
                return;
            }
            int selectMatches;

            if (p.CursorOnBeginMatchedItem && RTB.SelectionLength != _matches[p.PreviosMatchedNumber].Y) //if no previus matched selected, select it, other select next matched
            {
                selectMatches = p.PreviosMatchedNumber;
            }
            else
            {
                selectMatches = p.NextMatchedNumber;
            }

            if (selectMatches < 0)
            {
                selectMatches = 0;
            }
            //if (selectMatches > _matches.Length - 1) selectMatches = _matches.Length - 1; canceled: added check in start of function

            RTB.Select(_matches[selectMatches].X, _matches[selectMatches].Y);
            CurrentMatchedSelected = selectMatches + 1;
        }
Ejemplo n.º 3
0
        public static void SelectPreviosMatched()
        {
            RTB.Focus();
            if (_matches.Length == 0)
            {
                return;
            }
            PositionInMatches p = CursorBetweenMatches();
            int selectMatches   = p.PreviosMatchedNumber;

            if (selectMatches < 0)
            {
                return;
            }
            if (p.CursorOnBeginMatchedItem)
            {
                selectMatches--;
            }
            if (selectMatches < 0)
            {
                selectMatches = 0;
            }

            RTB.Select(_matches[selectMatches].X, _matches[selectMatches].Y);
            CurrentMatchedSelected = selectMatches + 1;
        }
Ejemplo n.º 4
0
 private void printout(string str)
 {
     if (CHK_NoPrint.Checked)
     {
         return;
     }
     RTB.Text += str;
     RTB.Select(RTB.Text.Length - 1, 0);
     RTB.ScrollToCaret();
 }
Ejemplo n.º 5
0
        private void B_Go_Click(object sender, EventArgs e)
        {
            // Continue only if a string path is loaded.
            if (textBox1.Text.Length < 1)
            {
                return;
            }

            // Fetch file extension (first 4 bytes) to check if it is a GARC
            BinaryReader brz = new BinaryReader(System.IO.File.OpenRead(textBox1.Text));

            try {
                string s = new string(Reverse(brz.ReadChars(4)));
                if (s != "GARC")
                {
                    RTB.Text += "Input file is not a .GARC";
                    return;
                }
                RTB.Text = s;
            }
            catch (EncoderFallbackException)
            {
                RTB.Text += "Invalid File.";
                return;
            }
            brz.Close();

            // Unpack the GARC
            GARC garc = ARC.Unpack(textBox1.Text);

            RTB.Text += "\r\nCount: " + garc.otaf.nFiles;
            ProgressInit(garc.otaf.nFiles);
            if (garc.otaf.nFiles > 50)
            {
                CHK_NoPrint.Checked = true;
            }

            // Get file path infos for exporting
            FileInfo     fileInfo   = new FileInfo(textBox1.Text);
            string       path       = fileInfo.DirectoryName;
            string       parentName = fileInfo.Name;
            string       basepath   = path + "\\" + parentName + "_";
            BinaryReader br         = new BinaryReader(System.IO.File.OpenRead(textBox1.Text));

            // Create Extraction folder if it does not exist.
            if (!Directory.Exists(basepath))
            {
                DirectoryInfo di = Directory.CreateDirectory(basepath);
            }

            // Pull out all the files
            for (int i = 0; i < garc.otaf.nFiles; i++)
            {
                string ext        = "bin";
                bool   compressed = false;

                string newext;
                br.BaseStream.Position = garc.btaf.entries[i].start_offset + garc.data_offset;
                try
                {
                    newext = TrimFromZero(new string(br.ReadChars(4)));
                    if ((System.Text.RegularExpressions.Regex.IsMatch(newext, @"^[a-zA-Z0-9]+$")) && (!CHK_ForceBIN.Checked))
                    {
                        ext = newext;
                    }
                    else
                    {
                        compressed = true;
                    }
                }
                catch { newext = null; }

                // Set File Name
                string       filename = i.ToString("D" + Math.Ceiling(Math.Log10(garc.otaf.nFiles)));
                string       fileout  = basepath + "\\" + filename + "." + ext;
                BinaryWriter bw       = new BinaryWriter(File.OpenWrite(fileout));

                // Write out the data for the file
                br.BaseStream.Position = garc.btaf.entries[i].start_offset + garc.data_offset;
                for (int x = 0; x < garc.btaf.entries[i].length; x++)
                {
                    bw.Write(br.ReadByte());
                }
                bw.Flush(); bw.Close();
                printout("\r\nWrote to " + fileout);

                // See if decompression should be attempted.
                if (compressed && !CHK_SkipDecompress.Checked)
                {
                    string decout = path + "\\" + parentName + "_\\" + "dec_" + filename;
                    string result = LZSS.Decompress11LZS(fileout, decout);

                    if (result != null)
                    {
                        printout("\r\n" + result);
                        if (CHK_delAfterD.Checked)
                        {
                            try { File.Delete(fileout); }
                            catch { }
                        }
                    }
                }
                pBar1.PerformStep();
            }
            br.Close();

            RTB.Text += "\r\nDone!";
            RTB.Select(RTB.Text.Length - 1, 0);
            RTB.ScrollToCaret();
        }
Ejemplo n.º 6
0
 void resetColor()
 {
     RTB.SelectAll();
     RTB.SelectionColor = Color.Black;
     RTB.Select(0, 0);
 }