Пример #1
0
        public object Execute(object sender, object parameter)
        {
            if (Track == null && parameter == null)
            {
                return(null);
            }

            IAudioTrack track = null;

            if (Track == null)
            {
                if (InputConverter != null)
                {
                    track = (IAudioTrack)InputConverter.Convert(parameter, null, null, null);
                }
                else
                {
                    track = (IAudioTrack)parameter;
                }
            }
            else
            {
                track = Track;
            }

            Messenger.Default.Send(new PlayTrackMessage {
                Tracks = (IEnumerable <IAudioTrack>)TracksList, TrackToPlay = track
            });
            NavigationHelper.Navigate(AppViews.PlayerView);

            return(null);
        }
Пример #2
0
        static void Main(string[] args)
        {
            try {
                InputConverter   inputConverter   = new InputConverter();
                CalculatorEngine calculatorEngine = new CalculatorEngine();

                System.Console.WriteLine("Enter operation");

                // Read the first number and converts it
                double firstNumber = inputConverter.ConvertInputToNumeric(Console.ReadLine());

                // Read the second number and converts it
                double secondNumber = inputConverter.ConvertInputToNumeric(Console.ReadLine());

                // Read the operator
                string operation = Console.ReadLine();

                // Do the calculation that returns a result
                double result = calculatorEngine.Calculate(operation, firstNumber, secondNumber);

                // Print the result
                System.Console.WriteLine("{0} + {1} = {2}", firstNumber, secondNumber, result);
            } catch (Exception ex) {
                System.Console.WriteLine(ex.Message);
            }
        }
Пример #3
0
        private static void ConvertInput()
        {
            string sourcePath = EditorUtility.OpenFilePanel("Select Unity input settings asset", "", "asset");

            if (!string.IsNullOrEmpty(sourcePath))
            {
                string destinationPath = EditorUtility.SaveFilePanel("Save imported input axes", "", "input_manager", "xml");
                if (!string.IsNullOrEmpty(destinationPath))
                {
                    try
                    {
                        InputConverter converter = new InputConverter();
                        converter.ConvertUnityInputManager(sourcePath, destinationPath);

                        EditorUtility.DisplayDialog("Success", "Unity input converted successfuly!", "OK");
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogException(ex);

                        string message = "Failed to convert Unity input! Please make sure 'InputManager.asset' is serialized as a YAML text file.";
                        EditorUtility.DisplayDialog("Error", message, "OK");
                    }
                }
            }
        }
Пример #4
0
        public static bool OverwriteProjectSettings()
        {
            int    length = Application.dataPath.LastIndexOf('/');
            string projectSettingsFolder = string.Concat(Application.dataPath.Substring(0, length), "/ProjectSettings");
            string inputManagerPath      = string.Concat(projectSettingsFolder, "/InputManager.asset");

            if (!Directory.Exists(projectSettingsFolder))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the ProjectSetting folder.", "OK");
                return(false);
            }

            if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
            {
                return(false);
            }

            InputConverter inputConverter = new InputConverter();

            inputConverter.GenerateDefaultUnityInputManager(inputManagerPath);

            EditorUtility.DisplayDialog("Success", "The input settings have been successfully replaced.\n\nYou might need to minimize and restore Unity to reimport the new settings.", "OK");

            return(true);
        }
Пример #5
0
        public void ShouldConvertUpperCaseAToAppropriateValue()
        {
            const string input = "A";

            var output = InputConverter.Convert(input);

            Assert.AreEqual(new[] { 27 }, output);
        }
Пример #6
0
        public void ShouldConvertAlleLettersToAppropriateValues()
        {
            var input = Helpers.GenerateAllLetters();

            var output = InputConverter.Convert(input);

            Assert.AreEqual(Helpers.GenerateAllNumberValuesForLetters(), output);
        }
 void Update()
 {
     _inputPairs.ForEach(inputPair =>
     {
         inputPair.controlVariable.SetValue(InputConverter.InputToIntValue(inputPair.keyCode));
     });
     secondDirectionalControl.SetValue(Input.mousePosition);
 }
Пример #8
0
        public void TestMethod1()
        {
            string[] str            = { "s" };
            var      expectedOutput = "104616";
            var      actualOutput   = InputConverter.ConvertInput(str);

            Assert.AreEqual(expectedOutput, actualOutput);
        }
Пример #9
0
        public override bool read()
        {
            Switch theSwitch = new Switch(myConn);

            Value = new endschalter(theSwitch.IsInputOn(InputConverter.GetInput(myConn.SMCSettings.AxisX.ReferencePinNumber), false),
                                    theSwitch.IsInputOn(InputConverter.GetInput(myConn.SMCSettings.AxisY.ReferencePinNumber), false),
                                    theSwitch.IsInputOn(InputConverter.GetInput(myConn.SMCSettings.AxisZ.ReferencePinNumber), false));

            return(true);
        }
