public DropShadowSettingsForm(DropShadowEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon = GreenshotResources.getGreenshotIcon();
     ShowSettings();
 }
 public DropShadowSettingsForm(DropShadowEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon = GreenshotResources.getGreenshotIcon();
     trackBar1.Value = (int)(effect.Darkness * 40);
     offsetX.Value = effect.ShadowOffset.X;
     offsetY.Value = effect.ShadowOffset.Y;
 }
示例#3
0
        private void ApplyDropShadowEffectValues(string valuesString, DropShadowEffect effect)
        {
            string[] values = valuesString.Split('|');
            foreach (string nameValuePair in values)
            {
                string[] pair = nameValuePair.Split(':');
                switch (pair[0])
                {
                case "Darkness":
                    float darkness;
                    // Fix to prevent BUG-1753
                    if (pair[1] != null && float.TryParse(pair[1], NumberStyles.Float, numberFormatInfo, out darkness))
                    {
                        if (darkness <= 1.0)
                        {
                            effect.Darkness = darkness;
                        }
                    }
                    break;

                case "ShadowSize":
                    int shadowSize;
                    if (int.TryParse(pair[1], out shadowSize))
                    {
                        effect.ShadowSize = shadowSize;
                    }
                    break;

                case "ShadowOffset":
                    Point    shadowOffset = new Point();
                    int      shadowOffsetX;
                    int      shadowOffsetY;
                    string[] coordinates = pair[1].Split(',');
                    if (int.TryParse(coordinates[0], out shadowOffsetX))
                    {
                        shadowOffset.X = shadowOffsetX;
                    }
                    if (int.TryParse(coordinates[1], out shadowOffsetY))
                    {
                        shadowOffset.Y = shadowOffsetY;
                    }
                    effect.ShadowOffset = shadowOffset;
                    break;
                }
            }
        }
