Exemple #1
0
        private void ClientHotkeyButton_Click(object sender, EventArgs e)
        {
            if (hotkeyEntering)
            {
                ClientHotkeyButton.BackColor = default(Color);
                hotkeyEntering = false;


                if (server == null || !server.Running || lastEnteredHotkey == null || selectedClient == null)
                {
                    RedrawClientSettings();
                    UpdateClientList();
                    return;
                }

                server.SetClientHotkey(selectedClient, lastEnteredHotkey);

                Hotkey key = server.GetclientHotkey(selectedClient);
                ClientHotkeyButton.Text = key.ToString();
                UpdateClientList();

                foreach (var info in ClientListBox.Items)
                {
                    ConnectedClientInfo client = info as ConnectedClientInfo;
                    selectedClient = client;
                }

                RedrawClientSettings();
            }
            else
            {
                hotkeyEntering = true;
                ClientHotkeyButton.BackColor = Color.Gray;
            }
        }
Exemple #2
0
        private void RedrawClientSettings()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action(() => { RedrawClientSettings(); }));
                return;
            }

            if (selectedClient == null)
            {
                selectedClient = GetlocalhostInfo();

                if (selectedClient == null)
                {
                    return;
                }
            }

            ClientSettingsClientNameLabel.Text = selectedClient.ClientName;
            if (selectedClient.Key == null)
            {
                ClientHotkeyButton.Text = "None";
            }
            else
            {
                ClientHotkeyButton.Text = selectedClient.Key.ToString();
            }

            FillComboBoxWithClients(LeftClientListBox, selectedClient, selectedClient.LeftClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.LeftClient);
            FillComboBoxWithClients(RightClientListBox, selectedClient, selectedClient.RightClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.RightClient);
            FillComboBoxWithClients(BelowClientListBox, selectedClient, selectedClient.BelowClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.BelowClient);
            FillComboBoxWithClients(AboveClientListBox, selectedClient, selectedClient.AboveClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.AboveClient);
        }
Exemple #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(); }));
 }
Exemple #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();
            }
        }
Exemple #5
0
        private void LeftClientListBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            ConnectedClientInfo clientA = LeftClientListBox.SelectedItem as ConnectedClientInfo;

            if (clientA == ConnectedClientInfo.None)
            {
                server.SetClientEdge(null, BoundEdge.Left, selectedClient);
            }
            else
            {
                server.SetClientEdge(clientA, BoundEdge.Left, selectedClient);
            }
            UpdateClientList();
            RedrawClientSettings();
        }
Exemple #6
0
        private void FillComboBoxWithClients(ComboBox list, ConnectedClientInfo ignoreClient = null, ConnectedClientInfo currentSetting = null)
        {
            if (list.InvokeRequired)
            {
                list.Invoke(new Action(() => { FillComboBoxWithClients(list, ignoreClient, currentSetting); }));
                return;
            }

            ConnectedClientInfo[] clients = server.GetClients();

            list.Items.Clear();
            list.SelectedItem = null;
            int index = 0;

            list.Items.Add(ConnectedClientInfo.None);
            list.SelectedIndex = 0;
            foreach (var client in clients)
            {
                if (ignoreClient == null)
                {
                    list.Items.Add(client);

                    if (currentSetting != ConnectedClientInfo.None && currentSetting.ClientName == client.ClientName)
                    {
                        list.SelectedItem = client;
                    }
                }
                else if (client.ClientId != ignoreClient.ClientId)
                {
                    list.Items.Add(client);
                    if (currentSetting != ConnectedClientInfo.None && currentSetting.ClientName == client.ClientName)
                    {
                        list.SelectedItem = client;
                    }

                    index++;
                }
            }
        }
    public static unsafe void addClient()
    {
        char * ip      = GetLastPacketIP();
        IntPtr careTwo = (IntPtr)ip;
        StraightCharPointer *dataTwo = (StraightCharPointer *)careTwo;
        string newIP = Marshal.PtrToStringAnsi((IntPtr)dataTwo->mes);
        ConnectedClientInfo newClient = new ConnectedClientInfo();

        newClient.IP = newIP;
        newClient.ID = clientID.ToString();
        ++clientID;
        mConnectedClients.Add(newClient);

        string gOCount = allGOs.Length.ToString() + "|";

        SendData((int)Serializer.Message.LOADLEVEL, gOCount, gOCount.Length, newIP);
        for (int i = 0; i < allGOs.Length; ++i)
        {
            string serializedObj = Serializer.serialize(allGOs[i]);
            SendData((int)Serializer.Message.GO_UPDATE, serializedObj, serializedObj.Length, newIP);
        }

        SendData((int)Serializer.Message.LEVELLOADED, gOCount, gOCount.Length, newIP);
    }
Exemple #8
0
 private void Server_ClientConnected(object sender, ConnectedClientInfo e)
 {
     UpdateClientList();
     RedrawClientSettings();
 }