Exemple #1
0
 public virtual void CopyTo(Layer other)
 {
     other.Top = this.Top;
     other.Left = this.Left;
     other.Bottom = Bottom;
     other.Right = Right;
     other.Width = Width;
     other.Height = Height;
     other.RelativeTo = RelativeTo;
     other.DrawAs = DrawAs;
     other.Align = Align;
 }
Exemple #2
0
        protected RequestedAction RenderLayersForLevel(ImageState s, Layer.LayerPlacement only)
        {
            string watermark = s.settings["watermark"]; //from the querystring
            Graphics g = s.destGraphics;
            if (string.IsNullOrEmpty(watermark) || g == null) return RequestedAction.None;

            string[] parts = watermark.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            bool foundPart = false;

            foreach (string w in parts) {
                if (NamedWatermarks.ContainsKey(w)) {
                    IEnumerable<Layer> layers = NamedWatermarks[w];
                    foreach (Layer l in layers) {
                        if (l.DrawAs == only) {
                            l.RenderTo(s);
                        }
                    }
                    foundPart = true;
                }
            }
            if ( !foundPart && only == Layer.LayerPlacement.Overlay) {
                //Parse named watermark files

                if (watermark.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) > -1 ||
                    watermark.IndexOfAny(new char[] { '\\', '/' }) > -1)
                    throw new ArgumentException("Watermark value contained invalid file name characters: " + watermark);

                if (OtherImages != null && OtherImages.Path != null) {
                    ImageLayer layer = OtherImages.Copy();

                    //Is the watermark dir a physical path?
                    char slash = layer.Path.Contains("/") ? '/' : '\\';
                    layer.Path = layer.Path.TrimEnd(slash) + slash + watermark.TrimStart(slash);

                    //If it's a forward-slash, and we're in asp.net,  verify the file exists
                    if (slash == '/' && HttpContext.Current != null && !c.Pipeline.FileExists(layer.Path, layer.ImageQuery)) return RequestedAction.None;
                    layer.RenderTo(s);

                } else {
                    this.LegacyDrawWatermark(s);
                }
            }
            return RequestedAction.None;
        }
Exemple #3
0
        protected RequestedAction RenderLayersForLevel(ImageState s, Layer.LayerPlacement only)
        {
            string watermark;
            string[] parts = WatermarksToUse(s.settings, out watermark);
            Graphics g = s.destGraphics;
            if (parts == null || g == null) return RequestedAction.None;

            bool foundPart = false;

            foreach (string w in parts) {
                if (NamedWatermarks.ContainsKey(w)) {
                    IEnumerable<Layer> layers = NamedWatermarks[w];
                    foreach (Layer l in layers) {
                        if (l.DrawAs == only) {
                            l.RenderTo(s);
                        }
                    }
                    foundPart = true;
                }
            }

            if ( !foundPart && only == Layer.LayerPlacement.Overlay) {
                //Parse named watermark files
                ImageLayer layer = this.CreateLayerFromOtherImages(watermark);

                if (layer != null) {
                    layer.RenderTo(s);
                } else {
                    this.LegacyDrawWatermark(s);
                }
            }

            return RequestedAction.None;
        }