예제 #1
0
        public override void TransferFile(object o, string filename)
        {
            EosFileImageEventArgs file = o as EosFileImageEventArgs;

            if (file != null)
            {
                Log.Debug("File transfer started");
                try
                {
                    if (File.Exists(file.ImageFilePath))
                    {
                        File.Copy(file.ImageFilePath, filename, true);
                        File.Delete(file.ImageFilePath);
                    }
                    else
                    {
                        Log.Error("Base file not found " + file.ImageFilePath);
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Transfer error ", exception);
                }
            }
            EosMemoryImageEventArgs memory = o as EosMemoryImageEventArgs;

            if (memory != null)
            {
                Log.Debug("Memory file transfer started");
                try
                {
                    using (FileStream fileStream = File.Create(filename, (int)memory.ImageData.Length))
                    {
                        fileStream.Write(memory.ImageData, 0, memory.ImageData.Length);
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error transfer memory file", exception);
                }
            }
        }
예제 #2
0
        void Camera_PictureTaken(object sender, EosImageEventArgs e)
        {
            try
            {
                Log.Debug("Picture taken event received type" + e.GetType().ToString());
                PhotoCapturedEventArgs args = new PhotoCapturedEventArgs
                {
                    WiaImageItem = null,
                    //EventArgs =
                    //  new PortableDeviceEventArgs(new PortableDeviceEventType()
                    //  {
                    //      ObjectHandle =
                    //        (uint)longeventParam
                    //  }),
                    CameraDevice = this,
                    FileName     = "IMG0000.jpg",
                    Handle       = e
                };

                EosFileImageEventArgs file = e as EosFileImageEventArgs;
                if (file != null)
                {
                    args.FileName = Path.GetFileName(file.ImageFilePath);
                }
                EosMemoryImageEventArgs memory = e as EosMemoryImageEventArgs;
                if (memory != null)
                {
                    if (!string.IsNullOrEmpty(memory.FileName))
                    {
                        args.FileName = Path.GetFileName(memory.FileName);
                    }
                }
                OnPhotoCapture(this, args);
            }
            catch (Exception exception)
            {
                Log.Error("EOS Picture taken event error", exception);
            }
        }