Ejemplo n.º 1
0
        private void OnHostWriterActionHandler(string str, HostWriterContext context)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { OnHostWriterActionHandler(str, context); });
            }
            else
            {
                System.Drawing.Color backupForecolor = RTB.SelectionColor;
                System.Drawing.Color backupHighlight = RTB.SelectionBackColor;

                if (context.ForeColor != System.Drawing.Color.Empty)
                {
                    RTB.SelectionColor = context.ForeColor;
                }

                if (context.HighlightColor != System.Drawing.Color.Empty)
                {
                    RTB.SelectionBackColor = context.HighlightColor;
                }

                RTB.AppendText(str);

                RTB.SelectionFont      = Constants.FONT_STANDARD;
                RTB.SelectionColor     = backupForecolor;
                RTB.SelectionBackColor = backupHighlight;
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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.º 4
0
        private void loadwcdata()
        {
            try
            {
                if ((wondercard_data[0x52] & 2) != 0) // is used
                {
                    if (DialogResult.Yes !=
                        Util.Prompt(MessageBoxButtons.YesNo,
                                    "Wonder Card is marked as USED and will not be able to be picked up in-game.",
                                    "Do you want to remove the USED flag so that it is UNUSED?"))
                    {
                        return;
                    }

                    wondercard_data[0x52] &= 0xFD; // keep all bits but bit1 (11111101)
                }
                RTB.Text         = getWCDescriptionString(wondercard_data);
                PB_Preview.Image = getWCPreviewImage(wondercard_data);
            }
            catch (Exception e)
            {
                Util.Error("Loading of data failed... is this really a Wonder Card?", e.ToString());
                Array.Copy(new byte[WC6.Size], wondercard_data, WC6.Size);
                RTB.Clear();
            }
        }
Ejemplo n.º 5
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.º 6
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.º 7
0
        private void loadwcdata()
        {
            if (wc6 == null)
            {
                return;
            }
            try
            {
                if (wc6.GiftUsed && DialogResult.Yes ==
                    Util.Prompt(MessageBoxButtons.YesNo,
                                "Wonder Card is marked as USED and will not be able to be picked up in-game.",
                                "Do you want to remove the USED flag so that it is UNUSED?"))
                {
                    wc6.GiftUsed = false;
                }

                RTB.Text         = wc6.Description;
                PB_Preview.Image = wc6.Preview;
            }
            catch (Exception e)
            {
                Util.Error("Loading of data failed... is this really a Wonder Card?", e.ToString());
                wc6 = new WC6();
                RTB.Clear();
            }
        }
Ejemplo n.º 8
0
        private void loadwcdata()
        {
            try
            {
                // Load up the data according to the wiki!
                int cardID = BitConverter.ToUInt16(wondercard_data, 0);
                if (cardID == 0)
                {
                    RTB.Text = "Empty Slot. No data!";
                    return;
                }
                string cardname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48));
                int    cardtype = wondercard_data[0x51];
                string s        = "";
                s += "Card #: " + cardID.ToString("0000") + Environment.NewLine + cardname + Environment.NewLine + Environment.NewLine;

                if (cardtype == 1) // Item
                {
                    int item = BitConverter.ToUInt16(wondercard_data, 0x68);
                    int qty  = BitConverter.ToUInt16(wondercard_data, 0x70);

                    s += "Item: " + Form1.itemlist[item] + Environment.NewLine + "Quantity: " + qty.ToString();
                }
                else if (cardtype == 0) // PKM
                {
                    int species  = BitConverter.ToUInt16(wondercard_data, 0x82);
                    int helditem = BitConverter.ToUInt16(wondercard_data, 0x78);
                    int move1    = BitConverter.ToUInt16(wondercard_data, 0x7A);
                    int move2    = BitConverter.ToUInt16(wondercard_data, 0x7C);
                    int move3    = BitConverter.ToUInt16(wondercard_data, 0x7E);
                    int move4    = BitConverter.ToUInt16(wondercard_data, 0x80);
                    int TID      = BitConverter.ToUInt16(wondercard_data, 0x68);
                    int SID      = BitConverter.ToUInt16(wondercard_data, 0x6A);

                    string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22));
                    s +=
                        "Species: " + Form1.specieslist[species] + Environment.NewLine
                        + "Item: " + Form1.itemlist[helditem] + Environment.NewLine
                        + "Move 1: " + Form1.movelist[move1] + Environment.NewLine
                        + "Move 2: " + Form1.movelist[move2] + Environment.NewLine
                        + "Move 3: " + Form1.movelist[move3] + Environment.NewLine
                        + "Move 4: " + Form1.movelist[move4] + Environment.NewLine
                        + "OT: " + OTname + Environment.NewLine
                        + "ID: " + TID.ToString() + "/" + SID.ToString();
                }
                else
                {
                    s = "Unsupported Wondercard Type!";
                }
                RTB.Text = s;
            }
            catch (Exception e)
            {
                Util.Error("Loading of data failed... is this really a Wondercard?", e.ToString());
                Array.Copy(new byte[0x108], wondercard_data, 0x108);
                RTB.Clear();
                return;
            }
        }
