LoadSettingsFromFile Method

Summary
Loads some or all of the convert object settings from a file.
Syntax
C#
C++/CLI
public virtual void LoadSettingsFromFile( 
   string sourceFile, 
   ConvertSettings flags 
) 
public: 
virtual void LoadSettingsFromFile(  
   String^ sourceFile, 
   ConvertSettings flags 
)  

Parameters

sourceFile
The file from which settings will be loaded.

flags
The setting flags specifying which settings to load. See the ConvertSettings enumeration for the setting options.

Remarks

Loads some or all of the convert object settings from a file. This reconstructs the conversion configuration using the settings found in the file. The convert object settings can be saved to a file by calling the SaveSettingsToFile method. Settings can be saved to a stream by calling the SaveSettingsToStream method. Settings saved to a stream can be loaded using the LoadSettingsFromStream method. It may be helpful to call the CanSaveObjectSettings method before calling the save methods. This ensures the settings can be saved. If either SaveSettingsToFile or SaveSettingsToStream is called for settings that cannot be saved, the save method will fail.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public bool _result = false; 
public ConvertCtrlForm _form = new ConvertCtrlForm(); 
public ConvertCtrl _convertctrl; 
 
public string _streamSettings = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample_Stream.xml"); 
public string _fileSettings = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample.xml"); 
 
public void ObjectSettingsExample() 
{ 
   // reference the play control 
   _convertctrl = _form.ConvertCtrl; 
 
   // input and output files 
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi"); 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample.avi"); 
 
   try 
   { 
      Processor pVideoDizzy = _convertctrl.VideoProcessors.EFXDizzy; 
      // set a video processor 
      _convertctrl.SelectedVideoProcessors.Add(pVideoDizzy); 
 
      // save the settings to a file 
      if (SaveFileSettings()) 
      { 
         // now clear the selected processors again 
         _convertctrl.SelectedVideoProcessors.Clear(); 
 
         // check whether 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 = _convertctrl.SelectedVideoProcessors.Contains(pVideoDizzy); 
         } 
      } 
 
      // save the settings to a stream 
      if (SaveStreamSettings()) 
      { 
         // now clear the selected processors again 
         _convertctrl.SelectedVideoProcessors.Clear(); 
 
         // check whether the 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 &= _convertctrl.SelectedVideoProcessors.Contains(pVideoDizzy); 
         } 
      } 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
private void LoadFileSettings() 
{ 
   _convertctrl.LoadSettingsFromFile(_fileSettings, ConvertSettings.Processors); 
} 
 
private bool SaveFileSettings() 
{ 
   //  check whether we can save the processors settings 
   if (_convertctrl.CanSaveObjectSettings(ConvertSettings.Processors)) 
   { 
      _convertctrl.SaveSettingsToFile(_fileSettings, ConvertSettings.Processors); 
      return true; 
   } 
   return false; 
} 
 
private void LoadStreamSettings() 
{ 
   Stream settings = new StreamReader(_streamSettings).BaseStream; 
   _convertctrl.LoadSettingsFromStream(settings, ConvertSettings.Processors); 
   settings.Close(); 
} 
 
private bool SaveStreamSettings() 
{ 
   //  check whether we can save the processors settings 
   if (_convertctrl.CanSaveObjectSettings(ConvertSettings.Processors)) 
   { 
      Stream settings = new StreamWriter(_streamSettings, false).BaseStream; 
      _convertctrl.SaveSettingsToStream(settings, ConvertSettings.Processors); 
      settings.Close(); 
      return true; 
   } 
   return false; 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS23\Media"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.