Exemplo n.º 1
0
        private void flopGlobals()
        {
            Control[] controls = { tbOpacity,   cbRecord,       cbAlertSound, bBrowseAudioFile, bBrowseRecordFolder,
                                   tbAudioFile, tbRecordFolder, cbCodec,      cbDetectorType,   cbEnableMotionAlarm, cbAlwaysShow };

            if (cbGlobalOptions.Checked)
            {
                //save undo
                undoAlertSoundEnabled = cbAlertSound.Checked;
                undoRecordEnabled     = cbRecord.Checked;
                undoRecordFolder      = tbRecordFolder.Text;
                undoAudioFile         = tbAudioFile.Text;
                undoOpacity           = tbOpacity.Value;
                undoCodec             = cbCodec.SelectedItem;
                undoAlwaysShow        = cbAlwaysShow.Checked;
                undoEnableMotion      = cbEnableMotionAlarm.Checked;
                undoDetectorType      = options.DetectorType;


                //pull in all globals
                GlobalVideoFeedOptions globals = Program.globalSettings;
                cbAlertSound.Checked = globals.EnableAlertSound;
                cbRecord.Checked     = globals.EnableRecording;
                tbRecordFolder.Text  = globals.RecordFolder;
                tbAudioFile.Text     = globals.AlertSoundFile;
                cbCodec.SelectedItem = globals.Codec;

                tbOpacity.Value = (int)(globals.Opacity * 100);
                options.Opacity = ((double)tbOpacity.Value) / 100.0;

                cbAlwaysShow.Checked        = globals.EnableAlwaysShow;
                cbEnableMotionAlarm.Checked = globals.EnableMotionAlert;
                cbDetectorType.SelectedItem = globals.DetectorType;

                foreach (Control c in controls)
                {
                    c.Enabled = false;
                }
            }
            else
            {
                //undo changes
                cbAlertSound.Checked        = undoAlertSoundEnabled;
                cbRecord.Checked            = undoRecordEnabled;
                tbRecordFolder.Text         = undoRecordFolder;
                tbAudioFile.Text            = undoAudioFile;
                tbOpacity.Value             = undoOpacity;
                options.Opacity             = ((double)tbOpacity.Value) / 100.0;
                cbCodec.SelectedItem        = undoCodec;
                cbAlwaysShow.Checked        = undoAlwaysShow;
                cbEnableMotionAlarm.Checked = undoEnableMotion;
                cbDetectorType.SelectedItem = undoDetectorType;

                foreach (Control c in controls)
                {
                    c.Enabled = true;
                }
            }
        }
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");
            }
        }
Exemplo n.º 3
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");
            }
        }