mirror of
https://github.com/greenshot/greenshot.git
synced 2025-01-10 15:52:48 -08:00
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Windows;
|
|
|
|
namespace TranslationByMarkupExtension
|
|
{
|
|
public class LanguageChangedEventManager : WeakEventManager
|
|
{
|
|
public static void AddListener(TranslationManager source, IWeakEventListener listener)
|
|
{
|
|
CurrentManager.ProtectedAddListener(source, listener);
|
|
}
|
|
|
|
public static void RemoveListener(TranslationManager source, IWeakEventListener listener)
|
|
{
|
|
CurrentManager.ProtectedRemoveListener(source, listener);
|
|
}
|
|
|
|
private void OnLanguageChanged(object sender, EventArgs e)
|
|
{
|
|
DeliverEvent(sender, e);
|
|
}
|
|
|
|
protected override void StartListening(object source)
|
|
{
|
|
var manager = (TranslationManager)source;
|
|
manager.LanguageChanged += OnLanguageChanged;
|
|
}
|
|
|
|
protected override void StopListening(object source)
|
|
{
|
|
var manager = (TranslationManager)source;
|
|
manager.LanguageChanged -= OnLanguageChanged;
|
|
}
|
|
|
|
private static LanguageChangedEventManager CurrentManager
|
|
{
|
|
get
|
|
{
|
|
Type managerType = typeof(LanguageChangedEventManager);
|
|
var manager = (LanguageChangedEventManager)GetCurrentManager(managerType);
|
|
if (manager == null)
|
|
{
|
|
manager = new LanguageChangedEventManager();
|
|
SetCurrentManager(managerType, manager);
|
|
}
|
|
return manager;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|