private void LoadStaticCommandPlugins()
        {
            var allStaticCommands =
                StaticCommander.GetStaticCommands().Select(x => new StaticCommandItem(x)).ToList();

            StaticCommandGroups = allStaticCommands.Where(x => !x.OfflineAvailable)
                                  .GroupBy(x => x.Category)
                                  .Select(x => new StaticCommandGroup {
                Name = x.Key, StaticCommands = x.ToList()
            })
                                  .ToList();

            OfflineStaticCommandGroups = allStaticCommands.Where(x => x.OfflineAvailable)
                                         .GroupBy(x => x.Category)
                                         .Select(x => new StaticCommandGroup {
                Name = x.Key, StaticCommands = x.ToList()
            })
                                         .ToList();

            CommandPresetsWithTarget = new CollectionViewSource {
                Source = CrowdControlPresets.Current.Presets
            };
            CommandPresetsWithTarget.Filter    +=
                (sender, args) => args.Accepted = !((PresetInfo)args.Item).Preset.IsCommandPreset;

            //idk why, but if we just take the ICollectionView, the SourceCollection becomes null and it doesn't update
            CommandPresets = new CollectionViewSource {
                Source = CrowdControlPresets.Current.Presets
            };
            CommandPresets.Filter +=
                (sender, args) => args.Accepted = ((PresetInfo)args.Item).Preset.IsCommandPreset;
        }
        public StaticCommandSelectionControl()
        {
            InitializeComponent();
            StaticCommandsCollectionView = new CollectionViewSource {
                Source = StaticCommander.GetStaticCommands()
            }.View;
            StaticCommandsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
            StaticCommandsCollectionView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            StaticCommandsCollectionView.Filter = FilterCommands;

            Loaded += OnLoaded;
        }
Example #3
0
        public void UniqueStaticCommandIdsTest()
        {
            var commandTokens  = new List <Guid>();
            var staticCommands = StaticCommander.GetStaticCommands();

            foreach (var staticCommand in staticCommands)
            {
                if (commandTokens.Any(x => x == staticCommand.CommandId))
                {
                    Assert.Fail($"Command tokens are doubled. Command: {staticCommand} and {staticCommands.First(x => x.CommandId == staticCommand.CommandId)}");
                }

                commandTokens.Add(staticCommand.CommandId);
            }
        }
        private ConnectionManager(string ip, int port, string password, IConnection connection)
        {
            DataTransferProtocolFactory = new DtpFactory(SendData);

            Ip       = ip;
            Port     = port;
            Password = password;
            Sender   = new Sender(connection);

            var serializer = new Serializer(new[] { typeof(WelcomePackage) });

            StaticCommander = new StaticCommander(this);

            var welcomePackage = (WelcomePackage)serializer.Deserialize(connection.BaseStream);

            _readByteDelegate += Sender.Connection.BinaryReader.ReadByte;
            _readByteDelegate.BeginInvoke(EndRead, null);

            var data = DataTransferProtocolFactory.ExecuteFunction <LightInformation>("GetAllClientsLight");

            ClientProvider  = new ClientProvider(data, DataTransferProtocolFactory);
            IpAddresses     = welcomePackage.IpAddresses;
            ExceptionsCount = welcomePackage.ExceptionCount;
        }
Example #5
0
 public CrowdControlViewModel(ConnectionManager connectionManager)
 {
     _connectionManager = connectionManager;
     StaticCommands     = StaticCommander.GetStaticCommands();
     Load();
 }