Пример #1
0
        private void RT_Tick(object sender, EventArgs e)
        {
            string buff = null;

            lock (sb)
            {
                if (sb.Length > 0)
                {
                    buff      = sb.ToString();
                    sb.Length = 0;
                }
            }

            if (buff != null)
            {
                RTB.Text = RTB.Text + buff;

                if (RTB.TextLength > 10000)
                {
                    RTB.Text = RTB.Text.Substring(RTB.Text.Length - 10000);
                }

                RTB.SelectionStart = RTB.TextLength;
                RTB.ScrollToCaret();
            }
        }
Пример #2
0
 private void printout(string str)
 {
     if (CHK_NoPrint.Checked)
     {
         return;
     }
     RTB.Text += str;
     RTB.Select(RTB.Text.Length - 1, 0);
     RTB.ScrollToCaret();
 }
Пример #3
0
        // key input filter listener
        private void HandleKeyInputResultAction(InputEventsFilterHandlerArgs args)
        {
            switch (args.Result)
            {
            case KeyInputFilterResult.Input_Submit:
                SubmitInput();
                args.IsHandled = true;
                break;

            case KeyInputFilterResult.Input_ShowPreviousHistory:
                ShowPreviousSubmit();
                args.IsHandled = true;
                break;

            case KeyInputFilterResult.Input_ShowNextHistory:
                ShowNextSubmit();
                args.IsHandled = true;
                break;

            case KeyInputFilterResult.Input_Focus:
                RTB.ScrollToCaret();
                args.IsHandled = true;
                break;

            case KeyInputFilterResult.Input_MoveToStart:
                RTB.SelectionStart = _inputStartPosition;
                args.IsHandled     = true;
                break;

            case KeyInputFilterResult.Input_SelectToStart:
                int endSelect = RTB.SelectionStart;
                RTB.SelectionStart  = _inputStartPosition;
                RTB.SelectionLength = endSelect - _inputStartPosition;
                break;

            case KeyInputFilterResult.Exec_CancelCommandExecution:
                args.IsHandled = true;
                if (_invoker.IsExecuting)    // if the invoker is not executing, then assume the system is executing (e.g., on startup) and cannot be canceled
                {
                    _invoker.CancelExecution();
                }
                break;
            }
        }
Пример #4
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();
        }
Пример #5
0
        private void RTBTextChange(object sender, EventArgs e)
        {
            RTB.SelectionStart = RTB.Text.Length;

            RTB.ScrollToCaret();
        }