public Config()
 {
     RegistryKey reg = Registry.CurrentUser.OpenSubKey(KEY);
     if (reg == null)
         return;
     xCount = (int)reg.GetValue("xCount", xCount);
     longInterval = (int)reg.GetValue("longInterval", longInterval);
     shortInterval = (int)reg.GetValue("shortInterval", shortInterval);
     isEnabledFileImageSource = (int)reg.GetValue("isEnabledFileImageSource", Convert.ToInt32(isEnabledFileImageSource)) == 1;
     fileImageSourcePath = (string)reg.GetValue("fileImageSourcePath", fileImageSourcePath);
     isEnabledFlickrImageSource = (int)reg.GetValue("isEnabledFlickrImageSource", Convert.ToInt32( isEnabledFlickrImageSource)) == 1;
     flickrImageSourceTags = (string)reg.GetValue("flickrImageSourceTags", flickrImageSourceTags);
     isFlickrImageSourceTagAndLogic = (int)reg.GetValue("isFlickrImageSourceTagAndLogic", isFlickrImageSourceTagAndLogic) == 1;
     flickrImageSourceUserName = (string)reg.GetValue("flickrImageSourceUserName", flickrImageSourceUserName);
     flickrImageSourceText = (string)reg.GetValue("flickrImageSourceText", flickrImageSourceText);
     backgroundstyle = (BackGroundStyle)Enum.Parse(typeof(BackGroundStyle), (string)reg.GetValue("backgroundstyle", Enum.GetName(typeof(BackGroundStyle), backgroundstyle)));
     imagestyle = (ImageStyle)Enum.Parse(typeof(ImageStyle), (string)reg.GetValue("imagestyle", Enum.GetName(typeof(ImageStyle), imagestyle)));
     transitionin = (TransitionStyle)Enum.Parse(typeof(TransitionStyle), (string)reg.GetValue("transitionin", Enum.GetName(typeof(TransitionStyle), transitionin)));
     transitionout = (TransitionStyle)Enum.Parse(typeof(TransitionStyle), (string)reg.GetValue("transitionout", Enum.GetName(typeof(TransitionStyle), transitionout)));
     //theme = (Theme)Enum.Parse(typeof(Theme), (string)reg.GetValue("theme", Enum.GetName(typeof(Theme), theme)));
     comicstyle = (Comicstyle)Enum.Parse(typeof(Comicstyle), (string)reg.GetValue("comicstyle", Enum.GetName(typeof(Comicstyle), comicstyle)));
     isLoggingEnabled = (int)reg.GetValue("isLoggingEnabled", Convert.ToInt32(isLoggingEnabled)) == 1;
     filesearchfilter = (string)reg.GetValue("filesearchfilter", filesearchfilter);
     enablefilesearchfilter = (int)reg.GetValue("enablefilesearchfilter", Convert.ToInt32(enablefilesearchfilter)) == 1;
     reg.Close();
 }
Example #2
0
        /// <summary>
        /// Resolves image using specified image style.
        /// </summary>
        /// <param name="imageStyle">Specifies how to resolve image.</param>
        /// <returns></returns>
        public Image GetImage(ImageStyle imageStyle)
        {
            if (imageStyle == null)
            {
                return(null);
            }

            string key = ComputeHash(imageStyle.ImageValue);
            Image  resultImage;

            if (_cache.TryGetValue(key, out resultImage))
            {
                return(resultImage);
            }

            Stream imageStream = GetImageStream(imageStyle);

            if (imageStream == null)
            {
                return(null);
            }

            using (imageStream)
                using (resultImage = LoadImageSafe(imageStream, key))
                {
                    if (resultImage != null)
                    {
                        // case 194962: if we want to make byte operations with image after stream closing.
                        resultImage = new System.Drawing.Bitmap(resultImage);
                        _cache[key] = resultImage;
                    }
                }

            return(resultImage);
        }
