public void ShowController(ControllerTypes controllerType) { switch (controllerType) { case ControllerTypes.Keyboard: { controller = new ViewModel.Controllers.Keyboard(); break; } case ControllerTypes.Joystick: { controller = new Joystick(); break; } case ControllerTypes.Other: { break; } default: { break; } } controller.SetConnection(connection); controller.window.Show(); }
protected Controller(int rawStartIndex, string rawValue, ControllerTypes controllerType, Global.ArgumentInfoCollection contentArguments) { this.UniqueID = Guid.NewGuid().ToString(); this.Mother = null; this.Parent = null; this.RawValue = rawValue; this.RawStartIndex = rawStartIndex; this.Value = rawValue; // Remove block signs, this value must not be null if (!string.IsNullOrEmpty(this.Value) && this.Value.Length > 2 && this.Value[0] == '$' && this.Value[this.Value.Length - 1] == '$') { this.Value = this.Value.Substring(1, this.Value.Length - 2); this.Value = this.Value.Trim(); } // !-- this.ControllerType = controllerType; this.ContentArguments = contentArguments; if (this.ContentArguments == null) { this.ContentArguments = new Global.ArgumentInfoCollection(); } this.RenderedValue = string.Empty; }
/* * This method is responsible for creating players. The types of players * as well as the controller and controller scheme are a must when calling * this method. * */ private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme) { Element player = new Element(); if (pacOrGhost == PlayerTypes.PacPlayer) { player.et = ElementTypes.PacPlayer; } else { player.et = ElementTypes.Ghost; } if (humanOrAI == PlayerTypes.Human) { if (controller == ControllerTypes.Keyboard) { player.AddController(new KeyboardInput(scheme)); } else { player.AddController(new ControllerInput(scheme)); } } else { player.AddController(new GhostAI(player)); } players.Add(player); }
/// <summary> /// Loads the named configuration file /// </summary> /// <param name="Parent">the parent form, or null</param> /// <param name="FileName">the config. file to load</param> /// <returns>'true' if successful</returns> private bool LoadConfig(Form Parent, string FileName) { XmlReader reader = null; XmlSerializer serializer; ControllerTypes ct = Settings.ControllerType; try { reader = XmlReader.Create(FileName); serializer = new XmlSerializer(typeof(ConfigSettings)); this.Settings = (ConfigSettings)serializer.Deserialize(reader); } catch (Exception ex) { MessageBox.Show(Parent, "Error doung config load: " + ex.Message); return(false); } finally { if (reader != null) { reader.Close(); } } // If the controller type changed, close/re-open the controller. if (ct != this.Settings.ControllerType) { Close(); Open(); } this.ConfigChanged = false; return(true); }
public string GetConfig(string key, ControllerTypes controllerType) { var controller = _bootstrap.GetController(controllerType); var props = controller.GetType().GetFields().ToList(); return(props.Find(x => x.Name == key).GetValue(controller).ToString()); }
public Element(PlayerTypes PlayerType, ControllerTypes ControllerType, ControllerScheme scheme) { this.PlayerType = PlayerType; this.ControllerType = ControllerType; Logic(scheme); }
/* * This method is responsible for creating players. The types of players * as well as the controller and controller scheme are a must when calling * this method. * */ private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme) { Element player; if (pacOrGhost == PlayerTypes.PacPlayer) player = new PacPlayer(); else player = new Ghost(); if (humanOrAI == PlayerTypes.Human) { if (controller == ControllerTypes.Keyboard) player.AddController(new KeyboardController(scheme)); else player.AddController(new XboxController(scheme)); } else { if (pacOrGhost == PlayerTypes.PacPlayer) player.AddController(new PacplayerAIController()); else player.AddController(new GhostAIController()); } players.Add(player); }
/// <summary> /// Retrieves all available controllers using the specified <see cref="ControllerTypes"/> mask. /// </summary> /// <param name="types">The mask that specified the types of controllers to use.</param> /// <param name="deviceCount">The number of devices that have been found.</param> /// <returns> /// <c>True</c> if <see cref="DAC.Instance"/> was successfully initialized. <c>False</c> else. /// </returns> /// <exception cref="T:System.InvalidOperationException">If <see cref="DAC.Instance"/> has been initialized.</exception> /// <exception cref="T:System.ArgumentException">If any error occurred while retrieving device information.</exception> public static bool TryGetControllers(ControllerTypes types, out uint deviceCount) { if (instance != null) { throw new InvalidOperationException(string.Format("DAC already initialized with '{0}'. Shutdown/Dispose DAC before retrieving new information.", instance.ControllerType)); } try { deviceCount = 0; if (NativeMethods.LDL_Init((uint)ConvertToNativeMask(types), ref deviceCount) != NativeConstants.DAC_OK) { return(false); } return(true); } catch (Exception ex) { throw new ArgumentException(string.Format("Could not retrieve controllers for '{0}'.", types), ex); } finally { NativeMethods.LDL_Close(); } }
private static object AddDependencyInjectionInternal <T>(this object app, ControllerTypes addFor = ControllerTypes.Both) where T : ServicesConfiguration, new() { var services = new T().ConfigureInterstellar(new ServiceCollection()); var appAssembly = app.GetType().Assembly; var configurationAssembly = typeof(T).Assembly; services.AddAllControllersFrom(appAssembly); if (appAssembly != configurationAssembly) { services.AddAllControllersFrom(configurationAssembly); } _resolver = new InterstellarDependencyResolver(services); if (addFor == ControllerTypes.Both || addFor == ControllerTypes.Mvc) { DependencyResolver.SetResolver(_resolver); } if (addFor == ControllerTypes.Both || addFor == ControllerTypes.WebApi) { GlobalConfiguration.Configuration.DependencyResolver = _resolver; } if (app is IAppBuilder appBuilder) { appBuilder.AddDependencyInjection(); } return(app); }
public void GoNextStep(ControllerTypes ctype) { if (NextSteps.Contains(ctype)) { var controller = controllerFactory.GetController(ctype); controller.Run(); } }
public void GetController_WhenId_ReturnController(ControllerTypes controllerType, Type type) { var repository = new MemoryRepository(); var factory = new ControllerFactory(repository); var result = factory.GetController(controllerType); Assert.Equal(type, result.GetType()); }
public void Can_resolve_all_controllers() { ControllerTypes.ForEach(controllerType => { Console.WriteLine($"Resolving {controllerType.Name}..."); var controller = BuildServiceProvider.Instance.GetService(controllerType); Assert.That(controller, Is.Not.Null); }); }
public GridLayout(GridLayout copyFrom) { controller = copyFrom.controller; gridSize = copyFrom.gridSize; pieceSize = copyFrom.pieceSize; spacing = copyFrom.spacing; grid = copyFrom.grid; editorScale = copyFrom.editorScale; }
public override IController CreateController(RequestContext requestContext, string controllerName) { IController controller = null; Type controllerType; if (ControllerTypes.TryGetValue(controllerName.ToLower(), out controllerType)) { controller = (IController)Activator.CreateInstance(controllerType); } return(controller); }
// Constructor public MidiConfiguration(string device, byte channel, byte controller, ControllerTypes controllerType, byte minValue, byte maxValue, float scalingValue) { MidiDevice = device; Channel = channel; Controller = controller; ControllerType = controllerType; MinValue = minValue; MaxValue = maxValue; ScalingValue = scalingValue; }
/// <summary>初始化 /// </summary> public void Initialize() { var types = Assembly.GetTypes() .Where(IsRemoteService) .WhereIf(TypePredicate != null, TypePredicate); foreach (var type in types) { ControllerTypes.Add(type); } }
public void SetConfig(string key, string value, ControllerTypes controllerType) { var controller = _bootstrap.GetController(controllerType); var props = controller.GetType().GetFields().ToList(); if (props.Exists(x => x.Name == key)) { var prop = props.Find(x => x.Name == key); prop.SetValue(controller, Convert.ChangeType(value, prop.GetValue(controller).GetType()), BindingFlags.Instance | BindingFlags.Public, null, null); } }
public IController GetController(ControllerTypes type) { if (_controllers.Exists(x => x.Type == type)) { return(_controllers.Find(x => x.Type == type)); } else { //Debug.LogWarning("Controller not founded '" + type + "' returning null"); return(null); } }
public static void Configure(IDependencyConfigurator di) { di.Register <ControllerFactory, ControllerFactory>(true); di.Factory(self => self); di.Register <IConnectionService, ConnectionService>(); di.Register <WebSocketConnection, WebSocketConnection>(); di.Register <ClientRepository, ClientRepository>(true); di.Register <IBroadcastService, BroadcastService>(); var types = new ControllerTypes(); di.Factory(d => types); di.Factory <IControllerTypeResolver>(d => types); di.Register <Catchme, Catchme>(true); }
public void RunCommand_WhenCommand_ThenFactoryRun(ControllerTypes command) { var controllerMock = new Mock <IController>(); controllerMock.Setup(c => c.Run()); var mock = new Mock <IControllerFactory>(); mock.Setup(a => a.GetController(It.Is <ControllerTypes>(i => i == command))).Returns(controllerMock.Object); var view = new Mock <IView <Help, IController> >(); view.Setup(v => v.Info).Returns(new PageInfo()); view.Setup(v => v.Model).Returns(new Help()); var controller = new HelpController(mock.Object, view.Object); controller.GoNextStep(command); mock.Verify(m => m.GetController(It.Is <ControllerTypes>(i => i == command)), Times.Once()); }
public static string GetControllerTypeString(ControllerTypes controllerType) { switch (controllerType) { case ControllerTypes.LinearPotentiometer: return(Properties.Resources.LinearPotentiometerText); case ControllerTypes.Button: return(Properties.Resources.ButtonText); case ControllerTypes.RotaryEncoder: return(Properties.Resources.RotaryEncoderText); default: return(""); } }
public Sample1Plugin() { ControllerTypes.Add(typeof(Sample1Controller)); ControllerTypes.Add(typeof(Sample12Controller)); //TODO : register to sub container per plugin IoCManager.Container.RegisterType <IPluginController, Sample1Controller>("Sample1Controller", new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <PluginControllerAuthorizationBehavior>()); IoCManager.Container.RegisterType <IPluginController, Sample12Controller>("Sample12Controller", new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <PluginControllerAuthorizationBehavior>()); //_controllerList.Add(IoCManager.Instance.Resolve<IPluginController>("Sample1Controller")); //_controllerList.Add(IoCManager.Instance.Resolve<IPluginController>("Sample12Controller")); }
static int ConvertToNativeMask(ControllerTypes types) { switch (types) { case ControllerTypes.All: return(NativeConstants.MASK_ALL); case ControllerTypes.EZAUDDAC: return(NativeConstants.MASK_EZAUDDAC); case ControllerTypes.EasyLase: return(NativeConstants.MASK_EASYLASE); case ControllerTypes.RiyaUSB: return(NativeConstants.MASK_RIYAUSB); case ControllerTypes.QM2000: return(NativeConstants.MASK_QM2000); case ControllerTypes.Moncha: return(NativeConstants.MASK_MONCHA); case ControllerTypes.Fiesta: return(NativeConstants.MASK_FIESTA); case ControllerTypes.Lumax: return(NativeConstants.MASK_LUMAX); case ControllerTypes.Netlase: return(NativeConstants.MASK_NETLASE); case ControllerTypes.Medialas: return(NativeConstants.MASK_MEDIALAS); case ControllerTypes.LDS: return(NativeConstants.MASK_LDS); case ControllerTypes.OLSD: return(NativeConstants.MASK_OLSD); default: throw new NotImplementedException(string.Format("There is no implementation for '{0}'", types)); } }
private Type GetControllerType(String area, String controller) { String controllerType = controller + "Controller"; IEnumerable <Type> controllers = ControllerTypes .Where(type => type.Name.Equals(controllerType, StringComparison.OrdinalIgnoreCase)); if (String.IsNullOrEmpty(area)) { controllers = controllers.Where(type => !type.IsDefined(typeof(AreaAttribute), false)); } else { controllers = controllers.Where(type => type.IsDefined(typeof(AreaAttribute), false) && String.Equals(type.GetCustomAttribute <AreaAttribute>(false).Name, area, StringComparison.OrdinalIgnoreCase)); } return(controllers.Single()); }
private void ControllerTypeRadioButton_Checked(object sender, RoutedEventArgs e) { RadioButton rb = (RadioButton)sender; if (rb.Content.ToString() == "Keyboard") { controllerType = ControllerTypes.Keyboard; } else if (rb.Content.ToString() == "Joystic") { controllerType = ControllerTypes.Joystick; } else if (rb.Content.ToString() == "Remote") { controllerType = ControllerTypes.Other; } else if (rb.Content.ToString() == "Custom") { controllerType = ControllerTypes.Other; } }
/// <summary> /// Tries to initialize the <see cref="DAC.Instance"/> using the specified <see cref="ControllerType"/> mask. /// </summary> /// <param name="types">The types of controllers that should be used during initialization.</param> /// <param name="type">The type of controllers to use.</param> /// <param name="deviceChooser">The device chooser. Once the overall number of devices has been retrieved, this /// callback is asked which device should actually be used. Can be null. If null, the first device that has been /// found will be used.</param> /// <exception cref="T:System.InvalidOperationException">If <see cref="DAC.Instance"/> has been initialized.</exception> /// /// <exception cref="T:System.ArgumentException">If any error occurred while initializing the device.</exception> public static DAC Initialize(ControllerTypes types, ControllerType type, DeviceChooser deviceChooser = null) { if (instance != null) { throw new InvalidOperationException(string.Format("DAC already initialized with '{0}'. Shutdown/Dispose DAC before retrieving new information.", instance.ControllerType)); } try { uint deviceCount = 0; if (NativeMethods.LDL_Init((uint)ConvertToNativeMask(types), ref deviceCount) != NativeConstants.DAC_OK) { throw new ArgumentException(string.Format("Could not intialize DAC with '{0}'", type)); } uint device = deviceChooser == null ? 0 : deviceChooser(deviceCount); uint tType = 0; uint tEnum = 0; var sName = new StringBuilder(128); if (NativeMethods.LDL_GetDACInfo(device, sName, (uint)sName.Length, ref tType, ref tEnum) != NativeConstants.DAC_OK) { throw new ArgumentException(string.Format("Could retriev name of DAC device number {0} with '{1}'.", device, type)); } if (NativeMethods.LDL_DAC_Init(device) != NativeConstants.DAC_OK) { throw new ArgumentException(string.Format("Could not intialize DAC with '{0}' using device number {1}", type, device)); } instance = new DAC(type, sName.ToString(), device); return(instance); } catch (Exception ex) { NativeMethods.LDL_Close(); throw new ArgumentException(string.Format("Could not initialize DAC.Instance with '{0}'.", type), ex); } }
public void ControllerCheck() { string[] currentControllers = new string[Input.GetJoystickNames().Length]; int numberOfControllers = 0; for (int i = 0; i < Input.GetJoystickNames().Length; i++) { currentControllers[i] = Input.GetJoystickNames()[i].ToLower(); if ((currentControllers[i] == "controller (xbox 360 for windows)" || currentControllers[i] == "controller (xbox 360 wireless receiver for windows)" || currentControllers[i] == "controller (xbox one for windows)")) { useController = true; controllerType = ControllerTypes.XBOX; ControllerSuffix = "XBOX"; } else if (currentControllers[i] == "wireless controller") { useController = true; controllerType = ControllerTypes.PS4; ControllerSuffix = "PS"; } else if (currentControllers[i] == "") { numberOfControllers++; } if (currentControllers[i] != "") { Debug.Log(currentControllers[i] + " is detected."); } } if (numberOfControllers == Input.GetJoystickNames().Length) { useController = false; ControllerSuffix = ""; Debug.Log("No controller found, using mouse and keyboard settings!"); } }
/* * This method is responsible for creating players. The types of players * as well as the controller and controller scheme are a must when calling * this method. * */ private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme) { Element player; if (pacOrGhost == PlayerTypes.PacPlayer) { player = new PacPlayer(); } else { player = new Ghost(); } if (humanOrAI == PlayerTypes.Human) { if (controller == ControllerTypes.Keyboard) { player.AddController(new KeyboardController(scheme)); } else { player.AddController(new XboxController(scheme)); } } else { if (pacOrGhost == PlayerTypes.PacPlayer) { player.AddController(new PacplayerAIController()); } else { player.AddController(new GhostAIController()); } } players.Add(player); }
internal void LoadPlugins(Assembly ass) { var allOfThemTypes = ass.GetTypes(); foreach (var type in allOfThemTypes) { if (typeof(IPlugin).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { logger.Info($"Loading Plugin {type.Name} from Assembly {ass.FullName}"); plugins.Add(PluginCreator <IPlugin> .GetInstance(type)); } else if (typeof(BaseController).IsAssignableFrom(type)) { ControllerTypes.Add(type); } else if (typeof(IDbUpdater).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { var updater = PluginCreator <IDbUpdater> .GetInstance(type); DbUpdater.Add(updater); } } }
/* * This method is responsible for creating players. The types of players * as well as the controller and controller scheme are a must when calling * this method. * */ private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme) { Element player = new Element(); if (pacOrGhost == PlayerTypes.PacPlayer) player.et = ElementTypes.PacPlayer; else player.et = ElementTypes.Ghost; if (humanOrAI == PlayerTypes.Human) { if (controller == ControllerTypes.Keyboard) player.AddController(new KeyboardInput(scheme)); else player.AddController(new ControllerInput(scheme)); } else { player.AddController(new GhostAI(player)); } players.Add(player); }
public ControllerTypes ChangePlayerControls(int _playerIdx) { ControllerTypes controllerType = controllerTypes[_playerIdx]; ControllerTypes prevType = controllerType; int controlCount = Enum.GetValues(typeof(ControllerTypes)).Length; bool finished = false; while (!finished) { // Increment with wraparound ++controllerType; if ((int)controllerType == controlCount) { controllerType = (ControllerTypes)0; } finished = true; // If rolled back around to same value, give up if (controllerType != prevType) { // Check no other player has the same control type for (int i = 0; i < controllerTypes.Length; ++i) { finished &= (controllerTypes[i] != controllerType); } // Found a valid one if (finished) { controllerTypes[_playerIdx] = controllerType; SaveControllerTypes(); } } } return(controllerType); }
// This function is used for defining what inputs are a public static bool isInputAccepted(this ControllerTypes controller, ControlsTypes control, KeyCode code) { switch (controller) { case ControllerTypes.KEYBOARD: if (!code.ToString().Contains("Joystick") && !code.ToString().Contains("Mouse")) { return(true); } else { return(false); } case ControllerTypes.JOYSTICK: if (code.ToString().Contains("Joystick")) { return(true); } else { return(false); } case ControllerTypes.MOUSE: if (code.ToString().Contains("Mouse")) { return(true); } else { return(false); } } return(false); }
public GamepadReader(ControllerTypes controllerType) { Initialize(controllerType); }
public ControllerScheme(ControllerTypes controller) { this.controller = controller; Logic(); }
private void InitializeControllerType(ControllerTypes controllerType) { ControllerType = controllerType; }
/// <summary> /// Creates the specified type of controller. /// </summary> /// <param name="type">The type.</param> /// <returns>Instance of controller.</returns> public IController Create(ControllerTypes type) { switch (type) { case ControllerTypes.AdminForm: return new AdminFormController(); case ControllerTypes.ClientSearch: return new ClientSearchController(); case ControllerTypes.EditRoomFeature: return new EditRoomFeatureController(); case ControllerTypes.EditRoomType: return new EditRoomTypeController(); case ControllerTypes.EditRoom: return new EditRoomController(); case ControllerTypes.EmployeeForm: return new EmployeeFormController(); case ControllerTypes.LoginForm: return new LoginFormController(); case ControllerTypes.NewClientForm: return new NewClientFormController(); case ControllerTypes.NewEmployeeForm: return new NewEmployeeFormController(); case ControllerTypes.ReservationForm: return new ReservationFormController(); case ControllerTypes.NewVisitForm: return new NewVisitFormController(); case ControllerTypes.ReceptionistForm: return new ReceptionistFormController(); case ControllerTypes.EditService: return new EditServiceFormController(); case ControllerTypes.ManagerForm: return new ManagerFormController(); case ControllerTypes.EditTaskForm: return new EditTaskController(); case ControllerTypes.EditTaskTypeForm: return new EditTaskTypeController(); case ControllerTypes.EditServiceForVisit: return new EditServiceForVisitController(); case ControllerTypes.EditServiceDetailsForm: return new EditServiceDetailsController(); case ControllerTypes.MealPlansForm: return new MealPlanController(); case ControllerTypes.GenerateReceiptForm: return new GenerateReceiptController(); case ControllerTypes.EditMealPlansForVisitForm: return new EditMealPlanController(); case ControllerTypes.GrantDiscountForm: return new GrantDiscountController(); default: return null; } }
private void Initialize(ControllerTypes controllerType) { InitializeControllerType(controllerType); InitializeTcpip(); InitializeChannel(); }