Пример #10
0
        static void Main(string[] args)
        {
            IInputConverter inputConverter = new InputConverter();
            string          fileName       = "Input.txt";
            string          path           = Path.Combine(Environment.CurrentDirectory, fileName);
            IInputReader    reader         = new FileReader(path);
            ITrainsApp      trainsApp      = new TrainsApp(reader, inputConverter);

            trainsApp.Run();

            Console.Read();
        }
Пример #11
0
        static void Main(string[] args)
        {
            ConsoleUI ui = new ConsoleUI();
            var       displayFormatter = new DisplayFormatter();
            var       inputConverter   = new InputConverter();
            var       displayDelayer   = new Delayer(milliSecDelay: 1100);
            var       fileReader       = new FileReader();

            Game life = new Game(ui, displayFormatter, inputConverter, displayDelayer, fileReader);

            life.Run();
        }
            public static void then_should_print_out_the_map_for_i()
            {
                // Arrange
                const string inputString    = "i";
                var          outputDevice   = new StringOutputDevice();
                var          inputConverter = new InputConverter(outputDevice, inputString);

                // Act
                inputConverter.Convert();

                // Assert
                Assert.That(outputDevice.Output, Is.EqualTo("++--***.."));
            }
            public static void then_should_print_out_floating_map_of_a_for_input_1a()
            {
                // Arrange
                const string inputString    = "1a";
                var          outputDevice   = new StringOutputDevice();
                var          inputConverter = new InputConverter(outputDevice, inputString);

                // Act
                inputConverter.Convert();

                // Assert
                Assert.That(outputDevice.Output, Is.EqualTo(" +"));
            }
            public static void then_should_convert_complex_string_to_full_map()
            {
                // Arrange
                const string inputString    = "j3f3e3e3d3d3c3cee3c3c3d3d3e3e3f3fjij3f3f3e3e3d3d3c3cee3c3c3d3d3e3e3fj";
                var          outputDevice   = new Mock <IOutputDevice>();
                var          inputConverter = new InputConverter(outputDevice.Object, inputString);

                // Act
                inputConverter.Convert();

                // Assert
                outputDevice.Verify(device => device.Write("++--***..."));
                outputDevice.Verify(device => device.Write("   ++--** "));
            }
Пример #15
0
        public static void Main(string[] args)
        {
            InputConverter converter                          = new InputConverter();
            string         convertSourceFile                  = "InputManager.asset";
            string         convertDestinationFile             = "InputManager.xml";
            string         defaultInputManagerDestinationFile = "InputManager_Generated.asset";
            string         keyConverterFile                   = "KeyCodeConverter.cs";
            string         keyConverterTemplate               = File.ReadAllText("key_code_converter_template.txt");

            converter.ConvertUnityInputManager(convertSourceFile, convertDestinationFile);
            converter.GenerateDefaultUnityInputManager(defaultInputManagerDestinationFile);
            KeyNameGenerator.GenerateKeyNames(keyConverterTemplate, keyConverterFile);

            Console.WriteLine("Your key is: {0}", KeyCodeConverter.KeyToString(KeyCode.Joystick1Button11));
        }
Пример #16
0
        public static int Main(string[] args)
        {
            InputConverterFactory inputConverterFactory = new InputConverterFactory();
            InputConverter        inputConverter        = inputConverterFactory.ComposeInputConverter();
            Attempt <string>      attempt = inputConverter.Convert(args);

            if (attempt.Failed)
            {
                Console.WriteLine(attempt.Error.Message);
                return(1);
            }

            Console.WriteLine(attempt.Result);
            return(0);
        }
Пример #17
0
        static void Main(string[] args)
        {
            InputConverter input     = new InputConverter();
            OutputService  output    = new OutputService();
            MenuExplorer   menu      = new MenuExplorer();
            string         closeTime = "23:30";
            DateTime       time      = DateTime.Parse(closeTime);

            output.callMenu(time, menu);
            input.readOrder(time, output, menu);
            output.order(2, menu);
            EditMenu edit = new EditMenu();

            input.AddingDish(edit);
            input.readOrder(time, output, menu);
        }