Example #3
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is ImageStyle))
            {
                return;
            }

            ImageStyle style = geometryStyle as ImageStyle;

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            if (style.ImageUri == null)
            {
                dc.DrawRectangle(Brushes.Transparent, _pen, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
            }
            else
            {
                BitmapSource source = new System.Windows.Media.Imaging.BitmapImage(style.ImageUri);
                dc.DrawImage(source, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
            }
        }
Example #4
0
        /// <summary>
        ///     Image Style object
        /// </summary>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width of the image.</param>
        /// <param name="Height">Height of the image.</param>
        /// <param name="Tooltip">Tooltip message that will appear when you hover over image.</param>
        /// <returns name="Style">Style object.</returns>
        /// <search>image style, style</search>
        public static ImageStyle Style(
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width      = 150,
            int Height     = 150,
            string Tooltip = "")
        {
            ImageStyle style = new ImageStyle();

            style.Width   = Width;
            style.Height  = Height;
            style.Tooltip = Tooltip;

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Example #5
0
        public void Import(ConfigNode data)
        {
            CommonOptions opt = GEnv.Options;

            _fontName = data["font-name"];
            if (_fontName == null)
            {
                _fontName = opt.FontName;
            }
            _japaneseFontName = data["japanese-font-name"];
            if (_japaneseFontName == null)
            {
                _japaneseFontName = opt.JapaneseFontName;
            }
            _fontSize     = (float)GUtil.ParseInt(data["font-size"], 10);
            _useClearType = GUtil.ParseBool(data["clear-type"], false);
            ClearFont();

            unchecked {
                _forecolor = Color.FromArgb(GUtil.ParseHexInt(data["fore-color"], (int)0xFF000000));
                _bgcolor   = Color.FromArgb(GUtil.ParseHexInt(data["back-color"], (int)0xFFFFFFFF));
            }
            if (_esColorSet == null)
            {
                _esColorSet = (EscapesequenceColorSet)opt.ESColorSet.Clone();
            }
            _esColorSet.Load(data["color-sequence"]);
            ClearBrush();

            _backgroundImageFileName = data["image-file"];
            _imageLoadIsAttempted    = false;
            _imageStyle = (ImageStyle)EnumDescAttribute.For(typeof(ImageStyle)).FromName(data["bg-style"], ImageStyle.Center);
        }
        private void DrawBackgroundImage_Normal(Graphics g, Image img, ImageStyle style, Rectangle clip)
        {
            int offset_x, offset_y;

            if (style == ImageStyle.Center)
            {
                offset_x = (this.Width - _VScrollBar.Width - img.Width) / 2;
                offset_y = (this.Height - img.Height) / 2;
            }
            else
            {
                offset_x = (style == ImageStyle.TopLeft || style == ImageStyle.BottomLeft) ? 0 : (this.ClientSize.Width - _VScrollBar.Width - img.Width);
                offset_y = (style == ImageStyle.TopLeft || style == ImageStyle.TopRight) ? 0 : (this.ClientSize.Height - img.Height);
            }
            //if(offset_x < BORDER) offset_x = BORDER;
            //if(offset_y < BORDER) offset_y = BORDER;

            //画像内のコピー開始座標
            Rectangle target = Rectangle.Intersect(new Rectangle(clip.Left - offset_x, clip.Top - offset_y, clip.Width, clip.Height), new Rectangle(0, 0, img.Width, img.Height));

            if (target != Rectangle.Empty)
            {
                g.DrawImage(img, new Rectangle(target.Left + offset_x, target.Top + offset_y, target.Width, target.Height), target, GraphicsUnit.Pixel);
            }
        }
Example #7
0
 protected static void ApplyImageStyles(FrameworkElement element, ImageStyle style)
 {
     if (style != null)
     {
         BindingOperations.SetBinding(element, FrameworkElement.MarginProperty, CreateBinding(style, "Margin"));
         BindingOperations.SetBinding(element, FrameworkElement.HorizontalAlignmentProperty, CreateBinding(style, "HorizontalAlignment"));
     }
 }
Example #8
0
 protected static void ApplyImageStyles(FrameworkElement element, ImageStyle style)
 {
     if (style != null)
     {
         BindingOperations.SetBinding(element, FrameworkElement.MarginProperty, CreateBinding(style, "Margin"));
         BindingOperations.SetBinding(element, FrameworkElement.HorizontalAlignmentProperty, CreateBinding(style, "HorizontalAlignment"));
     }
 }
        public static RequestOptions GetRequestOptions(ImageStyle style, ImagePlaceholders imagePlaceholders)
        {
            try
            {
                var options = new RequestOptions();


                switch (style)
                {
                case ImageStyle.CenterCrop:
                    options.CenterCrop();
                    break;

                case ImageStyle.FitCenter:
                    options.FitCenter();
                    break;

                case ImageStyle.CircleCrop:
                    options.CircleCrop();
                    break;

                case ImageStyle.CircleCropWithBorder:
                    options.CircleCrop();
                    options.Transform(new GlideCircleWithBorder(2, Color.White));
                    break;

                case ImageStyle.RoundedCrop:
                    options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(20)));
                    break;

                default:
                    options.CenterCrop();
                    break;
                }


                switch (imagePlaceholders)
                {
                case ImagePlaceholders.Color:
                    var color = Methods.FunString.RandomColor();
                    options.Placeholder(new ColorDrawable(Color.ParseColor(color))).Fallback(new ColorDrawable(Color.ParseColor(color)));
                    break;

                case ImagePlaceholders.Drawable:
                    options.Placeholder(Resource.Drawable.ImagePlacholder).Fallback(Resource.Drawable.ImagePlacholder);
                    break;
                }

                return(options);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(new RequestOptions());
            }
        }
Example #10
0
            //-----------------------------------------------------
            public ImageStyle Clone()
            {
                ImageStyle value = new ImageStyle();

                value.ImagingOptions = this.ImagingOptions.Clone();
                value.Alignment      = this.Alignment;
                value.BackColor      = this.BackColor;
                value.Opacity        = this.Opacity;
                return(value);
            }
Example #11
0
        public static void Draw(SKCanvas canvas, ImageStyle symbolStyle, Point destination,
                                SymbolCache symbolCache, float opacity, double mapRotation)
        {
            if (symbolStyle.BitmapId < 0)
            {
                return;
            }

            var bitmap = symbolCache.GetOrCreate(symbolStyle.BitmapId);

            // Calc offset (relative or absolute)
            var offsetX = symbolStyle.SymbolOffset.IsRelative ? bitmap.Width * symbolStyle.SymbolOffset.X : symbolStyle.SymbolOffset.X;
            var offsetY = symbolStyle.SymbolOffset.IsRelative ? bitmap.Height * symbolStyle.SymbolOffset.Y : symbolStyle.SymbolOffset.Y;

            var rotation = (float)symbolStyle.SymbolRotation;

            if (symbolStyle.RotateWithMap)
            {
                rotation += (float)mapRotation;
            }

            switch (bitmap.Type)
            {
            case BitmapType.Bitmap:
                BitmapRenderer.Draw(canvas, bitmap.Bitmap,
                                    (float)destination.X, (float)destination.Y,
                                    rotation,
                                    (float)offsetX, (float)offsetY,
                                    opacity: opacity, scale: (float)symbolStyle.SymbolScale);
                break;

            case BitmapType.Svg:
                SvgRenderer.Draw(canvas, bitmap.Svg,
                                 (float)destination.X, (float)destination.Y,
                                 rotation,
                                 (float)offsetX, (float)offsetY,
                                 opacity: opacity, scale: (float)symbolStyle.SymbolScale);
                break;

            case BitmapType.Sprite:
                var sprite = bitmap.Sprite;
                if (sprite.Data == null)
                {
                    var bitmapAtlas = symbolCache.GetOrCreate(sprite.Atlas);
                    sprite.Data = bitmapAtlas.Bitmap.Subset(new SKRectI(sprite.X, sprite.Y, sprite.X + sprite.Width,
                                                                        sprite.Y + sprite.Height));
                }
                BitmapRenderer.Draw(canvas, (SKImage)sprite.Data,
                                    (float)destination.X, (float)destination.Y,
                                    rotation,
                                    (float)offsetX, (float)offsetY,
                                    opacity: opacity, scale: (float)symbolStyle.SymbolScale);
                break;
            }
        }
