Beispiel #1
0
        private void SelectSubtitiles(SubtitlePicker picker)
        {
            if (picker.Subtitle.File != null)
            {
                var lines = Subtitles.ParseSubtitleItems(picker.Subtitle.File);
                if (lines.Count > 1)
                {
                    subtitles = lines;
                }
            }
            else if (picker.Subtitle.Stream != null)
            {
                picker.Subtitle.Stream.Position = 0;
                var lines = Subtitles.ParseSubtitleItems(new StreamReader(picker.Subtitle.Stream).ReadToEnd(), ".srt");
                if (lines.Count > 1)
                {
                    subtitles = lines;
                }
            }
            NoSubtitles.ItemSelected.Opacity = 0;
            int index = SubtitleSelectionPanel.Children.IndexOf(picker);

            picker.ItemSelected.Opacity = 1;
            foreach (SubtitlePicker pick in SubtitleSelectionPanel.Children)
            {
                if (SubtitleSelectionPanel.Children.IndexOf(pick) != index)
                {
                    pick.ItemSelected.Opacity = 0;
                }
            }
        }
Beispiel #2
0
 private void LoadSideBarSubs()
 {
     foreach (var item in allSubtitles)
     {
         Dispatcher.Invoke(() => {
             SubtitlePicker picker     = new SubtitlePicker(item);
             picker.Version.Text       = Path.GetFileNameWithoutExtension(item.Version);
             picker.MouseLeftButtonUp += (s, ev) => SelectSubtitiles(picker);
             SubtitleSelectionPanel.Children.Add(picker);
         });
     }
     Dispatcher.Invoke(() => {
         SubtitlePicker toLoad = null;
         foreach (SubtitlePicker pick in SubtitleSelectionPanel.Children)
         {
             if (pick.Subtitle.Stream != null)
             {
                 toLoad = pick;
             }
         }
         if (toLoad == null && SubtitleSelectionPanel.Children.Count > 0)
         {
             toLoad = (SubtitlePicker)SubtitleSelectionPanel.Children[0];
         }
         if (toLoad != null)
         {
             SelectSubtitiles(toLoad);
         }
     });
 }