コード例 #1
0
        private void TelnetWindowInputSignalHandler(ThreadMessageBase message)
        {
            if (message is MatchScreenDefnMessage)
            {
                var defnMessage = message as MatchScreenDefnMessage;
                this.Model.MatchScreenDefn = defnMessage.ScreenDefn;

                if (this.Dispatcher.CheckAccess() == false)
                {
                    this.Dispatcher.BeginInvoke(
                        DispatcherPriority.Input, new ThreadStart(
                            () =>
                    {
                        if (defnMessage.ScreenDefn != null)
                        {
                            tbStatusBarMessage.Text = defnMessage.ScreenDefn.ScreenName;

                            // auto capture of content of every screen with a matching
                            // screen defn. Signal the capture thread to perform the capture.
                            if (this.Model.CaptureAuto == true)
                            {
                                var captureMessage = new CaptureContentMessage(
                                    this.Model.CaptureFolderPath, this.Model.CaptureAuto,
                                    defnMessage.ScreenDefn, defnMessage.ScreenContent);
                                this.CaptureThread.PostInputMessage(captureMessage);
                            }
                        }
                    }));
                }
            }
        }
コード例 #2
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();
            }
        }