Example #12
0
        public static RequestOptions GetRequestOptions(ImageStyle style, ImagePlaceholders imagePlaceholders)
        {
            try
            {
                var options = new RequestOptions();


                switch (style)
                {
                case ImageStyle.CenterCrop:
                    options.CenterCrop();
                    break;

                case ImageStyle.FitCenter:
                    options.FitCenter();
                    break;

                case ImageStyle.CircleCrop:
                    options.CircleCrop();
                    break;

                case ImageStyle.RoundedCrop:
                    options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(25)))
                    .SetPriority(Priority.High).Override(450)
                    .SetUseAnimationPool(false).SetDiskCacheStrategy(DiskCacheStrategy.All)
                    .Error(Resource.Drawable.ImagePlacholder_circle)
                    .Placeholder(Resource.Drawable.ImagePlacholder_circle);
                    break;

                default:
                    options.CenterCrop();
                    break;
                }


                switch (imagePlaceholders)
                {
                case ImagePlaceholders.Color:
                    var color = Methods.FunString.RandomColor();
                    options.Placeholder(new ColorDrawable(Color.ParseColor(color))).Fallback(new ColorDrawable(Color.ParseColor(color)));
                    break;

                case ImagePlaceholders.Drawable:
                    options.Placeholder(Resource.Drawable.ImagePlacholder).Fallback(Resource.Drawable.ImagePlacholder);
                    break;
                }

                return(options);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new RequestOptions());
            }
        }
 private void DrawBackgroundImage(Graphics g, Image img, ImageStyle style, Rectangle clip)
 {
     if (style.IsScaled())
     {
         DrawBackgroundImage_Scaled(g, img, style, clip);
     }
     else
     {
         DrawBackgroundImage_Normal(g, img, style, clip);
     }
 }
Example #14
0
        public PropertyBuilder <TProperty> HasImageStyle(ImageStyle imageStyle)
        {
            if (imageStyle == null)
            {
                throw new ArgumentNullException(nameof(imageStyle));
            }

            _propertyMetadata.AddStyle(imageStyle);

            return(this);
        }
        public AdaptiveCardsContainerBuilder AddImage(string url, ImageSize size, ImageStyle style)
        {
            Image img = new Image()
            {
                Url   = url,
                Style = style,
                Size  = size
            };

            _container.Items.Add(img);
            return(this);
        }
        public static MvcHtmlString Image(this HtmlHelper html, string url, ImageStyle? style, string id, string alternateText, object htmlAttributes)
        {
            var builder = new TagBuilder("img");

            builder.GenerateId(id);
            if (style.HasValue) builder.AddCssClass(style.Value.ToCssClass());
            builder.MergeAttribute("src", url);
            builder.MergeAttribute("alt", alternateText);
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));

            return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing));
        }
Example #17
0
        public override void Reflow(DrawContext dc, BoundingContext bounds, bool incremental)
        {
            ReflowStart(dc);

            if (incremental)
            {
                bounds = bounds.Narrow(style.Left, style.Right);
            }

            MarkupItem tag = new StartTag(CurrentLine, ElementNode);

            ReflowMarkup(tag, dc, style, bounds);

            ImageStyle s = style as ImageStyle;

            if (s == null)
            {
                throw new InvalidOperationException("Expected style for image to be Custom");
            }

            string imgPath = ElementNode.GetAttribute(s.SourceAttribute);

            if (imgPath == null)
            {
                throw new InvalidOperationException("SourceAttribute for image is missing");
            }

            // think about relative to doc
            Bitmap bm;

            Uri docUri = new Uri(elementNode.BaseURI);
            Uri uri    = new Uri(docUri, imgPath);

            if (uri.IsFile && File.Exists(uri.AbsolutePath))
            {
                bm = new Bitmap(uri.AbsolutePath);
            }
            else
            {
                bm = ErrorBitmap;
            }

            ImageLineItem ili = new ImageLineItem(CurrentLine, ElementNode, bm);

            ReflowMarkup(ili, dc, style, bounds);

            tag = new EndTag(CurrentLine, ElementNode);
            ReflowMarkup(tag, dc, style, bounds);

            ReflowEnd(dc);
        }
        private void DrawBackgroundImage_Scaled(Graphics g, Image img, ImageStyle style, Rectangle clip)
        {
            Size clientSize = this.ClientSize;

            Size size = this.ClientSize;

            size.Width -= _VScrollBar.Width;
            if (size.Width < 1)
            {
                size.Width = 1;
            }
            if (size.Height < 1)
            {
                size.Height = 1;
            }

            float sw = (float)size.Width / img.Width;
            float sh = (float)size.Height / img.Height;

            switch (style)
            {
            case ImageStyle.Scaled:       break;

            case ImageStyle.HorizontalFit: sh = sw; break;

            case ImageStyle.VerticalFit:  sw = sh; break;

            case ImageStyle.MinimalFit:   if (sw < sh)
                {
                    sh = sw;
                }
                else
                {
                    sw = sh;
                } break;

            case ImageStyle.MaximalFit:   if (sw > sh)
                {
                    sh = sw;
                }
                else
                {
                    sw = sh;
                } break;
            }

            bgdrawer.UpdateImage(img, sw, sh, (size.Width - img.Width * sw) / 2, (size.Height - img.Height * sh) / 2, size);
            bgdrawer.DrawImageClipped(g, clip);
        }
 public Window(Rectangle bounds, int xSize, Config config, IImageSource imageSource)
 {
     Log.Instance.Write("Creating screen saver window at bounds " + bounds);
     this.bounds = bounds;
     this.xSize = xSize;
     this.config = config;
     this.backgroundstyle = config.BackGroundStyle;
     this.imagestyle = config.ImageStyle;
     //this.theme = theme;
     this.imageSource = imageSource;
     this.SetStyle(
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.UserPaint |
         ControlStyles.OptimizedDoubleBuffer, true);
 }
