예제 #1
0
        public void readQRCode()
        {
            Image mapI = Properties.Resources.map_with_qr_code;
            Bitmap mapB = new Bitmap(mapI);

            MapWithQRCodeReader reader = new MapWithQRCodeReader();
            string data = reader.getQRCodeData(mapB);
            Assert.AreEqual("50,7369372355816;7,09531188011169;0,0619", data);
        }
예제 #2
0
        public MainForm()
        {
            InitializeComponent();

            this.FormClosing += new FormClosingEventHandler(mainForm_FormClosing);
            this.Move += delegate { new UpdateMapSizeAndPosition(this.mainVideo, MapOverlayForm.Instance).execute(); };
            this.SizeChanged += delegate { new UpdateMapSizeAndPosition(this.mainVideo, MapOverlayForm.Instance).execute(); };
            this.Load += delegate { new UpdateMapSizeAndPosition(this.mainVideo, MapOverlayForm.Instance).execute(); };

            MapOverlayForm.Instance.Owner = this;
            MapOverlayForm.Instance.Show();

            this.setDetector(Settings.Default.SelectedDetectorIndex);
            this.detectorComboBox.SelectedIndex = Settings.Default.SelectedDetectorIndex;
            this.detectorComboBox.SelectedValueChanged += delegate { this.setDetector(this.detectorComboBox.SelectedIndex); };

            this.updateVideoSourceCombo();
            this.videoSourceCombo.SelectedValueChanged += delegate { new UpdateVideoFormatComboCommand(this.videoSourceCombo.SelectedIndex, this.videoFormatCombo).execute(); };
            try
            {
                this.videoSourceCombo.SelectedIndex = Settings.Default.VideoSourceIndex;
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            Command changeVideoFormatCommand = new ChangeVideoFormatCommand(this.mainVideo, this.videoSourceCombo, this.videoFormatCombo, this);
            this.videoFormatCombo.SelectedValueChanged += delegate { changeVideoFormatCommand.execute(); };
            try
            {
                this.videoFormatCombo.SelectedIndex = Settings.Default.VideoFormatIndex;
                changeVideoFormatCommand.execute();
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            this.brightness.Scroll += delegate { this.videoPreprocessor.Brightness = this.brightness.Value; };

            this.contrast.Scroll += delegate { this.videoPreprocessor.Contrast = this.contrast.Value; };

            this.saturation.Scroll += delegate { this.videoPreprocessor.Saturation = Convert.ToSingle(this.saturation.Value) / 100.0f; };

            this.checkServerState.CheckedChanged += delegate { if (this.checkServerState.Checked) { NetworkServer.Instance.Start(); } else { NetworkServer.Instance.Stop(); } };
            NetworkServer.Instance.serverLog = this.serverLog;
            if (Settings.Default.NetworkServerActive)
                NetworkServer.Instance.Start();

            this.checkBroadcast.CheckedChanged += delegate { if (this.checkBroadcast.Checked) { Broadcaster.Instance.Start(); } else { Broadcaster.Instance.Stop(); } };
            if (Settings.Default.BroadcastLocationSources)
                Broadcaster.Instance.Start();

            this.mapZoom.Scroll += delegate { new MapZoomCommand(this.mapZoom.Value, false).execute(); };
            this.mapOpacity.Scroll += delegate { MapOverlayForm.Instance.Opacity = Convert.ToDouble(this.mapOpacity.Value) / 100.0; };
            this.mapBearing.Scroll += delegate { MapOverlayForm.Instance.RotationAngle = Convert.ToSingle(this.mapBearing.Value); };

            this.showDetectorSettings.Click += delegate { this.detector.SettingsForm().Show(); };

            this.addUser.Click += delegate { new CreateLocationSourceCommand(this.userListContainer, this.detectorFactory).execute(); };

            this.checkRecordUsersTracks.CheckedChanged += delegate {
                if (this.checkRecordUsersTracks.Checked)
                {
                    RecorderManager.Instance.pauseRecording();
                }
                else
                {
                    RecorderManager.Instance.continueRecording();
                };
            };

            this.paperFormat.SelectedIndex = Settings.Default.QRCodePaperFormat;
            this.saveQR.Click += delegate
            {
                MapWithQRCodeWriter writer = new MapWithQRCodeWriter();
                SaveFileDialog saveFileDialog = new SaveFileDialog();

                saveFileDialog.Filter = "pdf files (*.pdf)|*.pdf";
                saveFileDialog.FilterIndex = 1;
                saveFileDialog.RestoreDirectory = true;
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    writer.write(this.paperFormat.SelectedIndex, saveFileDialog.FileName);
                }
                saveFileDialog.Dispose();
            };

            qrCodeEncoder = new MapWithQRCodeReader();
            this.encodeQR.Click += delegate
            {
                this.qrCodeEncoder.decode(this.mainVideo.GetCurrentVideoFrame());
            };
        }