Example #1
0
        public MessageBoxViewModel(Window window, string messageBoxText, string title = "", MessageBoxType messageBoxType = MessageBoxType.Ok)
        {
            this.window    = window;
            Title          = title;
            MessageBoxText = messageBoxText;
            MessageBoxType = messageBoxType;

            if (MessageBoxType == MessageBoxType.Ok)
            {
                OkCommand.Subscribe(_ =>
                {
                    this.window.Close(true);
                });
            }
            else if (MessageBoxType == MessageBoxType.YesNo)
            {
                YesCommand.Subscribe(_ =>
                {
                    this.window.Close(true);
                });

                NoCommand.Subscribe(_ =>
                {
                    this.window.Close(false);
                });
            }
        }
    string nom_act(string nom)
    {
        string          no_act = " ";
        MySqlCommand    NoCommand;
        MySqlDataReader NoReader;

        //while (QuestionReader.Read())
        //Connection.Open();
        if (Connection != null)
        {
            NoCommand             = Connection.CreateCommand();
            NoCommand.CommandText = "Select NumeroActivite from activites where TitreActivite ='" + nom + "'";
            NoReader = NoCommand.ExecuteReader();
            if (NoReader.Read())
            {
                no_act = NoReader["NumeroActivite"].ToString();
            }
            NoReader.Close();
        }
        else
        {
            //connexion non réussie
            Response.Redirect("Accueil.aspx");
        }
        return(no_act);
    }
Example #3
0
    public async Task OnMessageReceived(Message?message)
    {
        _logger.LogInformation(MessageLogMsg, message?.Chat.Id, message?.From?.Username, message?.Text);

        if (message?.Text is null || message.Type != MessageType.Text)
        {
            return;
        }

        var    command = new CommandParser(message.Text).Parse();
        var    chatId  = message.Chat.Id;
        string username;

        if (message.From is null)
        {
            username = "******";
        }
        else
        {
            username = string.IsNullOrEmpty(message.From.Username)
                ? $"{message.From.FirstName} {message.From.LastName}"
                : message.From.Username;
        }

        IAction cmd;

        if (_botService.IsPrivateMode && chatId != _botService.PrivateChetId)
        {
            cmd = new NoCommand();
        }
        else
        {
            cmd = command.Name switch
            {
                "echo" => new Echo(_botService, chatId, command.Arguments),
                "hey" => new Hey(_botService, chatId),
                "ex" => new CurrencyExchange(_botService, chatId, command.Arguments, _configuration["apiForexKey"]),
                "ud" => new UrbanDictionary(_botService, _clientFactory, chatId, command.Arguments),
                "go" => new DuckDuckGo(_botService, _clientFactory, chatId, command.Arguments),
                "dice" => new RollDice(_botService, chatId, command.Arguments, username),
                "l" => new GoogleMaps(_botService, _clientFactory, chatId, command.Arguments,
                                      _configuration["googleApiKey"]),
                "weekday" => new WeekDay(_botService, chatId),
                "timein" => new TimeInPlace(_botService, _clientFactory, chatId, command.Arguments,
                                            _configuration["googleApiKey"]),
                "ball" => new MagicBall(_botService, chatId, command.Arguments),
                "weather" => new Weather(_botService, _clientFactory, chatId, command.Arguments),
                _ => new NoCommand()
            }
        };

        try
        {
            await cmd.HandleAsync();
        }
        catch (Exception e)
        {
            _logger.LogError("Cannot execute command, error {Message}", e.Message);
        }
    }
Example #4
0
    public void AddCommand(float camPos, float camDist)
    {
        ICommand distCommand;
        ICommand posCommand;

        if (lastCamPos == camPos) // No movement
        {
            posCommand = new NoCommand();
        }
        else if (lastCamPos < camPos) // Moved right
        {
            posCommand = new CameraMoveRight();
        }
        else // Moved left
        {
            posCommand = new CameraMoveLeft();
        }

        if (lastCamDist == camDist) // No movement
        {
            distCommand = new NoCommand();
        }
        else if (lastCamDist < camDist) // Zoomed out
        {
            distCommand = new CameraForward();
        }
        else // Zoomed in
        {
            distCommand = new CameraBackward();
        }

        properties.SetCommands(currentSlot, posCommand, distCommand);
        currentSlot++;
    }
