Пример #1
0
            public override void PrintAsCode(Maps source, LinePrinter @out, bool includeChecks)
            {
                int?existingValue = source.NormalMap[Key];

                string removal = "map.remove( " + Key + " );";

                if (includeChecks)
                {
                    bool existing = existingValue != null;
                    @out.Println(format("boolean existedBefore = map.containsKey( %d );", Key));
                    @out.Println(format("Integer valueBefore = map.get( %d );", Key));
                    @out.Println(format("Integer removed = %s", removal));
                    @out.Println(format("boolean existsAfter = map.containsKey( %d );", Key));
                    @out.Println(format("Integer valueAfter = map.get( %d );", Key));

                    @out.Println(format("assert%s( \"%s\", existedBefore );", Capitilize(existing), Key + " should " + (existing ? "" : "not ") + "exist before putting here"));
                    if (existing)
                    {
                        @out.Println(format("assertEquals( \"%s\", (Integer)%d, valueBefore );", "value before should be " + existingValue, existingValue));
                        @out.Println(format("assertEquals( \"%s\", (Integer)%d, removed );", "value returned from put should be " + existingValue, existingValue));
                    }
                    else
                    {
                        @out.Println(format("assertNull( \"%s\", valueBefore );", "value before putting should be null"));
                        @out.Println(format("assertNull( \"%s\", removed );", "value returned from putting should be null"));
                    }
                    @out.Println(format("assertFalse( \"%s\", existsAfter );", Key + " should not exist"));
                    @out.Println(format("assertNull( \"%s\", valueAfter );", "value after removing should be null"));
                }
                else
                {
                    @out.Println(removal);
                }
            }
Пример #2
0
            public override void PrintAsCode(Maps source, LinePrinter @out, bool includeChecks)
            {
                string removal = "map.remove( " + Key + " );";

                if (includeChecks)
                {
                    bool existing      = source.NormalMap.ContainsKey(Key);
                    int  existingValue = existing ? source.NormalMap[Key] : -1;
                    @out.Println(format("boolean existedBefore = map.containsKey( %d );", Key));
                    @out.Println(format("int valueBefore = map.get( %d );", Key));
                    @out.Println(format("int removed = %s", removal));
                    @out.Println(format("boolean existsAfter = map.containsKey( %d );", Key));
                    @out.Println(format("int valueAfter = map.get( %d );", Key));

                    @out.Println(format("assert%s( \"%s\", existedBefore );", Capitilize(existing), Key + " should " + (existing ? "" : "not ") + "exist before removing here"));
                    @out.Println(format("assertEquals( \"%s\", %d, valueBefore );", "value before should be " + existingValue, existingValue));
                    @out.Println(format("assertEquals( \"%s\", %d, removed );", "value returned from remove should be " + existingValue, existingValue));
                    @out.Println(format("assertFalse( \"%s\", existsAfter );", Key + " should not exist"));
                    @out.Println(format("assertEquals( \"%s\", -1, valueAfter );", "value after removing should be -1"));
                }
                else
                {
                    @out.Println(removal);
                }
            }
Пример #3
0
            public override void PrintAsCode(Maps source, LinePrinter @out, bool includeChecks)
            {
                string addition = "map.put( " + Key + ", " + Value + " );";

                if (includeChecks)
                {
                    bool existing      = source.NormalMap.ContainsKey(Key);
                    int  existingValue = existing ? source.NormalMap[Key] : -1;
                    @out.Println("int sizeBefore = map.size();");
                    @out.Println(format("boolean existedBefore = map.containsKey( %d );", Key));
                    @out.Println(format("int valueBefore = map.get( %d );", Key));
                    @out.Println(format("int previous = %s", addition));
                    @out.Println(format("boolean existsAfter = map.containsKey( %d );", Key));
                    @out.Println(format("int valueAfter = map.get( %d );", Key));
                    @out.Println("int sizeAfter = map.size();");

                    int actualSizeBefore = source.NormalMap.Count;
                    @out.Println(format("assertEquals( \"%s\", %d, sizeBefore );", "Size before put should have been " + actualSizeBefore, actualSizeBefore));
                    @out.Println(format("assert%s( \"%s\", existedBefore );", Capitilize(existing), Key + " should " + (existing ? "" : "not ") + "exist before putting here"));
                    @out.Println(format("assertEquals( \"%s\", %d, valueBefore );", "value before should be " + existingValue, existingValue));
                    @out.Println(format("assertEquals( \"%s\", %d, previous );", "value returned from put should be " + existingValue, existingValue));
                    @out.Println(format("assertTrue( \"%s\", existsAfter );", Key + " should exist"));
                    @out.Println(format("assertEquals( \"%s\", %d, valueAfter );", "value after putting should be " + Value, Value));
                    int actualSizeAfter = existing ? actualSizeBefore : actualSizeBefore + 1;
                    @out.Println(format("assertEquals( \"%s\", %d, sizeAfter );", "Size after put should have been " + actualSizeAfter, actualSizeAfter));
                }
                else
                {
                    @out.Println(addition);
                }
            }
