Esempio n. 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog ccd = new CameraCaptureDialog();
            ccd.ShowDialog();

            //try
            //{

            this.Refresh();
            using (FileStream reader = new FileStream(ccd.FileName, FileMode.Open))
            {
                byte[] data = new byte[reader.Length];
                reader.Read(data, 0, (int)reader.Length);
                using (MemoryStream memory = new MemoryStream(data))
                {
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = new Bitmap(memory);
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
            }

                this.pictureBox1.Visible = true;

                this.button7.Visible = false;
            //}
            //catch(Exception)
            //{
            //    MessageBox.Show("1313");
            //}
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog camCapture = new CameraCaptureDialog();

            camCapture.Owner = null;

            camCapture.InitialDirectory = pathName;
            camCapture.Resolution       = new Size(200, 200);
            camCapture.Mode             = CameraCaptureMode.Still;

            //gerar nome aleatorio para a foto
            fileName = RandomString(5) + ".jpg";

            while (System.IO.File.Exists(pathName + fileName))
            {
                fileName = RandomString(5) + ".jpg";
            }

            camCapture.DefaultFileName = fileName;

            if (DialogResult.OK == camCapture.ShowDialog())
            {
                Bitmap img = new Bitmap(pathName + fileName);
                pictureBox1.Image = img;

                //label do caminho do arquivo
                foto_pathTextBox.Text = pathName + fileName;
            }
            this.BringToFront();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog camCapture = new CameraCaptureDialog();
            camCapture.Owner = null;

            camCapture.InitialDirectory = pathName;
            camCapture.Resolution = new Size(200, 200);
            camCapture.Mode = CameraCaptureMode.Still;

            //gerar nome aleatorio para a foto
            fileName = RandomString(5)+".jpg";

            while (System.IO.File.Exists(pathName + fileName))
            {
                fileName = RandomString(5) + ".jpg";
            }

            camCapture.DefaultFileName = fileName;

            if (DialogResult.OK == camCapture.ShowDialog())
            {
                Bitmap img = new Bitmap(pathName + fileName);
                pictureBox1.Image = img;

                //label do caminho do arquivo
                foto_pathTextBox.Text = pathName + fileName;
            }
            this.BringToFront();
        }
Esempio n. 4
0
        private void FotoPonto_Load(object sender, EventArgs e)
        {
            CameraCaptureDialog camCapture = new CameraCaptureDialog();
            camCapture.Owner = this;

            pathName =
                Library.appDir + "\\imagens\\cip\\" + Usuario.Chave + "\\";

            camCapture.InitialDirectory = pathName;
            camCapture.Resolution = new Size(240, 240);
            camCapture.Mode = CameraCaptureMode.Still;
            fileName = Usuario.Sequencia + ".jpg";
            camCapture.DefaultFileName = fileName;

            //try
            //{
            //    fotosBindingSource.CancelEdit();
            //    fotosBindingSource.AddNew();

            //}
            //catch (Exception ex)
            //{
            //    //
            //}

            if (DialogResult.OK == camCapture.ShowDialog())
            {
                Bitmap img = new Bitmap(pathName + fileName);

                pictureBox1.Image = img;
                textBox1.Text = fileName;
            }
        }
 /// <summary>
 /// Show Dialog
 /// </summary>
 /// <param name="sender">sender control</param>
 /// <param name="resolution">image size</param>
 /// <returns>filepath of photo</returns>
 public static FileInfo ShowDialog(Control sender, ImageSize resolution)
 {
     if (SystemState.CameraPresent && SystemState.CameraEnabled)
     {
         using (CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog())
         {
             cameraCaptureDialog.Owner = sender;
             cameraCaptureDialog.Mode = CameraCaptureMode.Still;
             cameraCaptureDialog.StillQuality = CameraCaptureStillQuality.Normal;
             cameraCaptureDialog.Title = "takeIncidentPhoto".Translate();
             if (resolution != null)
             {
                 cameraCaptureDialog.Resolution = resolution.ToSize();
             }
             if (cameraCaptureDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(cameraCaptureDialog.FileName);
             }
         }
     }
     else
     {
         using(OpenFileDialog openFileDialog = new OpenFileDialog())
         {
             openFileDialog.Filter = "JPEG (*.jpg,*.jpeg)|*.jpg;*.jpeg";
             if (openFileDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(openFileDialog.FileName);
             }
         }
     }
     return null;
 }
Esempio n. 6
0
 Boolean Command.accept( String instruction )
 {
     Boolean retVal = false;
     if( !Microsoft.WindowsMobile.Status.SystemState.CameraPresent )
         return retVal;
     if( instruction.StartsWith( "/capture" ) )
     {
         capture = new CameraCaptureDialog();
         retVal = true;
     }
     return retVal;
 }
