C# Sample
Demonstrates how to create a C# application using the VideoXpert SDK
SDKSampleApp.Source.MainForm Class Reference

The MainForm class. More...

Public Member Functions

 MainForm ()
 Initializes a new instance of the MainForm class. More...
 
void OnInternalEvent (InternalEvent internalEvent)
 The OnInternalEvent method. More...
 
void OnSystemEvent (Event systemEvent)
 The OnSystemEvent method. More...
 
async Task< HttpResponseMessage > SendRequest (Uri uri)
 The SendRequest method. More...
 
void WriteToLog (string message)
 The WriteToLog method. More...
 
void SetManualRecordingStatus ()
 Sets the state of the manual recording UI elements based on the manual recording status of the current stream. More...
 
void SubscribeToInternalEvents ()
 Subscribes to internal VxSDK events. More...
 

Properties

static List< DeviceCurrentDevices [get, set]
 Gets or sets the CurrentDevices property. More...
 
static List< DataSourceCurrentDataSources [get, set]
 Gets or sets the CurrentDataSources property. More...
 
static string CurrentPassword [get, set]
 Gets or sets the CurrentPassword property. More...
 
static VXSystem CurrentSystem [get, set]
 Gets or sets the CurrentSystem property. More...
 
static string CurrentUserName [get, set]
 Gets or sets the CurrentUserName property. More...
 
static string LogPath [get, set]
 Gets or sets the LogPath property. More...
 
static string SnapshotBasePath [get, set]
 Gets or sets the SnapshotBasePath property. More...
 
static MainForm Instance [get, private set]
 Gets the Instance property. More...
 
static PTZControlForm PtzForm [get, set]
 Gets or sets the PtzForm property. More...
 
ControlManager Control [get, set]
 Gets or sets the Control property. More...
 

Private Member Functions

void ButtonLive_Click (object sender, EventArgs args)
 The ButtonLive_Click method. More...
 
void ButtonManualRecord_Click (object sender, EventArgs args)
 The ButtonManualRecord_Click method. More...
 
void ButtonPause_Click (object sender, EventArgs args)
 The ButtonPause_Click method. More...
 
void ButtonPlay_Click (object sender, EventArgs args)
 The ButtonPlay_Click method. More...
 
void ButtonRefreshDataSources_Click (object sender, EventArgs args)
 The ButtonRefreshDataSources_Click method. More...
 
void ButtonSeek_Click (object sender, EventArgs args)
 The ButtonSeek_Click method. More...
 
void ButtonSnapshot_Click (object sender, EventArgs args)
 The ButtonSnapshot_Click method. More...
 
void ButtonStop_Click (object sender, EventArgs args)
 The ButtonStop_Click method. More...
 
void GridViewDataSources_CellDoubleClick (object sender, DataGridViewCellEventArgs args)
 The GridViewDataSources_CellDoubleClick method. More...
 
void MenuItemLog_Click (object sender, EventArgs args)
 The MenuItemLog_Click method. More...
 
void MenuItemAlarmInputManager_Click (object sender, EventArgs args)
 The MenuItemAlarmInputManager_Click method. More...
 
void MenuItemBookmarkManager_Click (object sender, EventArgs args)
 The MenuItemBookmarkManager_Click method. More...
 
void MenuItemClusterConfig_Click (object sender, EventArgs args)
 The MenuItemClusterConfig_Click method. More...
 
void MenuItemDataObjectManager_Click (object sender, EventArgs args)
 The MenuItemDataObjectManager_Click method. More...
 
void MenuItemDataSourceManager_Click (object sender, EventArgs args)
 The MenuItemDataSourceManager_Click method. More...
 
void MenuItemDataStorageManager_Click (object sender, EventArgs args)
 The MenuItemDataStorageManager_Click method. More...
 
void MenuItemConnect_Click (object sender, EventArgs args)
 The MenuItemConnect_Click method. More...
 
void MenuItemExit_Click (object sender, EventArgs args)
 The MenuItemExit_Click method. More...
 
void MenuItemDeviceManager_Click (object sender, EventArgs args)
 The MenuItemDeviceManager_Click method. More...
 
void MenuItemDrawingManager_Click (object sender, EventArgs args)
 The MenuItemDrawingManager_Click method. More...
 
void MenuItemExportManager_Click (object sender, EventArgs args)
 The MenuItemExportManager_Click method. More...
 
void MenuItemInsertEvent_Click (object sender, EventArgs args)
 The MenuItemInsertEvent_Click method. More...
 
void MenuItemLogLevel_Click (object sender, EventArgs args)
 The MenuItemLogLevel_Click method. More...
 
void MenuItemLicenseDetails_Click (object sender, EventArgs args)
 The MenuItemLicenseDetails_Click method. More...
 
void MenuItemLogout_Click (object sender, EventArgs args)
 The MenuItemLogout_Click method. More...
 
void MenuItemModifyLoggingPath_Click (object sender, EventArgs args)
 The MenuItemModifyLoggingPath_Click method. More...
 
void MenuItemMonitors_Click (object sender, EventArgs args)
 The MenuItemMonitors_Click method. More...
 
void MenuItemNotifications_Click (object sender, EventArgs args)
 The MenuItemNotifications_Click method. More...
 
void MenuItemProtocol_Click (object sender, EventArgs args)
 The MenuItemProtocol_Click method. More...
 
void MenuItemQuickLog_Click (object sender, EventArgs args)
 The MenuItemQuickLog_Click method. More...
 
void MenuItemQuickReport_Click (object sender, EventArgs args)
 The MenuItemQuickReport_Click method. More...
 
void MenuItemRelayOutputManager_Click (object sender, EventArgs args)
 The MenuItemRelayOutputManager_Click method. More...
 
void MenuItemRoleManager_Click (object sender, EventArgs args)
 The MenuItemRoleManager_Click method. More...
 
void MenuItemScheduleManager_Click (object sender, EventArgs args)
 The MenuItemScheduleManager_Click method. More...
 
void MenuItemSearchEvents_Click (object sender, EventArgs args)
 The MenuItemScheduleManager_Click method. More...
 
void MenuItemShowPtzControls_Click (object sender, EventArgs args)
 The MenuItemShowPtzControls_Click method. More...
 
void MenuItemSituationManager_Click (object sender, EventArgs args)
 The MenuItemSituationManager_Click method. More...
 
void MenuItemTagManager_Click (object sender, EventArgs args)
 The MenuItemTagManager_Click method. More...
 
void MenuItemSnapshotPath_Click (object sender, EventArgs args)
 The MenuItemSnapshotPath_Click method. More...
 
void MenuItemSubscribe_Click (object sender, EventArgs args)
 The MenuItemSubscribe_Click method. More...
 
void MenuItemSubscribeByType_Click (object sender, EventArgs args)
 The MenuItemSubscribeByType_Click method. More...
 
void MenuItemDisplayEventDialogs_Click (object sender, EventArgs args)
 The MenuItemDisplayEventDialogs_Click method. More...
 
void MenuItemUserManager_Click (object sender, EventArgs args)
 The MenuItemUserManager_Click method. More...
 
void PanelVideoStream_Click (object sender, EventArgs args)
 The PanelVideoStream_Click method. More...
 
void PanelVideoStream_MouseEnter (object sender, EventArgs args)
 The PanelVideoStream_MouseEnter method. More...
 
void PanelVideoStream_MouseLeave (object sender, EventArgs args)
 The PanelVideoStream_MouseLeave method. More...
 
void PanelVideoStream_MouseWheel (object sender, MouseEventArgs args)
 The PanelVideoStream_MouseWheel method. More...
 
void PanelVideoStreamLeft_MouseClick (object sender, MouseEventArgs args)
 The PanelVideoStreamLeft_MouseClick method. More...
 
