예제 #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}";
                });
            };
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;

            SourceInitialized += Main_HotkeyRegister;   //Inside Hotkey Registration Region
            Closing           += Main_HotkeyDeregister; //Inside Hotkey Registration Region

            //When the application is closing, remove the taskbar icon
            Closed += (sender, e) => {
                TaskbarIconManager.Dispose();
            };

            Loaded       += SetupComponents;
            StateChanged += MainWindow_StateChanged;
        }