Пример #4
0
        public virtual void Print(PrintStream @out)
        {
            T           target          = _targetFactory.newInstance();
            LinePrinter baseLinePrinter = new PrintStreamLinePrinter(@out, 0);

            baseLinePrinter.Println("@Test");
            baseLinePrinter.Println("public void " + _testName + "() throws Exception");
            baseLinePrinter.Println("{");

            LinePrinter codePrinter = baseLinePrinter.Indent();

            codePrinter.Println("// GIVEN");
            _given.print(codePrinter);
            foreach (Action <T, F> action in _actions)
            {
                action.PrintAsCode(target, codePrinter, false);
                action.Apply(target);
            }

            codePrinter.Println("");
            codePrinter.Println("// WHEN/THEN");
            _failingAction.printAsCode(target, codePrinter, true);
            baseLinePrinter.Println("}");
            @out.flush();
        }
Пример #5
0
 void menu_Print_Click(object InObj, EventArgs InArgs)
 {
     if (lbResults.Items.Count > 0)
     {
         string[] lines = new string[lbResults.Items.Count];
         int      ix    = 0;
         foreach (string lbItem in lbResults.Items)
         {
             lines[ix] = lbItem;
             ix       += 1;
         }
         LinePrinter.PrintLines(lines, 0);
     }
 }
Пример #6
0
        private static void SendToPrinter(LinePrinter printer, ILineFormatter line)
        {
            var data = line.GetFormattedLine();

            if (!data.StartsWith("<"))
            {
                printer.WriteLine(data, line.FontHeight, line.FontWidth, LineAlignment.Left);
            }
            else if (line.Tag.TagName == "eb")
            {
                printer.EnableBold();
            }
            else if (line.Tag.TagName == ("db"))
            {
                printer.DisableBold();
            }
            else if (line.Tag.TagName == "bmp")
            {
                printer.PrintBitmap(RemoveTag(data));
            }
            else if (line.Tag.TagName == "qr")
            {
                printer.PrintQrCode(RemoveTag(data));
            }
            else if (line.Tag.TagName == "bar")
            {
                printer.PrintBarCode(RemoveTag(data), line.FontHeight, line.FontWidth);
            }
            else if (line.Tag.TagName == "cut")
            {
                printer.Cut();
            }
            else if (line.Tag.TagName == "beep")
            {
                printer.Beep();
            }
            else if (line.Tag.TagName == "drawer")
            {
                printer.OpenCashDrawer();
            }
            else if (line.Tag.TagName == "b")
            {
                printer.Beep((char)line.FontHeight, (char)line.FontWidth);
            }
            else if (line.Tag.TagName == ("xct"))
            {
                printer.ExecCommand(RemoveTag(data));
            }
        }
Пример #7
0
        public override void DoPrint(string[] lines)
        {
            var printer = new LinePrinter(Printer.ShareName, Printer.CharsPerLine, Printer.CodePage);

            printer.StartDocument();

            var formatters = new FormattedDocument(lines, Printer.CharsPerLine).GetFormatters();

            foreach (var formatter in formatters)
            {
                SendToPrinter(printer, formatter);
            }

            printer.Cut();
            printer.EndDocument();
        }
