Ejemplo n.º 1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context == null ||
                context.Instance == null ||
                provider == null)
            {
                return(value);
            }

            service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (service == null)
            {
                return(value);
            }

            ShapeVideo shape = context.Instance as ShapeVideo;

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter = Constance.FileFilter.Video;
                if (dlg.ShowModalDialog() == DialogResult.OK)
                {
                    MessageControl.Current.SetFrameLayerFocus(shape);
                    LayerControl.Current.Layer.EmphasisEffect.Duration = CommonHelper.GetMediaLength(dlg.FileName) / DESConsts.UNITS;
                    return(dlg.FileName);
                }
            }
            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function: Update shape file url
        /// Author  : Jerry Xu
        /// Date    : 2009-4-20
        /// </summary>
        /// <param name="shape">ShapeBase</param>
        private void SetUrl(ShapeBase shape)
        {
            ShapeImage image = null;
            ShapeVideo video = null;

            if (shape.Type == ShapeType.Image)
            {
                image = shape as ShapeImage;
            }
            if (shape.Type == ShapeType.Video)
            {
                video = shape as ShapeVideo;
            }
            foreach (MessageFileItem item in _files)
            {
                if (item.OldItem != null)
                {
                    if (shape.Type == ShapeType.Image)
                    {
                        if (item.OldItem.Name == Path.GetFileName(image.ImageUrl))
                        {
                            image.ImageUrl = item.Item.Path;
                        }
                    }
                    if (shape.Type == ShapeType.Video)
                    {
                        if (item.OldItem.Name == Path.GetFileName(video.VideoUrl))
                        {
                            video.VideoUrl = item.Item.Path;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private ShapeLayer AddVideoLayer(FileLibraryItem item, SignInfo sign)
        {
            if (item == null || sign == null)
            {
                return(null);
            }

            ShapeVideo shape = new ShapeVideo();

            if (!SetSignInfo(shape, sign))
            {
                return(null);
            }
            shape.VideoUrl        = item.Path;
            shape.IsBackground    = true;
            shape.OldVirtualBound = new System.Drawing.Rectangle(0, 0, sign.Width / 2, sign.Height / 2);
            shape.FileHandle      = item.Id;

            ShapeLayer layer = new ShapeLayer(shape);

            layer.Name = "Layer 1";
            layer.EmphasisEffect.Duration = sign.Template.Message.DisplayTime;

            return(layer);
        }
Ejemplo n.º 4
0
        private ShapeLayer AddVideoLayer(FileLibraryItem item, int length, SignInfo sign)
        {
            if (item == null || sign == null)
            {
                return(null);
            }

            ShapeVideo shape = new ShapeVideo();

            if (!SetSignInfo(shape, sign))
            {
                return(null);
            }
            shape.VideoUrl        = item.Path;
            shape.IsBackground    = true;
            shape.OldVirtualBound = new System.Drawing.Rectangle(0, 0, sign.Width / 2, sign.Height / 2);
            shape.FileHandle      = item.Id;

            ShapeLayer layer = new ShapeLayer(shape);

            layer.Name = "Layer 1";
            //layer.EmphasisEffect.StartTime = 0;
            //layer.EmphasisEffect.EndTime = long.Parse(length.ToString());
            //layer.EmphasisEffect.Duration = length;// sign.Template.Message.DefaultLength;
            layer.EmphasisEffect.Left  = 0;
            layer.EmphasisEffect.Width = sign.Template.Message.DisplayTime * Constance.Effect.UnitWidth;
            return(layer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Function: Update shape file handle
        /// Author  : Jerry Xu
        /// Date    : 2008-12-29
        /// </summary>
        /// <param name="shape">ShapeBase</param>
        /// <param name="files">List<FileItem></param>
        private void SetHandleID(ShapeBase shape, List <FileItem> files)
        {
            ShapeImage image = null;
            ShapeVideo video = null;

            if (shape.Type == ShapeType.Image)
            {
                image = shape as ShapeImage;
            }
            if (shape.Type == ShapeType.Video)
            {
                video = shape as ShapeVideo;
            }
            foreach (FileItem item in files)
            {
                item.Id = Guid.NewGuid().ToString().Replace("-", "");
                if (!string.IsNullOrEmpty(item.Name))
                {
                    if (shape.Type == ShapeType.Image)
                    {
                        if (item.Name == Path.GetFileName(image.ImageUrl))
                        {
                            image.FileHandle = item.Id;
                            //libraryFileName = IOHelper.GetLibraryFileName(item.Name, string.Empty, LibraryType.Image);
                            image.ImageUrl = item.Path; //libraryFileName;
                        }
                    }
                    if (shape.Type == ShapeType.Video)
                    {
                        if (item.Name == Path.GetFileName(video.VideoUrl))
                        {
                            video.FileHandle = item.Id;
                            //libraryFileName = IOHelper.GetLibraryFileName(item.Name, string.Empty, LibraryType.Video);
                            video.VideoUrl = item.Path;// libraryFileName;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void SetLibraryFileLocalPath(MessageInfo message)
        {
            if (message == null || message.Items == null || message.Items.Length == 0)
            {
                return;
            }

            ShapeImage shapeImage = null;
            ShapeVideo shapeVideo = null;
            string     filepath   = null;

            foreach (ShapeLayer layer in message.Items)
            {
                if (layer.Shape != null && (layer.Shape.Type == ShapeType.Image || layer.Shape.Type == ShapeType.Video))
                {
                    if (layer.Shape.Type == ShapeType.Image)
                    {
                        shapeImage = layer.Shape as ShapeImage;
                        if (!string.IsNullOrEmpty(shapeImage.ImageUrl))
                        {
                            filepath            = IOHelper.GetLibraryFileName(Path.GetFileName(shapeImage.ImageUrl), string.Empty, LibraryType.Image);
                            shapeImage.ImageUrl = filepath;
                            //shapeImage.FileHandle =
                        }
                    }
                    if (layer.Shape.Type == ShapeType.Video)
                    {
                        shapeVideo = layer.Shape as ShapeVideo;
                        if (!string.IsNullOrEmpty(shapeVideo.VideoUrl))
                        {
                            filepath            = IOHelper.GetLibraryFileName(Path.GetFileName(shapeVideo.VideoUrl), string.Empty, LibraryType.Image);
                            shapeVideo.VideoUrl = filepath;
                            //shapeImage.FileHandle =
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private ShapeLayer MergeVideoLayers(MessageInfo mes, ShapeLayer[] videoLayers)
        {
            string fileID   = Guid.NewGuid().ToString().Replace("-", "");
            string fileName = LocalFilePathMapping.GetFile(FileType.Video, fileID);

            var   layers = new VideoLayerCollection();
            Layer layer  = null;


            long minStartTime = 0;
            long maxEndTime   = 0;

            Array.ForEach <ShapeLayer>(videoLayers, item =>
            {
                layer = DESLayerConverter.Instance.Convert(item);
                //comment out by Louis,for change video start time same as video layer's start time
                //layer.Level++;

                if (layer.Level == 0)
                {
                    minStartTime = layer.StartTime;
                    maxEndTime   = layer.EndTime;
                }
                else
                {
                    if (layer.StartTime < minStartTime)
                    {
                        minStartTime = layer.StartTime;
                    }
                    if (layer.EndTime > maxEndTime)
                    {
                        maxEndTime = layer.EndTime;
                    }
                }

                layer.Rect = new System.Drawing.Rectangle(layer.Rect.X / mes.Zoom, layer.Rect.Y / mes.Zoom, layer.Rect.Width / mes.Zoom, layer.Rect.Height / mes.Zoom);
                layers.Add(layer);
            });

            layers.BackColor = mes.BackColor;
            layers.SignType  = SignType.RGB;
            layers.VideoSize = videoLayers[0].Shape.SignSize;
            layers.Name      = mes.Name;
            layers.Zoom      = 1;

            layers.PlayLength = maxEndTime - minStartTime;


            layers.ParentName     = "";
            layers.EmphasisEffect = mes.EmphasisEffect;
            if (layers.Count > 1)
            {
                layers.Sort(new SortComparer <Layer>("Level", false));
            }

            IBaseFilter ibfVideoCompressor = DESHelper.GetVideoCompressor("Indeo?video 5.10 Compression Filter");
            PlayState   state = ProWrite.Core.PlayState.Stop;

            var des = new DESCombine(DESConsts.FPS, DESConsts.BitCount, layers.VideoSize.Width, layers.VideoSize.Height, layers);

            des.Completed += (s, e) => state = PlayState.Stop;
            des.RenderToVideo(MediaSubType.Mpeg2Video, fileName, ibfVideoCompressor, null, null, null, new List <Layer>(), 0, mes.Length, layers.VideoSize);
            des.StartRendering();

            state = PlayState.Run;
            while (state == PlayState.Run)
            {
                Thread.Sleep(100);
            }

            des.Dispose();
            des = null;

            var        newLayer = videoLayers[0].Copy();
            ShapeVideo shape    = newLayer.Shape as ShapeVideo;

            if (shape == null)//shape.Type == Gif
            {
                shape = new ShapeVideo();
                shape.FromTo(newLayer.Shape);
                newLayer.Shape = shape;
            }

            shape.VideoFileID = fileID;
            shape.VideoUrl    = fileName;

            newLayer.EntryEffect          = LayerEffect.Empty;
            newLayer.ExitEffect           = LayerEffect.Empty;
            newLayer.EmphasisEffect       = LayerEffect.Empty;
            newLayer.EmphasisEffect.Left  = (int)minStartTime * Constance.Effect.UnitWidth;
            newLayer.EmphasisEffect.Width = (int)maxEndTime * Constance.Effect.UnitWidth;

            return(newLayer);
        }
Ejemplo n.º 8
0
        private void SerializingMessage(MessageInfo message)
        {
            FileItem item = null;

            foreach (ShapeLayer layer in message.Items)
            {
                if (layer.Shape == null)
                {
                    continue;
                }
                if (layer.Shape.Type == ShapeType.Image)
                {
                    ShapeImage image = layer.Shape as ShapeImage;
                    if (image == null ||
                        image.Image == null ||
                        string.IsNullOrEmpty(image.ImageUrl) ||
                        !File.Exists(image.ImageUrl))
                    {
                        continue;
                    }
                    string imageName = Path.GetFileName(image.ImageUrl);

                    byte[] content = IOHelper.ReadAllBytes(image.ImageUrl);

                    item = _images.Find(p => { return(p.Name == imageName); });
                    if (item != null)
                    {
                        if (IOHelper.FileContentCompare(item.Content, content))
                        {
                            continue;
                        }
                        imageName = "_" + imageName;
                    }

                    _images.Add(new FileItem {
                        Id = image.FileHandle, Name = imageName, Path = image.ImageUrl, Content = content, Type = LibraryType.Image
                    });
                }
                else if (layer.Shape.Type == ShapeType.Video)
                {
                    ShapeVideo video = layer.Shape as ShapeVideo;
                    if (video == null ||
                        string.IsNullOrEmpty(video.VideoUrl) ||
                        !File.Exists(video.VideoUrl))
                    {
                        continue;
                    }
                    string videoName = Path.GetFileName(video.VideoUrl);

                    byte[] content = IOHelper.ReadAllBytes(video.VideoUrl);

                    item = _videos.Find(p => { return(p.Name == videoName); });
                    if (item != null)
                    {
                        if (IOHelper.FileContentCompare(item.Content, content))
                        {
                            continue;
                        }
                        videoName = "_" + videoName;
                    }

                    _videos.Add(new FileItem {
                        Id = video.FileHandle, Name = videoName, Path = video.VideoUrl, Content = content, Type = LibraryType.Video
                    });
                }

                if (!string.IsNullOrEmpty(message.ImagePath) &&
                    File.Exists(message.ImagePath))
                {
                    NailImageFileItem nailItem = new NailImageFileItem();
                    nailItem            = new NailImageFileItem();
                    nailItem.MemoryName = message.Name;
                    nailItem.Type       = message.Type;
                    nailItem.Content    = IOHelper.ReadAllBytes(message.ImagePath);
                    nailItem.Name       = Path.GetFileName(message.ImagePath);
                    _nailItems.Add(nailItem);
                }
            }
        }
Ejemplo n.º 9
0
 public override void VisitVideo(ShapeVideo video)
 {
     VisitShape(video);
     video.ComputeDestBound();
 }
Ejemplo n.º 10
0
 public virtual void VisitVideo(ShapeVideo video)
 {
 }
Ejemplo n.º 11
0
        private void Serializing(StreamingContext ctx)
        {
            if (_target == null ||
                _target.Items == null ||
                _target.Items.Length < 1)
            {
                return;
            }
            _images = new List <FileItem>();
            _videos = new List <FileItem>();

            FileItem item = null;

            foreach (ShapeLayer layer in _target.Items)
            {
                if (layer.Shape == null)
                {
                    continue;
                }
                if (layer.Shape.Type == ShapeType.Image)
                {
                    ShapeImage image = layer.Shape as ShapeImage;
                    if (image == null ||
                        image.Image == null ||
                        string.IsNullOrEmpty(image.ImageUrl) ||
                        !File.Exists(image.ImageUrl))
                    {
                        continue;
                    }
                    string imageName = Path.GetFileName(image.ImageUrl);

                    byte[] content = IOHelper.ReadAllBytes(image.ImageUrl);

                    item = _images.Find(p => { return(p.Name == imageName); });
                    if (item != null)
                    {
                        if (IOHelper.FileContentCompare(item.Content, content))
                        {
                            continue;
                        }
                        imageName = "_" + imageName;
                    }

                    _images.Add(new FileItem {
                        Id = image.FileHandle, Name = imageName, Path = image.ImageUrl, Content = content, Type = LibraryType.Image
                    });
                }
                else if (layer.Shape.Type == ShapeType.Video)
                {
                    ShapeVideo video = layer.Shape as ShapeVideo;
                    if (video == null ||
                        string.IsNullOrEmpty(video.VideoUrl) ||
                        !File.Exists(video.VideoUrl))
                    {
                        continue;
                    }
                    string videoName = Path.GetFileName(video.VideoUrl);

                    byte[] content = IOHelper.ReadAllBytes(video.VideoUrl);

                    item = _videos.Find(p => { return(p.Name == videoName); });
                    if (item != null)
                    {
                        if (IOHelper.FileContentCompare(item.Content, content))
                        {
                            continue;
                        }
                        videoName = "_" + videoName;
                    }

                    _videos.Add(new FileItem {
                        Id = video.FileHandle, Name = videoName, Path = video.VideoUrl, Content = content, Type = LibraryType.Video
                    });
                }
            }

            if (_images.Count < 1)
            {
                _images = null;
            }
            if (_videos.Count < 1)
            {
                _videos = null;
            }
            if (!string.IsNullOrEmpty(_target.ImagePath) &&
                File.Exists(_target.ImagePath))
            {
                _nailItem            = new NailImageFileItem();
                _nailItem.MemoryName = _target.Name;
                _nailItem.Type       = _target.Type;
                _nailItem.Content    = IOHelper.ReadAllBytes(_target.ImagePath);
                _nailItem.Name       = Path.GetFileName(_target.ImagePath);
            }
        }