Exemple #1
0
 private void MenuItem_Click_1(object sender, RoutedEventArgs e)
 {
     if (pluginsxd.Count > 0)
     {
         ISlideshowEffect.ISlideshowEffect tmp = pluginsxd.Find(x => x.Name == (string)((System.Windows.Controls.MenuItem)sender).Header);
         StartSlidesShow(tmp);
     }
     else
     {
         System.Windows.MessageBox.Show("No plugins avaliable", "EROR ", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Exemple #2
0
 private void StartSlidesShow(ISlideshowEffect.ISlideshowEffect plugin)
 {
     if (this.DataContext is List <ImgInfo> && pluginsxd.Count > 0)
     {
         if (((List <ImgInfo>) this.DataContext).Count > 0)
         {
             SlidesWindow slideWindow = new SlidesWindow(plugin);
             slideWindow.ShowDialog();
         }
         else
         {
             System.Windows.MessageBox.Show("The selected folder does not contain any images to start slideshow!", "An error occured", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     else
     {
         System.Windows.MessageBox.Show("The selected folder does not contain any images or plugins neccesasary to start slideshow!", "An error occured", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     //System.Windows.MessageBox.Show("XD");
 }
Exemple #3
0
        private void LoadPlugins()
        {
            //loading plugins
            string[] dllFileNames = null;
            if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory))
            {
                dllFileNames = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
            }

            ICollection <Assembly> assemblies = new List <Assembly>(dllFileNames.Length);

            foreach (string dllFile in dllFileNames)
            {
                AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
                Assembly     assembly = Assembly.Load(an);
                assemblies.Add(assembly);
            }
            Type pluginType = typeof(ISlideshowEffect.ISlideshowEffect);
            ICollection <Type> pluginTypes = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                if (assembly != null)
                {
                    Type[] types = assembly.GetTypes();
                    foreach (Type type in types)
                    {
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else
                        {
                            if (type.GetInterface(pluginType.Name) != null)
                            {
                                pluginTypes.Add(type);
                            }
                        }
                    }
                }
            }
            //ICollection<ISlideshowEffect.ISlideshowEffect> plugins = new List<ISlideshowEffect.ISlideshowEffect>(pluginTypes.Count);
            foreach (Type type in pluginTypes)
            {
                ISlideshowEffect.ISlideshowEffect plugin = (ISlideshowEffect.ISlideshowEffect)Activator.CreateInstance(type);
                //plugins.Add(plugin);
                pluginsxd.Add(plugin);
            }

            List <string> pluginnames = new List <string>();

            //List<PluginName> namesxd = new List<PluginName>();
            foreach (ISlideshowEffect.ISlideshowEffect plugin in pluginsxd)
            {
                //System.Windows.MessageBox.Show(plugin.Name);
                pluginnames.Add(plugin.Name);
                //Namesxd.Add(new PluginName(plugin.Name));
            }
            effectComboBox.DataContext         = pluginsxd;
            startslideshowMenuItem.DataContext = pluginsxd;
        }