Пример #8
0
            public override void PrintAsCode(Sets source, LinePrinter @out, bool includeChecks)
            {
                bool   alreadyExisting = source.NormalSet.Contains(Value);
                string addition        = "set.add( " + Value + "L );";

                if (includeChecks)
                {
                    @out.Println(format("boolean existedBefore = set.contains( %dL );", Value));
                    @out.Println(format("boolean added = %s", addition));
                    @out.Println(format("boolean existsAfter = set.contains( %dL );", Value));
                    @out.Println(format("assert%s( \"%s\", existedBefore );", Capitilize(alreadyExisting), Value + " should " + (alreadyExisting ? "" : "not ") + "exist before adding here"));
                    @out.Println(format("assert%s( \"%s\", added );", Capitilize(!alreadyExisting), Value + " should " + (!alreadyExisting ? "" : "not ") + "be reported as added here"));
                    @out.Println(format("assertTrue( \"%s\", existsAfter );", Value + " should exist"));
                }
                else
                {
                    @out.Println(addition);
                }
            }
Пример #9
0
            public override void PrintAsCode(Sets source, LinePrinter @out, bool includeChecks)
            {
                bool   alreadyExisting = source.NormalSet.Contains(Value);
                string removal         = "set.remove( " + Value + "L );";

                if (includeChecks)
                {
                    @out.Println(format("boolean existedBefore = set.contains( %dL );", Value));
                    @out.Println(format("boolean removed = %s", removal));
                    @out.Println(format("boolean existsAfter = set.contains( %dL );", Value));
                    @out.Println(format("assert%s( \"%s\", existedBefore );", Capitilize(alreadyExisting), Value + " should " + (alreadyExisting ? "" : "not ") + "exist before removing here"));
                    @out.Println(format("assert%s( \"%s\", removed );", Capitilize(alreadyExisting), Value + " should " + (alreadyExisting ? "" : "not ") + "be reported as removed here"));
                    @out.Println(format("assertFalse( \"%s\", existsAfter );", Value + " should not exist"));
                }
                else
                {
                    @out.Println(removal);
                }
            }
Пример #10
0
        public override void DoPrint(string[] lines)
        {
            lines = PrinterHelper.AlignLines(lines, Printer.CharsPerLine, true).ToArray();
            lines = PrinterHelper.ReplaceChars(lines, Printer.ReplacementPattern).ToArray();

            var printer = new LinePrinter(Printer.ShareName, Printer.CharsPerLine, Printer.CodePage);

            printer.StartDocument();

            foreach (var s in lines)
            {
                SendToPrinter(printer, s);
            }

            if (lines.Length >= 2)
            {
                printer.Cut();
            }
            printer.EndDocument();
            _lastHeight = 0;
            _lastWidth  = 0;
        }
Пример #11
0
        // main set up
        public void setUp(bool printerdefiner)
        {
            loadGraphics(@"./textures.txt");

            //
            Printer MainPrinter;

            if (printerdefiner)
            {
                MainPrinter = new LegacyPrinter();
            }
            else
            {
                MainPrinter = new LinePrinter();
            }
            // set screen
            // screen position is 5,5 at screen constructor
            // map interface is created at 0,0
            Screen screen = new Screen(Terminal.Size_x - 10, Terminal.Size_y - 10, MainPrinter);

            SBGame.setScreen(screen);

            // initialize map

            Map    map = new Map(getMainScreen().Size_x - 50, getMainScreen().Size_y, 5, 5);
            Battle bat = new Battle(map);

            AbstractForm abstractForm = new MapInterface(map, screen, 0, 0);

            bat.guiMap = abstractForm;
            //

            // set player and print it
            bat.setPlayer(new Player(true));
            //

            UserInterface.setInterface();
        }