void PanelVideoStreamRight_MouseClick (object sender, MouseEventArgs args)
 The PanelVideoStreamRight_MouseClick method. More...
 
async void SaveSnapshotLive (DataSource dataSource)
 The SaveSnapshotLive method. More...
 
async void SaveSnapshotRecorded (DataSource dataSource)
 The SaveSnapshotRecorded method. More...
 
void SetupPtzControls (DataSource dataSource)
 The SetupPtzControls method. More...
 
DataInterface SelectDataInterface (VxStreamProtocol selProtocol, DataSource dataSource, bool showWindow)
 The SelectDataInterface method. More...
 
void StartStream (DateTime seekTime=default(DateTime))
 The StartStream method. More...
 
void StopAllStreams ()
 The StopAllStreams method. More...
 
void StopStream ()
 The StopStream method. More...
 
void SelectAudioData (DataSource videoSource, bool showWindow, out DataSource audioSource, out DataInterface audioInterface)
 Select the audio data source and data interfaces from the MainForm.CurrentDataSources More...
 

Static Private Member Functions

static string EncodeToBase64 (string toEncode)
 The EncodeToBase64 method. More...
 
static void ShowSnapshotDialog (string fileName)
 The ShowSnapshotDialog method. More...
 

Detailed Description

The MainForm class.

This class contains the main UI form.

Definition at line 22 of file MainForm.cs.

Inherits Form.

Constructor & Destructor Documentation

SDKSampleApp.Source.MainForm.MainForm ( )
inline

Initializes a new instance of the MainForm class.

Definition at line 27 of file MainForm.cs.

28  {
29  InitializeComponent();
30  dtpSeekTime.Value = DateTime.Now.AddMinutes(-10);
31  scOuter.Panel2Collapsed = true;
32  Instance = this;
33  PtzForm = new PTZControlForm();
34  Control = new ControlManager();
35  SnapshotBasePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures) + "\\";
36  bgWorker.DoWork += Utilities.BackgroundWorker_DoWork;
37  bgWorker.ProgressChanged += Utilities.BackgroundWorker_ProgressChanged;
38  bgWorker.RunWorkerCompleted += Utilities.BackgroundWorker_RunWorkerCompleted;
39  LogPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
40  "\\Pelco\\VxSdk\\Logs";
41  }
static string SnapshotBasePath
Gets or sets the SnapshotBasePath property.
Definition: MainForm.cs:83
static PTZControlForm PtzForm
Gets or sets the PtzForm property.
Definition: MainForm.cs:95
static string LogPath
Gets or sets the LogPath property.
Definition: MainForm.cs:77
static MainForm Instance
Gets the Instance property.
Definition: MainForm.cs:89
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101

Member Function Documentation

void SDKSampleApp.Source.MainForm.ButtonLive_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonLive_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 201 of file MainForm.cs.

202  {
203  if (Control.Current == null)
204  StartStream();
205 
206  if (Control.Current == null)
207  return;
208 
212  }
void SetManualRecordingStatus()
Sets the state of the manual recording UI elements based on the manual recording status of the curren...
Definition: MainForm.cs:1200
PtzController PtzControl
Gets or sets the PtzControl property.
void ChangePtzFormState(bool enabled)
The ChangePtzFormState method.
void StartStream(DateTime seekTime=default(DateTime))
The StartStream method.
Definition: MainForm.cs:1237
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
MediaControl Current
Gets or sets the Current property.
void SDKSampleApp.Source.MainForm.ButtonManualRecord_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonManualRecord_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 219 of file MainForm.cs.

220  {
221  if (Control.Current == null)
222  return;
223 
224  if (Control.CurrentDataSource == null)
225  return;
226 
227  if (Control.CurrentManualRecording == null)
228  {
229  var newManualRecording = new NewManualRecording {DataSourceId = Control.CurrentDataSource.Id};
230 
232  if (Control.CurrentManualRecording == null)
233  {
234  WriteToLog("Unable to start manual recording.");
235  return;
236  }
237 
238  WriteToLog(string.Format("Started manual recording on {0}.", Control.CurrentDataSource.Name));
239  btnManualRecord.Text = @"Stop";
240  nudPreRecord.Enabled = false;
241  nudPostRecord.Enabled = false;
242  }
243  else
244  {
246  if (result != Results.Value.OK)
247  WriteToLog(string.Format("Error: {0}.", result));
248 
249  WriteToLog(string.Format("Stopped manual recording on {0}.", Control.CurrentDataSource.Name));
251  btnManualRecord.Text = @"Record";
252  if (Control.Current.Mode != MediaControl.Modes.Live)
253  return;
254 
255  nudPreRecord.Enabled = true;
256  nudPostRecord.Enabled = true;
257  }
258  }
Results::Value DeleteManualRecording(ManualRecording^manualRecordingItem)
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
System::String^ Name
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
DataSource CurrentDataSource
Gets or sets the CurrentDataSource property.
ManualRecording^ AddManualRecording(NewManualRecording^newManualRecording)
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
System::String^ Id
MediaControl Current
Gets or sets the Current property.
ManualRecording CurrentManualRecording
Gets or sets the CurrentManualRecording property.
void SDKSampleApp.Source.MainForm.ButtonPause_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonPause_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 265 of file MainForm.cs.

266  {
267  if (Control.Current == null)
268  return;
269 
272  btnLive.Enabled = true;
273  btnManualRecord.Enabled = false;
274  nudPostRecord.Enabled = false;
275  nudPreRecord.Enabled = false;
276  }
void ChangePtzFormState(bool enabled)
The ChangePtzFormState method.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
MediaControl Current
Gets or sets the Current property.
void SDKSampleApp.Source.MainForm.ButtonPlay_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonPlay_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 283 of file MainForm.cs.

284  {
285  StartStream();
286  }
void StartStream(DateTime seekTime=default(DateTime))
The StartStream method.
Definition: MainForm.cs:1237
void SDKSampleApp.Source.MainForm.ButtonRefreshDataSources_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonRefreshDataSources_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 293 of file MainForm.cs.

294  {
295  bgWorker.WorkerReportsProgress = true;
296  bgWorker.RunWorkerAsync();
297  }
void SDKSampleApp.Source.MainForm.ButtonSeek_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonSeek_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 304 of file MainForm.cs.

305  {
306  // The seek time value must be in UTC format.
307  StartStream(dtpSeekTime.Value.ToUniversalTime());
308  }
void StartStream(DateTime seekTime=default(DateTime))
The StartStream method.
Definition: MainForm.cs:1237
void SDKSampleApp.Source.MainForm.ButtonSnapshot_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonSnapshot_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 315 of file MainForm.cs.

316  {
317  if (Control.Current == null)
318  return;
319 
320  var dataSource = Control.Current.CurrentDataSource;
321  if (Control.Current.Mode == MediaControl.Modes.Live)
322  SaveSnapshotLive(dataSource);
323 
324  if (Control.Current.Mode == MediaControl.Modes.Playback)
325  SaveSnapshotRecorded(dataSource);
326  }
async void SaveSnapshotLive(DataSource dataSource)
The SaveSnapshotLive method.
Definition: MainForm.cs:1027
async void SaveSnapshotRecorded(DataSource dataSource)
The SaveSnapshotRecorded method.
Definition: MainForm.cs:1068
DataSource^ CurrentDataSource
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
MediaControl Current
Gets or sets the Current property.
void SDKSampleApp.Source.MainForm.ButtonStop_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The ButtonStop_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 333 of file MainForm.cs.

334  {
335  StopStream();
336  }
void StopStream()
The StopStream method.
Definition: MainForm.cs:1369
static string SDKSampleApp.Source.MainForm.EncodeToBase64 ( string  toEncode)
inlinestaticprivate

