Example #1
0
 //909522736
 private void button3_Click(object sender, System.EventArgs e)
 {
     if (ser == null || !ser.IsOpen)
     {
         SystemSounds.Exclamation.Play();
         this.BeginInvoke((Action)(() =>
         {
             TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
             TextOut.AppendText("Соеденинение нельзя разорвать т.к. оно ещё не было установлено\n");
             TextOut.ScrollToCaret();
         }));
     }
     else
     {
         Autorized = false;
         ser.Close();
         ser.Dispose();
         ser = null;
         this.BeginInvoke((Action)(() =>
         {
             TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
             TextOut.AppendText("Соеденинение разорвано.\n");
             TextOut.ScrollToCaret();
         }));
     }
 }
Example #2
0
 private void TextTimerCallback(object state)
 {
     if (_appendTextQueue.Count > 0)
     {
         lock (_appendTextQueue)
         {
             if (_appendTextQueue.Count > 0)
             {
                 Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                 {
                     do
                     {
                         var el = _appendTextQueue.Dequeue();
                         TextOut.AppendText((string)el);
                     } while (_appendTextQueue.Count > 0);
                     TextOut.ScrollToEnd();
                 }, null);
             }
         }
     }
     else
     {
         TimerOff();
     }
 }
Example #3
0
        private bool SearchCheck()
        {
            TextOut.Clear();
            Movie   movie = ReadParametrs();
            ISearch algo;

            if (radioLINQ.Checked)
            {
                algo   = new Linq(path);
                movies = algo.Method(movie);
                OutPut(movies);
                return(true);
            }
            if (radioSAX.Checked)
            {
                algo   = new SAX(path);
                movies = algo.Method(movie);
                OutPut(movies);
                return(true);
            }
            if (radioDOM.Checked)
            {
                algo   = new DOM(path);
                movies = algo.Method(movie);
                OutPut(movies);
                return(true);
            }
            return(false);
        }
Example #4
0
 public void Clear()
 {
     _appendTextQueue.Clear();
     Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
     {
         TextOut.Clear();
     }, null);
 }
Example #5
0
 private void Itt_TextReady(object sender, TextOut e)
 {
     processingWindow.ProcessedText.Invoke((MethodInvoker)(() => processingWindow.ProcessedText.Clear()));
     processingWindow.TranslatedText.Invoke((MethodInvoker)(() => processingWindow.ProcessedText.Clear()));
     foreach (var i in e.Text)
     {
         processingWindow.ProcessedText.Invoke((MethodInvoker)(() => processingWindow.ProcessedText.AppendText(i)));
     }
     foreach (var i in trntr.TranslateText(e.Text))
     {
         processingWindow.TranslatedText.Invoke((MethodInvoker)(() => processingWindow.ProcessedText.AppendText(i)));
     }
 }
Example #6
0
        private void OutPut(List <Movie> final)
        {
            int i = 1;

            foreach (Movie m in final)
            {
                TextOut.AppendText(i++ + ".\n");
                TextOut.AppendText("Genre: " + m.Genre + "\n");
                TextOut.AppendText("Studio: " + m.Studio + "\n");
                TextOut.AppendText("Name: " + m.Name + "\n");
                TextOut.AppendText("Year: " + m.Year + "\n");
                TextOut.AppendText("Time: " + m.Time + "\n");
                TextOut.AppendText("---------------------------------------------------\n");
            }
        }
Example #7
0
 private void Cleaner()
 {
     TextOut.Clear();
     checkBoxGenre.Checked  = false;
     checkBoxStudio.Checked = false;
     checkBoxName.Checked   = false;
     checkBoxYear.Checked   = false;
     checkBoxTime.Checked   = false;
     comboGenre.Text        = null;
     comboStudio.Text       = null;
     comboYear.Text         = null;
     comboName.Text         = null;
     comboTime.Text         = null;
     radioDOM.Checked       = false;
     radioLINQ.Checked      = false;
     radioSAX.Checked       = false;
 }
 private void Image_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (ValueStack.Width == 200)
     {
         TextIn.Stop();
         TextOut.Stop();
         TextOut.Begin();
         arrow.Source = new BitmapImage(new Uri("ms-appx:///Assets/arrow-right3.png"));
     }
     else
     {
         TextIn.Stop();
         TextOut.Stop();
         TextIn.Begin();
         arrow.Source = new BitmapImage(new Uri("ms-appx:///Assets/left-arrow.png"));
     }
 }