Пример #12
0
        ///------------------------------------------------
        /// <summary>
        /// Build string that contains all available information
        /// about the specified exception (all nested exceptions,
        /// type of exception, mesage, stack).
        /// </summary>
        public static StringBuilder BuildExceptionReport(string header, string footer, string separator, Exception ex, StringBuilder builder)
        {
            //validate arguments
            if (null == builder)
            {
                builder = new StringBuilder(512);
            }
            if (null == header)
            {
                header = "~~~~~~~~~" + Environment.NewLine + "Exception report";
            }
            if (null == footer)
            {
                footer = "~~~~~~~~~";
            }
            if (null == separator)
            {
                separator = "---------";
            }

            //header
            LinePrinter linePrinter = new LinePrinter(' ', 0, builder);

            if (header.Length > 0)
            {
                TraverseStringLines(header, linePrinter.Print);
                linePrinter.Print(separator);
            }

            //body
            TraverseExceptionTree(
                ex,
                0,                                                             //starting level
                true,                                                          //first exception in list
                delegate(KeyValuePair <KeyValuePair <int, bool>, string> info) //section header printer
            {
                //print section header
                linePrinter.UpdateIndent(info.Key.Key);
                if (info.Key.Value)     //first section
                {
                    linePrinter.Print(string.Empty);
                    linePrinter.Print("List of embedded exceptions:");
                    linePrinter.Print(string.Empty);
                }
                else
                {
                    linePrinter.Print(separator);
                }

                //user-friendly message (if present)
                if (string.IsNullOrEmpty(info.Value))
                {
                    linePrinter.Print("<no user friendly message>");
                }
                else
                {
                    linePrinter.PrintPrefix();
                    builder.Append("User-friendly message: ");
                    linePrinter.StartWithoutPrefix();
                    TraverseStringLines(info.Value, linePrinter.Print);
                }
            },
                delegate(KeyValuePair <KeyValuePair <int, bool>, Exception> info) //exception detail printer
            {
                //make sure indent is up-to-date
                linePrinter.UpdateIndent(info.Key.Key);

                //separator between exceptions (if needed)
                if (info.Key.Value)
                {
                    if (info.Key.Key > 0)
                    {
                        linePrinter.UpdateIndent(info.Key.Key - 1);
                        linePrinter.Print("Exception details:");
                        linePrinter.UpdateIndent(info.Key.Key);
                    }
                }
                else
                {
                    linePrinter.Print(separator);
                }

                //exception details
                if (null == info.Value)
                {
                    linePrinter.Print("<no exception was thrown>");
                }
                else
                {
                    linePrinter.PrintPrefix();
                    builder.Append(info.Value.GetType().FullName);
                    builder.Append(" - ");
                    linePrinter.StartWithoutPrefix();
                    TraverseStringLines(string.IsNullOrEmpty(info.Value.Message) ? "<no exception message>" : info.Value.Message, linePrinter.Print);

                    FileNotFoundException tex = info.Value as FileNotFoundException;
                    if (null != tex)
                    {
                        if (!string.IsNullOrEmpty(tex.FileName))
                        {
                            linePrinter.PrintPrefix();
                            builder.Append("FileNotFoundException.FileName: ");
                            linePrinter.StartWithoutPrefix();
                            TraverseStringLines(tex.FileName, linePrinter.Print);
                        }
                        if (!string.IsNullOrEmpty(tex.FusionLog))
                        {
                            linePrinter.PrintPrefix();
                            builder.Append("FileNotFoundException.FusionLog: ");
                            linePrinter.StartWithoutPrefix();
                            TraverseStringLines(tex.FusionLog, linePrinter.Print);
                        }
                    }
                    else
                    {
                        SqlException sex = info.Value as SqlException;
                        if (null != sex)
                        {
                            linePrinter.PrintPrefix();
                            builder.Append("SqlException.ErrorCode: ");
                            builder.Append(sex.ErrorCode);
                            builder.Append(" (0x");
                            builder.Append(sex.ErrorCode.ToString("X8", CultureInfo.InvariantCulture));
                            builder.AppendLine(")");

                            linePrinter.PrintPrefix();
                            builder.Append("SqlException.Errors.Count: ");
                            builder.AppendLine(sex.Errors.Count.ToString(CultureInfo.InvariantCulture));
                            builder.AppendLine();

                            int index = 0;
                            foreach (SqlError sqlError in sex.Errors)
                            {
                                string indexStr = (index++).ToString(CultureInfo.InvariantCulture);

                                linePrinter.PrintPrefix();
                                builder.Append("SqlException.Errors[");
                                builder.Append(indexStr);
                                builder.Append("].Class: ");
                                builder.AppendLine(sqlError.Class.ToString(CultureInfo.InvariantCulture));

                                linePrinter.PrintPrefix();
                                builder.Append("SqlException.Errors[");
                                builder.Append(indexStr);
                                builder.Append("].LineNumber: ");
                                builder.AppendLine(sqlError.LineNumber.ToString(CultureInfo.InvariantCulture));

                                if (!string.IsNullOrEmpty(sqlError.Message))
                                {
                                    linePrinter.PrintPrefix();
                                    builder.Append("SqlException.Errors[");
                                    builder.Append(indexStr);
                                    builder.Append("].Message: ");
                                    linePrinter.StartWithoutPrefix();
                                    TraverseStringLines(sqlError.Message, linePrinter.Print);
                                }

                                linePrinter.PrintPrefix();
                                builder.Append("SqlException.Errors[");
                                builder.Append(indexStr);
                                builder.Append("].Number: ");
                                builder.Append(sqlError.Number.ToString(CultureInfo.InvariantCulture));
                                builder.Append(" (0x");
                                builder.Append(sqlError.Number.ToString("X8", CultureInfo.InvariantCulture));
                                builder.AppendLine(")");

                                if (!string.IsNullOrEmpty(sqlError.Procedure))
                                {
                                    linePrinter.PrintPrefix();
                                    builder.Append("SqlException.Errors[");
                                    builder.Append(indexStr);
                                    builder.Append("].Procedure: ");
                                    linePrinter.StartWithoutPrefix();
                                    TraverseStringLines(sqlError.Procedure, linePrinter.Print);
                                }

                                if (!string.IsNullOrEmpty(sqlError.Server))
                                {
                                    linePrinter.PrintPrefix();
                                    builder.Append("SqlException.Errors[");
                                    builder.Append(indexStr);
                                    builder.Append("].Server: ");
                                    linePrinter.StartWithoutPrefix();
                                    TraverseStringLines(sqlError.Server, linePrinter.Print);
                                }

                                if (!string.IsNullOrEmpty(sqlError.Source))
                                {
                                    linePrinter.PrintPrefix();
                                    builder.Append("SqlException.Errors[");
                                    builder.Append(indexStr);
                                    builder.Append("].Source: ");
                                    linePrinter.StartWithoutPrefix();
                                    TraverseStringLines(sqlError.Source, linePrinter.Print);
                                }

                                linePrinter.PrintPrefix();
                                builder.Append("SqlException.Errors[");
                                builder.Append(indexStr);
                                builder.Append("].State: ");
                                builder.AppendLine(sqlError.State.ToString(CultureInfo.InvariantCulture));

                                builder.AppendLine();
                            }
                        }
                        else
                        {
                            ExternalException eex = info.Value as ExternalException;
                            if (null != eex)
                            {
                                linePrinter.PrintPrefix();
                                builder.Append("ExternalException.ErrorCode: ");
                                builder.Append(eex.ErrorCode);
                                builder.Append(" (0x");
                                builder.Append(eex.ErrorCode.ToString("X8", CultureInfo.InvariantCulture));
                                builder.AppendLine(")");
                            }
                        }
                    }

                    TraverseStringLines(string.IsNullOrEmpty(info.Value.StackTrace) ? "<no stack trace>" : info.Value.StackTrace, linePrinter.Print);
                }
            });

            //footer
            if (footer.Length > 0)
            {
                linePrinter.UpdateIndent(0);
                TraverseStringLines(footer, linePrinter.Print);
            }

            return(builder);
        }
