LEADTOOLS Multimedia (Leadtools.Multimedia assembly)
LEAD Technologies, Inc

SaveSettingsToFile Method (ConvertCtrl)

Example 





The file in which settings will be saved.
The settings flags specifying which settings to save. See the ConvertSettings enumeration for settings options.
Saves some or all of the convert object settings to a file.
Syntax
public virtual void SaveSettingsToFile( 
   string targetFile,
   ConvertSettings flags
)
'Declaration
 
Public Overridable Sub SaveSettingsToFile( _
   ByVal targetFile As String, _
   ByVal flags As ConvertSettings _
) 
'Usage
 
Dim instance As ConvertCtrl
Dim targetFile As String
Dim flags As ConvertSettings
 
instance.SaveSettingsToFile(targetFile, flags)
public virtual void SaveSettingsToFile( 
   string targetFile,
   ConvertSettings flags
)
 function Leadtools.Multimedia.ConvertCtrl.SaveSettingsToFile( 
   targetFile ,
   flags 
)
public:
virtual void SaveSettingsToFile( 
   String^ targetFile,
   ConvertSettings flags
) 

Parameters

targetFile
The file in which settings will be saved.
flags
The settings flags specifying which settings to save. See the ConvertSettings enumeration for settings options.
Remarks
The convert 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 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 fails.
Example
Copy CodeCopy Code  
Public _result As Boolean = False
      Public _form As ConvertCtrlForm = New ConvertCtrlForm()
      Public _convertctrl As ConvertCtrl
      Public _streamSettings As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample_Stream.xml")
      Public _fileSettings As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample.xml")

      Public Sub ObjectSettingsExample()
         ' reference the play control
         _convertctrl = _form.ConvertCtrl

         ' input and output files
         Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi")
         Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ObjectSettingsExample.avi")

         Try
            Dim pVideoDizzy As Processor = _convertctrl.VideoProcessors.EFXDizzy
            ' set a video processor
            _convertctrl.SelectedVideoProcessors.Add(pVideoDizzy)

            ' save the settings to a file
            If SaveFileSettings() Then
               ' now clear the selected processors again
               _convertctrl.SelectedVideoProcessors.Clear()

                     ' check if a 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 = _convertctrl.SelectedVideoProcessors.Contains(pVideoDizzy)
               End If
            End If

            ' save the settings to a stream
            If SaveStreamSettings() Then
               ' now clear the selected processors again
               _convertctrl.SelectedVideoProcessors.Clear()

                     ' check if a 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 _convertctrl.SelectedVideoProcessors.Contains(pVideoDizzy)
               End If
            End If
         Catch e1 As Exception
            _result = False
         End Try
      End Sub

      Private Sub LoadFileSettings()
         _convertctrl.LoadSettingsFromFile(_fileSettings, ConvertSettings.Processors)
      End Sub

      Private Function SaveFileSettings() As Boolean
             '  check if we can save the processor's settings
         If _convertctrl.CanSaveObjectSettings(ConvertSettings.Processors) Then
            _convertctrl.SaveSettingsToFile(_fileSettings, ConvertSettings.Processors)
            Return True
         End If
         Return False
      End Function

      Private Sub LoadStreamSettings()
         Dim settings As Stream = New StreamReader(_streamSettings).BaseStream
         _convertctrl.LoadSettingsFromStream(settings, ConvertSettings.Processors)
         settings.Close()
      End Sub

      Private Function SaveStreamSettings() As Boolean
         '  check if we can save the processors settings
         If _convertctrl.CanSaveObjectSettings(ConvertSettings.Processors) Then
            Dim settings As Stream = New StreamWriter(_streamSettings, False).BaseStream
            _convertctrl.SaveSettingsToStream(settings, ConvertSettings.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 175\Media";
End Class
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:\Program Files (x86)\LEAD Technologies\LEADTOOLS 175\Media";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ConvertCtrl Class
ConvertCtrl Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Multimedia requires a Multimedia or Multimedia Suite license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features