Beispiel #1
0
        /// <summary>
        /// Constructs a service to keep track of changes to the model objects and store them in the
        /// registry
        /// </summary>
        /// <param name="toSave">The model class with values we want to save in the registry</param>
        public LoggingService()
        {
            bool bEnabled = false;
            // Check in the registry for the logging value and if it's enabled
            RegistryKey properties = Registry.CurrentUser.OpenSubKey(RegistryService.m_szRegistryString, true);

            if (properties == null)
            {
                //If this is the first time we have run the app:
                properties = Registry.CurrentUser.CreateSubKey(RegistryService.m_szRegistryString);
                bEnabled   = true;
            }

            // Check if we are enabled
            string enabled = RegistryService.GetStringRegistryValue(properties, "LoggingEnabled");

            if (enabled != null)
            {
                bEnabled = bool.Parse(enabled);
            }

            // Get the Path
            string path = RegistryService.GetStringRegistryValue(properties, "LoggingPath");

            if (path == null)
            {
                path = ".\\Logs";
            }

            if (bEnabled)
            {
                this.SetupLogFileHelper(path);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Returns a property that is of type string.
 /// </summary>
 /// <param name="name">The name of the property to return.</param>
 /// <returns>The string that corresponds to the specified key or null
 /// if no such key exists.</returns>
 protected string GetStringRegistryValue(string name)
 {
     return(RegistryService.GetStringRegistryValue(this.m_RegistryKey, name));
 }
Beispiel #3
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
        }
Beispiel #4
0
        /// <summary>
        /// This is called from Dispose
        /// </summary>
        private void DisposeCapabilityResources() {
            if (m_DeckMatcher != null) {
                m_DeckMatcher.Dispose();
                m_DeckMatcher = null;
            }

            if (m_Association != null) {
                m_Association.Dispose();
                m_Association = null;
            }

            if (m_Undo != null) {
                m_Undo.Dispose();
                m_Undo = null;
            }

            if (m_Registry != null) {
                m_Registry.SaveAllProperties();
                m_Registry.Dispose();
                m_Registry = null;
            }

            if (m_ViewerState != null) {
                m_ViewerState.Dispose();
                m_ViewerState = null;
            }

            if (m_Loader != null) {
                m_Loader.Dispose();
                m_Loader = null;
            }
        }
Beispiel #5
0
        /// <summary>
        /// This constructor is used for launching as a CXP capability.
        /// </summary>
        public ViewerForm() {

            Application.EnableVisualStyles();
            //Application.DoEvents();  //Note: this seems to cause problems in the CXP Capability context.

#if DEBUG && LOGGING
            LoggingService logger = new LoggingService();
#endif
            PresenterModel model = new PresenterModel();
            m_Loader = new DefaultDeckMarshalService();

            this.SuspendLayout();
            this.m_EventQueue = new ControlEventQueue(this);

            this.m_Model = model;
            this.m_Marshal = m_Loader;

            UpdateTitle();

            this.Name = "ViewerForm";

            //Retrieve the icon
            System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            this.Icon = new Icon( thisExe.GetManifestResourceStream( "UW.ClassroomPresenter.Presenter.ico" ) );

            this.StartPosition = FormStartPosition.Manual;
            this.loadRegSettings();
            this.MinimumSize = new Size(440, 330);

            Menus.FileMenu.CloseFormDelegate cfd = new UW.ClassroomPresenter.Viewer.Menus.FileMenu.CloseFormDelegate(this.Close);
            this.Menu = new Menus.ViewerMainMenu(this.m_EventQueue, this.m_Model, m_Loader, cfd);


            this.m_MainToolBars = new MainToolBars(this.m_Model, this.m_EventQueue);
            this.m_PresentationLayout = new ViewerPresentationLayout(this.m_Model);
            //this.m_MainToolBar.Dock = DockStyle.Top;
            this.m_PresentationLayout.Dock = DockStyle.Fill;

            this.Controls.Add(this.m_PresentationLayout);
        
            // Hack: toggle the second monitor to make it scale correctly when using Surface Pro 3.
            // Bounds need to be set after the ViewerPresentationLayout control is added,
            // Otherwise DPI scaling appears to be done incorrectly.  This issue so far
            // appears to be unique to the Surface Pro 3.
            using (Synchronizer.Lock(model.ViewerState.SyncRoot)) {
                if (model.ViewerState.SecondMonitorEnabled) {
                    model.ViewerState.SecondMonitorEnabled = false;
                    model.ViewerState.SecondMonitorEnabled = true;
                }
            }

            this.Controls.Add(this.m_MainToolBars.m_MainToolBar);
            this.Controls.Add(this.m_MainToolBars.m_MainClassmateToolBar);
            this.Controls.Add(this.m_MainToolBars.m_ExtraClassmateToolBar);

            this.ResumeLayout(false);

            this.KeyDown += new KeyEventHandler(this.OnKeyDown);
            this.KeyPreview = true;

            ///add listeners for HumanName, Role, Stylus properties
            role_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.ParticipantRoleChanged));
            stylus_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.StylusChanged));
            instructor_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.InstructorChanged));

            this.m_Model.Participant.Changed["Role"].Add(role_listener_.Dispatcher);
            this.m_Model.Changed["Stylus"].Add(stylus_listener_.Dispatcher);
            this.m_Model.Network.Changed["Association"].Add(instructor_listener_.Dispatcher);

            //Add listener for the version exchange warning pop-up
            this.m_VersionExchangePopUpListener = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.PopUpWarningHandler));
            this.m_Model.VersionExchange.Changed["PopUpWarningMessage"].Add(m_VersionExchangePopUpListener.Dispatcher);

            //Add listener for NetworkStatus
            m_NetworkStatusListener = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.NetworkStatusChanged));
            this.m_Model.Network.Changed["NetworkStatus"].Add(m_NetworkStatusListener.Dispatcher);

            this.m_FullScreenAdapter = new FullScreenAdapter(this.m_Model, this.m_PresentationLayout);

            instructor_listener_.Dispatcher(this, null);
            role_listener_.Dispatcher(this, null);
            stylus_listener_.Dispatcher(this, null);

            this.FormClosing += this.SaveClose;

            //Store local DPI settings which are used to make sure ink is scaled correctly.
            using (Graphics g = this.CreateGraphics()) {
                ViewerStateModel.SetLocalDpi(g.DpiX, g.DpiY);
            }

            m_ViewerState = new ViewerStateService(model.ViewerState);
            m_Registry = new RegistryService(model.ViewerState); 