The EncodeToBase64 method.

Parameters
toEncodeThe string to encode to Base64.
Returns
The Base64 encoded string.

Definition at line 177 of file MainForm.cs.

178  {
179  var toEncodeAsBytes = Encoding.ASCII.GetBytes(toEncode);
180  var returnValue = Convert.ToBase64String(toEncodeAsBytes);
181  return returnValue;
182  }
void SDKSampleApp.Source.MainForm.GridViewDataSources_CellDoubleClick ( object  sender,
DataGridViewCellEventArgs  args 
)
inlineprivate

The GridViewDataSources_CellDoubleClick method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 343 of file MainForm.cs.

344  {
345  StartStream();
346  }
void StartStream(DateTime seekTime=default(DateTime))
The StartStream method.
Definition: MainForm.cs:1237
void SDKSampleApp.Source.MainForm.MenuItemAlarmInputManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemAlarmInputManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 374 of file MainForm.cs.

375  {
376  using (var alarmInputManagerForm = new AlarmInputManagerForm())
377  {
378  alarmInputManagerForm.ShowDialog();
379  }
380  }
void SDKSampleApp.Source.MainForm.MenuItemBookmarkManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemBookmarkManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 387 of file MainForm.cs.

388  {
389  using (var bookmarkForm = new BookmarkManagerForm())
390  {
391  bookmarkForm.ShowDialog();
392  }
393  }
void SDKSampleApp.Source.MainForm.MenuItemClusterConfig_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemClusterConfig_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 400 of file MainForm.cs.

401  {
402  using (var clusterConfigDetailsForm = new ClusterConfigDetailsForm())
403  {
404  clusterConfigDetailsForm.GetClusterConfig(CurrentSystem);
405  clusterConfigDetailsForm.ShowDialog();
406  }
407  }
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
void SDKSampleApp.Source.MainForm.MenuItemConnect_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemConnect_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 453 of file MainForm.cs.

454  {
455  using (var connectForm = new ConnectForm())
456  {
457  connectForm.ShowDialog();
458  }
459  }
void SDKSampleApp.Source.MainForm.MenuItemDataObjectManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDataObjectManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 414 of file MainForm.cs.

415  {
416  using (var dataObjectManager = new DataObjectManagerForm())
417  {
418  dataObjectManager.ShowDialog();
419  }
420  }
void SDKSampleApp.Source.MainForm.MenuItemDataSourceManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDataSourceManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 427 of file MainForm.cs.

428  {
429  using (var dataSourceManagerForm = new DataSourceManagerForm())
430  {
431  dataSourceManagerForm.ShowDialog();
432  }
433  }
void SDKSampleApp.Source.MainForm.MenuItemDataStorageManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDataStorageManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 440 of file MainForm.cs.

441  {
442  using (var dataStorageManager = new DataStorageManagerForm())
443  {
444  dataStorageManager.ShowDialog();
445  }
446  }
void SDKSampleApp.Source.MainForm.MenuItemDeviceManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDeviceManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 476 of file MainForm.cs.

477  {
478  using (var deviceManagerForm = new DeviceManagerForm())
479  {
480  deviceManagerForm.ShowDialog();
481  }
482  }
void SDKSampleApp.Source.MainForm.MenuItemDisplayEventDialogs_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDisplayEventDialogs_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 863 of file MainForm.cs.

864  {
865  displayEventDialogsToolStripMenuItem.Checked = !displayEventDialogsToolStripMenuItem.Checked;
866  }
void SDKSampleApp.Source.MainForm.MenuItemDrawingManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemDrawingManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 489 of file MainForm.cs.

490  {
491  using (var drawingManagerForm = new DrawingManagerForm())
492  {
493  drawingManagerForm.ShowDialog();
494  }
495  }
void SDKSampleApp.Source.MainForm.MenuItemExit_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemExit_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 466 of file MainForm.cs.

467  {
468  Close();
469  }
void SDKSampleApp.Source.MainForm.MenuItemExportManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemExportManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 502 of file MainForm.cs.

503  {
504  using (var exportForm = new ExportManagerForm())
505  {
506  exportForm.ShowDialog();
507  }
508  }
void SDKSampleApp.Source.MainForm.MenuItemInsertEvent_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemInsertEvent_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 515 of file MainForm.cs.

516  {
517  using (var addEventForm = new AddEventForm())
518  {
519  addEventForm.ShowDialog();
520  }
521  }
void SDKSampleApp.Source.MainForm.MenuItemLicenseDetails_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemLicenseDetails_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 550 of file MainForm.cs.

551  {
552  using (var licenseDetailsForm = new LicenseDetailsForm())
553  {
554  licenseDetailsForm.ShowDialog();
555  }
556  }
void SDKSampleApp.Source.MainForm.MenuItemLog_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemLog_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 353 of file MainForm.cs.

354  {
355  if (scOuter.Panel2Collapsed)
356  {
357  showLogToolStripMenuItem.Text = @"Hide Log";
358  ClientSize = new Size(ClientSize.Width, ClientSize.Height + 90);
359  scOuter.Panel2Collapsed = false;
360  }
361  else
362  {
363  showLogToolStripMenuItem.Text = @"Show Log";
364  ClientSize = new Size(ClientSize.Width, ClientSize.Height - 90);
365  scOuter.Panel2Collapsed = true;
366  }
367  }
void SDKSampleApp.Source.MainForm.MenuItemLogLevel_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemLogLevel_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 528 of file MainForm.cs.

529  {
530  var item = sender as ToolStripMenuItem;
531  if (item == null)
532  return;
533 
534  logTraceToolStripMenuItem.Checked = item == logTraceToolStripMenuItem;
535  logDebugToolStripMenuItem.Checked = item == logDebugToolStripMenuItem;
536  logInfoToolStripMenuItem.Checked = item == logInfoToolStripMenuItem;
537  logWarningToolStripMenuItem.Checked = item == logWarningToolStripMenuItem;
538  logErrorToolStripMenuItem.Checked = item == logErrorToolStripMenuItem;
539  logFatalToolStripMenuItem.Checked = item == logFatalToolStripMenuItem;
540  logDisableToolStripMenuItem.Checked = item == logDisableToolStripMenuItem;
541 
542  VxGlobal.SetLogLevel((LogLevel.Value)item.Tag);
543  }
static CPPCli::Results::Value SetLogLevel(CPPCli::LogLevel::Value logLevel)
void SDKSampleApp.Source.MainForm.MenuItemLogout_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemLogout_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 563 of file MainForm.cs.

564  {
565  StopAllStreams();
566  dgvDataSources.Rows.Clear();
567  CurrentUserName = string.Empty;
568  CurrentPassword = string.Empty;
569  if (CurrentDataSources != null)
570  CurrentDataSources.Clear();
571 
572  if (CurrentDevices != null)
573  CurrentDevices.Clear();
574 
575  CurrentDataSources = null;
576  CurrentDevices = null;
577  CurrentSystem = null;
578  eventsToolStripMenuItem.Enabled = false;
579  manageToolStripMenuItem.Enabled = false;
580  btnSeek.Enabled = false;
581  btnPause.Enabled = false;
582  btnPlay.Enabled = false;
583  btnStop.Enabled = false;
584  btnSnapshot.Enabled = false;
585  btnRefreshDataSources.Enabled = false;
586  btnManualRecord.Enabled = false;
587  nudPostRecord.Enabled = false;
588  nudPreRecord.Enabled = false;
589  }
void StopAllStreams()
The StopAllStreams method.
Definition: MainForm.cs:1349
static string CurrentPassword
Gets or sets the CurrentPassword property.
Definition: MainForm.cs:59
static string CurrentUserName
Gets or sets the CurrentUserName property.
Definition: MainForm.cs:71
static List< Device > CurrentDevices
Gets or sets the CurrentDevices property.
Definition: MainForm.cs:47
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
static List< DataSource > CurrentDataSources
Gets or sets the CurrentDataSources property.
Definition: MainForm.cs:53
void SDKSampleApp.Source.MainForm.MenuItemModifyLoggingPath_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemModifyLoggingPath_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 596 of file MainForm.cs.