Example #20
0
        public static string ToCssClass(this ImageStyle style)
        {
            switch (style)
            {
            case ImageStyle.Rounded:
                return("img-rounded");

            case ImageStyle.Circle:
                return("img-circle");

            case ImageStyle.Polaroid:
                return("img-polaroid");

            default:
                return(string.Empty);
            }
        }
Example #21
0
        private void Init(CommonOptions opt)
        {
            _fontName         = opt.FontName;
            _japaneseFontName = opt.JapaneseFontName;
            _fontSize         = opt.FontSize;
            _useClearType     = opt.UseClearType;
            _japaneseFont     = _font = null;
            _esColorSet       = (EscapesequenceColorSet)opt.ESColorSet.Clone();

            _forecolor = opt.TextColor;
            _bgcolor   = opt.BGColor;
            _bgbrush   = _brush = null;

            _backgroundImageFileName = opt.BackgroundImageFileName;
            _imageLoadIsAttempted    = false;
            _imageStyle = opt.ImageStyle;
        }
        /// <summary>
        /// Equivalence between the types <see cref="ContentAlignment" /> and <see cref="ImageStyle"/>.
        /// </summary>
        /// <param name="alignment">One of the values in the enumeration <see cref="ContentAlignment"/> that represents the type of alignment.</param>
        /// <returns>
        /// Equivalent style.
        /// </returns>
        public static ImageStyle ToImageStyle(this ContentAlignment alignment)
        {
            ImageStyle style = ImageStyle.CenterMiddle;

            switch (alignment)
            {
            case ContentAlignment.TopLeft:
                style = ImageStyle.TopLeft;
                break;

            case ContentAlignment.TopCenter:
                style = ImageStyle.TopMiddle;
                break;

            case ContentAlignment.TopRight:
                style = ImageStyle.TopRight;
                break;

            case ContentAlignment.MiddleLeft:
                style = ImageStyle.CenterLeft;
                break;

            case ContentAlignment.MiddleCenter:
                style = ImageStyle.CenterMiddle;
                break;

            case ContentAlignment.MiddleRight:
                style = ImageStyle.CenterRight;
                break;

            case ContentAlignment.BottomLeft:
                style = ImageStyle.BottomLeft;
                break;

            case ContentAlignment.BottomCenter:
                style = ImageStyle.BottomMiddle;
                break;

            case ContentAlignment.BottomRight:
                style = ImageStyle.BottomRight;
                break;
            }

            return(style);
        }