Example #9
0
        /// <summary>
        ///     Fixes the LBA table on the main ELF executable of the Harvest Moon: Save the Homeland game.
        /// </summary>
        /// <param name="Elf">The Stream with the ELF data</param>
        /// <param name="LBA">The LBA of the modified file</param>
        /// <param name="NewSize">The new size of the file</param>
        public static void Fix(Stream Elf, uint LBA, uint NewSize)
        {
            BinaryReader Reader = new BinaryReader(Elf);
            BinaryWriter Writer = new BinaryWriter(Elf);

            int  Difference = 0;
            bool Found      = false;

            Elf.Seek(LBATableStart, SeekOrigin.Begin);
            while (Elf.Position < LBATableEnd)
            {
                uint LBAStart = Reader.ReadUInt32();
                uint LBAEnd   = Reader.ReadUInt32();

                Elf.Seek(-8, SeekOrigin.Current);
                Writer.Write((uint)(LBAStart + Difference));
                Writer.Write((uint)(LBAEnd + Difference));

                if (LBAStart == LBA)
                {
                    Found = true;
                    uint Size = NewSize / BytesPerSector;
                    if ((NewSize % BytesPerSector) != 0)
                    {
                        Size++;
                    }

                    Elf.Seek(-4, SeekOrigin.Current);
                    uint NewEnd = (LBAStart + Size) - 1;
                    Writer.Write(NewEnd);
                    Difference = (int)(NewEnd - LBAEnd);
                }
            }

            if (!Found)
            {
                TextOut.PrintWarning("The LBA you entered was not found on the table!");
                TextOut.Print("Make sure you typed it in DECIMAL format.");
            }
            else
            {
                TextOut.PrintSuccess("LBA found and values patched successfully!");
            }
        }
Example #10
0
            //The execution context exposes two public properties (an input stream and
            //an output stream). Programs hosting intercal components can do string communication
            //by hooking the output stream and calling routines that do a DO READ OUT.

            //String manipulation is impossible.  Suppose an INTERCAL module calls a C# module, and
            //the C# module wants to do string manipulation on the string stored in ;0.  In order
            //to decipher the characters in the array it will be necessary for the C# module to
            //where the input tape was positioned when the characters were read in (since strings
            //are stored as deltas rather than absolute values).  For example, if the array contains
            //{ 65, 1, 1, 1} and LastIn is 68 then you could ostensibly conclude that the string
            //contains {A B C D}, but this is only true if the array was the last one written to.
            //In keeping with the spirit of the Turing Text model I think the context
            //should save the current input tape position whenever a WRITE IN is encountered,
            //e.g. (0) {65,1,1,1} is enough information to recover "ABCD".
            //Existing programs continue to work; new components can peek at the value if they want
            //to do string manipulation.  Hopefully we can make this completely transparent
            //to modules written in INTERCAL.

            //As of right now I haven't done anything yet to enable this.
            public void ReadOut(string identifier)
            {
                Trace.WriteLine(string.Format("Reading out variable '{0}'", identifier.Length));

                var next = Variables[identifier].ToString();

                Trace.WriteLine(string.Format("Reading out value '{0}'", next));

                if (Variables[identifier] is ArrayVariable)
                {
                    TextOut.Write(next);
                }
                else
                {
                    TextOut.WriteLine(next);
                }

                TextOut.Flush();
            }
Example #11
0
 public void ReadOut(object expression)
 {
     Trace.WriteLine(string.Format("Reading out object '{0}'", expression));
     TextOut.WriteLine(expression);
     TextOut.Flush();
 }
Example #12
0
        public void dataRecived(object sender, SerialDataReceivedEventArgs e)
        {
            if (!Autorized)
            {
                byte[] data = new byte[ser.BytesToRead];
                ser.Read(data, 0, ser.BytesToRead);
                if (data.Length == 4 && data[0] == 0xff && data[1] == 0x00 && data[2] == 0xf0 && data[3] == 0x0f)
                {
                    Autorized = true;
                    this.BeginInvoke((Action)(() =>
                    {
                        TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
                        TextOut.AppendText("Соеденинение установлено\n");
                        ser.Write(new byte[] { CMD_ABOUT }, 0, 1);
                        Thread.Sleep(1000);
                        sendComand(0x33);
                    }));
                }
                else
                {
                    this.BeginInvoke((Action)(() =>
                    {
                        TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
                        TextOut.AppendText("Соеденинение установить не удалось\n");
                        TextOut.ScrollToCaret();
                    }));
                }
            }
            else
            {
                int code = ser.ReadByte();
                switch (code)
                {
                case ANS_STR:
                    string text = ser.ReadLine();
                    this.BeginInvoke((Action)(() =>
                    {
                        TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "] ФН: ");
                        TextOut.AppendText(text);
                        TextOut.ScrollToCaret();
                    }));
                    break;

                case ANS_BTS:
                    while (ser.BytesToRead == 0)
                    {
                        ;
                    }
                    int len = ser.ReadByte();
                    buffer = new byte[len];
                    for (int i = 0; i < len; i++)
                    {
                        while (ser.BytesToRead == 0)
                        {
                            ;
                        }
                        buffer[i] = (byte)ser.ReadByte();
                    }
                    this.BeginInvoke((Action)(() =>
                    {
                        TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: длинна полученого сообщения: " + len.ToString() + "\n");
                        TextOut.AppendText("".PadLeft(120, '-') + "\n");
                    }));
                    handleBufferData();
                    break;
                }
            }
        }