Esempio n. 7
0
        public static string makeFoto()
        {
            CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();

            cameraCaptureDialog.Owner = null;
            cameraCaptureDialog.Title = "Neem een foto";
            cameraCaptureDialog.Mode  = CameraCaptureMode.Still;
            if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
            {
                return(cameraCaptureDialog.FileName);
            }
            return(null);
        }
Esempio n. 8
0
        private void DoCameraMagic()
        {
            //check droppedboxx folder exists
            var dropfolder = new DirectoryInfo(Settings.Instance.TempDirectory);

            if (!dropfolder.Exists)
            {
                dropfolder.Create();
            }

            string originalFileName;

            using (CameraCaptureDialog dlg = new CameraCaptureDialog())
            {
                dlg.Mode             = CameraCaptureMode.Still;
                dlg.InitialDirectory = dropfolder.FullName;
                dlg.StillQuality     = CameraCaptureStillQuality.High;
                dlg.Resolution       = Settings.Instance.GetCameraResolution();
                dlg.Title            = "Take a Photo";
                DialogResult res;
                try
                {
                    res = dlg.ShowDialog();
                    if (res != DialogResult.OK)
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                }

                this.Refresh();
                originalFileName = dlg.FileName;
            }
            //Now save the file!
            Host.Cursor = Cursors.WaitCursor;
            //If a File is selected select the folder its in
            if (!_selectedItem.Is_Dir)
            {
                _selectedItem = _selectedItem.Parent;
            }

            var tempFile = new FileInfo(originalFileName);

            MessageDialog.Show("Photo Uploading...", "OK", null);

            Uploader.BackgroundUpload(tempFile, _selectedItem);

            Host.Cursor = Cursors.Default;
        }
Esempio n. 9
0
        public static string makeVideo()
        {
            CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();

            cameraCaptureDialog.Owner = null;
            cameraCaptureDialog.Title = "Neem een video";
            cameraCaptureDialog.Mode  = CameraCaptureMode.VideoWithAudio;
            if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
            {
                return(cameraCaptureDialog.FileName);
                // viewVideoFileInWMP(cameraCaptureDialog.FileName);
            }
            return(null);
        }
        private void ShowCamera()
        {
            //Hide Start and Done/Close button symbol
            bool bOldStart = StartAndCloseButton.showStartButton(false);
            bool bOldDone  = StartAndCloseButton.showCloseButton(false);

            CameraCaptureDialog cdlg = new CameraCaptureDialog();

            cdlg.DefaultFileName  = "picture.jpg";
            cdlg.InitialDirectory = "\\My Documents";
            cdlg.Mode             = CameraCaptureMode.Still;
            cdlg.Owner            = this.pictureBox1;
            cdlg.StillQuality     = CameraCaptureStillQuality.High;
            cdlg.Title            = "Take a picture and Select";
            cdlg.Resolution       = new Size(240, 320);
            cdlg.VideoTypes       = CameraCaptureVideoTypes.All;

            //subclass main window with delay
            subClassUtils = new hwndutils();
            System.Threading.Thread threadTick = new System.Threading.Thread(new System.Threading.ThreadStart(thread));
            threadTick.Start();


            DialogResult dRes = cdlg.ShowDialog();

            if (dRes == DialogResult.OK)
            {
                //load image
                try
                {
                    loadImage(cdlg.FileName);
                }
                catch (SystemException sx)
                {
                    System.Diagnostics.Debug.WriteLine(sx.Message);
                }
            }
            subClassUtils.Dispose();
            cdlg.Dispose();
            //restore Start and Done/Close button display
            StartAndCloseButton.showStartButton(bOldStart);
            StartAndCloseButton.showCloseButton(bOldDone);
            if (threadTick.Join(1000))
            {
                threadTick.Abort();
                threadTick = null;
            }
        }
        private void cameraButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("After taking the photo, some devices require exiting the Camera App for the image to be sent to the printer.", "Note:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

            CameraCaptureDialog cam = new CameraCaptureDialog();

            cam.Owner = this;
            try {
                DialogResult result = cam.ShowDialog();
                if (result == DialogResult.OK)
                {
                    printImage(cam.FileName);
                }
            } catch (Exception) {
                updateGuiFromWorkerThread("Camera error or no camera", Color.Red);
            }
        }
Esempio n. 12
0
        public frmocula()
        {
            InitializeComponent();

            camera = new CameraCaptureDialog();
            camera.Owner = this;
            camera.Mode = CameraCaptureMode.Still;
            camera.Resolution = new Size(640, 480);
            camera.StillQuality = CameraCaptureStillQuality.Low;
            camera.Title = "ocula - Camera";

            library = new SelectPictureDialog();
            library.Title = "ocula - Photo Library";
            library.CameraAccess = false;
            library.Filter = "JPG Files (*.JPG)|*.JPG";
            library.Owner = this;
            ParasiteStoreLocation = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\parasite.jpg";
        }