Example #23
0
        /// <summary>
        ///     Releases or completely removes a resource.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="release">if set to <see langword="true" /> the resource will be released instead of completely removed.</param>
        private bool ReleaseRemove(IStyle style, bool release)
        {
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            // If we are disposed, then technically we have already released the style
            if (_brushes == null)
            {
                return(true);
            }
            lock (_lock)
            {
                if (_brushes == null)
                {
                    return(true);
                }

                ImageStyle imageStyle = style as ImageStyle;
                if (imageStyle != null)
                {
                    Release(imageStyle.Image);
                }

                Resource <Brush> brush;
                switch (_brushes.Remove(style, out brush, release ? true : (bool?)null))
                {
                case Removed.NotFound:
                    return(false);

                case Removed.Removed:
                    return(true);

                case Removed.RemovedLast:
                    Debug.Assert(brush != null, "brush != null");
                    brush.Dispose();
                    return(true);

                default:
                    Debug.Fail("Unexpected value");
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Example #24
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string     filePath = null;
            ImageStyle style    = null;

            if (!DA.GetData <string>(0, ref filePath))
            {
                return;
            }
            if (!DA.GetData <ImageStyle>(1, ref style))
            {
                return;
            }

            D3jsLib.Image image = new D3jsLib.Image(filePath, style);

            DA.SetData(0, image);
        }
Example #25
0
        /// <summary>
        ///     Image class.
        /// </summary>
        /// <param name="FilePath">Path to the image.</param>
        /// <param name="Style">Style</param>
        /// <returns name="Image">Image object</returns>
        /// <search>image</search>
        public static D3jsLib.Image Create(object FilePath, ImageStyle Style)
        {
            // get full path to file as string
            // if File.FromPath is used it returns FileInfo class
            string _filePath = "";

            try
            {
                _filePath = (string)FilePath;
            }
            catch
            {
                _filePath = ((FileInfo)FilePath).FullName;
            }

            D3jsLib.Image image = new D3jsLib.Image(_filePath, Style);
            return(image);
        }
Example #26
0
        private IImageEncoder GetEncoder(IImageFormat imageFormat, ImageStyle imageStyle)
        {
            if (imageFormat.Name == ImageFormats.Jpeg.Name)
            {
                return(new JpegEncoder
                {
                    Quality = imageStyle.EncodeOptions.Quality,
                    Subsample = JpegSubsample.Ratio444
                });
            }

            if (imageFormat.Name == ImageFormats.Png.Name) // TODO other formats
            {
                return(new PngEncoder());
            }

            throw new NotImplementedException($"No Encoder configured for '{imageStyle.EncodeOptions.MimeType}' MimeType");
        }
Example #27
0
        /// <summary>
        /// <ja>コピーして作成します。</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src)
        {
#if !MACRODOC
            _fontName         = src._fontName;
            _japaneseFontName = src._japaneseFontName;
            _fontSize         = src._fontSize;
            _useClearType     = src._useClearType;
            _japaneseFont     = _font = null;

            _forecolor  = src._forecolor;
            _bgcolor    = src._bgcolor;
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
            _bgbrush    = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted    = false;
            _imageStyle = src.ImageStyle;
#endif
        }
Example #28
0
        public void Transform(Image <Rgba32> image, ImageStyle style)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            if (style.ResizeOptions != null)
            {
                image.Mutate(x => x.Resize(ToResizeOptions(image, style.ResizeOptions)));
            }

            // TODO other
        }
 private void DrawBackgroundImage(Graphics g, Image img, ImageStyle style, Rectangle clip)
 {
     if (style == ImageStyle.HorizontalFit)
     {
         this.DrawBackgroundImage_Scaled(g, img, clip, true, false);
     }
     else if (style == ImageStyle.VerticalFit)
     {
         this.DrawBackgroundImage_Scaled(g, img, clip, false, true);
     }
     else if (style == ImageStyle.Scaled)
     {
         this.DrawBackgroundImage_Scaled(g, img, clip, true, true);
     }
     else
     {
         DrawBackgroundImage_Normal(g, img, style, clip);
     }
 }
        public void EmptyOption_ReturnsEqualStream()
        {
            var mockImageTransformer = new Mock <IImageTransformer>();
            var mockOptions          = new Mock <IOptions <ImageSharpImageProccessorOptions> >();
            var mockLogger           = new Mock <ILogger <ImageSharpImageProccessor> >();

            mockImageTransformer
            .Setup(x => x.Transform(It.IsAny <Image <Rgba32> >(), It.IsAny <ImageStyle>()));

            var imageSharpImageProccessor = new ImageSharpImageProccessor(mockImageTransformer.Object, mockOptions.Object, mockLogger.Object);

            var bytes = TestFile.Create(TestImages.Jpeg.Lake).Bytes;

            var imageStyle = new ImageStyle("name");

            var result = imageSharpImageProccessor.ProccessAsync(bytes, new[] { imageStyle });

            Assert.NotNull(result);
            mockImageTransformer.Verify(x => x.Transform(It.IsAny <Image <Rgba32> >(), It.Is <ImageStyle>(s => s == imageStyle)), Times.Once);
        }
Example #31
0
        private void FitImageToScreen(ImageStyle imageStyle)
        {
            switch (imageStyle)
            {
            case ImageStyle.Normal:
                pbOut.SizeMode = PictureBoxSizeMode.Normal;
                break;

            case ImageStyle.Center:
                pbOut.SizeMode = PictureBoxSizeMode.CenterImage;
                break;

            case ImageStyle.Stretch:
                pbOut.SizeMode = PictureBoxSizeMode.StretchImage;
                break;

            default:
                break;
            }
        }
        /// <summary>
        ///     Adds the styles from the <see cref="StyleManager" /> given to this resource manager.
        /// </summary>
        /// <param name="manager">The manager.</param>
        public void AddFromStyleManager([NotNull] StyleManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            foreach (IStyle style in manager.Styles.Select(ts => ts.Style).Distinct())
            {
                Debug.Assert(style != null, "style != null");

                ImageStyle imageStyle = style as ImageStyle;
                if (imageStyle != null)
                {
                    Add(imageStyle.Image);
                }

                Add(style);
            }
        }
        /// <summary>
        /// Equivalence between the types <see cref="ImageStyle"/> and <see cref="WrapMode"/>.
        /// </summary>
        /// <param name="style">One of the values of the enumeration <see cref="ImageStyle"/> that represents the alignment of the images on the surface of the control.</param>
        /// <returns>
        /// Equivalent style
        /// </returns>
        public static WrapMode ToWrapMode(this ImageStyle style)
        {
            switch (style)
            {
            case ImageStyle.Tile:
                return(WrapMode.Tile);

            case ImageStyle.TileFlipX:
                return(WrapMode.TileFlipX);

            case ImageStyle.TileFlipY:
                return(WrapMode.TileFlipY);

            case ImageStyle.TileFlipXY:
                return(WrapMode.TileFlipXY);

            default:
                return(WrapMode.Clamp);
            }
        }
        private void DrawBackgroundImage_Normal(Graphics g, Image img, ImageStyle style, Rectangle clip)
        {
            int offset_x, offset_y;

            if (style == ImageStyle.Center)
            {
                offset_x = (this.Width - _VScrollBar.Width - img.Width) / 2;
                offset_y = (this.Height - img.Height) / 2;
            }
            else
            {
                offset_x = (style == ImageStyle.TopLeft || style == ImageStyle.BottomLeft) ? 0 : (this.ClientSize.Width - _VScrollBar.Width - img.Width);
                offset_y = (style == ImageStyle.TopLeft || style == ImageStyle.TopRight) ? 0 : (this.ClientSize.Height - img.Height);
            }
            //if(offset_x < BORDER) offset_x = BORDER;
            //if(offset_y < BORDER) offset_y = BORDER;

            //画像内のコピー開始座標
            bgdrawer.UpdateImage(img, 1, 1, offset_x, offset_y, this.Size);
            bgdrawer.DrawImageClipped(g, clip);
        }
Example #35
0
        /// <summary>
        /// <ja>コピーして作成します。</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src) {
            _fontName = src._fontName;
            _cjkFontName = src._cjkFontName;
            _fontSize = src._fontSize;
            _lineSpacing = src._lineSpacing;
            _useClearType = src._useClearType;
            _enableBoldStyle = src._enableBoldStyle;
            _forceBoldStyle = src._forceBoldStyle;
            _cjkFont = _font = null;

            _forecolor = src._forecolor;
            _bgcolor = src._bgcolor;
#if !MACRODOC
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
#endif
            _bgbrush = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted = false;
            _imageStyle = src.ImageStyle;
        }