Example #13
0
        void handleBufferData()
        {
            if (buffer != null && buffer.Length > 5 && buffer[3] == 0)
            {
                string txt = "";
                switch (sended_command)
                {
                case 0x33:
                    if (buffer.Length != 23)
                    {
                        txt = incorrectMessege();
                    }
                    else
                    {
                        txt  = "Версия ФН: ";
                        txt += btToString(buffer, 4, 16);
                        if (buffer[20] == 0)
                        {
                            txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: " + "Это версия для отладки\n";
                        }
                        else
                        {
                            txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: " + "Это серийная модель\n";
                        }
                    }
                    break;

                case 0x30:
                    if (buffer.Length != 36)
                    {
                        txt = incorrectMessege();
                    }
                    else
                    {
                        txt  = "Состояние фазы жизни: " + Convert.ToString(buffer[4], 2).PadLeft(4, '0');
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Текущий документ: 0x" + buffer[5].ToString("X2");
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Данные документа: " + buffer[6];
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Состояние смены: " + Convert.ToString(buffer[7], 2).PadLeft(4, '0');
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Флаги предупреждения: " + Convert.ToString(buffer[8], 2).PadLeft(4, '0');;
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Время последнего документа: ";
                        txt += buffer[11] + "/" + buffer[10] + "/" + buffer[9] + " " + buffer[12] + ":" + buffer[13];
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Номер ФН: " + btToString(buffer, 14, 16);
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Номер последнего ФД: 0x" + buffer[30].ToString("X2") + buffer[31].ToString("X2") + buffer[32].ToString("X2") + buffer[33].ToString("X2");
                        txt += "\n";
                    }
                    break;

                case 0x31:
                    if (buffer.Length != 22)
                    {
                        txt = incorrectMessege();
                    }
                    else
                    {
                        txt += "Номер ФН: " + btToString(buffer, 4, 16);
                        txt += "\n";
                    }
                    break;

                case 0x40:
                    txt = incorrectMessege();
                    break;

                case 0x43:
                    if (buffer.Length != 69)
                    {
                        txt = incorrectMessege();
                    }
                    else
                    {
                        txt  = "Дата: " + buffer[6] + "/" + buffer[5] + "/" + buffer[4] + " " + buffer[7] + ":" + buffer[8];
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: ИНН" + btToString(buffer, 9, 12);
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Номер КТТ" + btToString(buffer, 21, 20);
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Номер ФН" + btToString(buffer, 41, 16);
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Код налогообложения" + buffer[57].ToString();
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Режим работы" + buffer[58].ToString();
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Номер ФД" + (((ulong)buffer[59] << 24) | ((ulong)buffer[60] << 16) | ((ulong)buffer[61] << 8) | ((ulong)buffer[62])).ToString();
                        txt += "\n[" + DateTime.Now.ToLongTimeString() + "]: Фискальный Признак" + (((ulong)buffer[63] << 24) | ((ulong)buffer[64] << 16) | ((ulong)buffer[65] << 8) | ((ulong)buffer[66])).ToString() + "\n";
                    }
                    break;

                default: txt = incorrectMessege(); break;
                }
                txt += "[" + DateTime.Now.ToLongTimeString() + "]: " + "CRC16: 0x" + buffer[buffer.Length - 2].ToString("X2") + buffer[buffer.Length - 1].ToString("X2") + "\n";


                this.BeginInvoke((Action)(() =>
                {
                    TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
                    TextOut.AppendText(txt);
                    TextOut.AppendText("".PadLeft(120, '-') + "\n");
                    TextOut.ScrollToCaret();
                }));
            }
            else if (buffer != null && buffer[3] != 0)
            {
                this.BeginInvoke((Action)(() =>
                {
                    TextOut.ForeColor = Color.Red;
                    TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
                    TextOut.AppendText("Фискальный накопитель вернул следующий код ошибки: 0x" + buffer[3].ToString("X") + "\n");
                    TextOut.AppendText("[" + DateTime.Now.ToLongTimeString() + "]: ");
                    TextOut.AppendText("Полное сообщение: ");
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        TextOut.AppendText("0x" + buffer[i].ToString("X") + " ");
                    }
                    TextOut.AppendText("\n");
                    TextOut.ScrollToCaret();
                    TextOut.ForeColor = Color.Black;
                }));
            }
        }
Example #14
0
 private void Clear_Click(object sender, RoutedEventArgs e)
 {
     TextOut.Clear();
 }