Ejemplo n.º 1
0
        /*       public void OpenChildForm<MiForm>() where MiForm : Form, new()
         *     {
         *
         *         currentChildForm = panelDesktop.Controls.OfType<MiForm>().FirstOrDefault();//Busca en la colecion el formulario
         *                                                                                  //si el formulario/instancia no existe
         *         if (currentChildForm == null)
         *         {
         *             currentChildForm = new MiForm();
         *             currentChildForm.TopLevel = false;
         *             currentChildForm.FormBorderStyle = FormBorderStyle.None;
         *             currentChildForm.Dock = DockStyle.Fill;
         *             panelDesktop.Controls.Add(currentChildForm);
         *             panelDesktop.Tag = currentChildForm;
         *             currentChildForm.Show();
         *             currentChildForm.BringToFront();
         *         }
         *         else
         *         {
         *             currentChildForm.BringToFront();
         *         }
         *
         *     }*/

        public void OpenChildForm(Form childForm)
        {
            if (childForm == null)
            {
                if (formServidor == null)
                {
                    formServidor = new FormServidor();
                    childForm    = formServidor;
                }
            }

            if (currentChildForm != null && currentChildForm != formServidor)
            {
                currentChildForm.Close();
            }
            currentChildForm                 = childForm;
            currentChildForm.TopLevel        = false;
            currentChildForm.FormBorderStyle = FormBorderStyle.None;
            currentChildForm.Dock            = DockStyle.Fill;
            panelDesktop.Controls.Add(currentChildForm);
            panelDesktop.Tag = currentChildForm;
            currentChildForm.Show();
            currentChildForm.BringToFront();
            lblTitleChildForm.Text = currentChildForm.Text;
        }
        public FormSocketTcpClient(FormServidor formServidor)
        {
            InitializeComponent();
            this.Text            = string.Empty;
            this.ControlBox      = false;
            this.DoubleBuffered  = true;
            this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;

            c = new Configurations();
            this.formServidor = formServidor;
            this.driverMaster = formServidor.d;
        }
Ejemplo n.º 3
0
 private void btnServerDA_Click(object sender, EventArgs e)
 {
     ActivateButton(btnServidor, RGBColors.color2);
     if (formServidor != null)
     {
         OpenChildForm(formServidor);
     }
     else
     {
         formServidor = new FormServidor();
         OpenChildForm(formServidor);
     }
 }
        void recibir(IAsyncResult result)
        {
            try
            {
                IPEndPoint RemoteIPSE = new IPEndPoint(IPAddress.Any, puertoSE);
                byte[]     recibido   = ServerSE.EndReceive(result, ref RemoteIPSE);

                data = BitConverter.ToString(recibido);

                Console.WriteLine("hex:" + data);

                DireccionDestinoSE = RemoteIPSE.Address.ToString();


                if (tcpSEDirection == null)
                {
                    int x = 0;
                    while (x < listClients.Count)
                    {
                        if (listClients[x].getId() == idModemSE)
                        {
                            tcpSEDirection = listClients[x].GetFormServidor();
                        }
                        x++;
                    }
                }


                formServidor.Invoke(new MethodInvoker(delegate
                {
                    //txtMensajes.Text += "Mensaje: " + data + " Enviado desde: " + RemoteIP.Address.ToString() + "\n";
                    /*****************************************ENVIO DE MENSAJES A LA VISTA*************************************/
                    formServidor.Mensajes("Mensaje: " + data + " Enviado desde: " + RemoteIPSE.Address.ToString() + "\n");

                    #region tcp
                    /***************************ENVIO DEL MENSAJE AL CONECTOR TCP*****************************/
                    tcpSEDirection.Send(recibido);

                    #endregion
                }));
                ServerSE.BeginReceive(new AsyncCallback(recibir), null);
            }
            catch (Exception ex)
            {
                this.CancelSyncronization();
                Console.WriteLine(ex.Message);
            }
        }
        void recibirHUE(IAsyncResult result)
        {
            try
            {
                IPEndPoint RemoteIP = new IPEndPoint(IPAddress.Any, puertoDestinoHUE);
                byte[]     recibido = ServerHUE.EndReceive(result, ref RemoteIP);
                dataHUE = Encoding.UTF8.GetString(recibido);

                if (tcpHUEDirection == null)
                {
                    int x = 0;
                    while (x < listClients.Count)
                    {
                        if (listClients[x].getId() == idModemHue)
                        {
                            tcpHUEDirection = listClients[x].GetFormServidor();
                        }
                        x++;
                    }
                }


                #region tcp HUE
                /***************************ENVIO DEL MENSAJE AL CONECTOR TCP*****************************/
                tcpHUEDirection.Send(recibido);

                #endregion

                ServerHUE.BeginReceive(new AsyncCallback(recibirHUE), null);
            }
            catch (Exception ex)
            {
                this.CancelSyncronization();
                Console.WriteLine(ex.Message);
            }
        }
 public UDPServidor(FormServidor formServidor, List <Forms.TCPProcess> list)
 {
     this.listClients  = list;
     this.formServidor = formServidor;
 }