Esempio n. 1
0
        public static void Initialize(MainWindow window)
        {
            if (instance != null)
                return;

            instance = new SettingsManager();
            instance.mainWindow = window;

            instance.commandmanager = new CommandManager(instance);

            instance.InitializeUI();
        }
Esempio n. 2
0
 public CommandManager(SettingsManager sm)
 {
     settingsmanager = sm;
 }
Esempio n. 3
0
        public bool SendCommand(string commandName, string param1, string param2, string param3, SettingsManager.CommandDestiny commandDestiny)
        {
            if (bluetoothConnection != null &&
                bluetoothConnection.ConnectionState == "ConnectionUp")
            {
                Command command = commands.Find(x => x.CommandName == commandName);

                string destiny = "S";

                switch(commandDestiny)
                {
                    case SettingsManager.CommandDestiny.Bluetooth:
                    {
                        destiny = "B";
                        break;
                    }
                    case SettingsManager.CommandDestiny.System:
                    {
                        destiny = "S";
                        break;
                    }
                    case SettingsManager.CommandDestiny.WiFi:
                    {
                        destiny = "W";
                        break;
                    }
                }
                string commandText = destiny + command.CommandText;

                if (command.ParameterNumber > 0)
                    commandText += "=" + param1;
                if (command.ParameterNumber > 1)
                    commandText += "," + param2;
                if (command.ParameterNumber > 2)
                    commandText += "," + param3;
                commandText += "\n";

                return bluetoothConnection.Send(commandText);
            }

            else
                return false;
        }