예제 #1
0
        private void ReadAppConfig_Tick(object sender, EventArgs e)
        {
            var temp = XmlManipulation.GetValue("FocusActivate");

            if (temp == "ON")
            {
                timContrôleFocus.Enabled = true;
            }
            else
            {
                timContrôleFocus.Enabled = false;
            }
        }
예제 #2
0
        // At start-up
        private void FrmMain_Load(object sender, EventArgs e)
        {
            //==============================AtStartUp===================================================
            lblDescription2.Visible = false;                                                   //Hidden label
            _sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Socket creation
            _sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            lblIPPersonnel.Text        = GetLocalIp();                                         //Show personnal Ip
            tbxMessageEnvoit.MaxLength = 72;                                                   //Limit max lenght
            pbxLogoPetit.Visible       = false;                                                //Don't show logo
            NomDestinataireToolStripMenuItem.Visible = false;
            NomDestinataireToolStripMenuItem.Text    = lblIPPersonnel.Text;
            iPPersonnelToolStripMenuItem.Visible     = false;
            MaximizeBox = false;             //Don't show maximize button on form
            //GESTIONFOCUS====================================================================================
            timContrôleFocus.Enabled = true; //Start timer focus
            lblNomPCDest.Visible     = false;
            lblEtatPing.Visible      = false;

            //==============SearchUpdate================================================================
            UpdateApplication.VersionVerification(AppInfo.GetChainFormattedVersion());//ApplicationVersionWeb
            //================================================================================================
            //UpdateAppYear===================================================================================
            lblDescription.Text  = $"Kubeah! {DateTime.Now.Year.ToString()}";
            lblDescription2.Text = $"Kubeah! {DateTime.Now.Year.ToString()}";
            //Create and read config==========================================================================
            var recipientIp = XmlManipulation.GetValue("LastIpConnexion");

            if (recipientIp != "")
            {
                IpSeparationString(recipientIp, true);
            }
            else
            {
                IpSeparationString(lblIPPersonnel.Text, false);
            }
            var focusState = XmlManipulation.GetValue("FocusActivate");

            if (focusState != "ON")
            {
                timContrôleFocus.Enabled = false;
            }
            if (XmlManipulation.GetValue("EnableLastIpConnexion") != "ON")
            {
                XmlManipulation.ModifyElementXml("LastIpConnexion", "");
            }
            //================================================================================================
        }
예제 #3
0
        //FINGestionNbrCaractères===================================================================FIN====================
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Envoi la clé pour dire à l'autre client qu'il est absent
            //Que si la conversation à démmarée
            if (!btnSart.Visible)
            {
                EnvoiDuMessage("789ZCFZTiniwjZTUvjkas79012798", KMessage.Type.Init());//Clé Absent

                var status = XmlManipulation.GetValue("SaveDiscussion");
                if (status == "ON")
                {
                    var text = "";
                    foreach (var item in lbxTchat.Items)
                    {
                        text += item + "\r\n";
                    }
                    ChatData.Export(_recipientIp, text);
                    // Why one line?
                }
            }
        }
예제 #4
0
        private void frmConfig_Load(object sender, EventArgs e)
        {
            //Display all settings with App.config
            var temp = "";

            temp = XmlManipulation.GetValue("FocusActivate");
            if (temp == "")
            {
            }
            else
            {
                if (temp == "ON")
                {
                    chbFocusOn.Checked = true;
                }
                else
                {
                    chbFocusOff.Checked = true;
                }
            }

            temp = XmlManipulation.GetValue("EnableLastIpConnexion");
            if (temp == "")
            {
            }
            else
            {
                if (temp == "ON")
                {
                    chbLastIpRecipientOn.Checked = true;
                }
                else
                {
                    chbLastIpRecipientOff.Checked = true;
                }
            }

            temp = XmlManipulation.GetValue("SaveDiscussion");
            if (temp == "")
            {
            }
            else
            {
                if (temp == "ON")
                {
                    chbSaveDiscussionOn.Checked = true;
                }
                else
                {
                    chbSaveDiscussionOff.Checked = true;
                }
            }

            temp = XmlManipulation.GetValue("NotificationsEnable");
            if (temp == "")
            {
            }
            else
            {
                if (temp == "ON")
                {
                    chbEnableNotificationsOn.Checked = true;
                }
                else
                {
                    chbEnableNotificationsOff.Checked = true;
                }
            }
        }
예제 #5
0
 private void FrmMain_Deactivate(object sender, EventArgs e)
 {
     _bNotificationsEnable = (XmlManipulation.GetValue("NotificationsEnable") == "ON") ? true : false;
 }
