Esempio n. 1
0
        public IList<object> GetContextMenu(MingTreeViewItem originator, PluginInfo plugin)
        {
            _contextMenuOriginator = originator;

            var keys = plugin.Instance.TreeViewClient.GetActiveNodeContextMenuKeys(originator);

            _contextMenuKeyProviders.ToList().ForEach(item => keys = keys.Union(item.GetActiveNodeContextMenuKeys(originator)));

            var items = _contextMenuItems.Where(item => item is MenuItem ? keys.Contains(((MenuItem) item).Name) : true).ToList();

            if (items.Count > 0)
            {
                if (items[0] is Separator)
                {
                    items.RemoveAt(0);
                }
                if (items.Count > 0)
                {
                    if (items.Last() is Separator)
                    {
                        items.RemoveAt(items.Count - 1);
                    }
                }
            }

            return items;
        }
Esempio n. 2
0
        private void FindPlugins()
        {
            _plugins = new List<PluginInfo>();

            var path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(PluginManager)).Location);
            var assemblies = Directory.GetFiles(path, "*.dll");

            foreach (var assemblyPath in assemblies)
            {
                var assembly = Assembly.LoadFrom(assemblyPath);

                var implementations = assembly.GetTypes()
                    .Where(t => t.GetInterfaces().ToList().Any(i => i.IsAssignableFrom(typeof(IMingPlugin)))).ToList();

                var idx = 0;
                foreach (var implementation in implementations)
                {
                    var instance = (IMingPlugin)Activator.CreateInstance(implementation);
                    instance.MingApp = MingApp.Instance;
                    var plugin = new PluginInfo(instance.Id, instance.Name, instance);
                    _plugins.Add(plugin);
                    idx++;
                }
            }
        }
Esempio n. 3
0
 public ConnectViewModel()
 {
     _service = PluginManager.Instance.Plugins[0];
     _port = _service.Instance.DefaultPort.ToString();
 }