void OnImageReady(NikonDevice sender, NikonImage image) { if (_imageReady != null) { _imageReady(sender, image); } }
void OnLowResolutionPreviewReady(NikonDevice sender, NikonPreview preview) { if (_lowResolutionPreviewReady != null) { _lowResolutionPreviewReady(sender, preview); } }
void OnThumbnailReady(NikonDevice sender, NikonThumbnail thumbnail) { if (_thumbnailReady != null) { _thumbnailReady(sender, thumbnail); } }
void OnCapabilityValueChanged(NikonDevice sender, eNkMAIDCapability capability) { if (_capabilityValueChanged != null) { _capabilityValueChanged(sender, capability); } }
void OnPreviewReady(NikonDevice sender, NikonPreview preview) { if (_previewReady != null) { _previewReady(sender, preview); } }
private void OnDeviceAdded(NikonManager sender, NikonDevice device) { if (_deviceAdded != null) { _deviceAdded(sender, device); } }
void OnVideoFragmentReady(NikonDevice sender, NikonVideoFragment fragment) { if (_videoFragmentReady != null) { _videoFragmentReady(sender, fragment); } }
void OnVideoRecordingInterrupted(NikonDevice sender, int error) { if (_videoRecordingInterrupted != null) { _videoRecordingInterrupted(sender, error); } }
void OnProgress(NikonDevice sender, eNkMAIDDataObjType type, int done, int total) { if (_progress != null) { _progress(sender, type, done, total); } }
void OnCaptureComplete(NikonDevice sender, int data) { if (_captureComplete != null) { _captureComplete(sender, data); } }
void OnDeviceRemoved(NikonManager sender, NikonDevice device) { if (_deviceRemoved != null) { _deviceRemoved(sender, device); } }
void manager_DeviceAdded(NikonManager sender, NikonDevice device) { if (_device == null) { // Save device _device = device; // Signal that we got a device _waitForDevice.Set(); } }
void HandleAddChild(uint data) { NikonDevice device = new NikonDevice(Md3, Scheduler, Object, ModuleType, data); lock (_devices) { Debug.Assert(!_devices.ContainsKey(data)); _devices[data] = device; } Scheduler.Callback(new DeviceAddedDelegate(OnDeviceAdded), this, device); }
private void HandleAddChild(IntPtr data) { uint id = (uint)data.ToInt32(); NikonDevice device = new NikonDevice(Md3, Scheduler, Object, ModuleType, id); lock (_devices) { Debug.Assert(!_devices.ContainsKey(id)); _devices[id] = device; } Scheduler.Callback(new DeviceAddedDelegate(OnDeviceAdded), this, device); }
public NikonDevice GetDeviceById(uint id) { NikonDevice device = null; lock (_devices) { if (!_devices.TryGetValue(id, out device)) { device = null; } } return(device); }
void HandleRemoveChild(uint data) { NikonDevice device = null; lock (_devices) { Debug.Assert(_devices.ContainsKey(data)); device = _devices[data]; _devices.Remove(data); } device.Object.Close(); Scheduler.Callback(new DeviceRemovedDelegate(OnDeviceRemoved), this, device); }
private void HandleRemoveChild(IntPtr data) { uint id = (uint)data.ToInt32(); NikonDevice device = null; lock (_devices) { Debug.Assert(_devices.ContainsKey(id)); device = _devices[id]; _devices.Remove(id); } device.Object.Close(); Scheduler.Callback(new DeviceRemovedDelegate(OnDeviceRemoved), this, device); }
public NikonDevice GetDeviceByIndex(uint index) { NikonDevice device = null; lock (_devices) { int i = 0; foreach (NikonDevice d in _devices.Values) { if (i == index) { device = d; break; } i++; } } return(device); }
void _device_VideoFragmentReady(NikonDevice sender, NikonVideoFragment fragment) { // Open the filestream when we receive the first video fragment if (fragment.IsFirst) { _fileStream = new FileStream(fragment.Filename, FileMode.Create, FileAccess.Write); } // Save video fragments to file _fileStream.Write(fragment.Buffer, 0, fragment.Buffer.Length); // When we recive the last fragment, close the file and signal that we're done if (fragment.IsLast) { _fileStream.Close(); _waitForVideoCompleted.Set(); } }
void _device_ImageReady(NikonDevice sender, NikonImage image) { // Save captured image to disk string filename = "image" + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef"); using (FileStream s = new FileStream(filename, FileMode.Create, FileAccess.Write)) { s.Write(image.Buffer, 0, image.Buffer.Length); } }
void device_VideoFragmentReady(NikonDevice sender, NikonVideoFragment fragment) { string path = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), fragment.Filename); if (fragment.IsFirst) { Debug.Assert(_videoFile == null); _videoFile = new FileStream(path, FileMode.Create, FileAccess.Write); Log.GetInstance().WriteLine("Downloading Video..."); } Log.GetInstance().WriteLine(fragment.PercentComplete.ToString(".0") + "%"); Debug.Assert(_videoFile != null); _videoFile.Write(fragment.Buffer, 0, fragment.Buffer.Length); if (fragment.IsLast) { _videoFile.Close(); _videoFile = null; Log.GetInstance().WriteLine("Saved Video: " + path + " (" + fragment.VideoWidth + "x" + fragment.VideoHeight + ")"); } }
void device_PreviewReady(NikonDevice sender, NikonPreview preview) { Save(preview.JpegBuffer, "preview.jpg"); }
void device_ImageReady(NikonDevice sender, NikonImage image) { Save(image.Buffer, "image" + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef")); }
void device_CapabilityChanged(NikonDevice sender, eNkMAIDCapability capability) { RefreshCaps(); }
void _manager_DeviceAdded(NikonManager sender, NikonDevice device) { _objects.Add(new ObjectModel(device)); OnPropertyChanged("NewestIndex"); }
void _device_CaptureComplete(NikonDevice sender, int data) { // Signal the the capture completed _waitForCaptureComplete.Set(); }
void device_CapabilityValueChanged(NikonDevice sender, eNkMAIDCapability capability) { if (_cap.ulID == capability) { OnPropertyChanged("CapValue"); switch (_cap.ulType) { case eNkMAIDCapType.kNkMAIDCapType_Enum: OnPropertyChanged("EnumSelectedIndex"); break; case eNkMAIDCapType.kNkMAIDCapType_Range: OnPropertyChanged("RangeValue"); break; } } }
// 撮影完了時にトグルボタンをONにするイベントメソッド(コールバック) void device_CaptureComplete(NikonDevice sender, int data) { // Re-enable buttons when the capture completes ToggleButtons(true); }
void _manager_DeviceRemoved(NikonManager sender, NikonDevice device) { ObjectModel deviceModelToRemove = null; foreach (ObjectModel deviceModel in _objects) { if (deviceModel.Object == device) { deviceModelToRemove = deviceModel; } } _objects.Remove(deviceModelToRemove); OnPropertyChanged("NewestIndex"); }
// 撮影画像の準備完了時のイベントメソッド:撮影画像を保存し、保存完了時に【writeImgFileCallback】Hubを呼び出す。 void device_ImageReady(NikonDevice sender, NikonImage image) { using (MemoryStream memStream = new MemoryStream(image.Buffer)) { // 画像データの検証オン _PhotImg = System.Drawing.Image.FromStream(memStream); //保存する写真画像のユーニークなファイル名 //確認用に、フォームに撮った写真をフォームに表示 picBoxPhotImage.Image = _PhotImg; //写真画像保存時のファイル名にユニークな名前を付ける。 string fileUnqNm = "phot" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString() + "_" + DateTime.Now.Millisecond.ToString() + ".jpg"; #region 条件分岐:ローカルサーバへのファイル保存がONなら if (chkBxFileSave.Checked == true) { try {//ファイル保存 Console.WriteLine("写真画像保存開始"); //flStream.BeginWriteイベントハンド呼び出し時に使用するステイタスパラメータクラスのインスタンスを作成 using (EvHndParamClass param = new EvHndParamClass()) { // ファイル書き込み終了時のイベントハンドラで実行されるコールバックメソッド内でファイル名を利用すため //そのイベントハンドラに渡すパラメータの、stプロパティにファイル名をセット param.str = fileUnqNm; //非同期書き込み用のファイルストリームを作成 using (FileStream flStream = new FileStream(@"C:\inetpub\wwwroot\images/" + fileUnqNm, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, image.Buffer.Length, true)) { //非同期書き込み、書き込み終了時に呼び出されるメソッド【writeFileCallback】 //flStream.BeginWrite(image.Buffer, 0, image.Buffer.Length, new AsyncCallback(writeImgFileCallback), flStream); flStream.BeginWrite(image.Buffer, 0, image.Buffer.Length, new AsyncCallback(writeImgFileCallback), param); // await writer.WriteAsync(input); } } } catch (Exception ex) { Console.WriteLine("err:" + ex.Message + " 写真画像ファイル書き込み失敗!"); } } #endregion #region 条件分岐: FTPアップロードチェックボックスがONなら if (chkBxFtpUpLoad.Checked == true) { try {//↓は、FTPにて写真アップロードの【場合】です。 WebClient wc = new WebClient(); //アップロード完了時イベントを登録 wc.UploadDataCompleted += (s, e) => { Console.WriteLine("アップロード完了"); _HubProxy.Invoke("PhotChange", fileUnqNm).Wait(); }; //Uri u = new Uri("" + fileUnqNm); Uri u = new Uri("ftp://waws-prod-os1-001.ftp.azurewebsites.windows.net/site/wwwroot/images/" + fileUnqNm); //認証設定 // wc.Credentials = new NetworkCredential(@"", ""); wc.Credentials = new NetworkCredential(@"picUpSignalR\$picUpSignalR", FtpCredentials); Console.WriteLine("写真画像FTPアップロード開始"); wc.UploadDataAsync(u, image.Buffer); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); Console.WriteLine("err:" + ex.Message + " 写真画像FTPアップロード失敗!"); } } #endregion } }
void device_CaptureComplete(NikonDevice sender, int data) { }
// カメラ接続開始時のイベントメソッド(コールバック) void manager_DeviceAdded(NikonManager sender, NikonDevice device) { this._Device = device; // Set the device name label_name.Text = device.Name; // Enable buttons ToggleButtons(true); // 撮影画像のバッファへの転送完了イベント device.ImageReady += new ImageReadyDelegate(device_ImageReady); // 撮影完了時のイベント(トグルボタンOFF→ON) device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete); }
void device_LowResolutionPreviewReady(NikonDevice sender, NikonPreview preview) { Save(preview.JpegBuffer, "preview_lowres.jpg"); }
// カメラ接続終了時のイベントメソッド(コールバック) void manager_DeviceRemoved(NikonManager sender, NikonDevice device) { this._Device = null; // Stop live view timer _LiveViewTimer.Stop(); // Clear device name label_name.Text = "No Camera"; // Disable buttons ToggleButtons(false); // Clear live view picture picBoxPhotImage.Image = null; }
void device_ThumbnailReady(NikonDevice sender, NikonThumbnail thumbnail) { // We're expecting to get RGB24 data, make sure that the format is correct if (thumbnail.Stride / thumbnail.Width < 3) { return; } // Note: Thumbnail pixels are uncompressed RGB24 - here's an example of how to jpeg encode it JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.QualityLevel = 90; BitmapSource source = BitmapFrame.Create( thumbnail.Width, thumbnail.Height, 96.0, 96.0, System.Windows.Media.PixelFormats.Rgb24, null, thumbnail.Pixels, thumbnail.Stride); BitmapFrame frame = BitmapFrame.Create(source); encoder.Frames.Add(frame); MemoryStream stream = new MemoryStream(); encoder.Save(stream); Save(stream.GetBuffer(), "thumbnail.jpg"); }
void device_VideoRecordingInterrupted(NikonDevice sender, int error) { Log.GetInstance().WriteLine("Video Recording Interrupted (" + error.ToString() + ")"); }