/// <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; } } } } }
private ShapeLayer AddImageLayer(FileLibraryItem item, SignInfo sign) { if (item == null || sign == null) { return(null); } ShapeImage shape = new ShapeImage(); if (!SetSignInfo(shape, sign)) { return(null); } shape.ImageUrl = item.Path; shape.IsBackground = true; shape.OldVirtualBound = new System.Drawing.Rectangle(0, 0, sign.Width / 2, sign.Height / 2); shape.FileHandle = item.Id; //shape.ComputeDestBoundBatchLoad(); ShapeLayer layer = new ShapeLayer(shape); layer.Name = "Layer 1"; //layer.EmphasisEffect.StartTime = 0; //layer.EmphasisEffect.EndTime = long.Parse(sign.Template.Message.DisplayTime.ToString()); layer.EmphasisEffect.Left = 0; layer.EmphasisEffect.Width = sign.Template.Message.DisplayTime * Constance.Effect.UnitWidth; shape.ComputeDestBoundBatchLoad(); return(layer); }
public void DrawShapes(float level) { Render.Begin(); DrawShapeNode(Root, level); ShapeImage.Bind(); Render.End2D(); ShapeImage.Release(); }
public EditPicture(ShapeImage shapeImage)//Image shape,string imageUrl) { InitializeComponent(); CurrentShapeImage = shapeImage; CurrentImage = shapeImage.Image; CurrentImageOld = (Image)CurrentImage.Clone(); ImageUrl = shapeImage.ImageUrl; InitImage(); }
private void RenderImages() { Bitmap bmp = new Bitmap(this.Width, this.Height); Graphics g = Graphics.FromImage(bmp); g.Clear(MouseOutBackgroundColor); if (!(ShapeImage == null)) { for (int y = 0; (y <= (ShapeImage.Height - 1)); y++) { for (int x = 0; (x <= (ShapeImage.Width - 1)); x++) { Color pixelColor = Color.FromArgb(ShapeImage.GetPixel(x, y).A, ShapeColor); g.FillRectangle(new SolidBrush(pixelColor), new Rectangle(x, y, 1, 1)); } } } _mouseOutImage = new Bitmap(bmp); g.Clear(MouseOverBackgroundColor); if (!(ShapeImage == null)) { for (int y = 0; (y <= (ShapeImage.Height - 1)); y++) { for (int x = 0; (x <= (ShapeImage.Width - 1)); x++) { Color pixelColor = Color.FromArgb(ShapeImage.GetPixel(x, y).A, ShapeColor); g.FillRectangle(new SolidBrush(pixelColor), new Rectangle(x, y, 1, 1)); } } } _mouseOverImage = new Bitmap(bmp); g.Clear(MouseDownBackgroundColor); if (!(ShapeImage == null)) { for (int y = 0; (y <= (ShapeImage.Height - 1)); y++) { for (int x = 0; (x <= (ShapeImage.Width - 1)); x++) { Color pixelColor = Color.FromArgb(ShapeImage.GetPixel(x, y).A, ShapeColor); g.FillRectangle(new SolidBrush(pixelColor), new Rectangle(x, y, 1, 1)); } } } _mouseDownImage = new Bitmap(bmp); g.Dispose(); bmp.Dispose(); }
protected override void OnLoad(EventArgs e) { if (ShapeImage != null) { this.Size = ShapeImage.Size; using (Region tmpRegion = new Region()) { tmpRegion.MakeEmpty(); using (Graphics g = Graphics.FromImage(ShapeImage)) { bool isMatch = false; Rectangle tmpRect = new Rectangle(0, 0, 0, 0); for (int x = 0; x < ShapeImage.Width; x++) { for (int y = 0; y < ShapeImage.Height; y++) { if (!isMatch) { if (ShapeImage.GetPixel(x, y).ToArgb() != TransparentColor.ToArgb()) { isMatch = true; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = 1; } } else { if (ShapeImage.GetPixel(x, y).ToArgb() == TransparentColor.ToArgb()) { isMatch = false; tmpRect.Height = y - tmpRect.Y; tmpRegion.Union(tmpRect); } } } if (isMatch) { isMatch = false; tmpRect.Height = ShapeImage.Height - tmpRect.Y; tmpRegion.Union(tmpRect); } } this.Region = tmpRegion.Clone(); } } } base.OnLoad(e); }
/// <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; } } } } }
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 = } } } } }
public EditImage(ShapeImage currentImage) { CurrentShapImage = currentImage; }
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); } } }
public override void VisitImage(ShapeImage image) { VisitShape(image); image.ComputeDestBound(); }
public virtual void VisitImage(ShapeImage image) { throw new NotImplementedException(); }
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); } }