예제 #1
0
        private void ApplyImageDecorator(ImageDecorator decorator, Bitmap bitmap, ref bool borderNeedsReset)
        {
            if (_embedType != ImageEmbedType.Embedded &&
                (decorator.IsBorderDecorator || decorator.Id == TiltDecorator.Id))
            {
                return;
            }

            if (borderNeedsReset &&
                _embedType == ImageEmbedType.Embedded &&
                (decorator.IsBorderDecorator || decorator.Id == TiltDecorator.Id))
            {
                borderNeedsReset = false;
                //BorderMargin = ImageBorderMargin.Empty;
            }

            try
            {
                using (ApplicationPerformance.LogEvent("ApplyDecorator: " + decorator.DecoratorName))
                    using (new WaitCursor())
                    {
                        _currImage    = bitmap;
                        _currSettings = _decoratorsList.GetImageDecoratorSettings(decorator);
                        decorator.Decorate(this);
                    }
            }
            catch (Exception e)
            {
                Trace.Fail(String.Format(CultureInfo.InvariantCulture, "Failed to apply image decorator [{0}]: {1}", decorator.DecoratorName, e.ToString()));
            }
        }
예제 #2
0
        void imageEffectsGalleryCommand_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
        {
            ImageEffectsGalleryCommand galleryCommand = (ImageEffectsGalleryCommand)sender;
            int            newSelectedIndex           = args.GetInt(galleryCommand.CommandId.ToString());
            string         newDecoratorId             = galleryCommand.Items[newSelectedIndex].Cookie;
            ImageDecorator newDecorator = _imageEditingContext.DecoratorsManager.GetImageDecorator(newDecoratorId);

            Debug.Assert(newDecorator != null);

            if (galleryCommand.SelectedItem != newDecorator.Id)
            {
                ImagePropertiesInfo.ImageDecorators.AddDecorator(newDecorator);

                if (!ImagePropertiesInfo.IsEditableEmbeddedImage())
                {
                    // If this is a web image, calling ApplyImageDecorations will keep properties up to date but won't
                    // actually do any decorating, so do it manually. Only borders should be manually decorated.
                    SimpleImageDecoratorContext context = new SimpleImageDecoratorContext(ImagePropertiesInfo);
                    newDecorator.Decorate(context);
                }

                ApplyImageDecorations();
            }
        }
        private void ApplyImageDecorator(ImageDecorator decorator, Bitmap bitmap, ref bool borderNeedsReset)
        {
            if (_embedType != ImageEmbedType.Embedded
                && (decorator.IsBorderDecorator || decorator.Id == TiltDecorator.Id))
            {
                return;
            }

            if (borderNeedsReset
                && _embedType == ImageEmbedType.Embedded
                && (decorator.IsBorderDecorator || decorator.Id == TiltDecorator.Id))
            {
                borderNeedsReset = false;
                //BorderMargin = ImageBorderMargin.Empty;
            }

            try
            {
                using (ApplicationPerformance.LogEvent("ApplyDecorator: " + decorator.DecoratorName))
                using (new WaitCursor())
                {
                    _currImage = bitmap;
                    _currSettings = _decoratorsList.GetImageDecoratorSettings(decorator);
                    decorator.Decorate(this);
                }
            }
            catch (Exception e)
            {
                Trace.Fail(String.Format(CultureInfo.InvariantCulture, "Failed to apply image decorator [{0}]: {1}", decorator.DecoratorName, e.ToString()));
            }
        }