←Select platform

SaveSettingsToFile Method

Summary

Saves some or all of the capture object settings to a file.

Syntax

C#
VB
C++
public virtual void SaveSettingsToFile( 
   string targetFile, 
   CaptureSettings flags 
) 
Public Overridable Sub SaveSettingsToFile( _ 
   ByVal targetFile As String, _ 
   ByVal flags As Leadtools.Multimedia.CaptureSettings _ 
)  
public: 
virtual void SaveSettingsToFile(  
   String^ targetFile, 
   Leadtools.Multimedia.CaptureSettings flags 
)  

Parameters

targetFile
The file in which settings will be saved.

flags
The settings flags specifying which settings to save. See the CaptureSettings enumeration for settings options.

Remarks

The capture object settings can be saved to a stream by calling SaveSettingsToStream. Saved settings can be loaded using the LoadSettingsFromFile method or the LoadSettingsFromStream method. It may be helpful to call CanSaveObjectSettings before calling the save methods, to make sure the settings can be saved. If either CaptureCtrl.SaveSettingsToFile or CaptureCtrl.SaveSettingsToStream is called for settings that cannot be saved, the save method will fail.

Example

C#
VB
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
public bool _result = false; 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
public CaptureCtrl _capturectrl; 
 
public string _streamSettings = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample_Stream.xml"); 
public string _fileSettings = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample.xml"); 
 
public void ObjectSettingsExample() 
{ 
   // reference the play control 
   _capturectrl = _form.CaptureCtrl; 
 
   // output file 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample.avi"); 
 
   try 
   { 
      Processor pVideoDizzy = _capturectrl.VideoProcessors.EFXDizzy; 
      // set a video processor 
      _capturectrl.SelectedVideoProcessors.Add(pVideoDizzy); 
 
      // save the settings to a file 
      if (SaveFileSettings()) 
      { 
         // now clear the selected processors again 
         _capturectrl.SelectedVideoProcessors.Clear(); 
 
         // check whether a stream file exists 
         if (File.Exists(_fileSettings)) 
         { 
            // load the saved settings from a file 
            // and check whether the processor is selected again 
            LoadFileSettings(); 
 
            // set the result  
            _result = _capturectrl.SelectedVideoProcessors.Contains(pVideoDizzy); 
         } 
      } 
 
      // save the settings to a stream 
      if (SaveStreamSettings()) 
      { 
         // now clear the selected processors again 
         _capturectrl.SelectedVideoProcessors.Clear(); 
 
         // check whether a stream file exists 
         if (File.Exists(_streamSettings)) 
         { 
            // load the saved settings from a stream  
            // and check whether the processor is selected again 
            LoadStreamSettings(); 
 
            // set the result  
            _result &= _capturectrl.SelectedVideoProcessors.Contains(pVideoDizzy); 
         } 
      } 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
private void LoadFileSettings() 
{ 
   _capturectrl.LoadSettingsFromFile(_fileSettings, CaptureSettings.Processors); 
} 
 
private bool SaveFileSettings() 
{ 
   //  check whether we can save the processors settings 
   if (_capturectrl.CanSaveObjectSettings(CaptureSettings.Processors)) 
   { 
      _capturectrl.SaveSettingsToFile(_fileSettings, CaptureSettings.Processors); 
      return true; 
   } 
   return false; 
} 
 
private void LoadStreamSettings() 
{ 
   Stream settings = new StreamReader(_streamSettings).BaseStream; 
   _capturectrl.LoadSettingsFromStream(settings, CaptureSettings.Processors); 
   settings.Close(); 
} 
 
private bool SaveStreamSettings() 
{ 
   //  check whether we can save the processors settings 
   if (_capturectrl.CanSaveObjectSettings(CaptureSettings.Processors)) 
   { 
      Stream settings = new StreamWriter(_streamSettings, false).BaseStream; 
      _capturectrl.SaveSettingsToStream(settings, CaptureSettings.Processors); 
      settings.Close(); 
      return true; 
   } 
   return false; 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media"; 
} 
Imports Leadtools 
Imports Leadtools.Multimedia 
Imports LeadtoolsMultimediaExamples.Fixtures 
 
Public _result As Boolean = False 
Public _form As CaptureCtrlForm = New CaptureCtrlForm() 
Public _capturectrl As CaptureCtrl 
 
Public _streamSettings As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample_Stream.xml") 
Public _fileSettings As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample.xml") 
 
Public Sub ObjectSettingsExample() 
   ' reference the play control 
   _capturectrl = _form.CaptureCtrl 
 
   ' output file 
   Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ObjectSettingsExample.avi") 
 
   Try 
      Dim pVideoDizzy As Processor = _capturectrl.VideoProcessors.EFXDizzy 
      ' set a video processor 
      _capturectrl.SelectedVideoProcessors.Add(pVideoDizzy) 
 
      ' save the settings to a file 
      If SaveFileSettings() Then 
         ' now clear the selected processors again 
         _capturectrl.SelectedVideoProcessors.Clear() 
 
         ' check if stream file exists 
         If File.Exists(_fileSettings) Then 
            ' load the saved settings from a file 
            ' and check if the processor is selected again 
            LoadFileSettings() 
 
            ' set the result  
            _result = _capturectrl.SelectedVideoProcessors.Contains(pVideoDizzy) 
         End If 
      End If 
 
      ' save the settings to a stream 
      If SaveStreamSettings() Then 
         ' now clear the selected processors again 
         _capturectrl.SelectedVideoProcessors.Clear() 
 
         ' check if stream file exists 
         If File.Exists(_streamSettings) Then 
            ' load the saved settings from a stream  
            ' and check if the processor is selected again 
            LoadStreamSettings() 
 
            ' set the result  
            _result = _result And _capturectrl.SelectedVideoProcessors.Contains(pVideoDizzy) 
         End If 
      End If 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 
 
Private Sub LoadFileSettings() 
   _capturectrl.LoadSettingsFromFile(_fileSettings, CaptureSettings.Processors) 
End Sub 
 
Private Function SaveFileSettings() As Boolean 
   '  check if we can save the processors settings 
   If _capturectrl.CanSaveObjectSettings(CaptureSettings.Processors) Then 
      _capturectrl.SaveSettingsToFile(_fileSettings, CaptureSettings.Processors) 
      Return True 
   End If 
   Return False 
End Function 
 
Private Sub LoadStreamSettings() 
   Dim settings As Stream = New StreamReader(_streamSettings).BaseStream 
   _capturectrl.LoadSettingsFromStream(settings, CaptureSettings.Processors) 
   settings.Close() 
End Sub 
 
Private Function SaveStreamSettings() As Boolean 
   '  check if we can save the processors settings 
   If _capturectrl.CanSaveObjectSettings(CaptureSettings.Processors) Then 
      Dim settings As Stream = New StreamWriter(_streamSettings, False).BaseStream 
      _capturectrl.SaveSettingsToStream(settings, CaptureSettings.Processors) 
      settings.Close() 
      Return True 
   End If 
   Return False 
End Function 
 
Public NotInheritable Class LEAD_VARS 
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly