Ads 468x60px

Wednesday, December 27, 2017

How to store .NET Project Options as XML in the Project's settings



  1. Right click on your project link, then click on "Properties"
  2. Navigate into "Settings" tab, then add a string parameter. i.e. "ProjectOptions"
  3. The idea is to store multiple Key/Value properties in a single variable using XML format.
  4. Use the function SetProjectOption to store options
        Public Sub SetProjectOption(ByRef ProjectOptions As StringByVal Key As StringByVal Value As String)
            Dim Options As Dictionary(Of StringString)
            Options = Me.GetDictoinary(ProjectOptions)
            If Options.ContainsKey(Key.ToLower) Then
                Options(Key) = Value
            Else
                Options.Add(Key.ToLower, Value)
            End If
     
            Me.storeDictionaryInString(Options, ProjectOptions)
     
        End Sub
  5.  Use the function GetProjectOption to get options values
        Public Function GetProjectOption(ByRef ProjectOptions As StringByVal Key As StringAs String
            Try
                Dim Options As Dictionary(Of StringString)
                Options = Me.GetDictoinary(ProjectOptions)
                Return Options(Key.ToLower)
            Catch ex As Exception
                Return Nothing
            End Try
        End Function
  6. Helper Function:
      Private Function storeDictionaryInString(ByRef dic As Dictionary(Of StringString), ByRef ProjectOption As StringAs String
            Dim doc As New XmlDocument()
            doc.CreateXmlDeclaration("1.0""utf-8"Nothing)
            doc.AppendChild(doc.CreateElement("AllSettings"))
            Dim root As XmlNode = doc.GetElementsByTagName("AllSettings")(0)
            For Each key As String In dic.Keys
                Dim e As XmlElement = doc.CreateElement(key)
                e.InnerText = dic(key)
                root.AppendChild(e)
            Next
            ProjectOption = doc.OuterXml
            Return doc.OuterXml
        End Function
     
        Private Function GetDictoinary(ByRef ProjectOption As StringAs Dictionary(Of StringString)
            Try
                Dim doc As New XmlDocument()
                doc.LoadXml(ProjectOption)
                Dim dic As New Dictionary(Of StringString)
                Dim root As XmlNode = doc.GetElementsByTagName("AllSettings")(0)
                For Each n As XmlNode In root.ChildNodes
                    dic.Add(n.Name.ToLower, n.InnerText)
                Next
     
                Return dic
            Catch ex As Exception
                Return New Dictionary(Of StringString)
            End Try
         
        End Function
Example:
1. Store Options
        Me.SetProjectOption(My.Settings.ProjectOptions, "General.CompanyName""ABC Company Inc")
        Me.SetProjectOption(My.Settings.ProjectOptions, "General.PurchasedDate""27 Dec 2017")
        Me.SetProjectOption(My.Settings.ProjectOptions, "General.OFlAG""True")

2. Read Options
        MsgBox(Me.GetProjectOption(My.Settings.ProjectOptions, "General.OFlAG"))
3. How options stored in the variable:
<?xml version="1.0" encoding="UTF-8"?> <AllSettings> <general.companyname>ABC Company Inc</general.companyname> <general.purchaseddate>27 Dec 2017</general.purchaseddate> <general.oflag>True</general.oflag> </AllSettings>

Thursday, August 24, 2017

How to make instructions video with Machine Voice and Hard-coded Subtitles

In this blog, we are going to learn how to make a video with machine voice commentary and hard-coded subtitles.


  1. Get the video you want to start with, if you plan to make a video related to something in your PC,  you can record your screen using IceCream Screen Recorder.
    You can record up to 5 minutes, but continue reading you would know how to record more than that by merging files together.

  2. The next idea is to get advantage of [Text to Speech] technique to make an MP3 file, that we are going to use later in our video. There are a few websites and applications that does this
    1. From Text to Speech Site [George's voice is the best]
    2. Sound of Text Site: they use the Google Translate voice. You can only convert up to 100 letters.

  3. It's time now to manipulate our video, cut some audio or video parts, bring different portions together, and so on.
    1. The best choice to do such things is Windows Movie Maker.

    2. OpenShot Video Editor is an alternative to Windows Movie Maker, but it's a hassle since it keeps hanging and freezing. But both almost have the same functionalities.
      Note: There are plenty of Youtube video tutorials on both Windows Movie Maker and Open Shot.
  4. we need to create a subtitle (.SRT) text file to the video. Subtitle Edit is an open source software application that does this.
    1. Just import the video file: the application doesn't support certian video formats, so you need to install their codecs.
      The system gives you a message what video codec packages you have to install, so don't worry, i.e. LAVFilters Package.

  5. The last step we need to do is to burn/hardcore subtitles inside the video itself, because not all media players support displaying subtitles. Specially if you want to embed the video in your website, email, etc.
    we have two applications to achieve this
    1. FormatFachtory.

    2. HandBrake.

Thursday, August 10, 2017

SubMerge - Learn Language by Merging Subtitles

Create Daily Backup - Using Windows Tasks

In this lesson we are going to learn how can we create automatic backups for our files, specially those files that change on daily basis.


  1. Install WinRar in your machine.

    it provides a command line tool (rar.exe) in which we can compress files from the Command Line Prompt.
  2. Open a new empty text file [via notepad], and save it with extension (.bat) on your disk.
  3. Fill the file with the following command.
    [rar.exe location] a -ep1 -r [Compressed File Location] [Your Project Folder]
    1. As Example, suppose I have a project on my local machine at [C:\MyProject], and I want to write the command above, of course I will add the date attached to my project name to make sure it has a unique name, then the command would be like:
       "C:\Program Files\WinRAR\Rar.exe" a -ep1 -r MyProject_%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%%time:~6,2%.rar "C:\MyProject"
  4. Open Windows Task Scheduler
     

  5.  Click on "Create Basic Task..." from the right upper menu