Пример #13
0
 private void Start()
 {
     m_printer = Camera.main.GetComponent<LinePrinter>();
     m_vertices = new Vector3[m_resolution];
     m_offsets = new float[m_resolution];
     m_drawObject = new LinePrinter.DrawObject(new Vector3[m_resolution], m_color);
     GenerateShape();
 }
Пример #14
0
        private static void SendToPrinter(LinePrinter printer, string line)
        {
            if (!string.IsNullOrEmpty(line.Trim()))
            {
                if (line.Length > 3 && Char.IsNumber(line[2]) && Char.IsNumber(line[3]))
                {
                    _lastHeight = Convert.ToInt32(line[2].ToString());
                    _lastWidth  = Convert.ToInt32(line[3].ToString());
                }

                if (line.StartsWith("<T>"))
                {
                    printer.PrintCenteredLabel(RemoveTag(line), true);
                }
                else if (line.StartsWith("<L"))
                {
                    printer.WriteLine(RemoveTag(line), _lastHeight, _lastWidth);
                }
                else if (line.StartsWith("<C"))
                {
                    printer.WriteLine(RemoveTag(line), _lastHeight, _lastWidth);
                }
                else if (line.StartsWith("<R"))
                {
                    printer.WriteLine(RemoveTag(line), _lastHeight, _lastWidth);
                }
                else if (line.StartsWith("<J"))
                {
                    printer.WriteLine(RemoveTag(line), _lastHeight, _lastWidth);
                }
                else if (line.StartsWith("<F") && line.Length > 3)
                {
                    printer.PrintFullLine(line[3]);
                }
                else if (line.StartsWith("<EB"))
                {
                    printer.EnableBold();
                }
                else if (line.StartsWith("<DB"))
                {
                    printer.DisableBold();
                }
                else if (line.StartsWith("<BMP"))
                {
                    printer.PrintBitmap(RemoveTag(line));
                }
                else if (line.StartsWith("<CUT"))
                {
                    printer.Cut();
                }
                else if (line.StartsWith("<BEEP"))
                {
                    printer.Beep();
                }
                else if (line.StartsWith("<DRAWER"))
                {
                    printer.OpenCashDrawer();
                }
                else if (line.StartsWith("<B"))
                {
                    printer.Beep((char)_lastHeight, (char)_lastWidth);
                }
                else if (line.StartsWith("<XCT") && line.EndsWith(">"))
                {
                    printer.ExecCommand(line.Substring(4, line.Length - 5));
                }
                else
                {
                    printer.WriteLine(line);
                }
            }
        }
