コード例 #1
0
ファイル: Video_Model.cs プロジェクト: Lozoute/MovieNation
        /// <summary>
        /// Constructor & Dtor
        /// </summary>
        public Library(string _File, ViewModel.Video_ViewModel VM)
        {
            _Films       = new ObservableCollection <Film>();
            _FilmsView   = new ObservableCollection <Film>();
            _LibFile     = _File;
            VM.Loading   = true;
            AudioChecked = true;
            VideoChecked = true;
            ImageChecked = true;
            TitleAsc     = true;
            DurationAsc  = true;
            TypeAsc      = true;
            Task T = new Task(() => { _Ok = Model.Xml.LoadXml_Async(_Films, _LibFile, VM); _FilmsView = _Films; });

            T.ContinueWith(antecedent => VM.Loading = false, TaskScheduler.FromCurrentSynchronizationContext());
            T.Start();
        }
コード例 #2
0
ファイル: Video_Model.cs プロジェクト: Lozoute/MovieNation
        public static bool               LoadXml_Async(ObservableCollection <Film> _List, String _File, ViewModel.Video_ViewModel VM)
        {
            if (File.Exists(_File))
            {
                try
                {
                    var       Player    = new WindowsMediaPlayer();
                    XDocument XmlLoader = XDocument.Load(_File);
                    var       xFilm     = from Lvl1 in XmlLoader.Descendants("Film") select new { xPath = Lvl1.Value };

                    foreach (var Lvl1 in xFilm)
                    {
                        string Tmp  = Lvl1.xPath;
                        var    Clip = Player.newMedia(Tmp);

                        if (!File.Exists(Tmp) || ViewModel.Video_ViewModel.MyGetType(Path.GetExtension(Tmp)) == Film.MediaType.Unknown)
                        {
                            System.Windows.Forms.MessageBox.Show("Unable To Load " + Tmp, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                        }
                        else
                        {
                            Film NewFilm = new Film(Path.GetFileNameWithoutExtension(Tmp), TimeSpan.FromSeconds((Clip.duration == 0 ? 4 : Clip.duration)), Tmp, false, ViewModel.Video_ViewModel.MyGetType(Path.GetExtension(Tmp)));
                            App.Current.Dispatcher.BeginInvoke((Action) delegate() { _List.Add(NewFilm); VM.NbFilesLoadedInt = VM.NbFilesLoadedInt + 1; });
                        }
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("Library Loading Error: " + e.Message.ToString() + e.Source.ToString(), "Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                    return(false);
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Library Loading Error: The File " + _File + " Does Not Exists.", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }
            return(false);
        }