public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string input = (string)value == null ? "" : (string)value;
            IEnumerable <string> args = CommandConsoleViewModel.GetArguments(input);
            string key = input.ToLower().Trim().Split(' ').FirstOrDefault().Replace("_", " ");

            return(key.Length == 0 ? new SolidColorBrush(new Color()
            {
                R = 192, G = 192, B = 192, A = 255
            }) : App.CommandRegisterService.Contains(key) ? Brushes.Green : Brushes.Red);
        }
示例#2
0
        public CommandConsoleView()
        {
            InitializeComponent();

            CommandConsoleViewModel vm = new CommandConsoleViewModel();

            this.DataContext    = vm;
            vm.CloseWindow      = new RelayCommand(this.Close);
            vm.ScrollIntoBottom = new RelayCommand(() => this.Scroller.ScrollToBottom());
            this.Closing       += (sender, e) => vm.Cleanup();

            this.MouseLeftButtonDown += (sender, e) => this.InputTextBox.Focus();
            this.MouseLeftButtonUp   += (sender, e) => this.InputTextBox.Focus();
        }
示例#3
0
        public override void CreateCommandConsole(CommandConsoleConfig config)
        {
            if (CreateUI == false)
            {
                return;
            }

            _commandConsoleConfig = config;

            _commandConsoleViewModel = new CommandConsoleViewModel();

            _commandConsoleWindow = new CommandConsoleWindow
            {
                Top    = config.Top,
                Left   = config.Left,
                Width  = config.Width,
                Height = config.Height
            };

            _commandConsoleWindow.DataContext = _commandConsoleViewModel;

            _profilerViewModel.LevelItemChanged += (sender, args) =>
            {
                OnLevelItemChanged(new LevelItemChangedEventArgs(args.Key, args.LevelId, args.Enabled));
            };

            _commandConsoleWindow.ClearOutput      += (sender, args) => _commandConsoleViewModel.ClearOutput();
            _commandConsoleWindow.IsVisibleChanged += (sender, args) => _commandConsoleConfig.Visible = _commandConsoleWindow.IsVisible;
            _commandConsoleWindow.LocationChanged  += (sender, args) => _commandConsoleLocationJustChanged = true;
            _commandConsoleWindow.SizeChanged      += (sender, args) => _commandConsoleLocationJustChanged = true;

            _commandConsoleWindow.ExecuteCommand  += (sender, args) => GearsetResources.Console.CommandConsole.ExecuteCommand(args.Command);
            _commandConsoleWindow.PreviousCommand += (sender, args) => _commandConsoleViewModel.CommandText = GearsetResources.Console.CommandConsole.PreviousCommand();
            _commandConsoleWindow.NextCommand     += (sender, args) => _commandConsoleViewModel.CommandText = GearsetResources.Console.CommandConsole.NextCommand();

            if (_commandConsoleConfig.Visible)
            {
                _commandConsoleWindow.Show();
            }

            _windows.Add(_commandConsoleWindow);

            _consoleScrollViewer = GetDescendantByType(_commandConsoleWindow.OutputListView, typeof(ScrollViewer)) as ScrollViewer;

            WindowHelper.EnsureOnScreen(_commandConsoleWindow);
            ElementHost.EnableModelessKeyboardInterop(_commandConsoleWindow);
        }