예제 #6
0
        //=====================================================================================================================/
        //====================================================================================================================/

        //=====================BTNSTART=============================================================================
        private async void btnSart_ClickAsync(object sender, EventArgs e)
        {
            lblPatience.Visible = true;
            var sIpDestinataire = tbxIP1.Text + "." + tbxIP2.Text + "." + tbxIP3.Text + "." + tbxIP4.Text;

            if (sIpDestinataire == lblIPPersonnel.Text)
            {
                tbxIP4.BackColor = Color.Red;
            }
            if (tbxIP1.BackColor != Color.Red)
            {
                if (tbxIP2.BackColor != Color.Red)
                {
                    if (tbxIP3.BackColor != Color.Red)
                    {
                        if (tbxIP4.BackColor != Color.Red)
                        {
                            if (tbxIP4.BackColor != Color.PaleGreen)
                            {
                                lblPatience.Visible  = true;
                                lblEtatPing.Visible  = false;
                                lblNomPCDest.Visible = false;
                                lblEtatPing.Visible  = true;
                                var sNameDestinataire = Ip.GetHostName(sIpDestinataire);
                                var bResultPing       = await Task.Run(() => Ip.PingDest(sIpDestinataire));

                                if (bResultPing)
                                {
                                    lblEtatPing.Text      = @"Ping : OK";
                                    lblEtatPing.ForeColor = Color.Green;
                                    if (btnSart.Text == @"Check IP")
                                    {
                                        if (sNameDestinataire == "")
                                        {
                                            lblNomPCDest.Text      = "Name :" + "\r\n" + "Not found";
                                            lblNomPCDest.ForeColor = Color.Red;
                                            lblNomPCDest.Visible   = true;
                                            tbxIP4.BackColor       = Color.Red;
                                        }
                                        else
                                        {
                                            btnSart.Text           = "Start";
                                            lblNomPCDest.Visible   = true;
                                            lblNomPCDest.Text      = "Name :" + "\r\n" + sNameDestinataire;
                                            lblNomPCDest.ForeColor = Color.Black;
                                        }
                                    }
                                    else
                                    {
                                        //___________MinimiserLaFenetre________________
                                        this.Width                = 620;
                                        lblDescription.Visible    = false;
                                        btnSart.Visible           = false;
                                        lblDescription2.Visible   = true;
                                        lblIPDESTINATAIRE.Visible = false;
                                        pbxLogo1.Visible          = false;
                                        pbxLogoPetit.Visible      = true;
                                        lblIPPersonnel.Visible    = false;
                                        lblFixeCePC.Visible       = false;
                                        NomDestinataireToolStripMenuItem.Visible = true;
                                        tbxIP1.Visible = false;
                                        tbxIP2.Visible = false;
                                        tbxIP3.Visible = false;
                                        tbxIP4.Visible = false;
                                        NomDestinataireToolStripMenuItem.Text = "Recipient : " + sNameDestinataire;
                                        lblNomPCDest.Visible = false;
                                        iPPersonnelToolStripMenuItem.Text    = "My IP : " + lblIPPersonnel.Text;
                                        iPPersonnelToolStripMenuItem.Visible = true;
                                        //______________________________________________
                                        //FichierConfig---------------------------------
                                        if (XmlManipulation.GetValue("EnableLastIpConnexion") == "ON")
                                        {
                                            XmlManipulation.ModifyElementXml("LastIpConnexion", sIpDestinataire);
                                        }
                                        else
                                        {
                                            XmlManipulation.ModifyElementXml("LastIpConnexion", "");
                                        }
                                        _recipientIp = sIpDestinataire;
                                        try
                                        {
                                            _epLocal = new IPEndPoint(IPAddress.Parse(lblIPPersonnel.Text), 3056);//Use 3056 port
                                            _sck.Bind(_epLocal);

                                            _epRemote = new IPEndPoint(IPAddress.Parse(sIpDestinataire), 3056);
                                            _sck.Connect(_epRemote);

                                            var buffer = new byte[1500];
                                            _sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref _epRemote, MessageReceived, buffer);

                                            btnSart.Text     = @"Connected";
                                            btnSart.Enabled  = false;
                                            btnEnvoi.Enabled = true;
                                            tbxMessageEnvoit.Focus();
                                            EnvoiDuMessage("tuiFZCz56786casdcssdcvuivgboRTSDetre67Rz7463178", KMessage.Type.Init());
                                            if (XmlManipulation.GetValue("SaveDiscussion") == "ON")
                                            {
                                                var temp = ChatData.Import(_recipientIp);
                                                if (temp.Count() != 0)
                                                {
                                                    foreach (var element in temp)
                                                    {
                                                        lbxTchat.Items.Add(element);
                                                    }
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            MessageBox.Show("An error occured. \r\nPlease restart Kubeah Chat" + "\r\n" + "\r\n", "An error occurred");
                                            Application.Exit();
                                        }
                                        //Send the key to the other client to connect
                                    }
                                }
                                else
                                {
                                    lblEtatPing.Text      = "Ping : Fail";
                                    lblEtatPing.ForeColor = Color.Red;
                                    lblNomPCDest.Visible  = false;
                                    tbxIP4.BackColor      = Color.Red;
                                }
                            }
                        }
                    }
                }
            }
            lblPatience.Visible = false;
        }