#if DEBUG && LOGGING
            logger.AttachToModel(model.ViewerState);
#endif
            PrintingService printing = new PrintingService(model.ViewerState);
            m_Undo = new WorkspaceUndoService(this.m_EventQueue, model);

            m_Association = new NetworkAssociationService(this.m_EventQueue, model);
            m_DeckMatcher = new DeckMatcherService(this.m_EventQueue, model);
            
        }
Beispiel #6
0
        /// <summary>
        /// This constructor is used for launching as a CXP capability.
        /// </summary>
        public ViewerForm() {

            Application.EnableVisualStyles();
            //Application.DoEvents();  //Note: this seems to cause problems in the CXP Capability context.

#if DEBUG && LOGGING
            LoggingService logger = new LoggingService();
#endif
            PresenterModel model = new PresenterModel();
            m_Loader = new DefaultDeckMarshalService();

            this.SuspendLayout();
            this.m_EventQueue = new ControlEventQueue(this);

            this.m_Model = model;
            this.m_Marshal = m_Loader;

            UpdateTitle();

            this.Name = "ViewerForm";

            //Retrieve the icon
            System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            this.Icon = new Icon( thisExe.GetManifestResourceStream( "UW.ClassroomPresenter.Presenter.ico" ) );

            // The form should fill 5/6 of the screen by default.
            // FIXME: Load/Store previous window size from/in the registry.
            this.Size = new Size(SystemInformation.WorkingArea.Size.Width * 5 / 6,
                SystemInformation.WorkingArea.Size.Height * 5 / 6);
            // the form should be no smaller than 1/2 it's original size
            this.MinimumSize = new Size(this.Size.Width / 2, this.Size.Height / 2);

            Menus.FileMenu.CloseFormDelegate cfd = new UW.ClassroomPresenter.Viewer.Menus.FileMenu.CloseFormDelegate(this.Close);
            this.Menu = new Menus.ViewerMainMenu(this.m_EventQueue, this.m_Model, m_Loader, cfd);


            this.m_MainToolBars = new MainToolBars(this.m_Model, this.m_EventQueue);
            this.m_PresentationLayout = new ViewerPresentationLayout(this.m_Model);
            //this.m_MainToolBar.Dock = DockStyle.Top;
            this.m_PresentationLayout.Dock = DockStyle.Fill;

            this.Controls.Add(this.m_PresentationLayout);

            this.Controls.Add(this.m_MainToolBars.m_MainToolBar);
            this.Controls.Add(this.m_MainToolBars.m_MainClassmateToolBar);
            this.Controls.Add(this.m_MainToolBars.m_ExtraClassmateToolBar);

            this.ResumeLayout(false);

            this.KeyDown += new KeyEventHandler(this.OnKeyDown);
            this.KeyPreview = true;

            ///add listeners for HumanName, Role, Stylus properties
            role_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.ParticipantRoleChanged));
            stylus_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.StylusChanged));
            instructor_listener_ = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.InstructorChanged));

            this.m_Model.Participant.Changed["Role"].Add(role_listener_.Dispatcher);
            this.m_Model.Changed["Stylus"].Add(stylus_listener_.Dispatcher);
            this.m_Model.Network.Changed["Association"].Add(instructor_listener_.Dispatcher);

            //Add listener for the version exchange warning pop-up
            this.m_VersionExchangePopUpListener = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.PopUpWarningHandler));
            this.m_Model.VersionExchange.Changed["PopUpWarningMessage"].Add(m_VersionExchangePopUpListener.Dispatcher);

            //Add listener for NetworkStatus
            m_NetworkStatusListener = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.NetworkStatusChanged));
            this.m_Model.Network.Changed["NetworkStatus"].Add(m_NetworkStatusListener.Dispatcher);

            this.m_FullScreenAdapter = new FullScreenAdapter(this.m_Model, this.m_PresentationLayout);

            instructor_listener_.Dispatcher(this, null);
            role_listener_.Dispatcher(this, null);
            stylus_listener_.Dispatcher(this, null);

            this.FormClosing += this.SaveClose;

            //Store local DPI settings which are used to make sure ink is scaled correctly.
            using (Graphics g = this.CreateGraphics()) {
                ViewerStateModel.SetLocalDpi(g.DpiX, g.DpiY);
            }

            m_ViewerState = new ViewerStateService(model.ViewerState);
            m_Registry = new RegistryService(model.ViewerState); 
#if DEBUG && LOGGING
            logger.AttachToModel(model.ViewerState);
#endif
            PrintingService printing = new PrintingService(model.ViewerState);
            m_Undo = new WorkspaceUndoService(this.m_EventQueue, model);

            m_Association = new NetworkAssociationService(this.m_EventQueue, model);
            m_DeckMatcher = new DeckMatcherService(this.m_EventQueue, model);
            
        }
Beispiel #7
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();
                                }
                            }
                        }
                    }
                }
            }
        }