597  {
598  using (var folderDialog = new FolderBrowserDialog())
599  {
600  folderDialog.SelectedPath = LogPath;
601  folderDialog.Description = @"Choose Logging Path...";
602 
603  var result = folderDialog.ShowDialog();
604  if (result != DialogResult.OK)
605  return;
606 
607  LogPath = folderDialog.SelectedPath;
608  VxGlobal.SetLogPath(LogPath.Replace(@"\", @"\\"));
609  WriteToLog(string.Format("Logging Path changed to: {0}", folderDialog.SelectedPath));
610  }
611  }
static CPPCli::Results::Value SetLogPath(System::String^logPath)
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
static string LogPath
Gets or sets the LogPath property.
Definition: MainForm.cs:77
void SDKSampleApp.Source.MainForm.MenuItemMonitors_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemMonitors_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 618 of file MainForm.cs.

619  {
620  using (var monitorManagerForm = new MonitorManagerForm())
621  {
622  monitorManagerForm.ShowDialog();
623  }
624  }
void SDKSampleApp.Source.MainForm.MenuItemNotifications_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemNotifications_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 631 of file MainForm.cs.

632  {
633  using (var notificationManagerForm = new NotificationManagerForm())
634  {
635  notificationManagerForm.ShowDialog();
636  }
637  }
void SDKSampleApp.Source.MainForm.MenuItemProtocol_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemProtocol_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 644 of file MainForm.cs.

645  {
646  var item = sender as ToolStripMenuItem;
647  if (item != null && item.Text == @"MJPEG")
648  {
649  rtspToolStripMenuItem.Checked = false;
650  mjpegToolStripMenuItem.Checked = true;
651  }
652  else
653  {
654  rtspToolStripMenuItem.Checked = true;
655  mjpegToolStripMenuItem.Checked = false;
656  }
657 
658  StopAllStreams();
659  }
void StopAllStreams()
The StopAllStreams method.
Definition: MainForm.cs:1349
void SDKSampleApp.Source.MainForm.MenuItemQuickLog_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemQuickLog_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 666 of file MainForm.cs.

667  {
668  using (var quickLogForm = new QuickLogForm())
669  {
670  quickLogForm.ShowDialog();
671  }
672  }
void SDKSampleApp.Source.MainForm.MenuItemQuickReport_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemQuickReport_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 679 of file MainForm.cs.

680  {
681  using (var quickReportForm = new QuickReportForm())
682  {
683  quickReportForm.ShowDialog();
684  }
685  }
void SDKSampleApp.Source.MainForm.MenuItemRelayOutputManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemRelayOutputManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 692 of file MainForm.cs.

693  {
694  using (var relayOutputManagerForm = new RelayOutputManagerForm())
695  {
696  relayOutputManagerForm.ShowDialog();
697  }
698  }
void SDKSampleApp.Source.MainForm.MenuItemRoleManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemRoleManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 705 of file MainForm.cs.

706  {
707  using (var roleForm = new RoleManagerForm())
708  {
709  roleForm.ShowDialog();
710  }
711  }
void SDKSampleApp.Source.MainForm.MenuItemScheduleManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemScheduleManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 718 of file MainForm.cs.

719  {
720  using (var scheduleForm = new ScheduleManagerForm())
721  {
722  scheduleForm.ShowDialog();
723  }
724  }
void SDKSampleApp.Source.MainForm.MenuItemSearchEvents_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemScheduleManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 731 of file MainForm.cs.

732  {
733  using (var eventSearchForm = new EventSearchForm())
734  {
735  eventSearchForm.ShowDialog();
736  }
737  }
void SDKSampleApp.Source.MainForm.MenuItemShowPtzControls_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemShowPtzControls_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 744 of file MainForm.cs.

745  {
746  PtzForm.Show();
747  }
static PTZControlForm PtzForm
Gets or sets the PtzForm property.
Definition: MainForm.cs:95
void SDKSampleApp.Source.MainForm.MenuItemSituationManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemSituationManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 754 of file MainForm.cs.

755  {
756  using (var situationForm = new SituationManagerForm())
757  {
758  situationForm.ShowDialog();
759  }
760  }
void SDKSampleApp.Source.MainForm.MenuItemSnapshotPath_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemSnapshotPath_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 780 of file MainForm.cs.

781  {
782  using (var folderDialog = new FolderBrowserDialog())
783  {
784  folderDialog.SelectedPath = SnapshotBasePath;
785  folderDialog.Description = @"Choose Snapshot Save Path...";
786 
787  var result = folderDialog.ShowDialog();
788  if (result != DialogResult.OK)
789  return;
790 
791  SnapshotBasePath = folderDialog.SelectedPath + "\\";
792  var message = string.Format("Snapshot Path changed: {0}", folderDialog.SelectedPath);
793  MessageBox.Show(message, @"Snapshot Path");
794  }
795  }
static string SnapshotBasePath
Gets or sets the SnapshotBasePath property.
Definition: MainForm.cs:83
void SDKSampleApp.Source.MainForm.MenuItemSubscribe_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemSubscribe_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 802 of file MainForm.cs.

803  {
804  if (!subscribeToSystemEventsToolStripMenuItem.Checked)
805  {
806  // Only one subscription can be active at once. So unsubscribe to the system
807  // events if it is active.
808  if (subscribeToSystemEventsByTypeToolStripMenuItem.Checked)
809  {
811  subscribeToSystemEventsByTypeToolStripMenuItem.Checked = false;
812  }
813 
815  subscribeToSystemEventsToolStripMenuItem.Checked = true;
816  WriteToLog("Subscribed to events.");
817  }
818  else
819  {
821  subscribeToSystemEventsToolStripMenuItem.Checked = false;
822  WriteToLog("Unsubscribed to events.");
823  }
824  }
EventDelegate^ SystemEvent
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
void OnSystemEvent(Event systemEvent)
The OnSystemEvent method.
Definition: MainForm.cs:116
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
void SDKSampleApp.Source.MainForm.MenuItemSubscribeByType_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemSubscribeByType_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 831 of file MainForm.cs.

832  {
833  if (!subscribeToSystemEventsByTypeToolStripMenuItem.Checked)
834  {
835  // Only one subscription can be active at once. So unsubscribe to the type specific
836  // system events if it is active.
837  if (subscribeToSystemEventsToolStripMenuItem.Checked)
838  {
840  subscribeToSystemEventsToolStripMenuItem.Checked = false;
841  }
842 
843  using (var situationTypeSelectionForm = new SituationTypeSelectionForm())
844  {
845  situationTypeSelectionForm.ShowDialog();
846  }
847 
848  subscribeToSystemEventsByTypeToolStripMenuItem.Checked = true;
849  }
850  else
851  {
853  subscribeToSystemEventsByTypeToolStripMenuItem.Checked = false;
854  WriteToLog("Unsubscribed to events.");
855  }
856  }
EventDelegate^ SystemEvent
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
void OnSystemEvent(Event systemEvent)
The OnSystemEvent method.
Definition: MainForm.cs:116
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
void SDKSampleApp.Source.MainForm.MenuItemTagManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemTagManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 767 of file MainForm.cs.

768  {
769  using (var tagForm = new TagManagerForm())
770  {
771  tagForm.ShowDialog();
772  }
773  }
void SDKSampleApp.Source.MainForm.MenuItemUserManager_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The MenuItemUserManager_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 873 of file MainForm.cs.

874  {
875  using (var userForm = new UserManagerForm())
876  {
877  userForm.ShowDialog();
878  }
879  }
void SDKSampleApp.Source.MainForm.OnInternalEvent ( InternalEvent  internalEvent)
inline

The OnInternalEvent method.

Parameters
internalEventThe internalEvent parameter.

Definition at line 107 of file MainForm.cs.

108  {
109  WriteToLog(internalEvent.Type.ToString());
110  }
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
void SDKSampleApp.Source.MainForm.OnSystemEvent ( Event  systemEvent)
inline

The OnSystemEvent method.

Parameters
systemEventThe systemEvent parameter.

Definition at line 116 of file MainForm.cs.

117  {
118  var type = EventDisplayForm.FormatText(systemEvent.SituationType.Split('/').Last());
119  var severity = Math.Abs(systemEvent.Severity - 11);
120  Device device = null;
121  foreach (var dev in CurrentDevices.Where(dev => dev.Id == systemEvent.SourceDeviceId))
122  device = dev;
123 
124  string devName = device != null ? device.Name : systemEvent.SourceDeviceId;
125  WriteToLog(string.Format(Resources.EventHeaderFormatString, severity, type, devName));
126 
127  if (displayEventDialogsToolStripMenuItem.Checked)
128  {
129  Instance.Invoke(new MethodInvoker(delegate
130  {
131  var eventForm = new EventDisplayForm(systemEvent);
132  eventForm.Show(Instance);
133  }));
134  }
135  }
System::String^ SituationType
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
static List< Device > CurrentDevices
Gets or sets the CurrentDevices property.
Definition: MainForm.cs:47
unsigned short Severity
static MainForm Instance
Gets the Instance property.
Definition: MainForm.cs:89
System::String^ SourceDeviceId
System::String^ Name
void SDKSampleApp.Source.MainForm.PanelVideoStream_Click ( object  sender,
EventArgs  args 
)
inlineprivate

The PanelVideoStream_Click method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 886 of file MainForm.cs.

887  {
888  var panel = sender as Panel;
889  if (panel == null)
890  return;
891 
892  if (Control.SelectedPanel != panel)
893  return;
894 
895  var point = panel.PointToClient(Cursor.Position);
896  if (Control.PtzControl == null)
897  return;
898 
899  float relX;
900  float relY;
901  var xMidPoint = (float)panel.Width / 2;
902  if (point.X > xMidPoint)
903  {
904  var adjustedX = point.X - xMidPoint;
905  relX = adjustedX / xMidPoint * 100;
906  }
907  else
908  {
909  var adjustedX = xMidPoint - point.X;
910  relX = adjustedX / xMidPoint * -100;
911  }
912 
913  var yMidPoint = (float)panel.Height / 2;
914  if (point.Y > yMidPoint)
915  {
916  var adjustedY = yMidPoint - point.Y;
917  relY = adjustedY / yMidPoint * 100;
918  }
919  else
920  {
921  var adjustedY = point.Y - yMidPoint;
922  relY = adjustedY / yMidPoint * -100;
923  }
924 
925  var result = Control.PtzControl.RelativePercentageMove((int)relX, (int)relY);
926  if (result != Results.Value.OK)
927  WriteToLog(string.Format("Error: {0}.", result));
928  }
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
Results::Value RelativePercentageMove(int percentageX, int percentageY)
void SDKSampleApp.Source.MainForm.PanelVideoStream_MouseEnter ( object  sender,
EventArgs  args 
)
inlineprivate

The PanelVideoStream_MouseEnter method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 935 of file MainForm.cs.

936  {
937  var panel = sender as Panel;
938  if (panel == null)
939  return;
940 
941  if (Control.SelectedPanel != panel)
942  return;
943 
944  if (Control.PtzControl == null)
945  return;
946 
947  panel.Cursor = Cursors.Cross;
948  }
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
void SDKSampleApp.Source.MainForm.PanelVideoStream_MouseLeave ( object  sender,
EventArgs  args 
)
inlineprivate

The PanelVideoStream_MouseLeave method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 955 of file MainForm.cs.

956  {
957  var panel = sender as Panel;
958  if (panel == null)
959  return;
960 
961  if (Control.SelectedPanel != panel)
962  return;
963 
964  if (Control.PtzControl == null)
965  return;
966 
967  panel.Cursor = Cursors.Default;
968  }
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
void SDKSampleApp.Source.MainForm.PanelVideoStream_MouseWheel ( object  sender,
MouseEventArgs  args 
)
inlineprivate

The PanelVideoStream_MouseWheel method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 975 of file MainForm.cs.

976  {
977  var panel = sender as Panel;
978  if (panel == null)
979  return;
980 
981  if (Control.SelectedPanel != panel)
982  return;
983 
984  if (Control.PtzControl == null)
985  return;
986 
987  var zoomLevel = (float)args.Delta / 2;
988  var result = Control.PtzControl.RelativeMove(0, 0, (int)zoomLevel);
989  if (result != Results.Value.OK)
990  WriteToLog(string.Format("Error: {0}.", result));
991  }
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Results::Value RelativeMove(int deltaX, int deltaY, int deltaZ)
Panel SelectedPanel
Gets the SelectedPanel property.
void SDKSampleApp.Source.MainForm.PanelVideoStreamLeft_MouseClick ( object  sender,
MouseEventArgs  args 
)
inlineprivate

The PanelVideoStreamLeft_MouseClick method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 998 of file MainForm.cs.

999  {
1000  Control.SelectControl(ControlManager.Controls.Left);
1002  if (Control.PtzControl == null)
1003  return;
1004 
1005  Control.SelectedPanel.Cursor = Cursors.Cross;
1006  }
void SelectControl(Controls control)
The SelectControl method.
void SetManualRecordingStatus()
Sets the state of the manual recording UI elements based on the manual recording status of the curren...
Definition: MainForm.cs:1200
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
void SDKSampleApp.Source.MainForm.PanelVideoStreamRight_MouseClick ( object  sender,
MouseEventArgs  args 
)
inlineprivate

The PanelVideoStreamRight_MouseClick method.

Parameters
senderThe sender parameter.
argsThe args parameter.

Definition at line 1013 of file MainForm.cs.

1014  {
1015  Control.SelectControl(ControlManager.Controls.Right);
1017  if (Control.PtzControl == null)
1018  return;
1019 
1020  Control.SelectedPanel.Cursor = Cursors.Cross;
1021  }
void SelectControl(Controls control)
The SelectControl method.
void SetManualRecordingStatus()
Sets the state of the manual recording UI elements based on the manual recording status of the curren...
Definition: MainForm.cs:1200
PtzController PtzControl
Gets or sets the PtzControl property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
async void SDKSampleApp.Source.MainForm.SaveSnapshotLive ( DataSource  dataSource)
inlineprivate

The SaveSnapshotLive method.

Parameters
dataSourceThe data source to use for the snapshot.

Definition at line 1027 of file MainForm.cs.

1028  {
1029  var uri = new Uri(dataSource.SnapshotUri);
1030  var response = await SendRequest(uri);
1031  if (response.StatusCode != HttpStatusCode.OK)
1032  {
1033  WriteToLog(string.Format("Unable to take snapshot, server returned {0}.", response.StatusCode));
1034  return;
1035  }
1036 
1037  var bytes = await response.Content.ReadAsByteArrayAsync();
1038  var imageTime = Control.SelectedPanelTime.Replace(":", string.Empty);
1039  var filename = SnapshotBasePath + "Live-" + imageTime + ".jpg";
1040  if (!Directory.Exists(SnapshotBasePath))
1041  {
1042  WriteToLog(string.Format("Unable to take snapshot, path no longer exists {0}.", SnapshotBasePath));
1043  return;
1044  }
1045 
1046  BinaryWriter binWriter = null;
1047  try
1048  {
1049  binWriter = new BinaryWriter(new FileStream(filename, FileMode.Append, FileAccess.Write));
1050  binWriter.Write(bytes);
1051  binWriter.Close();
1052  }
1053  finally
1054  {
1055  if (binWriter != null)
1056  {
1057  binWriter.Dispose();
1058  }
1059  }
1060 
1061  ShowSnapshotDialog(filename);
1062  }
async Task< HttpResponseMessage > SendRequest(Uri uri)
The SendRequest method.
Definition: MainForm.cs:142
System::String^ SnapshotUri
static string SnapshotBasePath
Gets or sets the SnapshotBasePath property.
Definition: MainForm.cs:83
string SelectedPanelTime
Gets the SelectedPanelTime property.
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
static void ShowSnapshotDialog(string fileName)
The ShowSnapshotDialog method.
Definition: MainForm.cs:188
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
async void SDKSampleApp.Source.MainForm.SaveSnapshotRecorded ( DataSource  dataSource)
inlineprivate

The SaveSnapshotRecorded method.

Parameters
dataSourceThe data source to use for the snapshot.

Definition at line 1068 of file MainForm.cs.

1069  {
1070  var listBytes = new List<ImageByteArray>();
1071  var clips = dataSource.Clips;
1072 
1073  // Find the clip that contains the section of video currently playing.
1074  Clip currentClip = null;
1075  foreach (var clip in clips)
1076  {
1077  var time = DateTime.Parse(Control.SelectedPanelTime).ToUniversalTime();
1078  if (time > clip.StartTime && time < clip.EndTime)
1079  currentClip = clip;
1080  }
1081 
1082  // Exit if no clip was found.
1083  if (currentClip == null)
1084  {
1085  WriteToLog("Error: Unable to find clip.");
1086  return;
1087  }
1088 
1089  var filter = new SnapshotFilter
1090  {
1091  StartTime = DateTime.Parse(Control.SelectedPanelTime).ToUniversalTime(),
1092  EndTime = DateTime.Parse(Control.SelectedPanelTime).ToUniversalTime().AddSeconds(1),
1093  Offset = 10
1094  };
1095 
1096  var uri = new Uri(currentClip.GetSnapshotEndpoint(filter));
1097  var response = await SendRequest(uri);
1098  if (response.StatusCode != HttpStatusCode.OK)
1099  {
1100  WriteToLog(string.Format("Unable to take snapshot, server returned {0}.", response.StatusCode));
1101  return;
1102  }
1103 
1104  var mpmsp = await response.Content.ReadAsMultipartAsync();
1105  foreach (var content in mpmsp.Contents)
1106  {
1107  var bytes = await content.ReadAsByteArrayAsync();
1108  if (bytes == null)
1109  continue;
1110 
1111  var imgByteArray = new ImageByteArray(bytes, content.Headers);
1112  listBytes.Add(imgByteArray);
1113  }
1114 
1115  foreach (var byteArray in listBytes)
1116  {
1117  var imageTime = byteArray.ImageTime.ToString("s").Replace(":", string.Empty);
1118  var filename = SnapshotBasePath + "Recorded-" + imageTime + ".jpg";
1119  if (!Directory.Exists(SnapshotBasePath))
1120  {
1121  WriteToLog(string.Format("Unable to take snapshot, path no longer exists {0}.", SnapshotBasePath));
1122  return;
1123  }
1124 
1125  BinaryWriter binWriter = null;
1126  try
1127  {
1128  binWriter = new BinaryWriter(new FileStream(filename, FileMode.Append, FileAccess.Write));
1129  binWriter.Write(byteArray.Bytes);
1130  binWriter.Close();
1131  }
1132  finally
1133  {
1134  if (binWriter != null)
1135  binWriter.Dispose();
1136  }
1137 
1138  ShowSnapshotDialog(filename);
1139  }
1140  }
async Task< HttpResponseMessage > SendRequest(Uri uri)
The SendRequest method.
Definition: MainForm.cs:142
static string SnapshotBasePath
Gets or sets the SnapshotBasePath property.
Definition: MainForm.cs:83
string SelectedPanelTime
Gets the SelectedPanelTime property.
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
System::String^ GetSnapshotEndpoint(SnapshotFilter^filter)
System::Collections::Generic::List< Clip^ >^ Clips
static void ShowSnapshotDialog(string fileName)
The ShowSnapshotDialog method.
Definition: MainForm.cs:188
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
void SDKSampleApp.Source.MainForm.SelectAudioData ( DataSource  videoSource,
bool  showWindow,
out DataSource  audioSource,
out DataInterface  audioInterface 
)
inlineprivate

Select the audio data source and data interfaces from the MainForm.CurrentDataSources

Parameters
videoSourceVideo data source
showWindowSpecifies wheather to show the window or not
audioSourceOut parameter for audio data source
audioInterfaceOut parameter for audio data interface

Definition at line 1411 of file MainForm.cs.

1412  {
1413  audioSource = null;
1414  audioInterface = null;
1415 
1416  foreach (var ds in CurrentDataSources)
1417  {
1418  if (videoSource.Name != ds.Name || ds.Type != DataSource.Types.Audio)
1419  continue;
1420 
1421  audioInterface = SelectDataInterface(VxStreamProtocol.RtspRtp, ds, showWindow);
1422  if (audioInterface == null)
1423  {
1424  WriteToLog("Error: No audio data interface found for selected camera.\n");
1425  return;
1426  }
1427 
1428  audioSource = ds;
1429  }
1430  }
VxStreamProtocol
The VxStreamProtocol enumeration.
Definition: Enums.cs:138
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
System::String^ Name
DataInterface SelectDataInterface(VxStreamProtocol selProtocol, DataSource dataSource, bool showWindow)
The SelectDataInterface method.
Definition: MainForm.cs:1161
static List< DataSource > CurrentDataSources
Gets or sets the CurrentDataSources property.
Definition: MainForm.cs:53
DataInterface SDKSampleApp.Source.MainForm.SelectDataInterface ( VxStreamProtocol  selProtocol,
DataSource  dataSource,
bool  showWindow 
)
inlineprivate

The SelectDataInterface method.

Parameters
selProtocolThe selected protocol.
dataSourceThe selected data source.
showWindowSelects the first available stream if False.
Returns
The currently selected data interface.

Definition at line 1161 of file MainForm.cs.

1162  {
1163  DataInterface dataInterface;
1164  if (selProtocol == VxStreamProtocol.RtspRtp)
1165  {
1166  var interfaceList = dataSource.DataInterfaces.Where(iface =>
1167  iface.Protocol == DataInterface.StreamProtocols.RtspRtp).ToList();
1168 
1169  if (interfaceList.Count == 0)
1170  return null;
1171 
1172  if (!showWindow)
1173  return interfaceList[0];
1174 
1175  if (interfaceList.Count > 1)
1176  {
1177  using (var streamSelectionForm = new StreamSelectionForm(interfaceList))
1178  {
1179  streamSelectionForm.ShowDialog();
1180  if (streamSelectionForm.SelectedInterface == null)
1181  return null;
1182  dataInterface = streamSelectionForm.SelectedInterface;
1183  }
1184  }
1185  else
1186  dataInterface = interfaceList[0];
1187  }
1188  else
1189  {
1190  dataInterface = dataSource.DataInterfaces.First(iface =>
1191  iface.Protocol == DataInterface.StreamProtocols.MjpegPull);
1192  }
1193 
1194  return dataInterface;
1195  }
System::Collections::Generic::List< DataInterface^ >^ DataInterfaces
VxStreamProtocol
The VxStreamProtocol enumeration.
Definition: Enums.cs:138
async Task<HttpResponseMessage> SDKSampleApp.Source.MainForm.SendRequest ( Uri  uri)
inline

The SendRequest method.

Parameters
uriThe request Uri.
Returns
The response message.

Definition at line 142 of file MainForm.cs.

143  {
144  // Create a new WebClient instance.
145  var client = new HttpClient();
146 
147  // Supply the username and password that was used to create the VideoXpert system.
148  var request = new HttpRequestMessage(HttpMethod.Get, uri);
149  request.Headers.Add("X-Serenity-User", EncodeToBase64(CurrentUserName));
150  request.Headers.Add("X-Serenity-Password", EncodeToBase64(CurrentPassword));
151 
152  // Forces the WebClient to trust the security certificate handed back from the VideoXpert server.
153  ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
154 
155  var response = await client.SendAsync(request);
156  return response;
157  }
static string EncodeToBase64(string toEncode)
The EncodeToBase64 method.
Definition: MainForm.cs:177
static string CurrentPassword
Gets or sets the CurrentPassword property.
Definition: MainForm.cs:59
static string CurrentUserName
Gets or sets the CurrentUserName property.
Definition: MainForm.cs:71
void SDKSampleApp.Source.MainForm.SetManualRecordingStatus ( )
inline

Sets the state of the manual recording UI elements based on the manual recording status of the current stream.

Definition at line 1200 of file MainForm.cs.

1201  {
1202  if (Control.CurrentDataSource == null)
1203  {
1204  btnManualRecord.Text = @"Record";
1205  btnManualRecord.Enabled = false;
1206  nudPreRecord.Enabled = false;
1207  nudPostRecord.Enabled = false;
1208  return;
1209  }
1210 
1211  var manualRecordings = CurrentSystem.GetManualRecordings();
1213  foreach (var manualRecording in manualRecordings)
1214  {
1215  if (manualRecording.DataSourceId == Control.CurrentDataSource.Id && manualRecording.OwnerName == userUpn)
1216  {
1217  Control.CurrentManualRecording = manualRecording;
1218  btnManualRecord.Text = @"Stop";
1219  btnManualRecord.Enabled = true;
1220  nudPreRecord.Enabled = false;
1221  nudPostRecord.Enabled = false;
1222  return;
1223  }
1224  }
1225 
1226  btnManualRecord.Text = @"Record";
1227  btnManualRecord.Enabled = Control.Current.Mode == MediaControl.Modes.Live;
1228  nudPreRecord.Enabled = Control.Current.Mode == MediaControl.Modes.Live;
1229  nudPostRecord.Enabled = Control.Current.Mode == MediaControl.Modes.Live;
1230  }
System::String^ Name
System::String^ Domain
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
DataSource CurrentDataSource
Gets or sets the CurrentDataSource property.
System::Collections::Generic::List< ManualRecording^ >^ GetManualRecordings()
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
System::String^ Id
MediaControl Current
Gets or sets the Current property.
ManualRecording CurrentManualRecording
Gets or sets the CurrentManualRecording property.
void SDKSampleApp.Source.MainForm.SetupPtzControls ( DataSource  dataSource)
inlineprivate

The SetupPtzControls method.

Parameters
dataSourceThe dataSource parameter.

Checks if PTZ is enabled on the device. If enabled, it also gets the available presets and patterns for the device.

Definition at line 1148 of file MainForm.cs.

1149  {
1150  Control.PtzControl = dataSource.IsPTZ ? dataSource.PTZController : null;
1151  Control.ChangePtzFormState(dataSource.IsPTZ);
1152  }
PtzController^ PTZController
PtzController PtzControl
Gets or sets the PtzControl property.
void ChangePtzFormState(bool enabled)
The ChangePtzFormState method.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
static void SDKSampleApp.Source.MainForm.ShowSnapshotDialog ( string  fileName)
inlinestaticprivate

The ShowSnapshotDialog method.

Parameters
fileNameThe file name of the snapshot image.

Definition at line 188 of file MainForm.cs.

189  {
190  var message = string.Format("Snapshot saved: {0}\n\n View snapshot?", fileName);
191  var result = MessageBox.Show(message, @"View Snapshot", MessageBoxButtons.YesNo);
192  if (result == DialogResult.Yes)
193  Process.Start(fileName);
194  }
void SDKSampleApp.Source.MainForm.StartStream ( DateTime  seekTime = default(DateTime))
inlineprivate

The StartStream method.

Parameters
seekTimeThe seekTime in UTC format. If no value or a default DateTime object is given then the stream is started in live mode.

Definition at line 1237 of file MainForm.cs.

1238  {
1239  try
1240  {
1241  // Get the data sources for the selected device.
1242  var dataSource = (DataSource)dgvDataSources.SelectedRows[0].Tag;
1243  var protocol = mjpegToolStripMenuItem.Checked ? VxStreamProtocol.MjpegPull : VxStreamProtocol.RtspRtp;
1244  var showWindow = true;
1245  if (Control.Current != null)
1246  showWindow = Control.Current.Mode == MediaControl.Modes.Stopped;
1247 
1248  var dataInterface = SelectDataInterface(protocol, dataSource, showWindow);
1249  if (dataInterface == null)
1250  {
1251  WriteToLog("Error: No data interface found for selected camera.\n");
1252  return;
1253  }
1254 
1255  DataSource audioDataSource;
1256  DataInterface audioDataInterface;
1257  var audioLink = dataSource.LinkedAudioRelation;
1258  if (audioLink != null)
1259  {
1260  audioDataSource = audioLink.Resource;
1261  audioDataInterface = SelectDataInterface(VxStreamProtocol.RtspRtp, audioDataSource, false);
1262  }
1263  else
1264  SelectAudioData(dataSource, showWindow, out audioDataSource, out audioDataInterface);
1265 
1266  // If the media controller exists then a stream is running and the user is
1267  // requesting a new action on it. If it's null then this is either the
1268  // first run or an existing stream has been stopped. So a new media controller
1269  // instance is needed.
1270  if (Control.Current == null)
1271  {
1272  Control.Current = new MediaControl(dataSource, dataInterface, audioDataSource, audioDataInterface);
1275  }
1276  else
1277  {
1278  // If a new device has been selected while another stream is running, stop the
1279  // old stream and set up the new stream using the new data source.
1280  if ((Control.CurrentDataSource == null) || (dataSource.Id != Control.CurrentDataSource.Id))
1281  {
1282  Control.Current.Stop();
1283  Control.Current.SetDataSource(dataSource, dataInterface, audioDataSource, audioDataInterface);
1284  }
1285  }
1286 
1287  if (seekTime == default(DateTime))
1288  {
1289  if (!Control.Current.Play((float)nudSpeed.Value))
1290  {
1291  WriteToLog(string.Format("Error: Unable to {0} stream.\n",
1292  Control.Current.Mode == MediaControl.Modes.Playback ? "resume" : "start"));
1294  {
1295  StopStream();
1296  return;
1297  }
1298 
1299  Control.Current.Dispose();
1300  Control.Current = null;
1301  Control.SelectedPanel.Refresh();
1302  return;
1303  }
1304  }
1305  else
1306  {
1307  if (!Control.Current.Seek(seekTime, (float)nudSpeed.Value))
1308  {
1309  WriteToLog("Error: Unable to start recorded stream.\n");
1311  {
1312  StopStream();
1313  return;
1314  }
1315 
1316  Control.SelectedLabel.BeginInvoke((MethodInvoker)delegate
1317  {
1318  Control.SelectedLabel.Text = string.Empty;
1319  });
1320  Control.Current.Dispose();
1321  Control.Current = null;
1322  Control.SelectedPanel.Refresh();
1323  return;
1324  }
1325  }
1326 
1328  SetupPtzControls(dataSource);
1329  Control.CurrentDataSource = dataSource;
1331  }
1332  catch (Exception ex)
1333  {
1334  WriteToLog(string.Format(@"Error: {0}\n", ex.Message));
1335  }
1336  }
void SetPlayingIndex()
The SetPlayingIndex method.
VxStreamProtocol
The VxStreamProtocol enumeration.
Definition: Enums.cs:138
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
void SetManualRecordingStatus()
Sets the state of the manual recording UI elements based on the manual recording status of the curren...
Definition: MainForm.cs:1200
void SetVideoWindow(System::IntPtr windowHandle)
bool Seek(System::DateTime time, float speed)
DataInterface SelectDataInterface(VxStreamProtocol selProtocol, DataSource dataSource, bool showWindow)
The SelectDataInterface method.
Definition: MainForm.cs:1161
DataSource CurrentDataSource
Gets or sets the CurrentDataSource property.
void SelectAudioData(DataSource videoSource, bool showWindow, out DataSource audioSource, out DataInterface audioInterface)
Select the audio data source and data interfaces from the MainForm.CurrentDataSources ...
Definition: MainForm.cs:1411
void StopStream()
The StopStream method.
Definition: MainForm.cs:1369
Label SelectedLabel
Gets the SelectedLabel property.
void SetDataSource(DataSource^videoDataSource, DataInterface^videoDataInterface, DataSource^audioDataSource, DataInterface^audioDataInterface)
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
System::String^ Id
Panel SelectedPanel
Gets the SelectedPanel property.
void SubscribeToTimestamps()
The SubscribeToTimestamps method.
void SetupPtzControls(DataSource dataSource)
The SetupPtzControls method.
Definition: MainForm.cs:1148
MediaControl Current
Gets or sets the Current property.
bool Play(float speed)
void SDKSampleApp.Source.MainForm.StopAllStreams ( )
inlineprivate

The StopAllStreams method.

Definition at line 1349 of file MainForm.cs.

1350  {
1351  try
1352  {
1353  var selControl = Control.SelectedControl;
1354  Control.SelectControl(ControlManager.Controls.Left);
1355  StopStream();
1356  Control.SelectControl(ControlManager.Controls.Right);
1357  StopStream();
1358  Control.SelectControl(selControl);
1359  }
1360  catch (Exception ex)
1361  {
1362  WriteToLog(string.Format(@"Error: {0}\n", ex.Message));
1363  }
1364  }
Controls SelectedControl
Gets or sets the SelectedControl property.
void SelectControl(Controls control)
The SelectControl method.
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
void StopStream()
The StopStream method.
Definition: MainForm.cs:1369
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
void SDKSampleApp.Source.MainForm.StopStream ( )
inlineprivate

The StopStream method.

Definition at line 1369 of file MainForm.cs.

1370  {
1371  try
1372  {
1373  if (Control.Current == null)
1374  return;
1375 
1376  Control.Current.Stop();
1377 
1379  Control.SelectedLabel.BeginInvoke((MethodInvoker)delegate
1380  {
1381  Control.SelectedLabel.Text = string.Empty;
1382  });
1383 
1384  Control.SelectedPanel.Refresh();
1385 
1386  Control.PtzControl = null;
1387  Control.CurrentDataSource = null;
1389  btnManualRecord.Text = @"Record";
1390  btnManualRecord.Enabled = false;
1391  nudPostRecord.Enabled = false;
1392  nudPreRecord.Enabled = false;
1393  Control.ChangePtzFormState(false);
1394 
1395  Control.Current.Dispose();
1396  Control.Current = null;
1397  }
1398  catch (Exception ex)
1399  {
1400  WriteToLog(string.Format(@"Error: {0}\n", ex.Message));
1401  }
1402  }
void WriteToLog(string message)
The WriteToLog method.
Definition: MainForm.cs:163
PtzController PtzControl
Gets or sets the PtzControl property.
DataSource CurrentDataSource
Gets or sets the CurrentDataSource property.
void ChangePtzFormState(bool enabled)
The ChangePtzFormState method.
void UnsubscribeToTimestamps()
The UnsubscribeToTimestamps method.
Label SelectedLabel
Gets the SelectedLabel property.
ControlManager Control
Gets or sets the Control property.
Definition: MainForm.cs:101
Panel SelectedPanel
Gets the SelectedPanel property.
MediaControl Current
Gets or sets the Current property.
ManualRecording CurrentManualRecording
Gets or sets the CurrentManualRecording property.
void SDKSampleApp.Source.MainForm.SubscribeToInternalEvents ( )
inline

Subscribes to internal VxSDK events.

Definition at line 1341 of file MainForm.cs.

1342  {
1344  }
InternalEventDelegate^ InternalEvent
static VXSystem CurrentSystem
Gets or sets the CurrentSystem property.
Definition: MainForm.cs:65
void OnInternalEvent(InternalEvent internalEvent)
The OnInternalEvent method.
Definition: MainForm.cs:107
void SDKSampleApp.Source.MainForm.WriteToLog ( string  message)
inline

The WriteToLog method.

Parameters
messageThe message parameter.

Definition at line 163 of file MainForm.cs.

164  {
165  var time = DateTime.Now;
166  txbxLog.BeginInvoke((MethodInvoker)delegate
167  {
168  txbxLog.AppendText(time.ToLongTimeString() + ": " + message + "\n");
169  });
170  }

Property Documentation

ControlManager SDKSampleApp.Source.MainForm.Control
getset

Gets or sets the Control property.

A ControlManager.

Definition at line 101 of file MainForm.cs.

List<DataSource> SDKSampleApp.Source.MainForm.CurrentDataSources
staticgetset

Gets or sets the CurrentDataSources property.

The current list of data sources found on the VideoXpert system.

Definition at line 53 of file MainForm.cs.

List<Device> SDKSampleApp.Source.MainForm.CurrentDevices
staticgetset

Gets or sets the CurrentDevices property.

The current list of devices found on the VideoXpert system.

Definition at line 47 of file MainForm.cs.

string SDKSampleApp.Source.MainForm.CurrentPassword
staticgetset

Gets or sets the CurrentPassword property.

The current VideoXpert system password.

Definition at line 59 of file MainForm.cs.

VXSystem SDKSampleApp.Source.MainForm.CurrentSystem
staticgetset

Gets or sets the CurrentSystem property.

The current VideoXpert system.

Definition at line 65 of file MainForm.cs.

string SDKSampleApp.Source.MainForm.CurrentUserName
staticgetset

Gets or sets the CurrentUserName property.

The current VideoXpert system user name.

Definition at line 71 of file MainForm.cs.

MainForm SDKSampleApp.Source.MainForm.Instance
staticgetprivate set

Gets the Instance property.

The current MainForm instance.

Definition at line 89 of file MainForm.cs.

string SDKSampleApp.Source.MainForm.LogPath
staticgetset

Gets or sets the LogPath property.

The logging directory for the VxSDK.

Definition at line 77 of file MainForm.cs.

PTZControlForm SDKSampleApp.Source.MainForm.PtzForm
staticgetset

Gets or sets the PtzForm property.

A PTZControlForm.

Definition at line 95 of file MainForm.cs.

string SDKSampleApp.Source.MainForm.SnapshotBasePath
staticgetset

Gets or sets the SnapshotBasePath property.

The directory to save snapshots.

Definition at line 83 of file MainForm.cs.


The documentation for this class was generated from the following file: