private void chbEnableNotificationsOff_CheckedChanged(object sender, EventArgs e) { //Management Checked - not checked if (chbEnableNotificationsOn.Checked == false && chbEnableNotificationsOff.Checked == false) { chbEnableNotificationsOn.Checked = true; } if (chbEnableNotificationsOff.Checked == true) { chbEnableNotificationsOn.Checked = false; //Change value on App.config XmlManipulation.ModifyElementXml("NotificationsEnable", "OFF"); } }
private void chbSaveDiscussionOn_CheckedChanged(object sender, EventArgs e) { //Management Checked - not checked if (chbSaveDiscussionOn.Checked == false && chbSaveDiscussionOff.Checked == false) { chbSaveDiscussionOff.Checked = true; } if (chbSaveDiscussionOn.Checked == true) { chbSaveDiscussionOff.Checked = false; //Change value on App.config XmlManipulation.ModifyElementXml("SaveDiscussion", "ON"); } }
private void chbLastIpRecipientOn_CheckedChanged(object sender, EventArgs e) { //Management Checked - not checked if (chbLastIpRecipientOn.Checked == false && chbLastIpRecipientOff.Checked == false) { chbLastIpRecipientOff.Checked = true; } if (chbLastIpRecipientOn.Checked == true) { chbLastIpRecipientOff.Checked = false; //Change value on App.config XmlManipulation.ModifyElementXml("EnableLastIpConnexion", "ON"); } }
private void chbSaveDiscussionOff_CheckedChanged(object sender, EventArgs e) { //Management Checked - not checked if (chbSaveDiscussionOn.Checked == false && chbSaveDiscussionOff.Checked == false) { chbSaveDiscussionOn.Checked = true; } if (chbSaveDiscussionOff.Checked == true) { chbSaveDiscussionOn.Checked = false; //Change value on App.config XmlManipulation.ModifyElementXml("SaveDiscussion", "OFF"); } // Objects.KNotification.Show("The saving of discussions is cancelled.\r\n!!! Old backups are not deleted !!!"); }
// 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", ""); } //================================================================================================ }
//=====================================================================================================================/ //====================================================================================================================/ //=====================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; }