Ejemplo n.º 9
0
        public Form1()
        {
            InitializeComponent();

            this.DragEnter += new DragEventHandler(Form_DragEnter);
            this.DragDrop  += new DragEventHandler(Form_DragDrop);
            RTB.Clear();
        }
Ejemplo n.º 10
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.º 11
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            savedlg.Filter = "Vsichki failove| *.*|Textovei Failove| *.txt| Formatirani failove|*.rtf";
            DialogResult answer = savedlg.ShowDialog();

            if (answer == DialogResult.OK)
            {
                RTB.SaveFile(savedlg.FileName, RichTextBoxStreamType.RichText);
                pathFile = savedlg.FileName;
            }
        }
Ejemplo n.º 12
0
        private void mnuOpen_Click(object sender, EventArgs e)
        {
            opendlg.Filter      = "Vsichki failove| *.*|Textovei Failove| *.txt| Formatirani failove|*.rtf";
            opendlg.FilterIndex = 2;
            DialogResult answer = opendlg.ShowDialog();

            if (answer == DialogResult.OK)
            {
                RTB.LoadFile(opendlg.FileName, RichTextBoxStreamType.RichText);
            }
        }
Ejemplo n.º 13
0
 public void Clear()
 {
     if (RTB.InvokeRequired)
     {
         RTB.Invoke((MethodInvoker) delegate { Clear(); });
     }
     else
     {
         RTB.Clear();
     }
 }
Ejemplo n.º 14
0
 private void mnuSave_Click(object sender, EventArgs e)
 {
     if (pathFile == "")
     {
         saveAsToolStripMenuItem_Click(sender, e);
     }
     else
     {
         RTB.SaveFile(savedlg.FileName, RichTextBoxStreamType.RichText);
     }
     pathFile = opendlg.FileName;
 }
Ejemplo n.º 15
0
 private void loadwcdata()
 {
     try
     {
         RTB.Text         = getWCDescriptionString(wondercard_data);
         PB_Preview.Image = getWCPreviewImage(wondercard_data);
     }
     catch (Exception e)
     {
         Util.Error("Loading of data failed... is this really a Wondercard?", e.ToString());
         Array.Copy(new byte[0x108], wondercard_data, 0x108);
         RTB.Clear();
     }
 }
Ejemplo n.º 16
0
        public Form1()
        {
            InitializeComponent();
            int    i1 = 3 * 4;
            int    i2 = 12 / 4;
            int    i3 = 14 / 4;
            int    i4 = 15 % 4;
            int    i5 = 2 + 3 * 4;
            int    i6 = 2 + (3 * 4) / (2 - 4);
            double d1 = 3.1 * 2.3;
            double d2 = 1.0 / 3.0;
            double d3 = 1 / 3;

            RTB.AppendText(i1 + "\n" + i2 + "\n" + i3 + "\n" + i4 + "\n" + i5 + "\n" + i6 + "\n");
            RTB.AppendText(d1 + "\n" + d2 + "\n" + d3 + "\n");

            string st = "3";

            try
            {
                int it = int.Parse(st);
            }
            catch
            {
                MessageBox.Show(st + " is not an integar");
            }

            string s2 = "3.2";

            try
            {
                int it = int.Parse(s2);
            }
            catch
            {
                MessageBox.Show(s2 + " is not an integer");
                int i7 = 0;
            }

            string s3 = "pi";

            try
            {
                double d7 = double.Parse(s3);
            }
            catch
            {
                double d7 = 0;
            }
        }
        private void loadwcdata()
        {
            // Load up the data according to the wiki!
            int cardID = BitConverter.ToUInt16(wondercard_data, 0);

            if (cardID == 0)
            {
                RTB.Text = "Empty Slot. No data!";
                return;
            }
            string cardname = Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48);
            int    cardtype = wondercard_data[0x51];

            RTB.Clear();
            RTB.AppendText("Card #: " + cardID.ToString("0000") + "\r\n" + cardname + "\r\n");

            if (cardtype == 1) // Item
            {
                int item = BitConverter.ToUInt16(wondercard_data, 0x68);
                int qty  = BitConverter.ToUInt16(wondercard_data, 0x70);

                RTB.AppendText("\r\nItem: " + Form1.itemlist[item] + "\r\n" + "Quantity: " + qty.ToString());
            }
            else if (cardtype == 0) // PKM
            {
                int species  = BitConverter.ToUInt16(wondercard_data, 0x82);
                int helditem = BitConverter.ToUInt16(wondercard_data, 0x78);
                int move1    = BitConverter.ToUInt16(wondercard_data, 0x7A);
                int move2    = BitConverter.ToUInt16(wondercard_data, 0x7C);
                int move3    = BitConverter.ToUInt16(wondercard_data, 0x7E);
                int move4    = BitConverter.ToUInt16(wondercard_data, 0x80);
                int TID      = BitConverter.ToUInt16(wondercard_data, 0x68);
                int SID      = BitConverter.ToUInt16(wondercard_data, 0x6A);

                string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22));
                RTB.Text +=
                    "\r\nSpecies: " + Form1.specieslist[species] + "\r\n"
                    + "Item: " + Form1.itemlist[helditem] + "\r\n"
                    + "Move 1: " + Form1.movelist[move1] + "\r\n"
                    + "Move 2: " + Form1.movelist[move2] + "\r\n"
                    + "Move 3: " + Form1.movelist[move3] + "\r\n"
                    + "Move 4: " + Form1.movelist[move4] + "\r\n"
                    + "OT: " + OTname + "\r\n"
                    + "ID: " + TID.ToString() + "/" + SID.ToString();
            }
            else
            {
                RTB.Text = "Unsupported Wondercard Type!";
            }
        }