Example #36
0
        /// <summary>
        /// <ja>�R�s�[���č쐬���܂��B</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src)
        {
            #if !MACRODOC
            _fontName = src._fontName;
            _japaneseFontName = src._japaneseFontName;
            _fontSize = src._fontSize;
            _useClearType = src._useClearType;
            _japaneseFont = _font = null;

            _forecolor = src._forecolor;
            _bgcolor = src._bgcolor;
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
            _bgbrush = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted = false;
            _imageStyle = src.ImageStyle;
            #endif
        }
Example #37
0
		string GetNodeImageUrl (string shape, ImageStyle imageStyle)
		{
			if (ShowLines) {
				if (LineImagesFolder != "")
					return LineImagesFolder + "/" + shape + ".gif";
			} else {
				if (shape == "plus") {
					if (ExpandImageUrl != "")
						return ExpandImageUrl;
					if (imageStyle != null && imageStyle.Expand != null)
						return imageStyle.Expand;
				}
				else if (shape == "minus") {
					if (CollapseImageUrl != "")
						return CollapseImageUrl;
					if (imageStyle != null && imageStyle.Collapse != null)
						return imageStyle.Collapse;
				}
				else if (shape == "noexpand") {
					if (NoExpandImageUrl != "")
						return NoExpandImageUrl;
					if (imageStyle != null && imageStyle.NoExpand != null)
						return imageStyle.NoExpand;
				}
			}
			return AssemblyResourceLoader.GetResourceUrl (typeof(TreeView), "TreeView_" + shape + ".gif");
		}
Example #38
0
        public void Import(ConfigNode data)
        {
            CommonOptions opt = GEnv.Options;
            _fontName = data["font-name"];
            if(_fontName==null) _fontName = opt.FontName;
            _japaneseFontName = data["japanese-font-name"];
            if(_japaneseFontName==null) _japaneseFontName = opt.JapaneseFontName;
            _fontSize = (float)GUtil.ParseInt(data["font-size"], 10);
            _useClearType = GUtil.ParseBool(data["clear-type"], false);
            ClearFont();

            unchecked {
                _forecolor = Color.FromArgb(GUtil.ParseHexInt(data["fore-color"], (int)0xFF000000));
                _bgcolor   = Color.FromArgb(GUtil.ParseHexInt(data["back-color"], (int)0xFFFFFFFF));
            }
            if(_esColorSet==null) _esColorSet = (EscapesequenceColorSet)opt.ESColorSet.Clone();
            _esColorSet.Load(data["color-sequence"]);
            ClearBrush();

            _backgroundImageFileName = data["image-file"];
            _imageLoadIsAttempted = false;
            _imageStyle = (ImageStyle)EnumDescAttribute.For(typeof(ImageStyle)).FromName(data["bg-style"], ImageStyle.Center);
        }
Example #39
0
        private void Init(CommonOptions opt)
        {
            //�N���̍������̂��߁A�t�H���g�̍쐬�͒x���]��
            _fontName = opt.FontName;
            _japaneseFontName = opt.JapaneseFontName;
            _fontSize = opt.FontSize;
            _useClearType = opt.UseClearType;
            _japaneseFont = _font = null;
            _esColorSet = (EscapesequenceColorSet)opt.ESColorSet.Clone();

            _forecolor = opt.TextColor;
            _bgcolor = opt.BGColor;
            _bgbrush = _brush = null;

            _backgroundImageFileName = opt.BackgroundImageFileName;
            _imageLoadIsAttempted = false;
            _imageStyle = opt.ImageStyle;
        }
Example #40
0
        private void DrawBackgroundImage(Graphics g, Image img, ImageStyle style, Rectangle clip)
        {
            int clip_left = clip.Left;
            int clip_top = clip.Top;
            int clip_right = clip.Right;
            int clip_bottom= clip.Bottom;
            if(clip_left < BORDER) clip_left = BORDER;
            if(clip_top  < BORDER) clip_top = BORDER;
            if(clip_right >=this.Width-BORDER)  clip_right  = this.Width-BORDER;
            if(clip_bottom>=this.Height-BORDER) clip_bottom = this.Height-BORDER;
            Rectangle clip2 = new Rectangle(clip_left, clip_top, clip_right-clip_left, clip_bottom-clip_top);

            if(style==ImageStyle.Scaled)
                DrawBackgroundImage_Scaled(g, img, clip2);
            else
                DrawBackgroundImage_Normal(g, img, style, clip2);
        }
 /// <summary>
 /// 背景画像を描画します。
 /// </summary>
 /// <param name="g"></param>
 /// <param name="img"></param>
 /// <param name="style"></param>
 /// <param name="clip"></param>
 private void DrawBackgroundImage(Graphics g, Image img, ImageStyle style, Rectangle clip)
 {
     if (style == ImageStyle.HorizontalFit)
     {
         this.DrawBackgroundImageScaled(g, img, clip, true, false);
     }
     else if (style == ImageStyle.VerticalFit)
     {
         this.DrawBackgroundImageScaled(g, img, clip, false, true);
     }
     else if (style == ImageStyle.Scaled)
     {
         this.DrawBackgroundImageScaled(g, img, clip, true, true);
     }
     else
     {
         DrawBackgroundImageNormal(g, img, style, clip);
     }
 }