Пример #18
0
        public void Draw(GameSceneViewContext viewContext)
        {
            int currentPinScore = 0;

            while (true)
            {
                Console.Clear();
                scoreBoardView.Draw(viewContext.LaneNumber, viewContext.UserScores);
                if (viewContext.IsGameCompleted)
                {
                    return;
                }

                Console.WriteLine();
                Console.WriteLine($" {viewContext.CurrentPlayerName} 턴 (0 ~ {viewContext.AvailableNextMaxPinScore} 중 선택, -1를 입력하면 타이틀로 돌아감)");
                Console.Write($" => ");
                var input = Console.ReadLine();
                if (InputConverter.TryConvertInteger(input, out currentPinScore))
                {
                    if (currentPinScore == -1)
                    {
                        OnGoToTitle?.Invoke();
                        return;
                    }

                    if (currentPinScore >= 0 && currentPinScore <= viewContext.AvailableNextMaxPinScore)
                    {
                        break;
                    }
                }

                Console.WriteLine();
                Console.WriteLine($" -1 ~ {viewContext.AvailableNextMaxPinScore} 사이 숫자만 입력해주세요.");
                Console.ReadLine();
            }

            OnInputPinScore?.Invoke(currentPinScore);
        }
Пример #19
0
        public void Draw()
        {
            int playerCount = 0;

            while (true)
            {
                Console.Clear();
                Console.WriteLine(" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
                Console.WriteLine(" $$$         볼링 한판?!       $$$");
                Console.WriteLine(" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
                Console.WriteLine();
                Console.WriteLine($" 플레이 할 인원을 선택해주세요. (1명 ~ {maxPlayerCount}명 중 선택, 0을 입력하면 게임 종료)");
                Console.Write(" => ");
                var input = Console.ReadLine();
                if (InputConverter.TryConvertInteger(input, out playerCount) && playerCount >= 0 && playerCount <= maxPlayerCount)
                {
                    break;
                }

                Console.WriteLine();
                Console.Write($"0 ~ {maxPlayerCount} 사이 숫자만 입력해주세요.");
                Console.ReadLine();
            }

            if (playerCount == 0)
            {
                Console.WriteLine();
                Console.WriteLine($" 게임을 종료합니다.");
                OnEndGame?.Invoke();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine($" 플레이 인원은 {playerCount}명 입니다. 게임을 시작합니다!");
                OnSelectPlayerCount?.Invoke(playerCount);
            }
        }
Пример #20
0
        public static bool OverwriteProjectSettings()
        {
            int    length = Application.dataPath.LastIndexOf('/');
            string projectSettingsFolder = string.Concat(Application.dataPath.Substring(0, length), "/ProjectSettings");
            string inputManagerPath      = string.Concat(projectSettingsFolder, "/InputManager.asset");

            if (!Directory.Exists(projectSettingsFolder))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the ProjectSetting folder.", "OK");
                return(false);
            }

            if (!File.Exists(inputManagerPath))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the InputManager file from the ProjectSettings folder.", "OK");
                return(false);
            }

            int    option     = EditorUtility.DisplayDialogComplex("Warning", "Do you want to export your old input settings?\n\nYour project needs to have asset serialization mode set to 'Force Text' in the Editor Settings. If text serialization is not enabled press the Abort button.\n\nYou can resume this process after text serialization is enabled from the File menu.", "Yes", "No", "Abort");
            string exportPath = null;

            if (option == 0)
            {
                exportPath = EditorUtility.SaveFilePanel("Export old input axes", "", "unity_input_export", "xml");
                if (string.IsNullOrEmpty(exportPath))
                {
                    if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (option == 1)
                {
                    if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            InputConverter inputConverter = new InputConverter();

            if (!string.IsNullOrEmpty(exportPath))
            {
                try
                {
                    inputConverter.ConvertUnityInputManager(inputManagerPath, exportPath);
                }
                catch (System.Exception ex)
                {
                    Debug.LogException(ex);

                    string message = "Failed to export your old input settings. Please make sure asset serialization mode is set to 'Forced Text' in the Editor Settings.\n\nDo you want to continue? If you continue your old input settings will be lost forever.";
                    if (!EditorUtility.DisplayDialog("Error", message, "Yes", "No"))
                    {
                        return(false);
                    }
                }
            }

            inputConverter.GenerateDefaultUnityInputManager(inputManagerPath);

            EditorUtility.DisplayDialog("Success", "The input settings have been successfully replaced.\n\nYou might need to minimize and restore Unity to reimport the new settings.", "OK");

            return(true);
        }
Пример #21
0
 public void Setup()
 {
     _inputConverter = new InputConverter();
 }
Пример #22
0
 private void HandleMouseButtonUp(object sender, MouseButtonEventArgs e)
 {
     currentScreen.MouseButtonUp(InputConverter.Map(e));
 }
Пример #23
0
        public MatrixRouteCounterTest()
        {
            var matrix = new InputConverter().ConvertToMatrix("Graph: AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            _matrixRouteCounter = new MatrixRouteCounter(matrix);
        }
Пример #24
0
 private void HandleKeyUp(object sender, KeyboardKeyEventArgs e)
 {
     currentScreen.KeyUp(InputConverter.Map(e));
 }
        public void SetUp()
        {
            InputConverterFactory inputConverterFactory = new InputConverterFactory();

            _inputConverter = inputConverterFactory.ComposeInputConverter();
        }
Пример #26
0
 public CsvParser(IWebClient webClient)
 {
     this.webClient = webClient;
     inputConverter = new InputConverter();
 }
Пример #27
0
        public void ShouldThrowErrorForInvalidInput()
        {
            const string input = "-";

            Assert.Throws <ArgumentException>(() => InputConverter.Convert(input));
        }
Пример #28
0
 private void HandleMouseWheel(object sender, MouseWheelEventArgs e)
 {
     currentScreen.MouseWheel(InputConverter.Map(e));
 }
Пример #29
0
        /// <summary>
        /// Generates a wxs file for use by wix.
        /// </summary>
        /// <param name="args">
        ///  CMD.EXE: SimpleWix.exe [SourceFolder] [AddInName] [AddInVersion] [RevitVersions] [UpgradeCode]
        ///
        /// SourceFolder:   The folder to build from. This will be the equivalent of the Autodesk\Revit\Addins\YYYY\ folder. e.g. "C:\repos\Interior Partition Tools\bin"
        ///
        /// AddInName:      The name of your addin e.g. "Interior Partition Tools"
        ///
        /// AddInVersion:   The version of your addin e.g. "0.0.0.1"
        ///
        /// RevitVersions:  The revit versions to build for, separated by a "-", e.g. "2017-2018-2019"
        ///
        /// UpgradeCode:    A GUID for your product. This essentially identifies your product as what it is, and let's the
        ///                 installer know to uninstall previous versions. If this changes your installer *will not* uninstall the previous
        ///                 version before installing this one. e.g. "ANY-VALID-GUID"
        /// </param>
        static void Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    if (args[0].ToLower() == "init")
                    {
                        RunInit();
                        return;
                    }
                }
                Manifest inputs = InputResult.GetManifest(args);
                QuietMode = inputs?.quietmode ?? false;

                Console.WriteLine(inputs.Print());
                //Console.ReadKey();
                ValidateManifest(inputs);


                printTitle(inputs);
                if (!QuietMode)
                {
                    Console.WriteLine("Press any key to continue: ...");
                    Console.ReadKey();
                }

                var fs = InputConverter.ConvertManifestToFileSystem(inputs.features);
                //Console.WriteLine(fs.Print());
                var wix = WixConverter.ConvertFileSystem(fs, inputs.upgradecode, inputs.appname, inputs.version, inputs.icon,
                                                         inputs.manufacturer, inputs.panel, inputs.banner, inputs.license);

                List <string> outPut = wix.Print(0);
                outPut.Insert(0, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

                using (StreamWriter wr = new StreamWriter(inputs.outputfile))
                {
                    foreach (string s in outPut)
                    {
                        wr.WriteLine(s);
                    }
                    // xs.Serialize(wr, targetDir);
                }

                using (StreamReader sr = new StreamReader(inputs.outputfile))
                {
                    while (sr.Peek() >= 0)
                    {
                        sr.ReadLine();
                        //Console.WriteLine(sr.ReadLine());
                    }
                }
                int x = 0;


                Console.WriteLine("XML WixFile Succesfully Saved To: " + inputs.outputfile);

                Console.WriteLine("");
                Console.WriteLine("");
                if (inputs.complete ?? false)
                {
                    var dir = Path.GetDirectoryName(inputs.outputfile);
                    PrintDir(dir);
                    var candlePath = FindCandlePath();
                    var wixobj     = "\"" + inputs.outputfile.Replace(".wxs", ".wixobj") + "\"";
                    Console.WriteLine(RunProcessAndWaitForOutput(candlePath, "\"" + inputs.outputfile + "\"" + " -out " + wixobj));
                    PrintDir(dir);

                    Console.WriteLine("");
                    Console.WriteLine("");
                    var msi       = wixobj.Replace(".wixobj", ".msi");
                    var lightPath = FindLightPath();
                    Console.Write(RunProcessAndWaitForOutput(lightPath, "-ext WixUIExtension " + wixobj + " -sice:ICE91" + " -out " + msi));
                    PrintDir(dir);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("An unexpected error occurred:" + Environment.NewLine + e.ToString());
                if (!QuietMode)
                {
                    Console.WriteLine();
                    Console.WriteLine("Press any key to exit ...");
                    Console.ReadKey();
                }
                Environment.Exit(1);
            }

            if (!QuietMode)
            {
                Console.WriteLine();
                Console.WriteLine("Press any key to exit ...");
                Console.ReadKey();
            }

            Console.WriteLine("Now exiting, goodbye.");
        }
Пример #30
0
 private void HandleKeyPress(object sender, KeyPressEventArgs e)
 {
     currentScreen.KeyPress(InputConverter.Map(e));
 }