Exemple #1
0
        public JMMPluginResult SetPluginOrder(List <Guid> order, JMMPluginTypes type)
        {
            if (!pluginorder.ContainsKey(type))
            {
                return new JMMPluginResult {
                           Error = "There is no plugin of type " + type + " loaded", Ok = false
                }
            }
            ;
            Dictionary <Guid, int> d = pluginorder[type];
            int xx = 0;

            foreach (Guid g in order)
            {
                d[g] = xx;

                JMMPluginPreferences ll = Settings.Default.Preferences.First(a => a.Guid == g);
                if (!ll.Orders.ContainsKey(type))
                {
                    ll.Orders.Add(type, xx);
                }
                else
                {
                    ll.Orders[type] = xx;
                }
                xx++;
            }
            Settings.Default.Save();
            return(new JMMPluginResult()
            {
                Ok = true
            });
        }
    }
Exemple #2
0
        private static List <JMMPluginTypes> EnumerateTypes(JMMPluginTypes type)
        {
            List <JMMPluginTypes> l = new List <JMMPluginTypes>();

            foreach (JMMPluginTypes p in Enum.GetValues(typeof(JMMPluginTypes)))
            {
                if ((type & p) == p)
                {
                    l.Add(p);
                }
            }
            return(l);
        }
Exemple #3
0
 public JMMPluginResult <List <Guid> > GetPluginOrder(JMMPluginTypes type)
 {
     if (!pluginorder.ContainsKey(type))
     {
         return new JMMPluginResult <List <Guid> > {
                    Error = "There is no plugin of type " + type + " loaded", Ok = false
         }
     }
     ;
     return(new JMMPluginResult <List <Guid> > {
         Ok = true, Result = pluginorder[type].OrderBy(a => a.Value).Select(a => a.Key).ToList()
     });
 }
Exemple #4
0
        private static void AddOrderToPreferences(Guid guid, JMMPluginPreferences pp, JMMPluginTypes p)
        {
            int val = Int32.MaxValue;

            if (pp.Orders.ContainsKey(p))
            {
                val = pp.Orders[p];
            }
            if (!pluginorder.ContainsKey(p))
            {
                pluginorder.Add(p, new Dictionary <Guid, int>());
            }
            Dictionary <Guid, int> kk = pluginorder[p];

            if (!kk.ContainsKey(guid))
            {
                kk.Add(guid, val);
            }
            else
            {
                kk[guid] = val;
            }
        }