Example #42
0
 /// <summary>
 /// Create a special dialog in the style of Windows XP or Vista. A dialog has a custom icon, an optional large
 /// title in the form, body text, window text, and one or two custom-labeled buttons.
 /// </summary>
 /// <param name="titleString">This string will be displayed in the system window frame.</param>
 /// <param name="bigString">This is the first string to appear in the dialog. It will be most prominent.</param>
 /// <param name="smallString">This string appears either under the big string, or is null, which means it is
 /// not displayed at all.</param>
 /// <param name="leftButton">This is the left button, typically the "accept" button--label it with an
 /// action verb (or "OK").</param>
 /// <param name="rightButton">The right button--typically "Cancel", but could be "No".</param>
 /// <param name="iconSet">An image to be displayed on the left side of the dialog. Should be 32 x 32 pixels.</param>
 public static DialogResult ShowDialog(string title, string largeHeading, string smallExplanation,
     string leftButton, string rightButton, Image iconSet, ImageStyle iconDock)
 {
     BetterDialog dlg = new BetterDialog(title, largeHeading, smallExplanation, leftButton,
         rightButton, iconSet, iconDock);
     dlg.Owner = Form1.form;
     return dlg.ShowDialog();
 }
Example #43
0
 /// <summary>
 /// Copies the image style.
 /// </summary>
 /// <param name="sourceImageStyle">The source image style.</param>
 /// <returns></returns>
 private static ImageStyle CopyImageStyle(ImageStyle sourceImageStyle)
 {
     ImageStyle imageStyle = new ImageStyle();
     imageStyle.BackColor = sourceImageStyle.BackColor;
     imageStyle.BackgroundImageUrl = sourceImageStyle.BackgroundImageUrl;
     imageStyle.BackgroundImageVerticalAlignment = sourceImageStyle.BackgroundImageVerticalAlignment;
     imageStyle.BackgroundImageVerticalRepeat = sourceImageStyle.BackgroundImageVerticalRepeat;
     imageStyle.Font.CopyFrom(sourceImageStyle.Font);
     imageStyle.ForeColor = sourceImageStyle.ForeColor;
     imageStyle.LeftImageUrl = sourceImageStyle.LeftImageUrl;
     imageStyle.RightImageUrl = sourceImageStyle.RightImageUrl;
     imageStyle.TextPaddingLeft = sourceImageStyle.TextPaddingLeft;
     imageStyle.TextPaddingTop = sourceImageStyle.TextPaddingTop;
     imageStyle.Width = sourceImageStyle.Width;
     return imageStyle;
 }
 public static MvcHtmlString Image(this HtmlHelper html, string url, ImageStyle style, string id, string alternateText)
 {
     return Image(html, url, style, id, alternateText, null);
 }
 public static MvcHtmlString Image(this HtmlHelper html, string url, ImageStyle style)
 {
     return Image(html, url, style, null, null, null);
 }
Example #46
0
		string GetNodeImageUrl (string shape, ImageStyle imageStyle)
		{
			if (ShowLines) {
				if (!String.IsNullOrEmpty (LineImagesFolder))
					return ResolveClientUrl (LineImagesFolder + "/" + shape + ".gif");
			} else {
				if (imageStyle != null) {
					if (shape == "plus") {
						if (!String.IsNullOrEmpty (imageStyle.Expand))
							return GetNodeIconUrl (imageStyle.Expand);
					} else if (shape == "minus") {
						if (!String.IsNullOrEmpty (imageStyle.Collapse))
							return GetNodeIconUrl (imageStyle.Collapse);
					} else if (shape == "noexpand") {
						if (!String.IsNullOrEmpty (imageStyle.NoExpand))
							return GetNodeIconUrl (imageStyle.NoExpand);
					}
				} else {
					if (shape == "plus") {
						if (!String.IsNullOrEmpty (ExpandImageUrl))
							return ResolveClientUrl (ExpandImageUrl);
					} else if (shape == "minus") {
						if (!String.IsNullOrEmpty (CollapseImageUrl))
							return ResolveClientUrl (CollapseImageUrl);
					} else if (shape == "noexpand") {
						if (!String.IsNullOrEmpty (NoExpandImageUrl))
							return ResolveClientUrl (NoExpandImageUrl);
					}
				}
				if (!String.IsNullOrEmpty (LineImagesFolder))
					return ResolveClientUrl (LineImagesFolder + "/" + shape + ".gif");
			}
			return Page.ClientScript.GetWebResourceUrl (typeof (TreeView), "TreeView_" + shape + ".gif");
		}
Example #47
0
 public MvcHtmlString Image(string source, string alt = "", ImageStyle type = ImageStyle.Thumbnail)
 {
     var builder = new TagBuilder("img");
     builder.MergeAttribute("class", "img-" + type.ToString().ToLower());
     builder.MergeAttribute("src", source);
     if (string.IsNullOrWhiteSpace(alt))
     {
         builder.MergeAttribute("alt", type.ToString() + " image");
     }
     else
     {
         builder.MergeAttribute("alt", alt);
     }
     return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
 }
