Пример #1
0
 public void Apply(StyleOption opt)
 {
     foreach (KeyValuePair <string, object> pair in _variants)
     {
         System.Type type = opt.GetType();
         System.Reflection.PropertyInfo prop = type.GetProperty(pair.Key);
         prop.SetValue(opt, pair.Value, null);
     }
 }
 public void Apply(StyleOption opt)
 {
     foreach (var pair in _variants)
     {
         var type = opt.GetType();
         var prop = type.GetProperty(pair.Key);
         prop.SetValue(opt, pair.Value, null);
     }
 }
Пример #3
0
 public void Apply(StyleOption opt)
 {
     foreach (var pair in _variants)
     {
         var type = opt.GetType();
         var prop = type.GetProperty(pair.Key);
         prop.SetValue(opt, pair.Value, null);
     }
 }
        /// <summary>
        /// embed style information into the image shapes,
        /// and then return a list of shape in which
        /// index-0 is the original image
        /// index-1 is the cropped image
        /// </summary>
        /// <param name="originalImageFile"></param>
        /// <param name="croppedImageFile"></param>
        /// <param name="imageContext"></param>
        /// <param name="imageSource"></param>
        /// <param name="rect"></param>
        /// <param name="opt"></param>
        /// <returns></returns>
        public List<PowerPoint.Shape> EmbedStyleOptionsInformation(string originalImageFile, string croppedImageFile,
            string imageContext, string imageSource, Rect rect, StyleOption opt)
        {
            if (originalImageFile == null) return new List<PowerPoint.Shape>();

            var originalImage = AddPicture(originalImageFile, EffectName.Original_DO_NOT_REMOVE);
            var slideWidth = SlideWidth;
            var slideHeight = SlideHeight;
            FitToSlide.AutoFit(originalImage, slideWidth, slideHeight);
            originalImage.Visible = MsoTriState.msoFalse;

            var croppedImage = AddPicture(croppedImageFile, EffectName.Cropped_DO_NOT_REMOVE);
            FitToSlide.AutoFit(croppedImage, slideWidth, slideHeight);
            croppedImage.Visible = MsoTriState.msoFalse;

            var result = new List<PowerPoint.Shape>();
            result.Add(originalImage);
            result.Add(croppedImage);

            // store source image info
            AddTag(originalImage, Tag.ReloadOriginImg, originalImageFile);
            AddTag(originalImage, Tag.ReloadCroppedImg, croppedImageFile);
            AddTag(originalImage, Tag.ReloadImgContext, imageContext);
            AddTag(originalImage, Tag.ReloadImgSource, imageSource);
            AddTag(originalImage, Tag.ReloadRectX, rect.X.ToString(CultureInfo.InvariantCulture));
            AddTag(originalImage, Tag.ReloadRectY, rect.Y.ToString(CultureInfo.InvariantCulture));
            AddTag(originalImage, Tag.ReloadRectWidth, rect.Width.ToString(CultureInfo.InvariantCulture));
            AddTag(originalImage, Tag.ReloadRectHeight, rect.Height.ToString(CultureInfo.InvariantCulture));

            // store style info
            var type = opt.GetType();
            var props = type.GetProperties();
            foreach (var propertyInfo in props)
            {
                try
                {
                    AddTag(originalImage, Tag.ReloadPrefix + propertyInfo.Name,
                        propertyInfo.GetValue(opt, null).ToString());
                }
                catch (Exception e)
                {
                    Logger.LogException(e, "EmbedStyleOptionsInformation");
                }
            }
            return result;
        }
        /// <summary>
        /// return true, when applying variant to this style options has no effect (still same)
        /// </summary>
        /// <param name="opt"></param>
        public bool IsNoEffect(StyleOption opt)
        {
            foreach (var pair in _variants)
            {
                if (pair.Key.Equals("OptionName") || pair.Value is bool)
                {
                    continue;
                }

                var type = opt.GetType();
                var prop = type.GetProperty(pair.Key);
                var optValue = prop.GetValue(opt, null);
                if (!pair.Value.Equals(optValue))
                {
                    return false;
                }
            }
            return true;
        }
 /// <summary>
 /// Copy corresponding variant info from the given style
 /// </summary>
 public StyleVariant Copy(StyleOption opt, string givenOptionName = null)
 {
     var newVariants = new Dictionary<string, object>();
     foreach (var pair in _variants)
     {
         if (pair.Key.Equals("OptionName"))
         {
             newVariants["OptionName"] = givenOptionName ?? "Reloaded";
         }
         else
         {
             var type = opt.GetType();
             var prop = type.GetProperty(pair.Key);
             var optValue = prop.GetValue(opt, null);
             newVariants[pair.Key] = optValue;
         }
     }
     return new StyleVariant(newVariants);
 }
Пример #7
0
        /// <summary>
        /// return true, when applying variant to this style options has no effect (still same)
        /// </summary>
        /// <param name="opt"></param>
        public bool IsNoEffect(StyleOption opt)
        {
            foreach (KeyValuePair <string, object> pair in _variants)
            {
                if (pair.Key.Equals("OptionName") || pair.Value is bool)
                {
                    continue;
                }

                System.Type type = opt.GetType();
                System.Reflection.PropertyInfo prop = type.GetProperty(pair.Key);
                object optValue = prop.GetValue(opt, null);
                if (!pair.Value.Equals(optValue))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #8
0
        /// <summary>
        /// return true, when applying variant to this style options has no effect (still same)
        /// </summary>
        /// <param name="opt"></param>
        public bool IsNoEffect(StyleOption opt)
        {
            foreach (var pair in _variants)
            {
                if (pair.Key.Equals("OptionName") || pair.Value is bool)
                {
                    continue;
                }

                var type     = opt.GetType();
                var prop     = type.GetProperty(pair.Key);
                var optValue = prop.GetValue(opt, null);
                if (!pair.Value.Equals(optValue))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #9
0
        /// <summary>
        /// Copy corresponding variant info from the given style
        /// </summary>
        public StyleVariant Copy(StyleOption opt, string givenOptionName = null)
        {
            Dictionary <string, object> newVariants = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> pair in _variants)
            {
                if (pair.Key.Equals("OptionName"))
                {
                    newVariants["OptionName"] = givenOptionName ?? "Reloaded";
                }
                else
                {
                    System.Type type = opt.GetType();
                    System.Reflection.PropertyInfo prop = type.GetProperty(pair.Key);
                    object optValue = prop.GetValue(opt, null);
                    newVariants[pair.Key] = optValue;
                }
            }
            return(new StyleVariant(newVariants));
        }
Пример #10
0
        /// <summary>
        /// Copy corresponding variant info from the given style
        /// </summary>
        public StyleVariant Copy(StyleOption opt, string givenOptionName = null)
        {
            var newVariants = new Dictionary <string, object>();

            foreach (var pair in _variants)
            {
                if (pair.Key.Equals("OptionName"))
                {
                    newVariants["OptionName"] = givenOptionName ?? "Reloaded";
                }
                else
                {
                    var type     = opt.GetType();
                    var prop     = type.GetProperty(pair.Key);
                    var optValue = prop.GetValue(opt, null);
                    newVariants[pair.Key] = optValue;
                }
            }
            return(new StyleVariant(newVariants));
        }
 private StyleOption ConstructStyleFromShapeInfo(Shape shape)
 {
     var opt = new StyleOption();
     var props = opt.GetType().GetProperties();
     foreach (var propertyInfo in props)
     {
         var valueInStr = shape.Tags[Service.Effect.Tag.ReloadPrefix + propertyInfo.Name];
         if (propertyInfo.PropertyType == typeof(string))
         {
             propertyInfo.SetValue(opt, valueInStr, null);
         }
         else if (propertyInfo.PropertyType == typeof(int))
         {
             var valueInInt = int.Parse(valueInStr);
             propertyInfo.SetValue(opt, valueInInt, null);
         }
         else if (propertyInfo.PropertyType == typeof(bool))
         {
             var valueInBool = bool.Parse(valueInStr);
             propertyInfo.SetValue(opt, valueInBool, null);
         }
     }
     return opt;
 }