Пример #15
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            string itemText   = null;
            string tagText    = null;
            var    senderItem = sender as MenuItem;

            if (sender is MenuItem)
            {
                itemText = (sender as MenuItem).Header as string;
            }
            tagText = senderItem.Tag as string;

            if (itemText == "Telnet")
            {
                var devName  = "STEVE26";
                var termType = "IBM-3477-FC"; // IBM-3477-FC, IBM-3179-2
                TelnetInitialConnect(
                    this.Model.SystemName, this.Model.AutoConnect, this.Model.DeviceName, this.Model.TerminalType);
            }

            else if (itemText == "Printer")
            {
                TelnetPrinterConnect(this.Model.SystemName);
            }

            else if (itemText == "Exit")
            {
                this.canAutoClose = true;
                this.Close();
            }

            else if (itemText == "Test")
            {
                var s2 = this.Model.ScreenDefnPath;
                Debug.Print("ScreenDefnPath:" + s2);
            }

            else if (itemText == "Read xml")
            {
                string    xmlPath = "c:\\skydrive\\c#\\TextCanvasLib\\xmlfile1.xml";
                var       items   = ScreenDocReader.ReadDoc(xmlPath);
                OneRowCol caret   = null;
                this.Model.TelnetCanvas.PaintScreen(items, caret);
            }

            else if (itemText == "Print log")
            {
                LinePrinter.PrintLines(this.Model.RunLog);
            }
            else if (itemText == "Clear log")
            {
                MainWindow.LogFile.ClearFile();
                this.Model.RunLog.Clear();
                this.PaintThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.MasterThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.ToThread.PostInputMessage(ThreadMessageCode.ClearLog);
                this.FromThread.PostInputMessage(ThreadMessageCode.ClearLog);
            }
            else if (itemText == "view special")
            {
                var    specialPath = "c:\\downloads\\specialLog.txt";
                string exePath     =
                    Environment.ExpandEnvironmentVariables(@"%windir%\system32\notepad.exe");
                Process.Start(exePath, specialPath);
            }

            else if (itemText == "Report canvas items")
            {
                MasterThread.PostInputMessage(ThreadMessageCode.ReportVisualItems);
                var visualItems = this.Model.TelnetCanvas.VisualItems;
                var report      = wtdReportExt.PrintVisualItems(visualItems);
                this.Model.RunLog.AddRange(report);
            }

            else if (itemText == "Send data")
            {
                var dataBytes = new byte[] { 0x00, 0x0a, 0x12, 0xa0, 0x01, 0x02,
                                             0x04, 0x00, 0x00, 0x01, 0xff, 0xef };

                dataBytes = new byte[] { 0x00, 0x0A, 0x12, 0xA0, 0x01, 0x02,
                                         0x04, 0x00, 0x00, 0x01, 0xFF, 0xEF };

                var dataMessage = new SendDataMessage(dataBytes);
                this.ToThread.PostInputMessage(dataMessage);
            }

            // capture the currently matched screen.
            else if (tagText == "Capture")
            {
                if (this.Model.MatchScreenDefn == null)
                {
                    MessageBox.Show("no matched screen to capture");
                }
                else
                {
                    // send message to master thread to get the current screen content.
                    var msg = new ExchangeMessage(ThreadMessageCode.GetScreenContent);
                    this.MasterThread.PostInputMessage(msg);
                    msg.WaitReplyEvent();
                    var content = msg.ReplyMessage as ScreenContent;

                    // send message to capture thread telling it to capture the current
                    // screen.
                    var captureMessage = new CaptureContentMessage(
                        this.Model.CaptureFolderPath, this.Model.CaptureAuto,
                        this.Model.MatchScreenDefn, content);
                    this.CaptureThread.PostInputMessage(captureMessage);
                }
            }

            else if (tagText == "CaptureViewer")
            {
                var window = new CaptureViewerWindow();
                window.CaptureFolderPath = this.Model.CaptureFolderPath;
                window.Show();
            }
        }
