public frmConversation(Connection ThisConnection, string ConversationID) { InitializeComponent(); this.ThisConnection = ThisConnection; this.ConversationID = ConversationID; ClickHandler = new HtmlElementEventHandler(frmConversation_Click); MouseDownHandler = new HtmlElementEventHandler(frmConversation_MouseDown); ClearMessages(); //LOAD THE EMOTICONS FROM THE CONFIG FILE Emoticons = ConfigWrapper.GetSetting(Path.Combine(Application.StartupPath, "Images\\Emoticons\\emoticons.xml"), "icon"); //CREATE A NEW EMOTICONS DISPLAY EmoticonsDisplay = new frmEmoticons(this, Emoticons); EmoticonsDisplay.EmoticonClicked += new frmEmoticons.EmoticonClickedDelegate(EmoticonsDisplay_EmoticonClicked); //CREATE PLUGIN LIST CreatePluginList(); //DETERMINE IF THE TIMESTAMPS SHOULD BE ENABLED BY DEFAULT OR NOT if (ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault() != null) { timestampToolStripMenuItem.Checked = bool.Parse(ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault()["ShowTimeStamps"]); } else { timestampToolStripMenuItem.Checked = true; } }
public ToolStripMenuItem Initialize(Form PassedWindow, Connection ThisConnection) { this.Window = PassedWindow; this.ThisConnection = ThisConnection; //CHECK TO SEE IF WE ARE EVEN SUPPOSED TO SAVE WINDOW POSITIONS BECAUSE IF WE ARE NOT SAVING THEM THEN WE ARE NOT LOADING THEM EITHER if (ConfigWrapper.GetSetting("SaveWindowPositions").FirstOrDefault() == null || bool.Parse(ConfigWrapper.GetSetting("SaveWindowPositions").First()[this.Window.GetType().ToString()]) == false) { return(null); } //GET THE SETTING FROM THE CONFIG FILE ABOUT WHERE TO PLACE THIS WINDOW List <Dictionary <string, string> > tmpReturn = ConfigWrapper.GetSetting("WindowPositions"); Dictionary <string, string> thisPosition = (from a in tmpReturn where a.Values.Contains((string)this.Window.Tag) select a).FirstOrDefault(); //IF THERE IS A LOCATION SAVED FOR THIS WINDOW THEN WE NEED TO APPLY IT if (thisPosition != null) { //MAKE SURE THE WINDOW PAYS ATTENTION TO THE LOCATION PREFERENCE WE SET HERE this.Window.StartPosition = FormStartPosition.Manual; //GET THE LOCATION AND SPLIT THE X AND Y COORIDNATES AND WIDTH AND HEIGHT VALUES string[] Location = thisPosition["windowposition"].Split('|'); string[] Size = thisPosition["windowsize"].Split('|'); //APPLY THESE VALUES TO THE WINDOW WE ARE CHANGING ITS SETTINGS FOR this.Window.Location = new Point(int.Parse(Location[0]), int.Parse(Location[1])); this.Window.Size = new Size(int.Parse(Size[0]), int.Parse(Size[1])); } //THIS PLUGIN DOES NOT HAVE A MENU OPTION SO RETURN NULL HERE return(null); }
public void LoadSettings() { if (ConfigWrapper.GetSetting("SaveWindowPositions").FirstOrDefault() != null) { chkContactsWindow.Checked = bool.Parse(ConfigWrapper.GetSetting("SaveWindowPositions").FirstOrDefault()["Client.frmContacts"]); chkConversationWindows.Checked = bool.Parse(ConfigWrapper.GetSetting("SaveWindowPositions").FirstOrDefault()["Client.frmConversation"]); } }
public void LoadSettings() { if (ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault() != null) { chkTimeStamps.Checked = bool.Parse(ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault()["ShowTimeStamps"]); chkMissedConversations.Checked = bool.Parse(ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault()["CheckMissedConversations"]); numConversationDays.Value = int.Parse(ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault()["ConversationHistory"]); } }
private void frmLogin_Load(object sender, EventArgs e) { //POPULATE THE LIST WITH ALL THE USERS WHO HAVE LOGGED IN THROUGH THIS COMPUTER foreach (Dictionary <string, string> tmpName in ConfigWrapper.GetSetting("userList")) { txtUserName.Items.Add(new RadComboBoxItem() { Text = tmpName.Values.First() }); } //SELECT THE LAST USERNAME FROM THE CONFIG FILE AND DISPLAY IT IN THE LOGIN SCREEN txtUserName.SelectedItem = txtUserName.Items.Where(a => a.Text == ConfigWrapper.GetSetting("lastuser")[0]["name"]).FirstOrDefault(); }
private void txtUserName_SelectedIndexChanged(object sender, EventArgs e) { Dictionary <string, string> tmpPassword = (from a in ConfigWrapper.GetSetting("userList") where a.Values.Contains(txtUserName.Text) select a).FirstOrDefault(); //CHECK TO SEE IF THE SELECTED USER HAS A PASSWORD IN THE CONFIG FILE AND IF THEY DO THEN POPULATE IT if (tmpPassword != null && !string.IsNullOrEmpty(tmpPassword["password"])) { txtPassword.Text = ConfigWrapper.DecryptString(tmpPassword["password"]); chkSavePassword.Checked = true; } else { //OTHERWISE REMOVE THE TEXT FROM THE PASSWORD AND UNCHECK THE SAVE PASSWORD BOX txtPassword.Text = ""; chkSavePassword.Checked = false; } }
public void ListenThread() { Dictionary <string, string> ListenInfo = ConfigWrapper.GetSetting("listen")[0]; TcpListener tcpServer = new TcpListener(System.Net.IPAddress.Any, int.Parse(ListenInfo["port"])); //START THE LISTENING PORT tcpServer.Start(); #if DEBUG Console.WriteLine("Listening for connections"); #endif //JUST LOOP UNTIL THE PROGRAM IS CLOSED AND TRY TO ACCEPT CONNECTIONS while (true) { //CREATE A NEW THREAD AND CONNECTION HOLDER IN PREPERATION FOR THE INCOMING CONNECTION Connection tmpConnection = new Connection(); Thread tmpThread = new Thread(new ParameterizedThreadStart(ReadThread)); //WAIT UNTIL THERE IS A CONNECTION TO ACCEPT AND THEN ACCEPT IT tmpConnection.TcpConnection = tcpServer.AcceptTcpClient(); //WAIT FOR THE CONNECTION TO SUCCEED BEFORE PROCEEDING while (tmpConnection.TcpConnection.Connected == false) { System.Threading.Thread.Sleep(10); } //SETUP THE CONNECTION ITEMS FOR LATER USES tmpConnection.TcpConnection.SendBufferSize = 1024 * 1024 * 20; tmpConnection.TcpConnection.ReceiveBufferSize = 1024 * 1024 * 20; tmpConnection.NetStream = tmpConnection.TcpConnection.GetStream(); tcpConnections.Add(tmpConnection); //SETUP THE THREAD TO RUN IN THE BACKGROUND SO IF THE SERVER EXITS ALL CONNECTION THREADS EXIT TOO tmpThread.IsBackground = true; //START THE READING THREAD tmpThread.Start(tmpConnection); } }
public void Dispose() { List <Dictionary <string, string> > tmpReturn = ConfigWrapper.GetSetting("WindowPositions"); Dictionary <string, string> thisPosition = (from a in tmpReturn where a.Values.Contains((string)this.Window.Tag) select a).FirstOrDefault(); //IF WE ARE NOT SUPPOSED TO SAVE WINDOW POSITIONS THEN JUST EXIT if (ConfigWrapper.GetSetting("SaveWindowPositions").FirstOrDefault() == null || bool.Parse(ConfigWrapper.GetSetting("SaveWindowPositions").First()[this.Window.GetType().ToString()]) == false) { return; } //MAKE SURE THE WINDOW IS NOT MINIMIZED BEFORE SAVING ITS SIZE if (this.Window.WindowState == FormWindowState.Minimized) { this.Window.WindowState = FormWindowState.Normal; this.Window.Show(); } //IF THIS WINDOW IS NOT SAVED THEN CREATE A NEW DICTIONARY TO SAVE IT ELSE CLEAR THE VALUES SO WE CAN ADD THEM ALL AGAIN if (thisPosition == null) { thisPosition = new Dictionary <string, string>(); } else { tmpReturn.Remove(thisPosition); } //CLEAR THE POSITIONS INCASE THIS IS ALREADY SAVED IN THE FILE AND ADD THE VALUES BACK TO IT thisPosition.Clear(); thisPosition.Add("windowtag", (string)this.Window.Tag); thisPosition.Add("windowposition", string.Format("{0}|{1}", this.Window.Location.X.ToString(), this.Window.Location.Y.ToString())); thisPosition.Add("windowsize", string.Format("{0}|{1}", this.Window.Size.Width.ToString(), this.Window.Size.Height.ToString())); tmpReturn.Add(thisPosition); //SAVE THIS SETTING TO THE CONFIG FILE ConfigWrapper.SaveSetting("WindowPositions", tmpReturn); }
private void btnLogin_Click(object sender, EventArgs e) { //CHECK TO MAKE SURE THERE IS NOT A NEWER VERSION AVAILABLE AND DOWNLOAD IF THERE IS if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.CheckForUpdate() == true) { MessageBox.Show("A newer version of this software exists and will be downloaded and installed now."); ApplicationDeployment.CurrentDeployment.Update(); MessageBox.Show("This application will now exit and restart"); Globals.Exiting = true; Application.Restart(); return; } //IF THE SAVE PASSWORD BUTTON IS CHECKED THEN WE WILL NEED TO ADD IT TO THE SETTINGS FILE if (chkSavePassword.Checked) { List <Dictionary <string, string> > tmpUserNames = new List <Dictionary <string, string> >((from a in ConfigWrapper.GetSetting("userList") where !a.Values.Contains(txtUserName.Text) select a).ToArray()); Dictionary <string, string> tmpDict = new Dictionary <string, string>(); //ADD THE CURRENT USER AND THEIR PASSWORD TO THE SAVED LIST tmpDict.Add("name", txtUserName.Text); tmpDict.Add("password", ConfigWrapper.EncryptString(txtPassword.Text)); tmpUserNames.Add(tmpDict); //SAVE THE UPDATED LIST TO THE CONFIG FILE ConfigWrapper.SaveSetting("userList", tmpUserNames); } //SAVE THE LAST USER WHICH WAS SELECTED FROM THE DROP DOWN BOX FOR NEXT TIME Dictionary <string, string> tmpSetting = new Dictionary <string, string>(); tmpSetting.Add("name", txtUserName.Text); ConfigWrapper.SaveSetting("lastuser", new List <Dictionary <string, string> >() { tmpSetting }); //CLOSE THIS FORM SINCE THE USER IS DONE WITH IT if (!string.IsNullOrEmpty(txtUserName.Text) || !string.IsNullOrEmpty(txtPassword.Text)) { this.UserName = txtUserName.Text; this.Password = txtPassword.Text; this.Close(); //MAKE NOTE THE USER IS NOT MEANING TO EXIT JUST LOGIN Globals.Exiting = false; } }
public static IAuthenticationProvider GetAuthenticationProvider() { Dictionary <string, string> AuthSetting = ConfigWrapper.GetSetting("AuthenticationProvider")[0]; return((IAuthenticationProvider)Activator.CreateInstanceFrom(Path.Combine(Application.StartupPath, @"ExternalModules\" + AuthSetting["file"]), AuthSetting["library"]).Unwrap()); }
public frmContacts(string userName, string password) { InitializeComponent(); Dictionary <string, string> ServerInfo = ConfigWrapper.GetSetting("server")[0]; //CHANGE THE TITLE TO MATCH WHOS CONTACT WINDOW THIS IS this.Text = string.Format("{0}'s - Contact List", userName); //CREATE A CONNECTION AND OPEN IT TO THE SERVER ThisConnection.TcpConnection = new TcpClient(); try { ThisConnection.TcpConnection.Connect(ServerInfo["host"], int.Parse(ServerInfo["port"])); } catch { //THIS WILL CATCH THE SERVER REFUSING CONNECTION BECAUSE THE SERVER IS NOT RUNNING OR THE SERVER IP IS INCORRECT //TODO: NEED TO TELL THE USER THIS HAS HAPPENED } //WAIT FOR THE CONNECTION TO CONNECT long StartTicks = DateTime.Now.Ticks; while (ThisConnection.TcpConnection.Connected == false && new TimeSpan(DateTime.Now.Ticks - StartTicks).Seconds <= 5) { System.Threading.Thread.Sleep(10); } if (ThisConnection.TcpConnection.Connected) { //IF THE CONNECTION WORKED THEN SHOW THIS FORM tmrKeepAlive.Enabled = true; //COPY THE STREAM VARIABLE TO THE CONNECTION FOR PASSING AROUND ThisConnection.TcpConnection.SendBufferSize = 1024 * 1024 * 20; ThisConnection.TcpConnection.ReceiveBufferSize = 1024 * 1024 * 20; ThisConnection.NetStream = ThisConnection.TcpConnection.GetStream(); //SETUP THE READING THREAD TO RUN IN THE BACKGROUND WAITING ON DATA TO COME IN mThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ReadThread)); mThread.SetApartmentState(System.Threading.ApartmentState.STA); mThread.IsBackground = true; mThread.Start(ThisConnection); //HAND SHAKE new Message_HandShake().Send(ThisConnection); //NEED TO AUTHENTICATE AND WAIT FOR A RESPONSE new Message_Authenticate() { UserName = userName, Password = password }.Send(ThisConnection); while (ThisConnection.Authenticated == false && ThisConnection.TcpConnection.Connected) { Application.DoEvents(); } //GET THE USERS CONTACTS ONCE WE ARE CONNECTED new Message_GetContacts().Send(ThisConnection); //GET A LIST OF MISSED CONVERSATIONS if (ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault() == null || bool.Parse(ConfigWrapper.GetSetting("ConversationSettings").FirstOrDefault()["CheckMissedConversations"]) == true) { new Message_GetMissedConversations() { IsLoginCall = true } }