示例#4
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     // to string
     if (destinationType == typeof(string))
     {
         StringBuilder sb = new StringBuilder();
         if (value.GetType() == typeof(DropShadowEffect))
         {
             DropShadowEffect effect = value as DropShadowEffect;
             RetrieveDropShadowEffectValues(effect, sb);
             return(sb.ToString());
         }
         if (value.GetType() == typeof(TornEdgeEffect))
         {
             TornEdgeEffect effect = value as TornEdgeEffect;
             RetrieveDropShadowEffectValues(effect, sb);
             sb.Append("|");
             RetrieveTornEdgeEffectValues(effect, sb);
             return(sb.ToString());
         }
     }
     // from string
     if (value is string)
     {
         string settings = value as string;
         if (destinationType == typeof(DropShadowEffect))
         {
             DropShadowEffect effect = new DropShadowEffect();
             ApplyDropShadowEffectValues(settings, effect);
             return(effect);
         }
         if (destinationType == typeof(TornEdgeEffect))
         {
             TornEdgeEffect effect = new TornEdgeEffect();
             ApplyDropShadowEffectValues(settings, effect);
             ApplyTornEdgeEffectValues(settings, effect);
             return(effect);
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
示例#5
0
 private void RetrieveDropShadowEffectValues(DropShadowEffect effect, StringBuilder sb)
 {
     // Fix to prevent BUG-1753 is to use the numberFormatInfo
     sb.AppendFormat("Darkness:{0}|ShadowSize:{1}|ShadowOffset:{2},{3}", effect.Darkness.ToString("F2", numberFormatInfo), effect.ShadowSize, effect.ShadowOffset.X, effect.ShadowOffset.Y);
 }
 /// <summary>
 /// This is used when the dropshadow button is used
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddDropshadowToolStripMenuItemClick(object sender, EventArgs e)
 {
     DropShadowEffect dropShadowEffect = new DropShadowEffect();
     // TODO: Use the dropshadow settings form to make it possible to change the default values
     //DialogResult result = new DropShadowSettingsForm(dropShadowEffect).ShowDialog(this);
     //if (result == DialogResult.OK) {
     surface.ApplyBitmapEffect(dropShadowEffect);
     updateUndoRedoSurfaceDependencies();
     //}
 }
示例#7
0
 /// <summary>
 /// This is used when the dropshadow button is used
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddDropshadowToolStripMenuItemClick(object sender, EventArgs e)
 {
     DropShadowEffect dropShadowEffect = new DropShadowEffect();
     //DialogResult result = new DropShadowSettingsForm(dropShadowEffect).ShowDialog(this);
     //if (result == DialogResult.OK) {
     surface.ApplyBitmapEffect(dropShadowEffect);
     updateUndoRedoSurfaceDependencies();
     //}
 }
示例#8
0
 private void RetrieveDropShadowEffectValues(DropShadowEffect effect, StringBuilder sb)
 {
     // Fix to prevent BUG-1753 is to use the numberFormatInfo
     sb.AppendFormat("Darkness:{0}|ShadowSize:{1}|ShadowOffset:{2},{3}", effect.Darkness.ToString("F2", numberFormatInfo), effect.ShadowSize, effect.ShadowOffset.X, effect.ShadowOffset.Y);
 }
示例#9
0
 private void ApplyDropShadowEffectValues(string valuesString, DropShadowEffect effect)
 {
     string[] values = valuesString.Split('|');
     foreach (string nameValuePair in values)
     {
         string[] pair = nameValuePair.Split(':');
         switch (pair[0])
         {
             case "Darkness":
                 float darkness;
                 // Fix to prevent BUG-1753
                 if (pair[1] != null && float.TryParse(pair[1], NumberStyles.Float, numberFormatInfo, out darkness))
                 {
                     if (darkness <= 1.0)
                     {
                         effect.Darkness = darkness;
                     }
                 }
                 break;
             case "ShadowSize":
                 int shadowSize;
                 if (int.TryParse(pair[1], out shadowSize))
                 {
                     effect.ShadowSize = shadowSize;
                 }
                 break;
             case "ShadowOffset":
                 Point shadowOffset = new Point();
                 int shadowOffsetX;
                 int shadowOffsetY;
                 string[] coordinates = pair[1].Split(',');
                 if (int.TryParse(coordinates[0], out shadowOffsetX))
                 {
                     shadowOffset.X = shadowOffsetX;
                 }
                 if (int.TryParse(coordinates[1], out shadowOffsetY))
                 {
                     shadowOffset.Y = shadowOffsetY;
                 }
                 effect.ShadowOffset = shadowOffset;
                 break;
         }
     }
 }
示例#10
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     // to string
     if (destinationType == typeof(string))
     {
         StringBuilder sb = new StringBuilder();
         if (value.GetType() == typeof(DropShadowEffect))
         {
             DropShadowEffect effect = value as DropShadowEffect;
             RetrieveDropShadowEffectValues(effect, sb);
             return sb.ToString();
         }
         if (value.GetType() == typeof(TornEdgeEffect))
         {
             TornEdgeEffect effect = value as TornEdgeEffect;
             RetrieveDropShadowEffectValues(effect, sb);
             sb.Append("|");
             RetrieveTornEdgeEffectValues(effect, sb);
             return sb.ToString();
         }
     }
     // from string
     if (value is string)
     {
         string settings = value as string;
         if (destinationType == typeof(DropShadowEffect))
         {
             DropShadowEffect effect = new DropShadowEffect();
             ApplyDropShadowEffectValues(settings, effect);
             return effect;
         }
         if (destinationType == typeof(TornEdgeEffect))
         {
             TornEdgeEffect effect = new TornEdgeEffect();
             ApplyDropShadowEffectValues(settings, effect);
             ApplyTornEdgeEffectValues(settings, effect);
             return effect;
         }
     }
     return base.ConvertTo(context, culture, value, destinationType);
 }
示例#11
0
		public DropShadowSettingsForm(DropShadowEffect effect) {
			this.effect = effect;
			InitializeComponent();
			ShowSettings();
		}