Пример #1
0
        public static void ViewerThreadStart(List<string> inputFiles, bool standalone) {
            Trace.WriteLine("ViewerThreadStart starting");
            Application.EnableVisualStyles();
            Application.DoEvents();
            Process p = Process.GetCurrentProcess();
            SetProcessWorkingSetSize(p.Handle, -1, -1);

#if WEBSERVER
            // Create the web service
            Web.WebService web_server = new Web.WebService( null, "9090" );
#endif
            
#if DEBUG && LOGGING
            LoggingService logger = new LoggingService();
#endif
            Trace.WriteLine("Make PresenterModel");

            PresenterModel model = new PresenterModel();

            Trace.WriteLine("Make DeckMarshalService");

            using (DeckMarshalService loader = new DefaultDeckMarshalService()) {
                Trace.WriteLine("Construct ViewerForm");

                ViewerForm viewer = new ViewerForm(loader, model);
                ConnectionManager rtp = null;
#if RTP_BUILD
                Trace.WriteLine("Make RTPConnectionManager");

                rtp = new RTPConnectionManager(model);
#endif
                ConnectionManager tcp = new TCPConnectionManager(model);

#if RTP_BUILD
                Trace.WriteLine("Make BroadcastManager");

                BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp, (RTPConnectionManager)rtp);
#else
                BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp);
#endif

                using (rtp) {
                    using (tcp) {
                        using (bm) {
                            Trace.WriteLine("Make ViewerStateService");

                            using (ViewerStateService viewerState = new ViewerStateService(model.ViewerState)) {
                                using (RegistryService registry = new RegistryService(model.ViewerState)) {
                                    using (RegistryService penreg = new RegistryService(model.PenState)) {
#if DEBUG && LOGGING
                                        // Attach the logger to the model
                                        logger.AttachToModel(model.ViewerState);
#endif

#if STUDENT_CLIENT_ONLY
                                        using (Synchronizer.Lock(model.ViewerState.SyncRoot)){
                                            model.ViewerState.iRole = 1;
                                        }
#endif
                                        // Start the printing service
                                        PrintingService printing = new PrintingService(model.ViewerState);

                                        using (WorkspaceUndoService undo = new WorkspaceUndoService(viewer.m_EventQueue, model)) {

                                            using (Synchronizer.Lock(model.Network.SyncRoot)) {
                                                model.Network.Protocols.Add(tcp.Protocol);
#if RTP_BUILD
                                                model.Network.Protocols.Add(rtp.Protocol);
#endif
                                            }

                                            using (NetworkAssociationService association = new NetworkAssociationService(viewer.m_EventQueue, model)) {
                                                using (DeckMatcherService deckMatcher = new DeckMatcherService(viewer.m_EventQueue, model)) {

                                                    // Set the Initial Deck to Load if we are Loading from an Icon
                                                    viewer.OpenInputFiles = inputFiles;
                                                    viewer.StandAlone = standalone;
                                                    Trace.WriteLine("Ready to run viewer");

                                                    Application.Run(viewer);

                                                }
                                            }
                                        }
                                        penreg.SaveAllProperties();
                                    }

                                    registry.SaveAllProperties();
                                }
                            }
                        }
                    }
                }
            }

#if WEBSERVER
            // Dispose of the web server
            web_server.Dispose();
#endif
        }
Пример #2
0
        public static void ViewerThreadStart(string inputFile) {
            //FIXME: Initialize model from values in registry.
            Application.EnableVisualStyles();
            Application.DoEvents();
            Process p = Process.GetCurrentProcess();
            SetProcessWorkingSetSize(p.Handle, -1, -1);

#if DEBUG && LOGGING
            LoggingService logger = new LoggingService();
#endif
            PresenterModel model = new PresenterModel();
            using (DeckMarshalService loader = new DefaultDeckMarshalService()) {
                ViewerForm viewer = new ViewerForm(loader, model);
                ConnectionManager rtp = null;
#if RTP_BUILD
                rtp = new RTPConnectionManager(model);
#endif
                ConnectionManager tcp = new TCPConnectionManager(model);

#if RTP_BUILD
                BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp, (RTPConnectionManager)rtp);
#else
                BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp);
#endif

                using (rtp) {
                    using (tcp) {
                        using (bm) {
                            using (ViewerStateService viewerState = new ViewerStateService(model.ViewerState)) {
                                using (RegistryService registry = new RegistryService(model.ViewerState)) {
                                    using (RegistryService penreg = new RegistryService(model.PenState)) {
#if DEBUG && LOGGING
                                        // Attach the logger to the model
                                        logger.AttachToModel(model.ViewerState);
#endif
                                        // Start the printing service
                                        PrintingService printing = new PrintingService(model.ViewerState);

                                        using (WorkspaceUndoService undo = new WorkspaceUndoService(viewer.m_EventQueue, model)) {

                                            using (Synchronizer.Lock(model.Network.SyncRoot)) {
                                                model.Network.Protocols.Add(tcp.Protocol);
#if RTP_BUILD
                                                model.Network.Protocols.Add(rtp.Protocol);
#endif
                                            }

                                            using (NetworkAssociationService association = new NetworkAssociationService(viewer.m_EventQueue, model)) {
                                                using (DeckMatcherService deckMatcher = new DeckMatcherService(viewer.m_EventQueue, model)) {

                                                    // Set the Initial Deck to Load if we are Loading from an Icon
                                                    viewer.OpenFromIconInputFile = inputFile;

                                                    Application.Run(viewer);

                                                }
                                            }
                                        }
                                        penreg.SaveAllProperties();
                                    }

                                    registry.SaveAllProperties();
                                }
                            }
                        }
                    }
                }
            }
        }