Ignore:
Timestamp:
May 11, 2010, 4:37:44 PM (12 years ago)
Author:
saternus
Message:

Add files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypTool/App.xaml.cs

    r1421 r1422  
    55using System.Linq;
    66using System.Windows;
     7using System.Threading;
     8using Cryptool.Core;
    79
    810namespace CrypTool
     
    1315    public partial class App : Application
    1416    {
     17        private void OnStartup(object sender, StartupEventArgs e)
     18        {
     19            new Thread(LoadPlugins).Start();
     20        }
     21
     22        private void LoadPlugins()
     23        {
     24            PluginManager pluginMgr = new PluginManager();
     25            pluginMgr.OnPluginLoaded += new CrypCorePluginLoadedHandler(OnPluginLoaded);
     26            Dictionary<string, Type> plugins = pluginMgr.LoadTypes(AssemblySigningRequirement.LoadAllAssemblies);
     27            OpenMainWindow(plugins);
     28        }
     29
     30        private void OnPluginLoaded(object sender, PluginLoadedEventArgs args)
     31        {
     32            if (!Application.Current.Dispatcher.CheckAccess())
     33            {
     34                Application.Current.Dispatcher.BeginInvoke(new Action<Object, PluginLoadedEventArgs>(OnPluginLoaded), sender, args);
     35            }
     36            else
     37            {
     38                SplashScreen screen = (SplashScreen)this.MainWindow;
     39                screen.Text = args.AssemblyName;
     40                screen.Value = args.CurrentPluginNumber == 0 ? 0 : (int)((double)args.CurrentPluginNumber / (double)args.NumberPluginsFound * 100);
     41            }
     42        }
     43
     44        private void OpenMainWindow(Dictionary<string, Type> plugins)
     45        {
     46
     47            if (!Application.Current.Dispatcher.CheckAccess())
     48            {
     49                Application.Current.Dispatcher.BeginInvoke(new Action<Dictionary<string, Type>>(OpenMainWindow), plugins);
     50            }
     51            else
     52            {
     53                SplashScreen screen = (SplashScreen)this.MainWindow;
     54                MainWindow wnd = new CrypTool.MainWindow();
     55                wnd.LoadedTypes = plugins;
     56                Application.Current.MainWindow = wnd;
     57               
     58                screen.Close();
     59                Application.Current.MainWindow.Show();
     60            }
     61        }
    1562    }
    1663}
Note: See TracChangeset for help on using the changeset viewer.