Ejemplo n.º 18
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;
            }
        }
Ejemplo n.º 19
0
        public void Resultados(List <string> MAC)
        {
            List <string> dirrMac  = new List <string>();
            List <string> dirrMac2 = new List <string>();
            string        cadena   = "";
            string        cadena2  = "";

            if (contador == 1)
            {
                foreach (string s in MAC)
                {
                    if (s.StartsWith("MAC"))
                    {
                        dirrMac.Add(s);
                        cadena += s;
                        cadena += "\n";
                    }
                }
                RTB.Text = cadena;
            }
            if (contador > 1)
            {
                int primerR = dirrMac.Count;
                foreach (string s in MAC)
                {
                    if (s.StartsWith("MAC"))
                    {
                        dirrMac2.Add(s);
                        cadena2 += s;
                        cadena2 += "\n";
                    }
                }
                int segundoR = dirrMac2.Count;
                if (segundoR > primerR)
                {
                    textBox1.Enabled = true;
                    MessageBox.Show(" Hay un intruso en tu red");
                    RTB.Clear();
                    RTB.Text = cadena2;
                }
            }
        }
Ejemplo n.º 20
0
        private void ViewGiftData(DataMysteryGift g)
        {
            try
            {
                // only check if the form is visible (not opening)
                if (Visible && g.GiftUsed && DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgMsyteryGiftUsedAlert, MsgMysteryGiftUsedFix))
                {
                    g.GiftUsed = false;
                }

                RTB.Lines        = g.GetDescription().ToArray();
                PB_Preview.Image = g.Sprite();
                mg = g;
            }
            catch (Exception e)
            {
                WinFormsUtil.Error(MsgMysteryGiftParseTypeUnknown, e);
                RTB.Clear();
            }
        }
Ejemplo n.º 21
0
        //Rich Text Box AppendText
        private void RTBAppendText(string Text, TextColors Color)
        {
            switch (Color)
            {
            case TextColors.Black:
                RTB.Invoke(new MethodInvoker(delegate { RTB.SelectionColor = System.Drawing.Color.Black; RTB.AppendText(Text); }));
                break;

            case TextColors.Green:
                RTB.Invoke(new MethodInvoker(delegate { RTB.SelectionColor = System.Drawing.Color.Green; RTB.AppendText(Text); }));
                break;

            case TextColors.Red:
                RTB.Invoke(new MethodInvoker(delegate { RTB.SelectionColor = System.Drawing.Color.Red; RTB.AppendText(Text); }));
                break;

            default:
                break;
            }
        }
