Esempio n. 1
0
        internal IFlexMacro[] AssignMacrosToSlots(List <IFlexMacro> macroImplementors)
        {
            IFlexMacro[] macros    = new IFlexMacro[MacroCount];
            var          conflicts = new List <IFlexMacro>();

            // Put each at its preferred key if possible
            foreach (var macro in macroImplementors)
            {
                int index = GetMacroIndex(macro.PreferredFunctionKey);
                if (macros[index] == null)
                {
                    macros[index] = macro;
                }
                else
                {
                    conflicts.Add(macro);
                }
            }
            // Put any conflicts in remaining slots; if too many, arbitrary ones will be left out.
            foreach (var macro in conflicts)
            {
                for (int index = 0; index < MacroCount; index++)
                {
                    if (macros[index] == null)
                    {
                        macros[index] = macro;
                        break;
                    }
                }
            }
            return(macros);
        }
Esempio n. 2
0
 internal IFlexMacro[] AssignMacrosToSlots(List<IFlexMacro> macroImplementors)
 {
     IFlexMacro[] macros = new IFlexMacro[MacroCount];
     var conflicts = new List<IFlexMacro>();
     // Put each at its preferred key if possible
     foreach (var macro in macroImplementors)
     {
         int index = GetMacroIndex(macro.PreferredFunctionKey);
         if (macros[index] == null)
             macros[index] = macro;
         else
             conflicts.Add(macro);
     }
     // Put any conflicts in remaining slots; if too many, arbitrary ones will be left out.
     foreach (var macro in conflicts)
     {
         for (int index = 0; index < MacroCount; index++)
         {
             if (macros[index] == null)
             {
                 macros[index] = macro;
                 break;
             }
         }
     }
     return macros;
 }