Beispiel #1
0
        private void SetupComponents(object sender, RoutedEventArgs e)
        {
            Closing += (o, args) => {
                Application.Current.Shutdown();
            };

            //Setup the command line interface
            Cmd = Cmd ?? CommandLine.GetInstance();

            //Taskbar notification icon
            TaskbarIconManager.AddItem("Show", () => {
                ShowInTaskbar = true;
                Visibility    = Visibility.Visible;
                Activate();
                WindowState = WindowState.Maximized;
            });
            TaskbarIconManager.AddItem("Exit", () => {
                Application.Current.Shutdown(0);
            });
            TaskbarIconManager.CommitItems();
            TaskbarIconManager.SetVisible(true);

            LoadedModules.SelectionChanged += LoadedModulesOnSelectionChanged;

            // Invokes commands recieved from TCP connections
            RemoteManager.CommandRecieved += (command, tcpClient) => {
                Task.Factory.StartNew(() => {
                    UserModule mod = null;
                    Command cm     = null;

                    if (UserModule.FindResponsibleUserModule(command, out mod, out cm, tcpClient))
                    {
                        Dispatcher.Invoke(() => {
                            Status = $"{(tcpClient != null ? (tcpClient.Client.RemoteEndPoint + " > ") : "")} [{mod.Name}:{mod.Prefix}] > {cm.LocalCommand}";
                            mod.GiveRegexCommand(cm);
                        });
                    }
                });
            };

            RemoteManager.ClientConnected += client => {
                Dispatcher.Invoke(() => {
                    Status = $"({client.Client.RemoteEndPoint}) has connected!";
                });
            };
            RemoteManager.ClientDisconnected += client => {
                Dispatcher.Invoke(() => {
                    Status = $"({client.Client.RemoteEndPoint}) has disconnected.";
                });
            };

            Command.Responded += (response, com, client) => {
                Dispatcher.Invoke(() => {
                    Status = $"{((com != null && com != Command.Empty) ? $"[{com?.UserModuleName}] > " : "")}{response}";
                });
            };
        }
        private void InitiateCommand()
        {
            var query = Input.Text;

            //_cmdInstance.Hide();

            Task.Run(() => {
                UserModule um = null;
                Command cm    = null;

                if (UserModule.FindResponsibleUserModule(query, out um, out cm))
                {
                    Dispatcher.Invoke(() => {
                        um.GiveRegexCommand(cm);
                        _commandHistory.Add(cm.ToString());
                    });
                }
            });
        }