Ejemplo n.º 22
0
 private void Log(string message)
 {
     this.Invoke(new Action <string>((string msg) => {
         if (RTB.Lines.Length > 2 && RTB.Lines[RTB.Lines.Length - 2].StartsWith("frame=") && msg.StartsWith("frame="))
         {
             ReplaceLastLines(RTB, msg);
         }
         else if (RTB.Lines.Length > 2 && RTB.Lines[RTB.Lines.Length - 2].StartsWith("size=") && msg.StartsWith("size="))
         {
             ReplaceLastLines(RTB, msg);
         }
         else
         {
             RTB.AppendText(msg + "\r\n");
         }
         ScrollToBottom(RTB);
         Application.DoEvents();
     }), message);
     Application.DoEvents();
 }
Ejemplo n.º 23
0
        private void viewGiftData(MysteryGift g)
        {
            try
            {
                // only check if the form is visible (not opening)
                if (Visible && g.GiftUsed && DialogResult.Yes ==
                        Util.Prompt(MessageBoxButtons.YesNo,
                            "Wonder Card is marked as USED and will not be able to be picked up in-game.",
                            "Do you want to remove the USED flag so that it is UNUSED?"))
                    g.GiftUsed = false;

                RTB.Text = getDescription(g);
                PB_Preview.Image = getSprite(g);
                mg = g;
            }
            catch (Exception e)
            {
                Util.Error("Loading of data failed... is this really a Wonder Card?", e);
                RTB.Clear();
            }
        }
Ejemplo n.º 24
0
        private void initializeFileProgram()
        {
            string lineRead = "";

            beginName.Text = nameFile;
            using (var streamReader = new StreamReader("\\\\Mac\\Home\\Desktop\\Универ\\Методы трансляции\\CompilerPascal\\CompilerPascal\\TextFile\\" + nameFile, System.Text.Encoding.Default))
            {
                int i = 1;

                while ((lineRead = streamReader.ReadLine()) != null)
                {
                    beginNumber.Text += i + "\n\n";
                    begin.AppendText(lineRead + "\n");
                    i++;
                }
            }

            using (var streamReader = new StreamReader("\\\\Mac\\Home\\Desktop\\Универ\\Методы трансляции\\CompilerPascal\\CompilerPascal\\TextFile\\Error.txt", System.Text.Encoding.Default))
            {
                RTB.AppendText(streamReader.ReadToEnd());
            }
        }
Ejemplo n.º 25
0
        private void ViewGiftData(DataMysteryGift g)
        {
            try
            {
                // only check if the form is visible (not opening)
                if (Visible && g.GiftUsed && DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgMsyteryGiftUsedAlert, MsgMysteryGiftUsedFix))
                {
                    g.GiftUsed = false;
                }

                RTB.Lines        = g.GetDescription().ToArray();
                PB_Preview.Image = g.Sprite();
                mg = g;
            }
            // Some user input mystery gifts can have out-of-bounds values. Just swallow any exception.
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                WinFormsUtil.Error(MsgMysteryGiftParseTypeUnknown, e);
                RTB.Clear();
            }
        }
