public void InitializeDefaultLocalizer (IAddinLocalizer localizer) { if (localizer != null) defaultLocalizer = new AddinLocalizer (localizer); else defaultLocalizer = null; }
/// <summary> /// Helper function for the above methods. The IAddinLocalizer provides a generic way to /// get translated strings both for Pinta's effects and for effect add-ins. /// </summary> private static bool LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) { if (effect == null) throw new ArgumentNullException ("effect"); if (effect.EffectData == null) throw new ArgumentException ("effect.EffectData is null."); var dialog = new SimpleEffectDialog (effect.Name, PintaCore.Resources.GetIcon (effect.Icon), effect.EffectData, localizer); // Hookup event handling for live preview. dialog.EffectDataChanged += (o, e) => { if (effect.EffectData != null) effect.EffectData.FirePropertyChanged (e.PropertyName); }; int response = dialog.Run (); bool ret = false; if (response == (int)Gtk.ResponseType.Ok && effect.EffectData != null) ret = !effect.EffectData.IsDefault; dialog.Destroy (); return ret; }
/// <summary> /// Helper function for the above methods. The IAddinLocalizer provides a generic way to /// get translated strings both for Pinta's effects and for effect add-ins. /// </summary> private static bool LaunchSimpleEffectDialog(BaseEffect effect, IAddinLocalizer localizer) { if (effect == null) { throw new ArgumentNullException("effect"); } if (effect.EffectData == null) { throw new ArgumentException("effect.EffectData is null."); } using (var dialog = new SimpleEffectDialog(effect.Name, PintaCore.Resources.GetIcon(effect.Icon), effect.EffectData, localizer)) { // Hookup event handling for live preview. dialog.EffectDataChanged += (o, e) => { if (effect.EffectData != null) { effect.EffectData.FirePropertyChanged(e.PropertyName); } }; int response = dialog.Run(); bool ret = false; if (response == (int)Gtk.ResponseType.Ok && effect.EffectData != null) { ret = !effect.EffectData.IsDefault; } return(ret); } }
private void BuildDialog (IAddinLocalizer localizer) { var members = EffectData.GetType ().GetMembers (); foreach (var mi in members) { Type mType = GetTypeForMember (mi); if (mType == null) continue; string caption = null; string hint = null; bool skip = false; bool combo = false; object[] attrs = mi.GetCustomAttributes (false); foreach (var attr in attrs) { if (attr is SkipAttribute) skip = true; else if (attr is CaptionAttribute) caption = ((CaptionAttribute)attr).Caption; else if (attr is HintAttribute) hint = ((HintAttribute)attr).Hint; else if (attr is StaticListAttribute) combo = true; } if (skip || string.Compare (mi.Name, "IsDefault", true) == 0) continue; if (caption == null) caption = MakeCaption (mi.Name); if (mType == typeof (int) && (caption == "Seed")) AddWidget (CreateSeed (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (int)) AddWidget (CreateSlider (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (double) && (caption == "Angle" || caption == "Rotation")) AddWidget (CreateAnglePicker (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (double)) AddWidget (CreateDoubleSlider (localizer.GetString (caption), EffectData, mi, attrs)); else if (combo && mType == typeof (string)) AddWidget (CreateComboBox (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (bool)) AddWidget (CreateCheckBox (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (Gdk.Point)) AddWidget (CreatePointPicker (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType == typeof (Cairo.PointD)) AddWidget (CreateOffsetPicker (localizer.GetString (caption), EffectData, mi, attrs)); else if (mType.IsEnum) AddWidget (CreateEnumComboBox (localizer.GetString (caption), EffectData, mi, attrs)); if (hint != null) AddWidget (CreateHintLabel (localizer.GetString (hint))); } }
public void InitializeDefaultLocalizer(IAddinLocalizer localizer) { if (localizer != null) { defaultLocalizer = new AddinLocalizer(localizer); } else { defaultLocalizer = null; } }
/// <summary> /// Sets the default localizer to be used for this add-in engine /// </summary> /// <param name="localizer"> /// The add-in localizer /// </param> public void InitializeDefaultLocalizer(IAddinLocalizer localizer) { CheckInitialized(); lock (LocalLock) { if (localizer != null) { defaultLocalizer = new AddinLocalizer(localizer); } else { defaultLocalizer = null; } } }
/// Since this dialog is used by add-ins, the IAddinLocalizer allows for translations to be /// fetched from the appropriate place. /// </param> public SimpleEffectDialog(string title, Gdk.Pixbuf icon, object effectData, IAddinLocalizer localizer) : base(title, Core.PintaCore.Chrome.MainWindow, Gtk.DialogFlags.Modal, Core.GtkExtensions.DialogButtonsCancelOk()) { Icon = icon; EffectData = effectData; BorderWidth = 6; ContentArea.Spacing = 12; WidthRequest = 400; Resizable = false; DefaultResponse = Gtk.ResponseType.Ok; BuildDialog(localizer); }
/// Since this dialog is used by add-ins, the IAddinLocalizer allows for translations to be /// fetched from the appropriate place. /// </param> public SimpleEffectDialog(string title, Gdk.Pixbuf icon, object effectData, IAddinLocalizer localizer) : base(title, Pinta.Core.PintaCore.Chrome.MainWindow, Gtk.DialogFlags.Modal, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Ok, Gtk.ResponseType.Ok) { Icon = icon; EffectData = effectData; BorderWidth = 6; VBox.Spacing = 12; WidthRequest = 400; Resizable = false; DefaultResponse = Gtk.ResponseType.Ok; AlternativeButtonOrder = new int[] { (int)Gtk.ResponseType.Ok, (int)Gtk.ResponseType.Cancel }; BuildDialog(localizer); }
/// Since this dialog is used by add-ins, the IAddinLocalizer allows for translations to be /// fetched from the appropriate place. /// </param> public SimpleEffectDialog (string title, Gdk.Pixbuf icon, object effectData, IAddinLocalizer localizer) : base (title, Pinta.Core.PintaCore.Chrome.MainWindow, Gtk.DialogFlags.Modal, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Ok, Gtk.ResponseType.Ok) { Icon = icon; EffectData = effectData; BorderWidth = 6; VBox.Spacing = 12; WidthRequest = 400; Resizable = false; DefaultResponse = Gtk.ResponseType.Ok; AlternativeButtonOrder = new int[] { (int)Gtk.ResponseType.Ok, (int)Gtk.ResponseType.Cancel }; BuildDialog (localizer); }
internal AddinLocalizer (IAddinLocalizer localizer) { this.localizer = localizer; pluralLocalizer = localizer as IPluralAddinLocalizer; }
/// <summary> /// Sets the default localizer to be used for this add-in engine /// </summary> /// <param name="localizer"> /// The add-in localizer /// </param> public static void InitializeDefaultLocalizer(IAddinLocalizer localizer) { AddinEngine.InitializeDefaultLocalizer(localizer); }
private void BuildDialog(IAddinLocalizer localizer) { var members = EffectData.GetType().GetMembers(); foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) { continue; } string caption = null; string hint = null; bool skip = false; bool combo = false; object[] attrs = mi.GetCustomAttributes(false); foreach (var attr in attrs) { if (attr is SkipAttribute) { skip = true; } else if (attr is CaptionAttribute) { caption = ((CaptionAttribute)attr).Caption; } else if (attr is HintAttribute) { hint = ((HintAttribute)attr).Hint; } else if (attr is StaticListAttribute) { combo = true; } } if (skip || string.Compare(mi.Name, "IsDefault", true) == 0) { continue; } if (caption == null) { caption = MakeCaption(mi.Name); } if (mType == typeof(int) && (caption == "Seed")) { AddWidget(CreateSeed(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(int)) { AddWidget(CreateSlider(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(double) && (caption == "Angle" || caption == "Rotation")) { AddWidget(CreateAnglePicker(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(double)) { AddWidget(CreateDoubleSlider(localizer.GetString(caption), EffectData, mi, attrs)); } else if (combo && mType == typeof(string)) { AddWidget(CreateComboBox(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(bool)) { AddWidget(CreateCheckBox(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(Gdk.Point)) { AddWidget(CreatePointPicker(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType == typeof(Cairo.PointD)) { AddWidget(CreateOffsetPicker(localizer.GetString(caption), EffectData, mi, attrs)); } else if (mType.IsEnum) { AddWidget(CreateEnumComboBox(localizer.GetString(caption), EffectData, mi, attrs)); } if (hint != null) { AddWidget(CreateHintLabel(localizer.GetString(hint))); } } }
/// <summary> /// Sets the default localizer to be used for this add-in engine /// </summary> /// <param name="localizer"> /// The add-in localizer /// </param> public void InitializeDefaultLocalizer (IAddinLocalizer localizer) { CheckInitialized (); lock (LocalLock) { if (localizer != null) defaultLocalizer = new AddinLocalizer (localizer); else defaultLocalizer = null; } }
public static void InitializeDefaultLocalizer (IAddinLocalizer localizer) { CheckInitialized (); SessionService.InitializeDefaultLocalizer (localizer); }
public static void InitializeDefaultLocalizer(IAddinLocalizer localizer) { CheckInitialized(); SessionService.InitializeDefaultLocalizer(localizer); }