Example #5
0
        public AskDialog()
        {
            CommandBindings.AddRange(new[]
            {
                new CommandBinding(RoutedYesCommand,
                                   (s, e) =>
                {
                    if (YesCommand == null)
                    {
                        return;
                    }

                    YesCommand.Execute(null);
                },
                                   (s, e) => { e.CanExecute = true; }),
                new CommandBinding(RoutedNoCommand,
                                   (s, e) =>
                {
                    if (NoCommand == null)
                    {
                        return;
                    }

                    NoCommand.Execute(null);
                },
                                   (s, e) => { e.CanExecute = true; }),
            });
        }
 public RemoteControl()
 {
     for (int i = 0; i < ButtonCount; i++)
     {
         _onCommands[i]  = new NoCommand();
         _offCommands[i] = new NoCommand();
     }
 }
Example #7
0
 public InvokerRemoteControl()
 {
     for (int i = 0; i < capacity; i++)
     {
         slotsOnCommand[i]  = new NoCommand();
         slotsOffCommand[i] = new NoCommand();
     }
 }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if(nameBox.Text == "")
            {
                MessageBox.Show("You must include a name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            else
            {
                NC = new NoCommand
                {
                    Name = "",
                    TriggerNumbers = new TriggerNumbers(),
                    TriggerLists = new TriggerLists()
                };

                NC.Name = nameBox.Text;
                List<SteamID> ignores = new List<SteamID>();
                List<SteamID> rooms = new List<SteamID>();
                List<SteamID> users = new List<SteamID>();
                if (delayBox.Text == "") NC.TriggerNumbers.Delay = null;
                else NC.TriggerNumbers.Delay = Convert.ToInt32(delayBox.Text);

                if (probBox.Text == "") NC.TriggerNumbers.Probability = null;
                else NC.TriggerNumbers.Probability = (float)Convert.ToDouble(probBox.Text);

                if (timeoutBox.Text == "") NC.TriggerNumbers.Timeout = null;
                else NC.TriggerNumbers.Timeout = Convert.ToInt32(timeoutBox.Text);

                if (ignoresBox.Text.Split(',').Length > 0 && ignoresBox.Text != "")
                {
                    foreach (string ignore in ignoresBox.Text.Split(','))
                    {
                        ignores.Add(new SteamID(Convert.ToUInt64(ignore)));
                    }
                }
                if (roomsBox.Text.Split(',').Length > 0 && roomsBox.Text != "")
                {
                    foreach (string room in roomsBox.Text.Split(','))
                    {
                        rooms.Add(new SteamID(Convert.ToUInt64(room)));
                    }
                }
                if (usersBox.Text.Split(',').Length > 0 && usersBox.Text != "")
                {
                    foreach (string user in usersBox.Text.Split(','))
                    {
                        users.Add(new SteamID(Convert.ToUInt64(user)));
                    }
                }

                NC.TriggerLists.Ignore = ignores;
                NC.TriggerLists.Rooms = rooms;
                NC.TriggerLists.User = users;
                DialogResult = true;
                Close();
            }
        }
Example #9
0
 public MultiPult()
 {
     buttons = new ICommand[2];
     for (int i = 0; i < buttons.Length; i++)
     {
         buttons[i] = new NoCommand();
     }
     commandsHistory = new Stack <ICommand>();
 }
Example #10
0
        public RemoteControl()
        {
            OnCommands  = new ICommand[7];
            OffCommands = new ICommand[7];

            for (int i = 0; i < 7; i++)
            {
                OnCommands[i]  = new NoCommand();
                OffCommands[i] = new NoCommand();
            }
        }
Example #11
0
        public SimpleRemoteControl()
        {
            onCommands  = new ICommand[7];
            offCommands = new ICommand[7];

            for (int i = 0; i < onCommands.Length; i++)
            {
                onCommands[i]  = new NoCommand();
                offCommands[i] = new NoCommand();
            }
        }
Example #12
0
        //初始化遥控器类 一开始都是无操作noCommand是一个无操作对象
        //在测试输出时 没有被明确指明命令的插槽 其命令默认为noCommand对象
        public RemoteControl()
        {
            Command noCommand = new NoCommand();

            for (int i = 0; i < onCommands.Length; i++)
            {
                onCommands[i]  = noCommand;
                offCommands[i] = noCommand;
            }
            undoCommand = noCommand;
        }
    public GameController()
    {
        commands = new Command[5];

        Command noCommand = new NoCommand();

        for (int i = 0; i < commands.Length; ++i)
        {
            commands[i] = noCommand;
        }
    }
    public RemoteControl()
    {
        onCommands   = new ICommand[5];
        offCommands  = new ICommand[5];
        undoCommands = new Stack <ICommand>();

        for (int i = 0; i > 5; i++)
        {
            onCommands[i] = new NoCommand();
        }
    }
        public MyToyPiano(int numKeys)
        {
            PlayCommands = new Command[numKeys];
            Command noCommand = new NoCommand();

            UndoCommands.Push(noCommand);

            for (int i = 0; i < numKeys; i++)
            {
                PlayCommands[i] = noCommand;
            }
        }
Example #16
0
        public RemoteControl()
        {
            _onCommands  = new ICommand[7];
            _offCommands = new ICommand[7];
            ICommand noCommand = new NoCommand();

            for (int i = 0; i < _onCommands.Length; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
        }
        public AdvancedRemote()
        {
            onCommands  = new Command[2];
            offCommands = new Command[2];
            Command noCommand = new NoCommand();

            for (int i = 0; i < onCommands.Length; i++)
            {
                onCommands[i]  = noCommand;
                offCommands[i] = noCommand;
            }
        }
        public RemoteControl()
        {
            onCommands  = new ICommand[7];
            offCommands = new ICommand[7];

            ICommand noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                onCommands[i]  = noCommand;
                offCommands[i] = noCommand;
            }
        }
Example #19
0
        public RemoteControl()
        {
            OnCommand  = new ICommand[7];
            OffCommand = new ICommand[7];
            ICommand noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                OnCommand[i]  = noCommand;
                OffCommand[i] = noCommand;
            }
            UndoCommand = noCommand;
        }
        public RemoteControl()
        {
            this.onCommand  = new ICommand[SlotRemoteControl];
            this.offCommand = new ICommand[SlotRemoteControl];
            var noCommand = new NoCommand();

            for (int i = 0; i < SlotRemoteControl; i++)
            {
                onCommand[i]  = noCommand;
                offCommand[i] = noCommand;
            }
            this.undoCommand = noCommand;
        }
