/// <summary>
        /// 添加新的媒体文件
        /// </summary>
        public void AddNewMediaFile(ViewModelVideoItem itemFile)
        {
            string functionName = "AddNewMediaFile";

            try
            {
                bool isNew = true;
                foreach (ViewModelVideoItem item in MediaFileList)
                {
                    if (item.MD5Value == itemFile.MD5Value)
                    {
                        isNew = false;
                        break;
                    }
                }
                if (isNew)
                {
                    MediaFileList.Add(itemFile);
                }
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
            }
        }
        /// <summary>
        /// 删除多余文件
        /// </summary>
        private void ClearFileList()
        {
            string functionName = "ClearFileList";

            try
            {
                for (int i = 0; i < MediaFileList.Count; i++)
                {
                    bool isExit = false;
                    foreach (ViewModelVideoItem item in PlayFileList)
                    {
                        if (MediaFileList[i].MD5Value == item.MD5Value)
                        {
                            isExit = true;
                            break;
                        }
                    }
                    if (!isExit)
                    {
                        MediaFileList.RemoveAt(i);
                        i--;
                    }
                }
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
            }
        }
 public ViewModelPlayListEditWindow()
 {
     _PlayListModel = new Model.AMS_PlayList();
     MediaFileList.Clear();
     PlayFileList.Clear();
     foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.MediaFiles)
     {
         ViewModelVideoItem newItem = new ViewModelVideoItem();
         newItem.Name          = item.Name;
         newItem.PlayTime      = item.PlayTime;
         newItem.ReRelativeUrl = item.ReRelativeUrl;
         newItem.SunTime       = item.SunTime;
         newItem.MD5Value      = item.MD5Value;
         MediaFileList.Add(newItem);
     }
     foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.PlayFileList)
     {
         ViewModelVideoItem newItem = new ViewModelVideoItem();
         newItem.Name          = item.Name;
         newItem.PlayTime      = item.PlayTime;
         newItem.ReRelativeUrl = item.ReRelativeUrl;
         newItem.SunTime       = item.SunTime;
         newItem.MD5Value      = item.MD5Value;
         PlayFileList.Add(newItem);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Loads a pre-existing mediafile/queue into the mediafile object.
        /// </summary>
        /// <param name="afilename"></param>
        public void LoadMediaFileList(string afilename)
        {
            if (File.Exists(afilename))
            {
                try {
                    this.mediafilelist = Functions.DeserializeMediaFileList(afilename);

                    // Add new presets, where necessary...
                    if (mediafilelist != null)
                    {
                        foreach (MediaFile f in mediafilelist.Items)
                        {
                            Preset internalpreset = f.Preset;

                            if (this.presetdata.FindPresetIndex(internalpreset) == -1)
                            {
                                this.presetdata.AddPreset(internalpreset);
                            }
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 5
0
 public frmTerminal(MediaFileList afilelist, string anexecutable) : this()
 {
     this.executable = anexecutable;
     if (afilelist != null)
     {
         mediafilelist = afilelist;
     }
 }
        public void RefreshModel()
        {
            string functionName = "RefreshModel";

            try
            {
                MediaFileList.Clear();
                PlayFileList.Clear();
                foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.MediaFiles)
                {
                    ViewModelVideoItem newItem = new ViewModelVideoItem();
                    newItem.Name          = item.Name;
                    newItem.PlayTime      = item.PlayTime;
                    newItem.ReRelativeUrl = item.ReRelativeUrl;
                    newItem.SunTime       = item.SunTime;
                    newItem.MD5Value      = item.MD5Value;
                    MediaFileList.Add(newItem);
                }
                foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.PlayFileList)
                {
                    ViewModelVideoItem newItem = new ViewModelVideoItem();
                    newItem.Name          = item.Name;
                    newItem.PlayTime      = item.PlayTime;
                    newItem.ReRelativeUrl = item.ReRelativeUrl;
                    newItem.SunTime       = item.SunTime;
                    newItem.MD5Value      = item.MD5Value;
                    PlayFileList.Add(newItem);
                }
                StartH = DateTime.Parse(_PlayListModel.PlayFileList[0].PlayTime).Hour;
                StartM = DateTime.Parse(_PlayListModel.PlayFileList[0].PlayTime).Minute;
                RefreshPlayList();
                RefreshFileList();
                OnPropertyChanged("PlayeListNo");
                OnPropertyChanged("PlayerListName");
                OnPropertyChanged("EffectDate");
                OnPropertyChanged("EndDate");
                OnPropertyChanged("Operator");
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Fold these in a generic.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static MediaFileList DeserializeMediaFileList(string filename)
        {
            MediaFileList desc = null;

            if (File.Exists(filename))
            {
                XmlSerializer nser  = new XmlSerializer(typeof(MediaFileList));
                TextReader    ntext = new StreamReader(filename);
                try {
                    desc = (MediaFileList)nser.Deserialize(ntext);
                } finally {
                    ntext.Close();
                    ntext.Dispose();
                }
            }

            return(desc);
        }
Esempio n. 8
0
        /// <summary>
        /// Fold these in generic...
        /// Note: Complete presets are stored in the MediaFileList, in case these need to be
        /// restored on a third party-computer. "Take your Queue to where-ever you want"
        /// </summary>
        /// <param name="afilename"></param>
        /// <param name="filelist"></param>
        /// <returns></returns>
        public static bool SerializeMediaFileList(string afilename, MediaFileList filelist)
        {
            bool res = false;

            XmlSerializer nser  = new XmlSerializer(typeof(MediaFileList));
            TextWriter    ntext = new StreamWriter(afilename);

            try {
                nser.Serialize(ntext, filelist);
                ntext.Flush();
                res = true;
            } catch {
                res = false;
            } finally {
                ntext.Dispose();
            }

            return(res);
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mediafilesTestRunToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MediaFileList newlist = new MediaFileList();

            foreach (ListViewItem n in listViewFiles.SelectedItems)
            {
                string filename = Path.Combine(n.SubItems[SUBCOL_PATH].Text, n.SubItems[SUBCOL_FILENAME].Text);
                Preset preset   = presetdata.FindPreset(n.SubItems[SUBCOL_PRESETNAME].Text);

                if (preset != null)
                {
                    newlist.AddMediaFile(filename, preset, n.Index);
                }
            }

            frmTerminal nterm = new frmTerminal(newlist,
                                                Config.Settings.FFMPEGFilePath);

            nterm.Show();
            nterm.StartProcessing();
        }