コード例 #1
0
		public void InitializeDefaultLocalizer (IAddinLocalizer localizer)
		{
			if (localizer != null)
				defaultLocalizer = new AddinLocalizer (localizer);
			else
				defaultLocalizer = null;
		}
コード例 #2
0
ファイル: EffectHelper.cs プロジェクト: msiyer/Pinta
		/// <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;
		}
コード例 #3
0
ファイル: EffectHelper.cs プロジェクト: mfcallahan/Pinta
        /// <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);
            }
        }
コード例 #4
0
ファイル: SimpleEffectDialog.cs プロジェクト: msiyer/Pinta
		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)));
			}
		}
コード例 #5
0
 public void InitializeDefaultLocalizer(IAddinLocalizer localizer)
 {
     if (localizer != null)
     {
         defaultLocalizer = new AddinLocalizer(localizer);
     }
     else
     {
         defaultLocalizer = null;
     }
 }
コード例 #6
0
ファイル: AddinEngine.cs プロジェクト: erikbra/nunit
 /// <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;
         }
     }
 }
コード例 #7
0
        /// 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);
        }
コード例 #8
0
        /// 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);
        }
コード例 #9
0
ファイル: SimpleEffectDialog.cs プロジェクト: msiyer/Pinta
		/// 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);
		}
コード例 #10
0
		internal AddinLocalizer (IAddinLocalizer localizer)
		{
			this.localizer = localizer;
			pluralLocalizer = localizer as IPluralAddinLocalizer;
		}
コード例 #11
0
ファイル: AddinManager.cs プロジェクト: wsalik/mono-addins
 /// <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);
 }
コード例 #12
0
        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)));
                }
            }
        }
コード例 #13
0
		internal AddinLocalizer (IAddinLocalizer localizer)
		{
			this.localizer = localizer;
			pluralLocalizer = localizer as IPluralAddinLocalizer;
		}
コード例 #14
0
ファイル: AddinEngine.cs プロジェクト: wanglehui/mono-addins
		/// <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;
			}
		}
コード例 #15
0
		public static void InitializeDefaultLocalizer (IAddinLocalizer localizer)
		{
			CheckInitialized ();
			SessionService.InitializeDefaultLocalizer (localizer);
		}
コード例 #16
0
 public static void InitializeDefaultLocalizer(IAddinLocalizer localizer)
 {
     CheckInitialized();
     SessionService.InitializeDefaultLocalizer(localizer);
 }