Example #21
0
            public RemoteControl()
            {
                _iOnCommands  = new ICommand[3];
                _iOffCommands = new ICommand[3];
                ICommand noCommand = new NoCommand();

                for (int i = 0; i < 3; i++)
                {
                    _iOnCommands[i]  = noCommand;
                    _iOffCommands[i] = noCommand;
                }
                _undoCommand = noCommand;
            }
        public RemoteControl()
        {
            _onCommands  = new ICommand[7];
            _offCommands = new ICommand[7];

            var noCommand = new NoCommand();

            for (var i = 0; i < 7; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
        }
Example #23
0
        public RemoteControl()
        {
            _onCommands = new ICommand[MaxCommandsCount];
            _offCommands = new ICommand[MaxCommandsCount];

            var noCommand = new NoCommand();
            for (int i = 0; i < MaxCommandsCount; i++)
            {
                _onCommands[i] = noCommand;
                _offCommands[i] = noCommand;
            }

            _undoCommand = noCommand;
        }
Example #24
0
        public RemoteControl()
        {
            _onCommands  = new Command[7];
            _offCommands = new Command[7];
            //创建空命令
            Command nc = new NoCommand();

            for (int i = 0; i < _onCommands.Count(); i++)
            {
                _onCommands[i]  = nc;
                _offCommands[i] = nc;
            }
            undoCommand = nc;
        }
        public RemoteControl()
        {
            _onCommands  = new ICommand[7];
            _offCommands = new ICommand[7];

            var noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
            _undoCommands.Push(noCommand);
        }
Example #26
0
        public RemoteControl(int slots)
        {
            _onCommand  = new ICommand[slots];
            _offCommand = new ICommand[slots];

            var none = new NoCommand();

            _undoCommand = none;
            for (var i = 0; i < slots; i++)
            {
                _onCommand[i]  = none;
                _offCommand[i] = none;
            }
        }
        public RemoteControlWithUndo()
        {
            _onCommands  = new ICommand[7];
            _offCommands = new ICommand[7];

            ICommand noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
            _undoCommand = new NoCommand();
        }
Example #28
0
        private void AssignEmptyCommandToSlots()
        {
            _onCommands  = new ICommand[7];
            _offCommands = new ICommand[7];

            ICommand noCommand = new NoCommand();

            for (var i = 0; i < 7; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
            _undoCommand = noCommand;
        }
        public RemoteControlWithUndo()
        {
            onCommands  = new ICommand[7];
            offCommands = new ICommand[7];

            var noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                onCommands[i]  = noCommand;
                offCommands[i] = noCommand;
            }
            undoCommand = noCommand;
        }
        public SimpleRemoteControl()
        {
            _onCommand  = new List <ICommand>(7);
            _offCommand = new List <ICommand>(7);

            ICommand noCommand = new NoCommand();

            for (int i = 0; i < 7; i++)
            {
                _onCommand.Add(noCommand);
                _offCommand.Add(noCommand);
            }
            _undoCommand = noCommand;
        }
        public RemoteControl()
        {
            int len = 7;

            _onCommands  = new ICommand[len];
            _offCommands = new ICommand[len];

            NoCommand noCommand = new NoCommand();

            for (int i = 0; i < len; i++)
            {
                _onCommands[i]  = noCommand;
                _offCommands[i] = noCommand;
            }
        }
        private void doneButton_Click(object sender, RoutedEventArgs e)
        {
            ncw.ShowDialog();
            if(ncw.DialogResult == true)
            {
                NC = ncw.NC;
                DO = new DiscordOptions
                {
                    Name = NC.Name,
                    Token = "",
                    SteamChat = new SteamKit2.SteamID(),
                    DiscordServerID = 0
                };
            }

            if(tokenBox.Text == "")
            {
                MessageBox.Show("Token is required!", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            else
            {
                DO.Token = tokenBox.Text;
            }

            if (steamchatBox.Text == "")
            {
                MessageBox.Show("Steam Chat ID is required!", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            else
            {
                DO.SteamChat = new SteamKit2.SteamID(Convert.ToUInt64(steamchatBox.Text));
            }

            if (serverIDBox.Text == "")
            {
                MessageBox.Show("Discord Server ID is required!", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            else
            {
                DO.DiscordServerID = Convert.ToUInt64(serverIDBox.Text);
            }

            DialogResult = true;
            Close();
        }
Example #33
0
 public Remote()
 {
     onCommands = new Command[7];
     offCommands = new Command[7];
     Command noCommand = new NoCommand();
     for (int i = 0; i < 7; i++)
     {
         onCommands[i] = noCommand;
         offCommands[i] = noCommand;
     }
 }
        private void doneButton_Click(object sender, RoutedEventArgs e)
        {
            ncw.ShowDialog();
            if (ncw.DialogResult == true)
            {
                NC = ncw.NC;
                ASTO = new AntiSpamTriggerOptions
                {
                    Name = NC.Name,
                    admins = new List<SteamID>(),
                    warnMessage = "Spamming is against the rules!",
                    msgPenalty = 1,
                    score = new Score
                    {
                        warn = 3,
                        warnMax = 5,
                        kick = 6,
                        ban = 8,
                        tattle = 4,
                        tattleMax = 5
                    },
                    timers = new Timers
                    {
                        messages = 5000,
                        unban = 1000 * 60 * 5
                    },
                    ptimer = new PTimer
                    {
                        resolution = 1000,
                        amount = 1
                    },
                    groups = new Dictionary<SteamID, Dictionary<SteamID, int>>(),
                    NoCommand = NC
                };

                List<SteamID> admins = new List<SteamID>();

                if (adminsBox.Text.Split(',').Length > 0 && adminsBox.Text != "")
                {
                    try {
                        foreach (string admin in adminsBox.Text.Split(','))
                        {
                            admins.Add(new SteamID(Convert.ToUInt64(admin)));
                        }
                    }
                    catch(Exception err)
                    {
                        MessageBox.Show(err.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    }
                }

                if (warnMsgBox.Text != "") ASTO.warnMessage = warnMsgBox.Text;
                if (penaltyBox.Text != "") ASTO.msgPenalty = Convert.ToInt32(penaltyBox.Text);
                if (resolutionBox.Text != "") ASTO.ptimer.resolution = Convert.ToInt32(resolutionBox.Text);
                if (amountBox.Text != "") ASTO.ptimer.amount = Convert.ToInt32(amountBox.Text);
                if (unbanBox.Text != "") ASTO.timers.unban = Convert.ToInt32(unbanBox.Text);

                if (warn.Text != "") ASTO.score.warn = Convert.ToInt32(warn.Text);
                if (warnMax.Text != "") ASTO.score.warnMax = Convert.ToInt32(warnMax.Text);
                if (ban.Text != "") ASTO.score.ban = Convert.ToInt32(ban.Text);
                if (kick.Text != "") ASTO.score.kick = Convert.ToInt32(kick.Text);
                if (tattle.Text != "") ASTO.score.tattle = Convert.ToInt32(tattle.Text);
                if (tattleMax.Text != "") ASTO.score.tattleMax = Convert.ToInt32(tattleMax.Text);

                ASTO.admins = admins;
                DialogResult = true;
                Close();
            }
        }