public ScannerController(ScannerControllerWidget scanControllerWidget) { this.scanControllerWidget = scanControllerWidget; // connect to the scanner controller var serverProvider = new BinaryServerFormatterSinkProvider(); var clientProvider = new BinaryClientFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; var props = new Hashtable(); props["name"] = "ipc"; props["portName"] = ScanWorker.Program.APP_NAME + "_CLIENT"; IpcChannel clientChannel = new IpcChannel(props, clientProvider, serverProvider); ChannelServices.RegisterChannel(clientChannel); scanWorker = (IScanWorker)Activator.GetObject( typeof(ScanWorker.ScanWorker), "ipc://ScanSimple/ScanWorker"); try { // try to connect to existing scan worker process first (for debugging) bool alive = scanWorker.ping(); Console.WriteLine("scanworker ping() output = " + alive); } catch (System.Runtime.Remoting.RemotingException e) { // if we fail, launch a scan worker... LaunchScanWorker(); for (int i = 0; i < 10; i++) { Thread.Sleep(50); // and try to connect again try { bool alive2 = scanWorker.ping(); Console.WriteLine("scanworker ping() output = " + alive2); break; } catch (System.Runtime.Remoting.RemotingException e2) { // try again. Console.WriteLine("failed to connect to ScanWorker, trying again..."); } } // if we didn't connect, this will throw an exception bool alive = scanWorker.ping(); // now create our scan master listener, and send it over scanMaster = new ScanMaster(scanControllerWidget.mainWindow, scanControllerWidget); scanWorker.RegisterMaster(scanMaster); } }
public MainWindow() { Title = "ScanSimple"; Width = Prefs.GetPref("MainWindow.Width", 800); Height = Prefs.GetPref("MainWindow.Height", 800); if (Prefs.HasPref("MainWindow.X")) { X = Prefs.GetPref("MainWindow.X", 100); Y = Prefs.GetPref("MainWindow.Y", 100); } // TODO: check that our window is not too small and on the visible screen // Get this type's assembly Assembly assem = this.GetType().Assembly; // Enumerate the assembly's manifest resources foreach (string resourceName in assem.GetManifestResourceNames()) { Console.WriteLine(resourceName); } this.Content = topPanel = new VBox(); topPanel.PackStart(scanControllerWidget = new ScannerControllerWidget(this)); topPanel.PackStart(mainScrollView = new ScrollView(), expand: true); { var panel = new VBox(); mainScrollView.Content = panel; mainScrollView.VerticalScrollPolicy = ScrollPolicy.Always; panel.PackStart(scanSessionsVBox = new VBox()); panel.PackStart(new Canvas(), true); panel.PackStart(imageView = new ImageView(), expand: true); } }
public ScanMaster(MainWindow mainWindow, ScannerControllerWidget scanControllerWidget) { this.mainWindow = mainWindow; this.scanControllerWidget = scanControllerWidget; }