public RCONWindow(RCONParameters parameters)
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this);

            this.CurrentInputWindowMode = InputWindowMode.None;
            this.RCONParameters         = parameters;
            this.PlayerFiltering        = (PlayerFilterType)Config.Default.RCON_PlayerListFilter;
            this.PlayerSorting          = (PlayerSortType)Config.Default.RCON_PlayerListSort;
            this.ServerRCON             = new ServerRCON(parameters);
            this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput);
            this.PlayersView        = CollectionViewSource.GetDefaultView(this.ServerRCON.Players);
            this.PlayersView.Filter = p =>
            {
                var player = p as PlayerInfo;

                return((this.PlayerFiltering.HasFlag(PlayerFilterType.Online) && player.IsOnline) ||
                       (this.PlayerFiltering.HasFlag(PlayerFilterType.Offline) && !player.IsOnline) ||
                       (this.PlayerFiltering.HasFlag(PlayerFilterType.Banned) && player.IsBanned) ||
                       (this.PlayerFiltering.HasFlag(PlayerFilterType.Whitelisted) && player.IsWhitelisted));
            };

            var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (s, a) =>
            {
                this.RenderConnectionStateChange(a);
            });

            this.DataContext = this;

            AddCommentsBlock(
                "Enter commands or chat into the box at the bottom.",
                "In Command mode, everything you enter will be a normal admin command",
                "In Broadcast mode, everything you enter will be a global broadcast",
                "You may always prefix a command with / to be treated as a command and not chat.",
                "Right click on players in the list to access player commands",
                "Type /help to get help");

            if (this.RCONParameters.RCONWindowExtents.Width > 50 && this.RCONParameters.RCONWindowExtents.Height > 50)
            {
                this.Left   = this.RCONParameters.RCONWindowExtents.Left;
                this.Top    = this.RCONParameters.RCONWindowExtents.Top;
                this.Width  = this.RCONParameters.RCONWindowExtents.Width;
                this.Height = this.RCONParameters.RCONWindowExtents.Height;

                //
                // Fix issues where the console was saved while offscreen.
                if (this.Left == -32000)
                {
                    this.Left = 0;
                }

                if (this.Top == -32000)
                {
                    this.Top = 0;
                }
            }

            this.ConsoleInput.Focus();
        }
        public RCONWindow(RCONParameters parameters)
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this);

            this.CurrentInputWindowMode = InputWindowMode.None;
            this.PlayerFiltering        = (PlayerFilterType)Config.Default.RCON_PlayerListFilter;
            this.PlayerSorting          = (PlayerSortType)Config.Default.RCON_PlayerListSort;
            this.RCONParameters         = parameters;
            this.ServerRCON             = new ServerRCON(parameters);
            this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput);
            this.ServerRCON.Players.CollectionChanged += Players_CollectionChanged;
            this.ServerRCON.PlayersCollectionUpdated  += Players_CollectionUpdated;

            this.PlayersView        = CollectionViewSource.GetDefaultView(this.ServerRCON.Players);
            this.PlayersView.Filter = new Predicate <object>(PlayerFilter);

            var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (s, a) =>
            {
                this.RenderConnectionStateChange(a);
            });

            this.DataContext = this;

            AddCommentsBlock(
                _globalizer.GetResourceString("RCON_Comments_Line1"),
                _globalizer.GetResourceString("RCON_Comments_Line2"),
                _globalizer.GetResourceString("RCON_Comments_Line3"),
                _globalizer.GetResourceString("RCON_Comments_Line4"),
                _globalizer.GetResourceString("RCON_Comments_Line5"),
                String.Format(_globalizer.GetResourceString("RCON_Comments_Line6"),
                              _globalizer.GetResourceString("RCON_Help_Keyword")));

            if (this.RCONParameters.RCONWindowExtents.Width > 50 && this.RCONParameters.RCONWindowExtents.Height > 50)
            {
                this.Left   = this.RCONParameters.RCONWindowExtents.Left;
                this.Top    = this.RCONParameters.RCONWindowExtents.Top;
                this.Width  = this.RCONParameters.RCONWindowExtents.Width;
                this.Height = this.RCONParameters.RCONWindowExtents.Height;

                //
                // Fix issues where the console was saved while offscreen.
                if (this.Left == -32000)
                {
                    this.Left = 0;
                }

                if (this.Top == -32000)
                {
                    this.Top = 0;
                }
            }

            this.ConsoleInput.Focus();
        }
 public static RCONWindow GetRCON(RCONParameters parameters)
 {
     return(new RCONWindow(parameters));
 }
Exemple #4
0
        public RCONWindow(RCONParameters parameters)
        {
            InitializeComponent();
            WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);

            this.CurrentInputWindowMode = InputWindowMode.None;
            this.PlayerFiltering        = (PlayerFilterType)Config.Default.RCON_PlayerListFilter;
            this.PlayerSorting          = (PlayerSortType)Config.Default.RCON_PlayerListSort;
            this.RCONParameters         = parameters;
            this.ServerRCON             = new ServerRCON(parameters);
            this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput);
            this.ServerRCON.Players.CollectionChanged += Players_CollectionChanged;
            this.ServerRCON.PlayersCollectionUpdated  += Players_CollectionUpdated;

            this.PlayersView        = CollectionViewSource.GetDefaultView(this.ServerRCON.Players);
            this.PlayersView.Filter = new Predicate <object>(PlayerFilter);

            var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (o, e) =>
            {
                this.RenderConnectionStateChange(e);
            });

            if (this.RCONParameters?.Server?.Runtime != null)
            {
                this.RCONParameters.Server.Runtime.StatusUpdate += Runtime_StatusUpdate;
            }

            if (this.RCONParameters?.Server == null)
            {
                this.PlayerCountSeparator.Visibility = Visibility.Collapsed;
                this.MaxPlayerLabel.Visibility       = Visibility.Collapsed;
            }

            this.ServerRCON.Initialize();

            this.DataContext = this;

            RenderCommentsBlock(
                _globalizer.GetResourceString("RCON_Comments_Line1"),
                _globalizer.GetResourceString("RCON_Comments_Line2"),
                _globalizer.GetResourceString("RCON_Comments_Line3"),
                _globalizer.GetResourceString("RCON_Comments_Line4"),
                _globalizer.GetResourceString("RCON_Comments_Line5"),
                String.Format(_globalizer.GetResourceString("RCON_Comments_Line6"),
                              _globalizer.GetResourceString("RCON_Help_Keyword")));

            if (this.RCONParameters.WindowExtents.Width > 50 && this.RCONParameters.WindowExtents.Height > 50)
            {
                this.Left   = this.RCONParameters.WindowExtents.Left;
                this.Top    = this.RCONParameters.WindowExtents.Top;
                this.Width  = this.RCONParameters.WindowExtents.Width;
                this.Height = this.RCONParameters.WindowExtents.Height;

                //
                // Fix issues where the console was saved while offscreen.
                if (this.Left == -32000)
                {
                    this.Left = 0;
                }

                if (this.Top == -32000)
                {
                    this.Top = 0;
                }
            }

            SetPlayerListWidth(this.RCONParameters.PlayerListWidth);

            this.ConsoleInput.Focus();

            // hook into the language change event
            GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
        }