Example #48
0
        private void DrawBackgroundImage_Normal(Graphics g, Image img, ImageStyle style, Rectangle clip)
        {
            int offset_x, offset_y;
            if(style==ImageStyle.Center) {
                offset_x = (this.Width-_VScrollBar.Width - img.Width) / 2;
                offset_y = (this.Height - img.Height) / 2;
            }
            else {
                offset_x = (style==ImageStyle.TopLeft || style==ImageStyle.BottomLeft)? BORDER : this.Width - _VScrollBar.Width - img.Width;
                offset_y = (style==ImageStyle.TopLeft || style==ImageStyle.TopRight)? BORDER : this.Height - img.Height - BORDER;
            }
            //if(offset_x < BORDER) offset_x = BORDER;
            //if(offset_y < BORDER) offset_y = BORDER;

            //�摜��̃R�s�[�J�n���W
            Rectangle target = Rectangle.Intersect(new Rectangle(clip.Left-offset_x, clip.Top-offset_y, clip.Width, clip.Height), new Rectangle(0,0,img.Width,img.Height));
            if(target!=Rectangle.Empty)
                g.DrawImage(img, new Rectangle(target.Left + offset_x, target.Top + offset_y, target.Width, target.Height), target, GraphicsUnit.Pixel);
        }
        /// <summary>
        /// 背景画像を指定の位置に描画します。
        /// </summary>
        /// <param name="g"></param>
        /// <param name="image"></param>
        /// <param name="style"></param>
        /// <param name="clip"></param>
        private void DrawBackgroundImageNormal(Graphics g, Image image, ImageStyle style,
            Rectangle clip)
        {
            int offsetX, offsetY;
            if (style == ImageStyle.Center)
            {
                offsetX = (this.Width - image.Width) / 2;
                offsetY = (this.Height - image.Height) / 2;
            }
            else
            {
                offsetX = (style == ImageStyle.TopLeft || style == ImageStyle.BottomLeft)
                    ? 0 : (this.ClientSize.Width - image.Width);
                offsetY = (style == ImageStyle.TopLeft || style == ImageStyle.TopRight)
                    ? 0 : (this.ClientSize.Height - image.Height);
            }

            Rectangle target = Rectangle.Intersect(
                new Rectangle(clip.Left - offsetX, clip.Top - offsetY, clip.Width, clip.Height),
                new Rectangle(0, 0, image.Width, image.Height));
            if (target != Rectangle.Empty)
            {
                g.DrawImage(image, new Rectangle(
                    target.Left + offsetX, target.Top + offsetY, target.Width, target.Height),
                    target, GraphicsUnit.Pixel);
            }
        }
Example #50
0
        /// <summary>
        /// The private constructor. This is only called by the static method ShowDialog.
        /// </summary>
        public BetterDialog(string title, string largeHeading, string smallExplanation,
            string leftButton, string rightButton, Image iconSet, ImageStyle iconDock)
        {
            this.Font = SystemFonts.MessageBoxFont;
            this.ForeColor = SystemColors.WindowText;

            InitializeComponent();
            Form1.form.WindowState = FormWindowState.Normal;
            this.WindowState = Form1.form.WindowState;
            this.TopMost = Form1.form.TopMost;

            if (iconDock == ImageStyle.Icon)
                this.pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            else
                this.pictureBox1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left;

            // set our width and height to these values (redundant, but who cares?)
            this.Width = 350;

            using (Graphics graphics = this.CreateGraphics())
            {
                SizeF smallSize;
                SizeF bigSize;

                if (string.IsNullOrEmpty(smallExplanation) == false)
                {
                    if (SystemFonts.MessageBoxFont.FontFamily.Name == "Segoe UI")
                    {
                        // use the special, windows-vista font style if we are running vista (using Segoe UI).
                        label1.ForeColor = Color.FromArgb(0, 51, 153); // [ColorTranslator.FromHtml("#003399")]
                        label1.Font = new Font("Segoe UI", 12.0f, FontStyle.Regular, GraphicsUnit.Point);

                        // bigger for vista/aero
                        this.Width += 50;

                        label1.Width += 50;
                        label2.Width += 50;

                        smallSize = graphics.MeasureString(smallExplanation, this.Font, this.label2.Width);
                        bigSize = graphics.MeasureString(largeHeading, label1.Font, this.label1.Width);
                    }
                    else
                    {
                        // might want to special case the old, MS Sans Serif font.
                        // use the regular font but bold it for XP, etc.
                        label1.Font = new Font(SystemFonts.MessageBoxFont.FontFamily.Name, 8.0f,
                            FontStyle.Bold, GraphicsUnit.Point);

                        smallSize = graphics.MeasureString(smallExplanation, this.Font, this.label2.Width);
                        bigSize = graphics.MeasureString(largeHeading, label1.Font, this.label1.Width);

                        // set our height according to the small string
                        this.Height = (int)smallSize.Height + 166; // went from 164 to 168 to improve bottom space on XP.
                        // removed 2 pixels for XP
                    }

                    // modify our width (clean this up a bit) based on the longest text's width
                    double bigger = (smallSize.Width > bigSize.Width) ? smallSize.Width : bigSize.Width;
                    this.Width = (int)bigger + 100;
                }
                else
                {
                    // do layout for a single-message dialog
                    // reduce size for plain dialog
                    this.Width -= 20;

                    // this is our text's dimensions
                    bigSize = graphics.MeasureString(largeHeading, label1.Font, label1.Width);

                    // remove the top margin from the label (everything is vertically centered)
                    label1.Margin = new Padding(label1.Margin.Left, 0, label1.Margin.Right, label1.Margin.Bottom);

                    // modify our width (clean this up a bit) based on text's physical width
                    this.Width = (int)bigSize.Width + 100;

                    this.Height -= tableLayoutPanel2.Height;
                }
            }

            // expand to be at least 260 pixels
            if (this.Width < 260)
            {
                this.Width = 260;
            }

            // set our text
            this.Text = title;
            label1.Text = largeHeading;
            label2.Text = string.IsNullOrEmpty(smallExplanation) ? string.Empty : smallExplanation;

            // setup our left button (optional)
            if (string.IsNullOrEmpty(leftButton) == false)
            {
                // if we have the button, we are fine
                this.buttonLeft.Text = leftButton;
            }
            else
            {
                // move settings to right button if we don't have the left button
                this.AcceptButton = buttonRight;
                this.buttonLeft.Visible = false;
            }

            // this button must always be present
            this.buttonRight.Text = rightButton;
            pictureBox1.Image = iconSet;

            buttonLeft.Focus();
        }