Ejemplo n.º 26
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //upp
            if (keyData == Keys.Up)
            {
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        if (World[i].Text == "green")
                        {
                            World[i].BackColor = Color.LightGreen;
                            World[i].ForeColor = World[i].BackColor;
                        }
                        if (World[i].Text == "brown")
                        {
                            World[i].BackColor = Color.Brown;
                            World[i].ForeColor = World[i].BackColor;
                        }
                    }
                }


                currentY = currentY - basemovementspeed;


                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.DarkGreen || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(86, 51, 20) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(78, 47, 18) || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(69, 36, 14) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Black || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Blue)
                    {
                        currentY = currentY + basemovementspeed;
                    }
                }

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        World[i].BackColor = Color.Black;
                        World[i].ForeColor = World[i].BackColor;
                    }
                }
                return(true);
            }

            //niður
            if (keyData == Keys.Down)
            {
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        if (World[i].Text == "green")
                        {
                            World[i].BackColor = Color.LightGreen;
                            World[i].ForeColor = World[i].BackColor;
                        }
                        if (World[i].Text == "brown")
                        {
                            World[i].BackColor = Color.Brown;
                            World[i].ForeColor = World[i].BackColor;
                        }
                    }
                }

                currentY = currentY + basemovementspeed;

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.DarkGreen || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(86, 51, 20) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(78, 47, 18) || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(69, 36, 14) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Black || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Blue)
                    {
                        currentY = currentY - basemovementspeed;
                    }
                }

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        World[i].BackColor = Color.Black;
                        World[i].ForeColor = World[i].BackColor;
                    }
                }
                return(true);
            }

            //vinstri
            if (keyData == Keys.Left)
            {
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        if (World[i].Text == "green")
                        {
                            World[i].BackColor = Color.LightGreen;
                            World[i].ForeColor = World[i].BackColor;
                        }
                        if (World[i].Text == "brown")
                        {
                            World[i].BackColor = Color.Brown;
                            World[i].ForeColor = World[i].BackColor;
                        }
                    }
                }

                currentX = currentX - basemovementspeed;

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.DarkGreen || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(86, 51, 20) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(78, 47, 18) || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(69, 36, 14) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Black || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Blue)
                    {
                        currentX = currentX + basemovementspeed;
                    }
                }

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        World[i].BackColor = Color.Black;
                        World[i].ForeColor = World[i].BackColor;
                    }
                }
                return(true);
            }

            //hægri
            if (keyData == Keys.Right)
            {
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        if (World[i].Text == "green")
                        {
                            World[i].BackColor = Color.LightGreen;
                            World[i].ForeColor = World[i].BackColor;
                        }
                        if (World[i].Text == "brown")
                        {
                            World[i].BackColor = Color.Brown;
                            World[i].ForeColor = World[i].BackColor;
                        }
                    }
                }


                currentX = currentX + basemovementspeed;

                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.DarkGreen || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(86, 51, 20) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(78, 47, 18) || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.FromArgb(69, 36, 14) ||
                        World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Black || World[i].Name == currentX + ":" + currentY && World[i].BackColor == Color.Blue)
                    {
                        currentX = currentX - basemovementspeed;
                    }
                }
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == currentX + ":" + currentY)
                    {
                        World[i].BackColor = Color.Black;
                        World[i].ForeColor = World[i].BackColor;
                    }
                }
                return(true);
            }


            //SPACEBAR
            if (keyData == Keys.Space && tal1 == 3 && ja == 1)
            {
                RTB.Clear();
                for (int i = 0; i < World.Length; i++)
                {
                    if (World[i].Name == 57 + ":" + 6 && World[i].BackColor == Color.Black)
                    {
                        tikk2 = rand.Next(1, 6);
                        if (tikk2 == 1)
                        {
                            RTB.Text += "Þú náðir einum Ingosilung";
                            ingosilungar++;
                            label2.Text = ingosilungar.ToString();
                        }
                        else
                        {
                            RTB.Text += "Þú náðir eingu";
                        }
                    }
                }
            }
            if (keyData == Keys.Space && tal1 == 0)
            {
                for (int i = 0; i < World.Length; i++)
                {
                    if (tal1 == 0)
                    {
                        if (World[i].Name == 18 + ":" + 16 && World[i].BackColor == Color.Black || World[i].Name == 16 + ":" + 17 && World[i].BackColor == Color.Black || World[i].Name == 17 + ":" + 17 && World[i].BackColor == Color.Black || World[i].Name == 18 + ":" + 17 && World[i].BackColor == Color.Black ||
                            World[i].Name == 16 + ":" + 16 && World[i].BackColor == Color.Black)
                        {
                            RTB.Text = "HJÁÁÁÁÁÁÁÁLP";
                            tal1     = 1;
                        }
                    }
                }
                return(true);
            }
            if (keyData == Keys.Space && tal1 == 1)
            {
                RTB.Text = "Ég er svangur \n" + "villtu hjálpa mér? \n";
                tal1     = 2;
            }

            if (keyData == Keys.J && tal1 == 2)
            {
                ja++;
                tal1++;
                RTB.Text = "æðislegt, ég hélt ég þyrfti að gera þetta sjálfur \n " +
                           "farðu austur og veiddu handa mér 3 Ingosilunga á brúnni á bryggjunni \n "
                           + "ég skal gefa þér verðlaun (gamli maðurinn blikkar einu auga) ";
            }
            if (keyData == Keys.N && tal1 == 2)
            {
                tal1++;
                RTB.Text = "argasti dónaskapur";
            }
            if (keyData == Keys.Space && tal1 == 3 && ingosilungar >= 3)
            {
                RTB.Text = "ummmm nom nom nom þetta eru fínir fiskar hér er súkkulaði ;) ";
            }


            return(base.ProcessCmdKey(ref msg, keyData));
        }
Ejemplo n.º 27
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.º 28
0
 private void clearTextbox(object sender, EventArgs e)
 {
     RTB.Clear();
 }
Ejemplo n.º 29
0
 public FibonacciNumbers()
 {
     InitializeComponent();
     write = rtbWrite;
     progress = pbProgress;
 }
Ejemplo n.º 30
0
 public void Clear()
 {
     RTB.Clear();
 }
Ejemplo n.º 31
0
 public RTBHub(RTB rtb)
 {
     _RTB = rtb;
 }