private static void OnCaptionTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ClosedCaptionDependencyObject me = d as ClosedCaptionDependencyObject;

            if (me != null)
            {
                me.Caption.Definition = me.CaptionText;
            }
        }
        private static void OnSoundEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ClosedCaptionDependencyObject me = d as ClosedCaptionDependencyObject;

            if (me != null)
            {
                me.Name = me.SoundEvent.EventName;
            }
        }
        private void OnDeleteCaption(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                ClosedCaptionDependencyObject obj = btn.CommandParameter as ClosedCaptionDependencyObject;
                if (obj != null)
                {
                    Captions.Remove(obj);
                }
            }
        }
        private static void OnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ClosedCaptionDependencyObject me = d as ClosedCaptionDependencyObject;

            if (me != null)
            {
                if (!string.IsNullOrEmpty(me.Name))
                {
                    me.Caption.SoundEvent = me.Name;
                }
                else
                {
                }
            }
        }
        void LoadCaptionData()
        {
            string addonFolder = Steam.SteamData.GetHLAAddOnFolder(AddOn);

            Captions    = new ObservableCollection <ClosedCaptionDependencyObject>();
            SoundEvents = new ObservableCollection <Soundevent>();
            hashToName  = new Dictionary <uint, Soundevent>();
            foreach (var eventFiles in new DirectoryInfo(addonFolder).GetFiles("*." + Steam.SteamData.SoundEventsExtension, SearchOption.AllDirectories))
            {
                foreach (var soundName in AAT.AddonHelper.DeserializeFile(eventFiles.FullName))
                {
                    SoundEvents.Add(soundName);
                    hashToName.Add(ValveResourceFormat.Crc32.Compute(Encoding.UTF8.GetBytes(soundName.EventName)), soundName);
                }
            }

            //Look for and load any caption file.
            string targetPath = System.IO.Path.Combine(Steam.SteamData.GetHLAInstallFolder(), Steam.SteamData.HLAWIPAddonGamePath, AddOn, Steam.SteamData.CaptionFolder);

            if (Directory.Exists(targetPath))
            {
                foreach (var captionFiles in new DirectoryInfo(targetPath).GetFiles(string.Format(workingCCFileFormat, SelectedLanguage + "_custom"), SearchOption.AllDirectories))
                {
                    var closedCaptions = new ClosedCaptions();
                    using (var stream = captionFiles.OpenRead())
                    {
                        closedCaptions.Read(stream);
                    }
                    foreach (var caption in closedCaptions.Captions)
                    {
                        var cap = new ClosedCaptionDependencyObject(caption);
                        if (hashToName.ContainsKey(caption.SoundEventHash))
                        {
                            cap.SoundEvent = hashToName[caption.SoundEventHash];
                        }
                        Captions.Add(cap);
                    }
                }
            }
        }