예제 #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.KeyPreview              = true;
            this.KeyDown                += MainForm_KeyDown;
            ConsoleTextBox.BackColor     = SystemColors.ControlLightLight;
            this.MaximizeBox             = false;
            ISLogger.MessageOut         += ISLogger_MessageOut;
            server.ClientConnected      += Server_ClientConnected;
            server.ClientDisconnected   += Server_ClientDisconnected;
            server.InputClientSwitched  += Server_InputClientSwitched;
            server.ServerStopped        += Server_ServerStopped;
            server.DisplayConfigChanged += Server_DisplayConfigChanged;
            ClientListBox.MouseClick    += ClientListBox_MouseClick;
            LeftClientListBox.SelectionChangeCommitted  += LeftClientListBox_SelectionChangeCommitted;
            RightClientListBox.SelectionChangeCommitted += RightClientListBox_SelectionChangeCommitted;
            AboveClientListBox.SelectionChangeCommitted += AboveClientListBox_SelectionChangeCommitted;
            BelowClientListBox.SelectionChangeCommitted += BelowClientListBox_SelectionChangeCommitted;

            ClientListBox.Hide();
            ClientSettingsPanel.Hide();

            trayIcon = new NotifyIcon();

            try
            {
                trayIcon.Icon = new Icon("TrayIcon.ico");
            }catch (Exception ex)
            {
                ISLogger.Write($"Failed to open TrayIcon.ico");
                ISLogger.Write(ex.Message);
            }

            trayIcon.Visible = true;
            trayIcon.Click  += TrayIcon_Click;
        }
예제 #2
0
        private void UpdateClientList()
        {
            if (ClientListBox.InvokeRequired)
            {
                ClientListBox.Invoke(new Action(() => { UpdateClientList(); }));
                return;
            }

            ClientListBox.Items.Clear();

            if (server == null || !server.Running)
            {
                return;
            }

            foreach (ConnectedClientInfo client in server.GetClients())
            {
                ClientListBox.Items.Add(client);
            }

            if (selectedClient == null)
            {
                ClientSettingsPanel.Hide();
            }
        }
예제 #3
0
 private void StartServer(int port)
 {
     server.Start(port);
     ServerStartButton.Invoke(new Action(() => { ServerStartButton.Text = "Stop server";
                                                 ClientSettingsPanel.Show();
                                                 selectedClient = GetlocalhostInfo();
                                                 ClientListBox.Show();
                                                 UpdateClientList();
                                                 RedrawClientSettings();
                                                 ReadServerSettings(); }));
 }
예제 #4
0
        private void ClientListBox_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int iIndex = ClientListBox.IndexFromPoint(e.Location);

            if (iIndex != ListBox.NoMatches)
            {
                ConnectedClientInfo info = ClientListBox.Items[iIndex] as ConnectedClientInfo;
                selectedClient = info;
                ClientSettingsPanel.Show();
                //UpdateClientList();
                RedrawClientSettings();
            }
        }
예제 #5
0
        private void Server_ServerStopped(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action(() => { Server_ServerStopped(sender, e); }));
                return;
            }

            ServerPortTextBox.Visible = true;
            ServerStartButton.Text    = "Start server";
            ClientSettingsPanel.Hide();
            UpdateClientList();
            RedrawClientSettings();
        }