/// <summary> /// Load application settings /// </summary> private void LoadSettings() { try { _typeOfInput = (TypeOfInput)Enum.Parse(typeof(TypeOfInput), Settings.Default.TypeOfInput); } catch (Exception) { _typeOfInput = TypeOfInput.None; } finally { ChangeChecked(_typeOfInput.ToString(), AudioInputControl); } try { _backgroundColor = Settings.Default.Color; } catch (Exception) { _backgroundColor = Color.FromArgb(255, 0, 0, 0); } finally { ChangeChecked($"{Convert.ToInt32(_backgroundColor.A / 255 * 100)}%", TransparentlyControl); } }
public static byte[] GetInput(TypeOfInput type, string input) { IOProcess inp = new IOProcess(); byte[] res = new byte[1 << 10]; if (type == TypeOfInput.Arr) { string t = input; int n = inp.NextInt(); string a = inp.NextLine(); res = Encoding.ASCII.GetBytes(t + "|" + n + " " + a); } else if (type == TypeOfInput.Matrix) { string t = input; int n = inp.NextInt(); int m = inp.NextInt(); StringBuilder builder = new StringBuilder(); builder.Append(t + " " + n + " " + m + "|"); //builder.Append(inp.NextLine()); for (int i = 0; i < n; i++) { builder.Append(inp.NextLine() + ","); } res = Encoding.ASCII.GetBytes(builder.ToString()); } inp.Dispose(); return(res); }
public EndPoint Form() { do { Console.WriteLine("Serial Number: "); serial = Console.ReadLine(); } while (serial == ""); Console.WriteLine(); do { Console.WriteLine("Meter Model Id (only numbers): (Use this catalog: 16 - NSX1P2W, 17 - NSX1P3W, 18 - NSX2P2W, 19 - NSX3P4W):"); meterModelIdAux = Console.ReadLine(); } while (!TypeOfInput.isMeterModelId(meterModelIdAux)); EnumMeterModelId meterModelId = (EnumMeterModelId)int.Parse(meterModelIdAux); Console.WriteLine(); do { Console.WriteLine("Meter Number: "); meterNumberAux = Console.ReadLine(); } while (!TypeOfInput.isNumeric(meterNumberAux)); int meterNumber = int.Parse(meterNumberAux); Console.WriteLine(); do { Console.WriteLine("Meter Firmware Version: "); meterFirmwareVersion = Console.ReadLine(); } while (meterFirmwareVersion == ""); Console.WriteLine(); do { Console.WriteLine("Switch State (only numbers): (Use this catalog: 0 - Disconnected, 1 - Connected, 2 - Armed):"); switchStateAux = Console.ReadLine(); } while (!TypeOfInput.isSwitchState(switchStateAux)); EnumSwitchState switchState = (EnumSwitchState)int.Parse(switchStateAux); var endPoint = new EndPoint(); endPoint.SerialNumber = serial; endPoint.MeterModelId = meterModelId; endPoint.MeterNumber = meterNumber; endPoint.MeterFirmwareVersion = meterFirmwareVersion; endPoint.SwitchState = switchState; return(endPoint); }
public static EndPoint Edition(EndPoint endPoint) { string switchStateAux = ""; do { Console.WriteLine("Switch State (only numbers): (Use this catalog: 0 - Disconnected, 1 - Connected, 2 - Armed):"); switchStateAux = Console.ReadLine(); } while (!TypeOfInput.isSwitchState(switchStateAux)); EnumSwitchState switchState = (EnumSwitchState)int.Parse(switchStateAux); endPoint.SwitchState = switchState; return(endPoint); }
/// <summary> /// Change options of audio source /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AudioInputMenuItem_Checked(object sender, RoutedEventArgs e) { if (!(sender is MenuItem item)) { return; } switch (item.Header.ToString()) { case "None": _waveIn?.StopRecording(); _wasapiLoopbackCapture?.StopRecording(); _typeOfInput = TypeOfInput.None; break; case "Microphone": _typeOfInput = TypeOfInput.Microphone; try { _waveIn?.StartRecording(); _wasapiLoopbackCapture?.StopRecording(); } catch (Exception exp) { MessageBox.Show($"Cannot start capture audio from input device.\n{exp.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } break; case "System": _waveIn?.StopRecording(); _wasapiLoopbackCapture?.StartRecording(); _typeOfInput = TypeOfInput.System; break; default: throw new ArgumentOutOfRangeException(); } UpdateSettings(_typeOfInput); ChangeChecked(item.Header.ToString(), item.Parent); }
public static int MakeConsoleInput(TypeOfInput type) { int input; switch (type) { case TypeOfInput.InputBigger0: while (!int.TryParse(Console.ReadLine(), out input) || input < 1) { Console.WriteLine("incorrect input, please enter a positive number"); } return(input); case TypeOfInput.InputBiggerOrEquals0: while (!int.TryParse(Console.ReadLine(), out input) || input < 0) { Console.WriteLine("incorrect input, please enter number>0"); } return(input); default: return(int.MinValue); } }
public int CheckBulletToDestroy(NoteColor c, TypeOfInput t, float time) { double pressedTime = patternSynch.noteTimes[bulletToDestroy] - AudioSettings.dspTime; pressedTime = pressedTime < 0 ? -pressedTime : pressedTime; if (pressedTime <= offsetTolerance) { projectile = objectPooler.GetBulletToDestroy(bulletToDestroy); if (projectile == null) { return(-1); } else if ((projectile.isActiveAndEnabled && c.ToString().Equals(projectile.tag) && t == projectile.InputType)) { if (projectile.InputType != TypeOfInput.HOLD) { projectile.DestroyOnHit(); UpdateBulletToDestroy(); patternSynch.DestroyNote(); //if (projectile.Source != Projectile.Projectile_Source.ENEMY) //{ if (pressedTime < offsetTolerance / 4.5f) { //Debug.Log("PERFECT"); return(1); } else if (pressedTime >= offsetTolerance / 4 && pressedTime < offsetTolerance / 3) { //Debug.Log("GOOD"); return(2); } else if (pressedTime >= offsetTolerance / 3 && pressedTime < offsetTolerance / 2) { //Debug.Log("MEH"); return(3); } else if (pressedTime >= offsetTolerance / 2) // && pressedTime < offsetTolerance / 1.5f) { //Debug.Log("BAD"); return(4); } //} //else //{ if (pressedTime < offsetTolerance / 4) { //Debug.Log("PERFECT"); return(-1); } else if (pressedTime >= offsetTolerance / 4 && pressedTime < offsetTolerance / 3) { //Debug.Log("GOOD"); return(-2); } else if (pressedTime >= offsetTolerance / 3 && pressedTime < offsetTolerance / 2) { //Debug.Log("MEH"); return(-3); } else if (pressedTime >= offsetTolerance / 2) // && pressedTime < offsetTolerance / 1.5f) { //Debug.Log("BAD"); return(-4); } //} } } } return(0); }
public ShipBuilder WithTypeOfInput(TypeOfInput input) { _typeOfInput = input; return(this); }
public StrategyForInput(TypeOfInput typeOfInput, ShipControllerMediator shipControllerMediator, AnimationCurve curveMovement) { this.typeOfInput = typeOfInput; this.shipControllerMediator = shipControllerMediator; this.curveMovement = curveMovement; }