Exemplo n.º 1
0
        public SystemTray()
        {
            InitializeComponent();
            System.Windows.Forms.Application.EnableVisualStyles(); //XP style
            logviewer = new LogViewer();
            this.Resize += SystemTray_Resize;

            //Log Mode
            Log.info(String.Format("Running in {0}-bit mode.",
                (Environment.Is64BitProcess) ? 64: 32
            ));

            //first time, make sure update checks are alright
            if (Properties.Settings.Default.firstTime)
            {
                if (MessageBox.Show("Would you like Rear View Mirror to automatically check for updates?", "Check for Updates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Properties.Settings.Default.checkUpdates = true;
                }
                else
                {
                    Properties.Settings.Default.checkUpdates = false;
                }
                Properties.Settings.Default.firstTime = false;
                Properties.Settings.Default.Save();
            }

            //upgrade our settings from previous versions
            if (Properties.Settings.Default.updateSettings)
            {
                Log.info("Upgrading settings from previous Rear View Mirror version");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.updateSettings = false;
                Properties.Settings.Default.Save();
            }

            //load and start all video sources which were started previously
            VideoSource[] loadSources = Properties.Settings.Default.videoSources;

            //Seralizing for older versions of RearViewMirror searziled the entire
            // capture object which no longer works with new versions of AForge
            // If we have any of these saved cameras, we'll need to drop them.
            sources = new ArrayList();
            if (loadSources != null)
            {
                foreach (VideoSource vs in loadSources)
                {
                    if (vs.SerializeddDeviceString != null)
                    {
                        sources.Add(vs);
                    }
                    else
                    {
                        Log.warn(String.Format("Camera {0} from older version of RearViewMirror could not be restored",vs.Name));
                    }
                }
            }

            foreach(VideoSource i in sources) {

                if (i.SaveState == VideoSource.CameraState.Started)
                {
                    i.startCamera();
                }
                i.RemoveSelected += new VideoSource.RemoveEventHandler(r_RemoveSelected);
            }

            //Global Settings
            if (Properties.Settings.Default.globalVideoOptions != null)
            {
                Log.info("Loading Saved Global Properties");
                globalOptions = Properties.Settings.Default.globalVideoOptions;
                Log.debug(globalOptions.ToString());
                globalOptions.updateViewers();
            }
            else
            {
                Log.info("No Saved Global Properties. Creating New Properties");
                globalOptions = new GlobalVideoFeedOptions();
                Log.debug(globalOptions.ToString());
            }
            globalOptions.VideoSources =  sources ;

            //previous URLs for MJPEG streams
            recentURLs = Properties.Settings.Default.recentURLs;
            if (recentURLs == null) { recentURLs = new StringCollection(); }

            //video server
            videoServer = VideoServer.Instance;
            videoServer.Port = Properties.Settings.Default.serverPort;
            connectionsWindow = new ServerConnections(videoServer);

            //load previous server running state
            if (Properties.Settings.Default.serverRunning)
            {
                videoServer.startServer();
            }

            //load global stickey
            showAllToolStripMenuItem.Checked = Properties.Settings.Default.showAll;
            foreach (VideoSource s in sources)
            {
                s.setViewerGlobalStickey(showAllToolStripMenuItem.Checked);
            }

            //check for updates
            if (Properties.Settings.Default.checkUpdates)
            {
                Updater.checkForUpdates();
                checkForUpdatesToolStripMenuItem.Checked = true;
            }
            else
            {
                checkForUpdatesToolStripMenuItem.Checked = false;
                Log.info("Update check not enabled");
            }
        }
Exemplo n.º 2
0
        public SystemTray()
        {
            InitializeComponent();
            System.Windows.Forms.Application.EnableVisualStyles(); //XP style
            logviewer    = new LogViewer();
            this.Resize += SystemTray_Resize;

            //Log Mode
            Log.info(String.Format("Running in {0}-bit mode.",
                                   (Environment.Is64BitProcess) ? 64: 32
                                   ));

            //first time, make sure update checks are alright
            if (Properties.Settings.Default.firstTime)
            {
                if (MessageBox.Show("Would you like Rear View Mirror to automatically check for updates?", "Check for Updates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Properties.Settings.Default.checkUpdates = true;
                }
                else
                {
                    Properties.Settings.Default.checkUpdates = false;
                }
                Properties.Settings.Default.firstTime = false;
                Properties.Settings.Default.Save();
            }


            //upgrade our settings from previous versions
            if (Properties.Settings.Default.updateSettings)
            {
                Log.info("Upgrading settings from previous Rear View Mirror version");
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.updateSettings = false;
                Properties.Settings.Default.Save();
            }

            //load and start all video sources which were started previously
            VideoSource[] loadSources = Properties.Settings.Default.videoSources;

            //Seralizing for older versions of RearViewMirror searziled the entire
            // capture object which no longer works with new versions of AForge
            // If we have any of these saved cameras, we'll need to drop them.
            sources = new ArrayList();
            if (loadSources != null)
            {
                foreach (VideoSource vs in loadSources)
                {
                    if (vs.SerializeddDeviceString != null)
                    {
                        sources.Add(vs);
                    }
                    else
                    {
                        Log.warn(String.Format("Camera {0} from older version of RearViewMirror could not be restored", vs.Name));
                    }
                }
            }

            foreach (VideoSource i in sources)
            {
                if (i.SaveState == VideoSource.CameraState.Started)
                {
                    i.startCamera();
                }
                i.RemoveSelected += new VideoSource.RemoveEventHandler(r_RemoveSelected);
            }

            //Global Settings
            if (Properties.Settings.Default.globalVideoOptions != null)
            {
                Log.info("Loading Saved Global Properties");
                globalOptions = Properties.Settings.Default.globalVideoOptions;
                Log.debug(globalOptions.ToString());
                globalOptions.updateViewers();
            }
            else
            {
                Log.info("No Saved Global Properties. Creating New Properties");
                globalOptions = new GlobalVideoFeedOptions();
                Log.debug(globalOptions.ToString());
            }
            globalOptions.VideoSources = sources;


            //previous URLs for MJPEG streams
            recentURLs = Properties.Settings.Default.recentURLs;
            if (recentURLs == null)
            {
                recentURLs = new StringCollection();
            }

            //video server
            videoServer       = VideoServer.Instance;
            videoServer.Port  = Properties.Settings.Default.serverPort;
            connectionsWindow = new ServerConnections(videoServer);

            //load previous server running state
            if (Properties.Settings.Default.serverRunning)
            {
                videoServer.startServer();
            }

            //load global stickey
            showAllToolStripMenuItem.Checked = Properties.Settings.Default.showAll;
            foreach (VideoSource s in sources)
            {
                s.setViewerGlobalStickey(showAllToolStripMenuItem.Checked);
            }

            //check for updates
            if (Properties.Settings.Default.checkUpdates)
            {
                Updater.checkForUpdates();
                checkForUpdatesToolStripMenuItem.Checked = true;
            }
            else
            {
                checkForUpdatesToolStripMenuItem.Checked = false;
                Log.info("Update check not enabled");
            }
        }