public string RenameAsset(IMediaAsset asset, String newName) { string OldName = asset.Name; bool boolRenamed = false; IDictionaryEnumerator enRemove = m_htAssetList.GetEnumerator(); while (enRemove.MoveNext()) { if (enRemove.Key.ToString() == asset.Name) { m_htAssetList.Remove(OldName); m_htExists.Remove(OldName); asset.Name = newName; m_htAssetList.Add(asset.Name, asset); m_htExists.Add(asset.Name, asset); boolRenamed = true; break; } } if (boolRenamed == false) { throw new Exception("Asset cannot be renamed : not in hashtable"); } return(OldName); }
//specify newName without extension public IMediaAsset RenameAsset(IMediaAsset asset, String newName) { string OldName = asset.Name; IDictionaryEnumerator en = m_htAssetList.GetEnumerator(); while (en.MoveNext()) { if (en.Key.ToString() == asset.Name) { m_htAssetList.Remove(en.Key); asset.Name = newName; m_htAssetList.Add(asset.Name, asset); AssetRenamed ob_AssetRenamed = new AssetRenamed(asset, OldName); //ob_AssetRenamed.AssetRenamedEvent+= new DAssetRenamedEvent (ob_CatchEvents.CatchAssetRenamedEvent) ; //ob_AssetRenamed.NotifyAssetRenamed ( this, ob_AssetRenamed ) ; AssetRenamedEvent(this, ob_AssetRenamed); return(asset); } } MessageBox.Show("Key not found, null will be returned"); return(null); // end of function }
//Delete asset from Project directory and hash table public void DeleteAsset(IMediaAsset assetToDelete) { FileInfo m_file = new FileInfo(assetToDelete.Path); if (m_file.Exists && m_htAssetList.ContainsKey(assetToDelete.Name)) { m_htAssetList.Remove(assetToDelete.Name); try { m_file.Delete(); } catch (Exception e) { MessageBox.Show(String.Format("Error in deleting file:\n{0}", e.ToString())); } AssetDeleted ob_AssetDeleted = new AssetDeleted(assetToDelete); //ob_AssetDeleted.AssetDeletedEvent+=new DAssetDeletedEvent (ob_CatchEvents.CatchAssetDeletedEvent ) ; //ob_AssetDeleted.NotifyAssetDeleted ( this , ob_AssetDeleted) ; AssetDeletedEvent(this, ob_AssetDeleted); } else { MessageBox.Show("File could not be deleted"); } }
internal string GenerateNewAssetName(IMediaAsset Asset) { long i = 0; string sTemp; sTemp = "MediaAsset"; string sTempName; sTempName = sTemp + i.ToString(); AssetManager manager = Asset.Manager as AssetManager; while (manager.m_htExists.ContainsKey(sTempName) && i < 9000000) { i++; sTempName = sTemp + i.ToString(); } if (i < 9000000) { manager.m_htExists.Add(sTempName, Asset); return(sTempName); } else { return(null); } }
public IMediaAsset RemoveAsset(IMediaAsset assetToRemove) { if (m_htAssetList.ContainsKey(assetToRemove.Name)) { m_htAssetList.Remove(assetToRemove.Name); return(assetToRemove); } else { MessageBox.Show("Asset not in Hash Table"); return(null); } }
public void DeleteAsset(IMediaAsset assetToDelete) { if (m_htAssetList.ContainsKey(assetToDelete.Name)) { m_htAssetList.Remove(assetToDelete.Name); m_htExists.Remove(assetToDelete.Name); assetToDelete = null; } else { throw new Exception("Asset could not be deleted : not in hashtable"); } }
public void RemoveAsset(IMediaAsset assetToRemove) { MediaAsset MediaAssetToRemove = assetToRemove as MediaAsset; if (m_htAssetList.ContainsKey(MediaAssetToRemove.Name)) { m_htAssetList.Remove(MediaAssetToRemove.Name); MediaAssetToRemove.m_AssetManager = null; } else { throw new Exception("Asset could not be removed : not in hashtable"); } }
public void AddAsset(IMediaAsset asset) { if (asset.Type == MediaType.Audio) { AudioMediaAsset Asset = asset as AudioMediaAsset; if (Asset.Name == null) { Asset.Name = NewMediaAssetName(); } Asset.m_AssetManager = this; m_htAssetList.Add(Asset.Name, asset); m_htExists.Add(Asset.Name, asset); } }
public IMediaAsset CopyAsset(IMediaAsset asset) { if (m_htAssetList.ContainsKey(asset.Name)) { MediaAsset ob_MediaAsset = asset.Copy() as MediaAsset; ob_MediaAsset.Name = NewMediaAssetName(); m_htAssetList.Add(ob_MediaAsset.Name, ob_MediaAsset); m_htExists.Add(ob_MediaAsset.Name, ob_MediaAsset); return(ob_MediaAsset); } else { throw new Exception("Asset not found in Hashtable"); } }
public void DeleteAsset(IMediaAsset assetToDelete) { if (m_htAssetList.ContainsKey(assetToDelete.Name)) { m_htAssetList.Remove(assetToDelete.Name); m_htExists.Remove(assetToDelete.Name); AssetDeleted ob_AssetDeleted = new AssetDeleted(assetToDelete); ob_AssetDeleted.AssetDeletedEvent += new DAssetDeletedEvent(ob_Catch.CatchAssetDeletedEvent); ob_AssetDeleted.NotifyAssetDeleted(this, ob_AssetDeleted); assetToDelete = null; } else { throw new Exception("Asset could not be deleted : not in hashtable"); } }
//create a new file in project directory and copy contents of source file to it. public IMediaAsset CopyAsset(IMediaAsset asset) { FileInfo file = new FileInfo(asset.Path); string sTemp = GenerateFileName(file.Extension, m_sDirPath); try { file.CopyTo(sTemp, false); } catch { MessageBox.Show("Can not copy the file"); return(null); } AudioMediaAsset ob = new AudioMediaAsset(sTemp); m_htAssetList.Add(ob.Name, ob); return(ob); }
public override void MergeWith(IMediaAsset next) { AudioMediaAsset ob_AudioMediaAsset = next as AudioMediaAsset; // checks if the formats of both clips is same if (CompareAudioAssetFormat(this, ob_AudioMediaAsset) == true) { // append clips of next asset to clip list of original asset for (int i = 0; i < ob_AudioMediaAsset.m_alClipList.Count; i++) { m_alClipList.Add(ob_AudioMediaAsset.m_alClipList [i]); } m_dAudioLengthInTime = m_dAudioLengthInTime + ob_AudioMediaAsset.LengthInMilliseconds; m_lAudioLengthInBytes = m_lAudioLengthInBytes + ob_AudioMediaAsset.AudioLengthInBytes; m_lSizeInBytes = m_lSizeInBytes + ob_AudioMediaAsset.SizeInBytes; next = null; } else { throw new Exception("Cannot merge assets: incompatible format"); } }
/// <summary> /// Create a new AssetDeleted event. /// </summary> /// <param name="asset">The asset that was deleted.</param> public AssetDeleted(IMediaAsset asset) { mAsset = asset; }
public virtual IMediaAsset MergeWith(IMediaAsset next) { return(null); }
public AssetRenamed(string oldName, IMediaAsset newAsset) { mOldName = oldName; mRenamedAsset = newAsset; }
private string mOldName; // the asset's name before renaming /// <summary> /// Create a new AssetRenamed event. /// </summary> /// <param name="asset">The renamed asset (with its new name.)</param> /// <param name="oldName">The name of the asset before renaming.</param> public AssetRenamed(IMediaAsset asset, string oldName) { mOldName = oldName; mAsset = asset; }
public abstract void MergeWith(IMediaAsset next);
/// <summary> /// Create a new command to rename an asset in the asset manager. /// </summary> /// <param name="asset">The asset to rename.</param> /// <param name="name">The new name of the asset.</param> public RenameAssetCommand(IMediaAsset asset, string name) { mAsset = asset; mName = name; m_sOldName = asset.Name; }
/// <summary> /// Create a new command to delete an asset. /// </summary> /// <param name="asset">The asset to delete.</param> public DeleteAssetCommand(IMediaAsset asset) { mAsset = asset; mAssetManager = mAsset.Manager; }
public void AddAsset(IMediaAsset asset) { m_htAssetList.Add(asset.Name, asset); }
public void deleteAsset(IMediaAsset assetToDelete) { //FileInfo m_file= new FileInfo (assetToDelete.FilePath); //m_file.Delete(); }