Esempio n. 13
0
 public string MakePhoto(string photoname)
 {
     try
     {
         CameraCaptureDialog camera = new CameraCaptureDialog();
         camera.Title = "Photo";
         camera.Mode = CameraCaptureMode.Still;
         camera.Resolution = new System.Drawing.Size(1024, 768);
         camera.DefaultFileName = photoname;
         //camera.DefaultFileName = "Bild";
         if (camera.ShowDialog() == System.Windows.Forms.DialogResult.OK /*&& camera.FileName.Length > 0*/)
         {
             return camera.FileName;
         }
         return null;
     }catch(Exception ex){
         return null;
     }
 }
Esempio n. 14
0
        private void TomarFoto()
        {
            var cameraCapture = new CameraCaptureDialog();

            cameraCapture.Mode       = CameraCaptureMode.Still;
            cameraCapture.Resolution = Configuration.Resolution;
            cameraCapture.Owner      = this;
            var result = cameraCapture.ShowDialog();

            if (result != DialogResult.OK)
            {
                Acepto = false;
                Close();
                return;
            }
            else
            {
                Acepto = true;
                try
                {
                    using (var file = File.OpenRead(cameraCapture.FileName))
                    {
                        var bitmap = new Bitmap(file);

                        pictureBox1.Image = bitmap;

                        Image = new byte[file.Length];

                        file.Read(Image, 0, (int)file.Length);
                        file.Close();
                    }

                    File.Delete(cameraCapture.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Se produjo un error");
                }
            }
        }
Esempio n. 15
0
        /**********************************************************************************
         * Desc: This function is called when Camera Print button is clicked. Pops up Camera
         * capture dialog box and allows user to take an image and send that image to print.
         ***********************************************************************************/
        private void CameraPrintButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("After taking the photo, some devices require exiting the Camera App for the image to be sent to the printer.", "Note:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

            // Opens camera capture dialog box
            CameraCaptureDialog cam = new CameraCaptureDialog();

            cam.Owner = this;
            try
            {
                DialogResult result = cam.ShowDialog();

                // Send image for printing
                if (result == DialogResult.OK)
                {
                    printImage(cam.FileName);
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("No Camera Found");
                return;
            }
        }
        private void camerascan()
        {
            string fullAppName = Assembly.GetCallingAssembly().GetName().CodeBase;
            string fullAppPath = Path.GetDirectoryName(fullAppName);

            CameraCaptureDialog cameraCapture = new CameraCaptureDialog();

            cameraCapture.Resolution       = new Size(640, 480); // Set Resolution
            cameraCapture.InitialDirectory = @fullAppPath;       // Initial directory to store the captured pictures
            cameraCapture.DefaultFileName  = "scan.jpg";         //System.DateTime.Now.Ticks.ToString() + ".jpg"; //Image name creation

            string bmpimage = cameraCapture.DefaultFileName;

            cameraCapture.Mode         = CameraCaptureMode.Still;        // Camera Mode setting
            cameraCapture.StillQuality = CameraCaptureStillQuality.High; // Set the picture still quality
            cameraCapture.ShowDialog();                                  // show camera Dialog.



            /* try
             * {
             *
             *
             *  Hashtable hints = new Hashtable();
             *  ArrayList fmts = new ArrayList();
             *  fmts.Add(BarcodeFormat.DATA_MATRIX);
             *  fmts.Add(BarcodeFormat.QR_CODE);
             *  fmts.Add(BarcodeFormat.PDF_417);
             *  fmts.Add(BarcodeFormat.UPC_E);
             *  fmts.Add(BarcodeFormat.UPC_A);
             *  fmts.Add(BarcodeFormat.CODE_128);
             *  fmts.Add(BarcodeFormat.CODE_39);
             *  fmts.Add(BarcodeFormat.ITF);
             *  fmts.Add(BarcodeFormat.EAN_8);
             *  fmts.Add(BarcodeFormat.EAN_13);
             *  hints.Add(DecodeHintType.TRY_HARDER, true);
             *  hints.Add(DecodeHintType.POSSIBLE_FORMATS, fmts);
             *
             *  MemoryStream memoryStream = new MemoryStream();
             *  Bitmap newBitmap = new Bitmap(bmpimage);
             *  newBitmap.Save(memoryStream, ImageFormat.Bmp);
             *  byte[] bitmapRecord = memoryStream.ToArray();
             *
             *
             *  QRCodeReader reader = new QRCodeReader();
             *
             *
             *
             *  LuminanceSource s = new RGBLuminanceSource(bitmapRecord, newBitmap.Width, newBitmap.Height);
             *  BinaryBitmap bb = new BinaryBitmap(new GlobalHistogramBinarizer(s));
             *
             *
             *  Result result = reader.decode(bb); */

            Bitmap bitmap = new Bitmap(@fullAppPath + "\\scan.jpg");

            try
            {
                BarcodeReader reader = new BarcodeReader {
                    AutoRotate = true, TryHarder = true
                };
                Result result      = reader.Decode(bitmap);
                string decodedData = result.Text;
                kod_t.Text = decodedData;
                FindIndex();
            }
            catch (Exception e)
            {
                DialogResult czytac = MessageBox.Show("Odczyt kodu nie powiód³ siê czy ponowiæ próbê", "Pytanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                if (czytac == DialogResult.Yes)
                {
                    camerascan();
                }
                else
                {
                    kod_t.Focus();
                }
            }
        }
Esempio n. 17
0
        private void inspectMenuItem_Click(object sender, EventArgs e)
        {
            if (taskListBox.SelectedIndex >= 0)
            {

                #region Take Picture

                string file = "\\Program Files\\Inspector\\InsPhoto01.jpg";

                CameraCaptureDialog dialog = new CameraCaptureDialog();

                dialog.Title = "Inpection Photo";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    file = dialog.FileName;
                };

                #endregion

                #region Add Location and Timestamp
                Bitmap image = new Bitmap(file);
                Graphics editor = Graphics.FromImage(image);
                Font font = this.Font;
                float fontSize = font.Size + 2;
                SolidBrush brush = new SolidBrush(SystemColors.ControlText);
                GpsPosition pos = gps.GetPosition();

                editor.DrawString(
                    string.Format("Lat:{0}", pos.Latitude),
                    font, brush, 0, fontSize * 0);

                editor.DrawString(
                    string.Format("Lon:{0}", pos.Longitude),
                    font, brush, 0, fontSize * 1);

                editor.DrawString(
                    DateTime.Now.ToString(),
                    font, brush, 0, fontSize * 2);

                image.Save(file, ImageFormat.Jpeg);

                brush.Dispose();
                image.Dispose();

                #endregion

                #region Display Photo

                PhotoForm preview = new PhotoForm();
                preview.SetPhoto(file);

                if (preview.ShowDialog() == DialogResult.OK)
                {
                    #region Update task with inspection results

                    Task task = (Task)taskListBox.SelectedItem;

                    task.Subject += " (Inspected)";
                    task.Body = string.Format(
                        "Inspected. See [{0}].\r\n\r\n{1}",
                        Path.GetFileName(file),
                        task.Body);

                    task.Properties["Photo"] = file;

                    task.Update();

                    #endregion
                }

                preview.Dispose();

                #endregion

            }
        }
Esempio n. 18
0
        private void btnCamera_Click(object sender, EventArgs e)
        {
            //
            checkFolderExists(camera_const.getCameraWorkFolder());
            //
            cameraFileName_ = Guid.NewGuid().ToString()+".jpg";
            lblInfo.Text = "cameraing";
            CameraCaptureDialog cameraCapture = new CameraCaptureDialog();

            cameraCapture.Owner = null;
            cameraCapture.InitialDirectory = camera_const.getCameraWorkFolder();
            cameraCapture.DefaultFileName = cameraFileName_;
            cameraCapture.Title = "Camera Demo";
            cameraCapture.VideoTypes = CameraCaptureVideoTypes.Standard;
            cameraCapture.Resolution = new Size(176, 144);
            cameraCapture.VideoTimeLimit = new TimeSpan(0, 0, 15);  // Limited to 15 seconds of video.
            cameraCapture.Mode = CameraCaptureMode.Still;

            if (DialogResult.OK == cameraCapture.ShowDialog())
            {
                MessageBox.Show(string.Format("The picture or video has been successfully captured to:\n{0}", cameraCapture.FileName));
                btnStartSession.Focus();
            }
            lblInfo.Text = "ok";
        }
Esempio n. 19
0
        private void menuItemTakePicture_Click(object sender, EventArgs e)
        {
            if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null || this.treeViewFieldData.SelectedNode.Tag == null)
            {
                return;
            }
            TreeNode node = this.treeViewFieldData.SelectedNode;
            TreeViewNodeData data = node.Tag as TreeViewNodeData;
            if (!(data.NodeType == TreeViewNodeTypes.EventNode || data.NodeType==TreeViewNodeTypes.SpecimenNode || data.NodeType==TreeViewNodeTypes.IdentificationUnitNode))
            {
                MessageBox.Show("You can´t associate a picture with the selected node!");
                return;
            }

            String FileName = null;
            string progPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            string picturePath = progPath + @"\pictures";
            if (!System.IO.Directory.Exists(picturePath))
                System.IO.Directory.CreateDirectory(picturePath);
            // is camera present?
            if (SystemState.CameraPresent /*&& SystemState.CameraEnabled*/)
            {
                try
                {
                    // Note: Camera is not working in case the GPS thread is running; strange but that is what we found out
                    //       Therefore we "stop" the GPS thread, take the picture and the re-start the GPS service ...
                    if (UserProfiles.Instance.Current != null)
                    {
                        if (UserProfiles.Instance.Current.StopGPS == true)
                            this.StopGPS();
                    }
                    else
                        this.StopGPS();
                }
                catch (ConnectionCorruptedException ex)
                {
                    this.StopGPS();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("GPS functions aren't available. (" + ex.Message + ")", "GPS Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return;
                }

                CameraCaptureDialog camCapDlg = new CameraCaptureDialog();
                camCapDlg.Mode = CameraCaptureMode.Still;
                camCapDlg.Title = "Diversity Mobile";
                camCapDlg.InitialDirectory = picturePath;
                DialogResult dlgRes = camCapDlg.ShowDialog();
                if (dlgRes == DialogResult.OK)
                {
                    FileName = camCapDlg.FileName;
                }

                try
                {
                    if (UserProfiles.Instance.Current != null)
                    {
                        if (UserProfiles.Instance.Current.StopGPS == true)
                            this.StartGPS();
                    }
                    else
                        this.StartGPS();
                }
                catch (ConnectionCorruptedException ex)
                {
                    this.StartGPS();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("GPS functions aren't available. ("+ex.Message+")", "GPS Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("No camera access possible!");
            }
            if (!String.IsNullOrEmpty(FileName))
            {
                //Save Image for CollectionSpecimen, IU, CollectionEvent
                try
                {
                    switch (data.NodeType)
                    {
                        case TreeViewNodeTypes.EventNode: // event node
                            DataFunctions.Instance.CreateCollectionEventImage(FileName, picturePath, "photograph", (int)data.ID);
                            break;
                        case TreeViewNodeTypes.SpecimenNode:
                            DataFunctions.Instance.CreateCollectionSpecimenImage(FileName, picturePath, (int)data.ID, "photograph");
                            break;
                        case TreeViewNodeTypes.IdentificationUnitNode:
                            DataFunctions.Instance.CreateCollectionSpecimenImage(FileName, picturePath, this.findSpecimenID(), (int)data.ID, "photograph");
                            break;
                        default:
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.afterSelect(this.treeViewFieldData.SelectedNode);
                    return;
                }

                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 20
0
        private void menuRecordVideo_Click(object sender, EventArgs e)
        {
            if (this.treeViewFieldData.Nodes.Count == 0)
            {
                return;
            }

            String FileName = null;
            string progPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            string picturePath = progPath + @"\pictures";
            if (!System.IO.Directory.Exists(picturePath))
                System.IO.Directory.CreateDirectory(picturePath);

                // is camera present?
                if (SystemState.CameraPresent /*&& SystemState.CameraEnabled*/)
                {
                    try
                    {
                        if (UserProfiles.Instance.Current != null)
                        {
                            if (UserProfiles.Instance.Current.StopGPS == true)
                                this.StopGPS();
                        }
                        else
                            this.StopGPS();
                    }
                    catch (ConnectionCorruptedException ex)
                    {
                        this.StopGPS();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("GPS functions aren't available. (" + ex.Message + ")", "GPS Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    CameraCaptureDialog camCapDlg = new CameraCaptureDialog();
                    camCapDlg.Mode = CameraCaptureMode.VideoWithAudio;
                    camCapDlg.Title = "Diversity Mobile";
                    camCapDlg.InitialDirectory = picturePath;

                    if (camCapDlg.ShowDialog() == DialogResult.OK)
                    {
                        FileName = camCapDlg.FileName;
                    }

                    try
                    {
                        if (UserProfiles.Instance.Current != null)
                        {
                            if (UserProfiles.Instance.Current.StopGPS == true)
                                this.StartGPS();
                        }
                        else
                            this.StartGPS();
                    }
                    catch (ConnectionCorruptedException ex)
                    {
                        this.StartGPS();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("GPS functions aren't available. (" + ex.Message + ")", "GPS Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                else
                {
                    MessageBox.Show("No camera access possible!");
                }
            if (!String.IsNullOrEmpty(FileName) && this.treeViewFieldData.SelectedNode != null && this.treeViewFieldData.SelectedNode.Tag != null)
            {
                //Save Image for CollectionSpecimen, IU, CollectionEvent
                Cursor.Current = Cursors.WaitCursor;
                TreeNode node = this.treeViewFieldData.SelectedNode;
                TreeViewNodeData data = node.Tag as TreeViewNodeData;
                List<String> typeList = new List<string>();
                try
                {
                    switch (data.NodeType)
                    {
                        case TreeViewNodeTypes.EventNode: // event node
                            DataFunctions.Instance.CreateCollectionEventImage(FileName, picturePath, "video", (int)data.ID);
                            break;
                        case TreeViewNodeTypes.SpecimenNode:
                            DataFunctions.Instance.CreateCollectionSpecimenImage(FileName, picturePath, (int)data.ID, "video");
                            break;
                        case TreeViewNodeTypes.IdentificationUnitNode:
                            DataFunctions.Instance.CreateCollectionSpecimenImage(FileName, picturePath, this.findSpecimenID(), (int)data.ID, "video");
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.afterSelect(this.treeViewFieldData.SelectedNode);
                    return;
                }
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 21
0
        private void menuTakePicture_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog cameraCapture = new CameraCaptureDialog();
                        cameraCapture.Owner = this;

                        object cameraEnabled = Microsoft.WindowsMobile.Status.SystemState.GetValue(Microsoft.WindowsMobile.Status.SystemProperty.CameraEnabled);

                        cameraCapture.DefaultFileName = "haggle-temp.jpg";
                        cameraCapture.Title = "Take PhotoShare Picture";
                        cameraCapture.Mode = CameraCaptureMode.Still;
                        cameraCapture.Resolution = new Size(1024, 768);

                        // The filename of the picure taken
                        string fileName;

                        if (null != cameraEnabled && 0 == (int)cameraEnabled)
                        {
                                MessageBox.Show("The camera is disabled", this.Text,
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                return;
                        }

                        try
                        {
                                if (cameraCapture.ShowDialog() == DialogResult.OK)
                                {
                                        fileName = cameraCapture.FileName;

                                        Debug.WriteLine("file name of photo is " + fileName);

                                        if (cameraCapture.Mode == CameraCaptureMode.Still)
                                        {
                                                string extension = fileName.Substring(fileName.LastIndexOf("."));
                                                string directory = "";
                                                long extra_digit;

                                                if (fileName.LastIndexOf("\\") != -1)
                                                {
                                                        directory = fileName.Substring(0, fileName.LastIndexOf("\\") + 1);
                                                }

                                                fileName = directory + this.defaultPictureFileName + extension;
                                                extra_digit = 0;
                                                while (System.IO.File.Exists(fileName))
                                                {
                                                    fileName = directory + this.defaultPictureFileName + "-" + extra_digit + extension;
                                                    extra_digit++;
                                                }

                                                System.IO.File.Move(cameraCapture.FileName, fileName);
                                        }

                                        FileAttributeWindow fileAttrWin = new FileAttributeWindow(fileName);
                                        DialogResult ret = DialogResult.Cancel;

                                        try {
                                                ret = fileAttrWin.ShowDialog();
                                        } catch (Exception) {
                                                Debug.WriteLine("Could not show fileAttrWind dialog");
                                        }
                                        //fileAttrWin.BringToFront();
                                        char[] separators = { ';', ' ' };

                                        string[] keywords = fileAttrWin.getResultValueString().Split(separators);

                                        Debug.WriteLine("Attributes string is: " + fileAttrWin.getResultValueString());

                                        //DialogResult ret = MessageBox.Show("The picture was saved to:\n" + fileName +
                                        //        "\nDo you want to publish the picture with Haggle now?",
                                        //    this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

                                        if (ret == DialogResult.OK)
                                        {
                                                try
                                                {
                                                        Haggle.Attribute.AttributeList al = new Haggle.Attribute.AttributeList();

                                                        Haggle.DataObject dObj = new Haggle.DataObject(fileName);
                                                        dObj.AddHash();
                                                        // Add thumbnail:
                                                        dObj.SetThumbnail(GetThumbnail(fileName, 32, 0));

                                                        foreach (string kw in keywords)
                                                        {
                                                                Haggle.Attribute a = new Haggle.Attribute("Picture", kw);

                                                                if (!dObj.AddAttribute(a))
                                                                {
                                                                        MessageBox.Show("Could not add attribute");
                                                                        return;
                                                                }

                                                                if (fileAttrWin.getAddAsInterest())
                                                                {

                                                                        if (ps.addInterestWindow.interestListUpdate(new Haggle.Attribute.AttributeList(a)) > 0)
                                                                        {
                                                                                Debug.WriteLine("Adding interest " + a.ToString());
                                                                                al.Add(a);
                                                                        }
                                                                }

                                                        }
                                                        // We need to add the interest first if we want the filters to match the
                                                        // data object we add
                                                        if (fileAttrWin.getAddAsInterest())
                                                        {
                                                                ps.hh.AddInterests(al);
                                                        }
                                                        //Haggle.Attribute attr = dObj.GetAttribute("DeviceName");

                                                        //MessageBox.Show("Data object file name is: " + dObj.GetFileName()
                                                        //               + " Attribute is: " + attr.GetValue());
                                                        int sent = ps.hh.PublishDataObject(dObj);

                                                        if (sent < 0)
                                                        {
                                                                MessageBox.Show("Could not publish data object on handle=" +
                                                                        ps.hh.handle + " Error=" + sent);
                                                        }
                                                }
                                                catch (Haggle.DataObject.NoSuchAttributeException)
                                                {
                                                        MessageBox.Show("No such attribute in data object");
                                                }
                                                catch (Haggle.DataObject.DataObjectException ex)
                                                {
                                                        MessageBox.Show(ex.ToString());
                                                }
                                                catch (Haggle.Attribute.AttributeNullPtrException)
                                                {
                                                        MessageBox.Show("Attribute null pointer exception");
                                                }
                                                catch (Exception)
                                                {
                                                        MessageBox.Show("Unknown error");
                                                }
                                        }
                                        else if (ret == DialogResult.No)
                                        {

                                                Debug.WriteLine("camera dialog result \'NO\'");
                                        }
                                        else
                                        {
                                                Debug.WriteLine("Unknown camera dialog result");
                                                MessageBox.Show("Unknown selection.");
                                        }
                                        Debug.WriteLine("camera exit");
                                }
                        }
                        catch (ArgumentException ex)
                        {
                                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        catch (OutOfMemoryException ex)
                        {
                                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                    MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                        }
                        catch (InvalidOperationException ex)
                        {
                                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                    MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                        }
        }
Esempio n. 22
0
        private void menuTakePicture_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog cameraCapture = new CameraCaptureDialog();

            cameraCapture.Owner = this;

            object cameraEnabled = Microsoft.WindowsMobile.Status.SystemState.GetValue(Microsoft.WindowsMobile.Status.SystemProperty.CameraEnabled);

            cameraCapture.DefaultFileName = "haggle-temp.jpg";
            cameraCapture.Title           = "Take PhotoShare Picture";
            cameraCapture.Mode            = CameraCaptureMode.Still;
            cameraCapture.Resolution      = new Size(1024, 768);

            // The filename of the picure taken
            string fileName;

            if (null != cameraEnabled && 0 == (int)cameraEnabled)
            {
                MessageBox.Show("The camera is disabled", this.Text,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            try
            {
                if (cameraCapture.ShowDialog() == DialogResult.OK)
                {
                    fileName = cameraCapture.FileName;

                    Debug.WriteLine("file name of photo is " + fileName);

                    if (cameraCapture.Mode == CameraCaptureMode.Still)
                    {
                        string extension = fileName.Substring(fileName.LastIndexOf("."));
                        string directory = "";
                        long   extra_digit;

                        if (fileName.LastIndexOf("\\") != -1)
                        {
                            directory = fileName.Substring(0, fileName.LastIndexOf("\\") + 1);
                        }

                        fileName    = directory + this.defaultPictureFileName + extension;
                        extra_digit = 0;
                        while (System.IO.File.Exists(fileName))
                        {
                            fileName = directory + this.defaultPictureFileName + "-" + extra_digit + extension;
                            extra_digit++;
                        }

                        System.IO.File.Move(cameraCapture.FileName, fileName);
                    }

                    FileAttributeWindow fileAttrWin = new FileAttributeWindow(fileName);
                    DialogResult        ret         = DialogResult.Cancel;

                    try {
                        ret = fileAttrWin.ShowDialog();
                    } catch (Exception) {
                        Debug.WriteLine("Could not show fileAttrWind dialog");
                    }
                    //fileAttrWin.BringToFront();
                    char[] separators = { ';', ' ' };

                    string[] keywords = fileAttrWin.getResultValueString().Split(separators);

                    Debug.WriteLine("Attributes string is: " + fileAttrWin.getResultValueString());

                    //DialogResult ret = MessageBox.Show("The picture was saved to:\n" + fileName +
                    //        "\nDo you want to publish the picture with Haggle now?",
                    //    this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

                    if (ret == DialogResult.OK)
                    {
                        try
                        {
                            Haggle.Attribute.AttributeList al = new Haggle.Attribute.AttributeList();

                            Haggle.DataObject dObj = new Haggle.DataObject(fileName);
                            dObj.AddHash();
                            // Add thumbnail:
                            dObj.SetThumbnail(GetThumbnail(fileName, 32, 0));

                            foreach (string kw in keywords)
                            {
                                Haggle.Attribute a = new Haggle.Attribute("Picture", kw);

                                if (!dObj.AddAttribute(a))
                                {
                                    MessageBox.Show("Could not add attribute");
                                    return;
                                }

                                if (fileAttrWin.getAddAsInterest())
                                {
                                    if (ps.addInterestWindow.interestListUpdate(new Haggle.Attribute.AttributeList(a)) > 0)
                                    {
                                        Debug.WriteLine("Adding interest " + a.ToString());
                                        al.Add(a);
                                    }
                                }
                            }
                            // We need to add the interest first if we want the filters to match the
                            // data object we add
                            if (fileAttrWin.getAddAsInterest())
                            {
                                ps.hh.AddInterests(al);
                            }
                            //Haggle.Attribute attr = dObj.GetAttribute("DeviceName");

                            //MessageBox.Show("Data object file name is: " + dObj.GetFileName()
                            //               + " Attribute is: " + attr.GetValue());
                            int sent = ps.hh.PublishDataObject(dObj);

                            if (sent < 0)
                            {
                                MessageBox.Show("Could not publish data object on handle=" +
                                                ps.hh.handle + " Error=" + sent);
                            }
                        }
                        catch (Haggle.DataObject.NoSuchAttributeException)
                        {
                            MessageBox.Show("No such attribute in data object");
                        }
                        catch (Haggle.DataObject.DataObjectException ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        catch (Haggle.Attribute.AttributeNullPtrException)
                        {
                            MessageBox.Show("Attribute null pointer exception");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Unknown error");
                        }
                    }
                    else if (ret == DialogResult.No)
                    {
                        Debug.WriteLine("camera dialog result \'NO\'");
                    }
                    else
                    {
                        Debug.WriteLine("Unknown camera dialog result");
                        MessageBox.Show("Unknown selection.");
                    }
                    Debug.WriteLine("camera exit");
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            catch (OutOfMemoryException ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }
        }
Esempio n. 23
0
        private void btFoto_Click(object sender, EventArgs e)
        {
            CameraCaptureDialog camCapture = new CameraCaptureDialog();
            camCapture.Owner = null;

                pathName =
                    Library.appDir + "\\imagens\\cip\\" + Usuario.Chave + "\\";

            bool exists = System.IO.Directory.Exists(pathName);
            if (!exists)
            {
                System.IO.Directory.CreateDirectory(pathName);
            }

            camCapture.InitialDirectory = @pathName;
            camCapture.Resolution = new Size(200, 200);
            camCapture.Mode = CameraCaptureMode.Still;
            fileName = seqTextBox.Text + ".jpg";

            exists = System.IO.File.Exists(pathName + fileName);
            int t = 1;
            while (exists)
            {
                fileName = seqTextBox.Text +"-" + t++ +".jpg";
                exists = System.IO.File.Exists(pathName+ fileName);
            }

            camCapture.DefaultFileName = @fileName;

            if (DialogResult.OK == camCapture.ShowDialog())
            {
                Bitmap img = new Bitmap(pathName + fileName);

                pictureBox1.Image = img;
            }
        }
Esempio n. 24
0
        private void CameraCapture(bool video)
        {
            /*
             * @params video identifica si el dispositivo cuenta con una camara.
             */
            CameraCaptureDialog cameraCapture = new CameraCaptureDialog();

            cameraCapture.Owner = this;

            cameraCapture.InitialDirectory = @"\My Documents";

            cameraCapture.Title = "Camera";

            cameraCapture.VideoTypes = CameraCaptureVideoTypes.Messaging;

            cameraCapture.Resolution = new Size(176, 144);

            cameraCapture.VideoTimeLimit = new TimeSpan(0, 0, 15);

            cameraCapture.Mode = CameraCaptureMode.Still;

            cameraCapture.DefaultFileName = @"Photo "+DateTime.Now.ToString("MMddyyhhmm")+".jpg";

            if (DialogResult.OK == cameraCapture.ShowDialog())
            {

                if (!cameraCapture.FileName.Equals(""))
                {

                    this.pTakePhoto.Image = new Bitmap(cameraCapture.FileName);

                    this.lblUploadPhoto.Visible = false;

                    this.pTakePhoto.Visible = true;

                    this.file_name = cameraCapture.FileName;
                }

                else
                {

                    this.lblUploadPhoto.Visible = false;

                    this.pTakePhoto.Visible = true;

                    MessageBox.Show("Presione la tecla ENT para capturar foto");

                }
            }
            /* if (video){cameraCapture.Mode = CameraCaptureMode.VideoWithAudio;cameraCapture.DefaultFileName = @"videotest.3gp";
             }else{cameraCapture.Mode = CameraCaptureMode.Still;cameraCapture.DefaultFileName = @"imagetest.jpg";}
            */
        }