private void SetTarget(MemoryLibraryItem target) { _target = target; if (_target != null) { _targetId = _target.Id; } }
public override void FromTo(MemoryLibraryItem memory) { if (memory != null) { base.FromTo(memory); InternalFromTo(memory as SchedulerInfo); } }
/// <summary> /// Function: Get data from a object to current object /// Author : Jerry Xu /// Date : 2008-7-8 /// </summary> /// <param name="memory">LibraryAdapter</param> public virtual void FromTo(LibraryAdapter item) { this.Id = item.Id; this.Name = item.Name; _targetId = item._targetId; _target = item._target; _targetName = item._targetName; //_active = item._active; }
public LibraryPropertys(MemoryLibraryItem Target) { if (Target != null) { this._Type = Target.Type; this._Name = Target.Name; this._Length = Target.Length; } }
public override void FromTo(MemoryLibraryItem memory) { if (memory != null) { base.FromTo(memory); //TODO: InternalFromTo(memory as TimeSliceGroupInfo); } }
public override void FromTo(MemoryLibraryItem memory) { base.FromTo(memory); var item = memory as MLPlaylistInfo; if (item != null) { if (item._items != null && item._items.Count > 0) { foreach (var region in item._items) { _items.Add(region.Copy() as RegionInfo); } } } }
public override void FromTo(MemoryLibraryItem memory) { base.FromTo(memory); var item = memory as RegionInfo; if (item != null) { if (item._items != null && item._items.Count > 0) { foreach (var adp in item._items) { _items.Add(adp.Copy()); } } } }
public LibraryAdapter(MemoryLibraryItem target) { base.Name = KeyGenerator.Library.ToString(); SetTarget(target); }
/// <summary> /// Function: Get data from a object to current object /// Author : Jerry Xu /// Date : 2008-7-8 /// </summary> /// <param name="memory">MemoryLibraryItem</param> public override void FromTo(MemoryLibraryItem memory) { base.FromTo(memory); InternalFromTo(memory as PlaylistInfo); }
//public bool CheckSignIsEqual(Size newSign) //{ // if (_layers[0].Shape.SignSize == newSign) // return true; // return false; //} //public System.Drawing.Rectangle GetVirtualBoundsBySign(ShapeBase shape, Size signSize, int Zoom) //{ // int width = signSize.Width / 4; // int height = signSize.Height / 8; // System.Drawing.Point location = System.Drawing.Point.Empty; // decimal oldSizeRatio = decimal.Divide(shape.SignSize.Width, shape.SignSize.Height); // decimal newSizeRatio = decimal.Divide(signSize.Width, signSize.Height); // decimal tempZoom; // int newWidth = 0, newHeight = 0; // int widthOffset = 0, heightOffset = 0; // if (oldSizeRatio <= newSizeRatio) // { // tempZoom = decimal.Divide(signSize.Height, shape.SignSize.Height); // newWidth = (int)Math.Round(shape.SignSize.Width * tempZoom * Zoom); // widthOffset = (int)Math.Round((double)(signSize.Width * Zoom - newWidth) / 2); // location = new System.Drawing.Point(widthOffset + (int)(shape.LocationX * tempZoom * Zoom), (int)(shape.LocationY * tempZoom * Zoom)); // } // else // { // tempZoom = decimal.Divide(signSize.Width, shape.SignSize.Width); // newHeight = (int)Math.Round(shape.SignSize.Height * tempZoom * Zoom); // heightOffset = (int)Math.Round((double)(signSize.Height * Zoom - newHeight) / 2); // location = new System.Drawing.Point((int)(shape.LocationX * tempZoom * Zoom), heightOffset + (int)(shape.LocationY * tempZoom * Zoom)); // } // width = (int)(shape.Width * tempZoom * Zoom); // height = (int)(shape.Height * tempZoom * Zoom); // return new System.Drawing.Rectangle(location, new Size(width, height)); //} //public void Populate(SignInfo newSign) //{ // float _widthScale = 1; // float _heightScale = 1; // int wn = (int)Math.Round(Size.Width * 1.0f / newSign.Width); // int hn = (int)Math.Round(Size.Height * 1.0f / newSign.Height); // Size = newSign; // _widthScale = wn; // _heightScale = hn; // int zoom = 1; // zoom = wn < hn ? wn : hn; // zoom = zoom < 1 ? 1 : zoom; // MessageInfo mes = this; // foreach (ShapeLayer sl in mes.Items) // { // sl.Shape.VirtualBounds = Common.CommonHelper.GetRectangleBySign(sl.Shape.VirtualBounds, sl.Shape.SignSize, _playlistControl._signSize, mes.Zoom); // sl.Shape.DestBounds = Common.CommonHelper.GetRectangleBySign(sl.Shape.DestBounds, sl.Shape.SignSize, _playlistControl._signSize, mes.Zoom); // if (sl.Shape.Type == ShapeType.ShapeDraw) // { // foreach (ShapePaint s in (sl.Shape as ShapeDraw).Childs) // { // s.VirtualBounds = GetVirtualBoundsBySign(s, new Size(newSign.Width, newSign.Height), zoom); // s.Zoom = 1; // s.Populate(s.VirtualLocation, s.VirtualBounds.Size, newSign.Type, new Size(newSign.Width, newSign.Height), zoom); // } // (sl.Shape as ShapeDraw).PopulateSignInfo(newSign.Type, new Size(newSign.Width, newSign.Height), zoom); // (sl.Shape as ShapeDraw).Zoom = 1; // } // else // { // sl.Shape.VirtualBounds = System.Drawing.Rectangle.Empty; // sl.Shape.Zoom = 1; // sl.Shape.VirtualBounds = GetVirtualBoundsBySign(sl.Shape, new Size(newSign.Width, newSign.Height), zoom); // sl.Shape.Populate(sl.Shape.VirtualLocation, sl.Shape.VirtualBounds.Size, newSign.Type, new Size(newSign.Width, newSign.Height), zoom); // if (sl.Shape.Type == ShapeType.Image) // (sl.Shape as ShapeImage).ComputeDestBoundBatchLoad(); // if (sl.Shape.Type == ShapeType.Video) // (sl.Shape as ShapeVideo).ComputeDestBound(); // sl.Shape.DestBounds = Common.CommonHelper.GetRectangleBySign(sl.Shape.DestBounds, sl.Shape.SignSize, _playlistControl._signSize, _playlistControl._Zoom); // } // sl.Shape.VirtualBounds = Common.CommonHelper.GetRectangleBySign(sl.Shape.VirtualBounds, sl.Shape.SignSize, _playlistControl._signSize, _playlistControl._Zoom); // } // mes.Zoom = zoom; //} //public void SetZoom(Size newSign) //{ // int wn = (int)Math.Round(Size.Width * 1.0f / newSign.Width); // int hn = (int)Math.Round(Size.Height * 1.0f / newSign.Height); // _Zoom = wn < hn ? wn : hn; // _Zoom = _Zoom < 1 ? 1 : _Zoom; //} //public MessageInfo GetMessage() //{ // if (this == null || this.Items == null || this.Length == 0 || this.Items.Length == 0) // return null; // List<ShapeLayer> layers = new List<ShapeLayer>(); // foreach (ShapeLayer layer in this.Items) // { // if (layer.Shape != null && layer.IsVisible && layer.Shape.IsVisible) // layers.Add(layer); // } // if (layers.Count == 0) // return null; // MessageInfo message = this.Copy() as MessageInfo; // message.Items = layers.ToArray(); // return message; //} ///// <summary> ///// Function: Create MessageInfo by MessageInfo and Sign.Size ///// Author : Jerry Xu ///// Date : 2008-12-2 ///// </summary> ///// <param name="generator">generatorVideo</param> ///// <param name="newSign">Sign.Size</param> ///// <returns>MessageInfo</returns> //public MessageInfo CreateMessage(SignInfo Sign, IVideoGenerator generator) //{ // Size newSign = new Size(Sign.Width, Sign.Height); // bool isEqualSign = CheckSignIsEqual(newSign); // MessageInfo newMessage = null; // //Reverse layers // newMessage = this.Copy() as MessageInfo; // var items = this._layers; // ShapeLayer layer = null; // for(int i=0;i<items.Count;i++) // { // layer = items[i]; // if (layer.Shape.Type == ShapeType.Video) // { // if (string.IsNullOrEmpty((layer.Shape as ShapeVideo).VideoUrl)) // { // //newMessage._layers.RemoveAt(i); // newMessage._layers.Remove(newMessage._layers.Find(p => { return p.ID == layer.ID; })); // continue; // } // } // else // if (layer.Shape.Type == ShapeType.Image) // { // if (string.IsNullOrEmpty((layer.Shape as ShapeImage).ImageUrl)) // { // //newMessage._layers.RemoveAt(i); // newMessage._layers.Remove(newMessage._layers.Find(p => { return p.Name == layer.Name; })); // continue; // } // } // //if (!layer.IsVisible || layer.Shape == null || !layer.Shape.IsVisible) // if (!layer.IsVisible || layer.Shape == null || layer.Duration==0) // newMessage._layers.Remove(newMessage._layers.Find(p => { return p.Name == layer.Name; })); // //newMessage._layers.RemoveAt(i); // } // newMessage._layers.Reverse(); // bool isCreateVideo = newMessage.IsCreateVideo(); // if (isEqualSign && !isCreateVideo) // { // newMessage.Size = GetSignSize(); // return newMessage; // } // //ReInit all message elements by new sign.size // if (!isEqualSign) // { // //newMessage.SetZoom(newSign); // newMessage.Populate(Sign); // } // if (isCreateVideo) // newMessage = newMessage.CreateVideoMessage(generator); // newMessage.Size = GetSignSize(); // return newMessage; //} ///// <summary> ///// Function: Get sign size ///// Author : Jerry Xu ///// Date : 2008-12-29 ///// </summary> ///// <returns>Sign Size</returns> //public Size GetSignSize() //{ // //int w = Convert.ToInt32(Math.Ceiling(_origSize.Width * 1.0d / Zoom)); // //int h = Convert.ToInt32(Math.Ceiling(_origSize.Height * 1.0 / Zoom)); // int w = _layers[0].Shape.SignSize.Width; // int h = _layers[0].Shape.SignSize.Height; // return new Size(w,h); //} //private void SetElemets() //{ // if (_layers != null && _layers.Count > 0) // { // foreach (ShapeLayer layer in _layers) // { // if (layer.Shape != null) // { // layer.Shape.Zoom = _Zoom; // } // } // } //} ///// <summary> ///// Function: Create video message ///// Author : Jerry Xu ///// Date : 2008-12-3 ///// </summary> ///// <returns>MemoryLibraryItem(MessageInfo)</returns> //private MessageInfo CreateVideoMessage(IVideoGenerator generator) //{ // string fileID = Guid.NewGuid().ToString().Replace("-", ""); // string fileName = LocalFilePathMapping.GetFile(FileType.Video, fileID); // MessageInfo message = this.Copy() as MessageInfo; // List<ShapeLayer> layers = new List<ShapeLayer>(); // float startTime = 0; // float endTime = 0; // bool first = true; // //Dynamic layers // foreach (var item in message.Items) // { // if (item.Shape.Type == ShapeType.DynamicText || item.Shape.Type == ShapeType.Time || item.Shape.Type == ShapeType.Temperature) // { // layers.Add(item.Copy() as ShapeLayer); // } // else // { // if (first) // { // first = false; // startTime = item.StartTime; // endTime = item.EndTime; // } // else // { // if (item.StartTime < startTime) // startTime = item.StartTime; // if (item.EndTime > endTime) // endTime = item.EndTime; // } // } // } // //Video layer // if(!generator.CreateVideo(this, fileName)) // throw new Exception("Generate video file is failure!"); // generator = null; // ShapeLayer layer = new ShapeLayer(); // ShapeVideo shape = new ShapeVideo(); // //layer.EmphasisEffect.StartTime = long.Parse(startTime.ToString()); // //layer.EmphasisEffect.EndTime = long.Parse(endTime.ToString()); //long.Parse(message.Length.ToString()); // layer.EmphasisEffect.Left = (int)startTime * Constance.Effect.UnitWidth; // layer.EmphasisEffect.Width = (int)endTime * Constance.Effect.UnitWidth; // Size size = this.GetSignSize(); // shape.VideoUrl = fileName; // shape.DestBounds = new System.Drawing.Rectangle(0, 0, size.Width, size.Height); // //shape.LocationX = 0; // //shape.LocationY = 0; // //shape.Size = GetSignSize(); // //shape.Rect.OffsetX = 0; // //shape.Rect.OffsetY = 0; // //shape.Rect.Width = shape.Size.Width; // //shape.Rect.Height = shape.Size.Height; // shape.VideoFileID = fileID; // layer.Shape = shape.Copy(); // layers.Add(layer); // message.Items = layers.ToArray(); // return message; //} /// <summary> /// Function: Get data from a object to current object /// Author : Jerry Xu /// Date : 2008-7-8 /// </summary> /// <param name="memory">MemoryLibraryItem</param> public override void FromTo(MemoryLibraryItem memory) { base.FromTo(memory); InternalFromTo(memory as MessageInfo); }