예제 #1
0
        private SettingsSubsection createSectionFor(InputHandler handler)
        {
            SettingsSubsection section;

            switch (handler)
            {
            // ReSharper disable once SuspiciousTypeConversion.Global (net standard fuckery)
            case ITabletHandler th:
                section = new TabletSettings(th);
                break;

            case MouseHandler mh:
                section = new MouseSettings(mh);
                break;

            // whitelist the handlers which should be displayed to avoid any weird cases of users touching settings they shouldn't.
            case JoystickHandler _:
            case MidiHandler _:
                section = new HandlerSection(handler);
                break;

            default:
                return(null);
            }

            return(section);
        }
예제 #2
0
        private bool HandlerInit()
        {
            Logger.Debug("=== Handler loader start ===");
            var config = HandlerSection.Get();

            var aggregateCatalog = new AggregateCatalog();

            if (config != null)
            {
                foreach (Handler handler in config.HandlerItems)
                {
                    if (handler.Used)
                    {
                        if (File.Exists(ExtensionPath.LocalPath + String.Format("\\{0}.dll", handler.Name)))
                        {
                            var directoryCatalog = new DirectoryCatalog(ExtensionPath.LocalPath, String.Format("{0}.dll", handler.Name));
                            aggregateCatalog.Catalogs.Add(directoryCatalog);
                            Logger.Debug(String.Format("Library for {0} is loaded", handler.Name));
                        }
                        else
                        {
                            Logger.Error(String.Format("Library for {0} is not found", handler.Name));
                        }
                    }
                }
            }
            var container = new CompositionContainer(aggregateCatalog);

            container.ComposeParts(this);
            Logger.Debug("Found {0} modules. Loaded {1} modules.", config.HandlerItems.Count, Transformers.Count());
            Logger.Debug("=== Handler loader end ===");
            return(config.HandlerItems.Count == Transformers.Count());
        }