Пример #16
0
 public override void PrintAsCode(T source, LinePrinter @out, bool includeChecks)
 {
     @out.Println(this.GetType().Name + "#printAsCode not implemented");
 }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            string itemText = null;

            if (sender is MenuItem)
            {
                itemText = (sender as MenuItem).Header as string;
            }

            if (itemText == "Test")
            {
                var logList     = new TelnetLogList();
                var negSettings = NegotiateSettings.Build5250Settings("SRICHTER", "Steve25");

                var lines = System.IO.File.ReadAllLines("c:\\downloads\\hextext.txt");
                var ba    = ParseHexLines(lines);

                // print the bytes of the response stream as lines of hex text.
                {
                    var rep = ba.ToHexReport(16);
                    logList.AddItem(Direction.Read, "Length:" + ba.Length + " Byte stream bytes:");
                    logList.AddItems(Direction.Read, rep);
                }

                var inputArray      = new NetworkStreamBackedInputByteArray(ba, ba.Length);
                var sessionSettings = new SessionSettings();

                var rv = Process5250.GetAndParseWorkstationCommandList(
                    inputArray, sessionSettings);

                logList.AddItems(rv.Item2);
                var wrkstnCmdList = rv.Item1;

                // draw the fields and literals on the canvas.
                if (wrkstnCmdList != null)
                {
                    foreach (var workstationCmd in wrkstnCmdList)
                    {
                    }
                }

                foreach (var item in logList)
                {
                    this.Model.RunLog.Add(item.Text);
                }

                return;
            }

            else if (itemText == "Parse server stream")
            {
                var text  = TextBox1.Text;
                var lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                var ba = ParseHexLines(lines);

                // print the bytes of the response stream as lines of hex text.
                {
                    TelnetLogList logList = new TelnetLogList();
                    var           rep     = ba.ToHexReport(16);
                    logList.AddItem(Direction.Read, "Length:" + ba.Length + " Byte stream bytes:");
                    logList.AddItems(Direction.Read, rep);
                }
            }

            else if (itemText == "Parse response stream")
            {
                var logList     = new TelnetLogList();
                var negSettings = NegotiateSettings.Build5250Settings("SRICHTER", "Steve25");

                var lines = System.IO.File.ReadAllLines("c:\\downloads\\hextext.txt");
                var ba    = ParseHexLines(lines);

                // print the bytes of the response stream as lines of hex text.
                {
                    var rep = ba.ToHexReport(16);
                    logList.AddItem(Direction.Read, "Length:" + ba.Length + " Byte stream bytes:");
                    logList.AddItems(Direction.Read, rep);
                }

                Process5250.ParseResponseStream(logList, ba);

                foreach (var item in logList)
                {
                    if (item.NewGroup == true)
                    {
                        this.Model.RunLog.Add("");
                    }
                    this.Model.RunLog.Add(item.Text);
                }

                return;
            }

            else if (itemText == "Exit")
            {
                this.Close();
            }

            else if (itemText == "Settings")
            {
            }

            else if (itemText == "Print")
            {
                LinePrinter.PrintLines(this.Model.RunLog);
            }
            else if (itemText == "Clear log")
            {
                Model.RunLog.Clear();
            }
        }