void MainWindow_Closed(object sender, EventArgs e) { // signal that the tnClient app is shutting down. Background threads all wait // on this event. this.ShutdownFlag.Set(); // wait for background threads to end. if (this.FromThread != null) { this.FromThread.ThreadEndedEvent.WaitOne(); } if (this.PaintThread != null) { this.PaintThread.ThreadEndedEvent.WaitOne(); } if (this.MasterThread != null) { this.MasterThread.ThreadEndedEvent.WaitOne(); } if (this.PrinterThread != null) { this.PrinterThread.ThreadEndedEvent.WaitOne(); } if (this.ToThread != null) { this.ToThread.ThreadEndedEvent.WaitOne(); } if (this.MatchThread != null) { this.MatchThread.ThreadEndedEvent.WaitOne(); } if (this.CaptureThread != null) { this.CaptureThread.ThreadEndedEvent.WaitOne(); } // make sure the telnet connection is closed. this.ConnectPack?.Dispose(); this.TelnetCanvas.Dispose(); this.ClientSettingsControl_ApplySettings(this.Model); // serialize the ScreenDefnList if (this.Model.ScreenDefnPath.IsNullOrEmpty( ) == false) { var defnList = new ScreenDefnList(this.Model.ScreenDefnObservableList); defnList.StoreToXmlFile(this.Model.ScreenDefnPath); } }
private IScreenDefn FindMatchingScreenDefn( ScreenContent Content, ScreenDefnList ScreenDefnList) { IScreenDefn matchDefn = null; foreach (var screenDefn in ScreenDefnList) { var isMatch = screenDefn.Match(Content); if (isMatch == true) { matchDefn = screenDefn; break; } } return(matchDefn); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { this.LogList = new TelnetLogList("Main"); { var settings = ClientSettings.RecallSettings(); if (settings.WindowClientSize.Height > 0) { this.Height = settings.WindowClientSize.Height; this.Width = settings.WindowClientSize.Width; } this.Model = ClientModel.ToModel(settings); // recall list of screen defn from screen defn xml file. var defnList = ScreenDefnList.RecallFromXmlFile(this.Model.ScreenDefnPath); this.Model.ScreenDefnObservableList = defnList.ToObservableCollection(); this.Model.SystemList_AddBlankItem(); grdMain.DataContext = this.Model; this.Canvas1.Focusable = true; this.Canvas1.IsEnabled = true; this.Canvas1.Focus(); this.Model.TelnetCanvas = new ItemCanvas( this.Canvas1, 9.83, 18.5, new ScreenDim(24, 80), settings.FontPointSize, null); this.udFontSize.NumericValue = (int)this.Model.TelnetCanvas.FontPointSize; this.Model.TelnetCanvas.CanvasChanged += ScreenCanvas_CanvasChanged; TrafficLogFile.ClearFile(); } }
/// <summary> /// method called from the ConnectThread. Called when telnet startup has been /// completed. Telnet client is now ready to process workstation messages and /// render them to the canvas. /// </summary> /// <param name="obj"></param> private void MainWindow_TelnetStartupComplete(bool obj, TypeTelnetDevice?TypeDevice) { // send message to FromThread telling it the connection is complete and the // device type. { var message = new TelnetDeviceAttrMessage(TypeDevice.Value); this.FromThread.PostInputMessage(message); } // start the master screen content thread. { var job = new ThreadStart(this.MasterThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Name = "MasterThread"; t.Start(); } // start the printer thread. if (TypeDevice.Value == TypeTelnetDevice.Printer) { var job = new ThreadStart(this.PrinterThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Name = "PrinterThread"; t.Start(); } // start the paint thread. This thread reads WorkstationCommand blocks that are // created by the FromThread and paints them to the ItemCanvas. { var job = new ThreadStart(this.PaintThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Name = "PaintThread"; t.Start(); } // start the match thread. This thread matches the screenContent against the // ScreenDefn screen definitions. The screen defn contains hover scripts, // screen enhancements, etc. { var job = new ThreadStart(this.MatchThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Name = "MatchThread"; t.Start(); // the model can send alert messages to the threads. set ref to the threads. this.Model.MatchThread = this.MatchThread; // send the screenDefnList to the match thread. var screenDefnList = new ScreenDefnList(this.Model.ScreenDefnObservableList); var assignMessage = new AssignScreenDefnListMessage(screenDefnList); this.MatchThread.PostInputMessage(assignMessage); } // start the capture thread. This thread capture screen contents according // to a screen defn. Captured data is stored to database, stream file or // clipboard. { var job = new ThreadStart(this.CaptureThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Name = "CaptureThread"; t.Start(); // the model can send alert messages to the threads. set ref to the threads. this.Model.CaptureThread = this.CaptureThread; } // todo: make this two method calls. // FindSelectCanvas( ). then SetCanvasFocus( ). // also, move SetCanvasFocus into Canvas class. probably make a // Canvas class extension method. SetCompleteFocus. But try to make // ItemCanvas to have Canvas as a base class. FindCanvasSetFocus(); }
public AssignScreenDefnListMessage(ScreenDefnList ScreenDefnList) { this.ScreenDefnList = ScreenDefnList; }