private void PasswordCheck_Unchecked(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Do you want remove password .??", "Alert", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (PasswordBox.Password != null || PasswordBox.Password != "") { string old_pwd = Interaction.InputBox("Please give your old password", "Change password", "Old password"); XmlDocument xd = new XmlDocument(); SecurityPW sc = new SecurityPW(); xd.Load("UserSettings.xml"); string old_pssd = sc.Decryptstring(xd.SelectSingleNode("UserProfile/General/Password").InnerText); if (old_pssd == old_pwd) { PasswordBox.Password = ""; PasswordBox.IsEnabled = false; ChangePassword.IsEnabled = false; } else { System.Windows.MessageBox.Show("You entered wrong password!!"); PasswordCheck.IsChecked = true; PasswordBox.IsEnabled = false; } } } else { PasswordCheck.IsChecked = true; PasswordBox.IsEnabled = false; } }
private void Button_Click(object sender, RoutedEventArgs e) { System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.Load(path); SecurityPW security = new SecurityPW(); if (PasswordBoxLogin.Password == security.Decryptstring(xd.SelectSingleNode("UserProfile/General/Password").InnerText)) { new MainWindow().Show(); this.Close(); } else { MessageBox.Show("Wrong Password entered"); } }
private void ChangePassword_Click(object sender, RoutedEventArgs e) { string old_pwd = Interaction.InputBox("Please give your old password", "Change password", "Old password"); XmlDocument xd = new XmlDocument(); SecurityPW sc = new SecurityPW(); xd.Load("UserSettings.xml"); string old_pssd = sc.Decryptstring(xd.SelectSingleNode("UserProfile/General/Password").InnerText); if (old_pssd.Equals(old_pwd)) { string new_pwd = Interaction.InputBox("Please give your new password", "Change password", "New password"); PasswordBox.Password = new_pwd; xd.SelectSingleNode("UserProfile/General/Password").InnerText = sc.Encryptstring(new_pwd); xd.Save("UserSettings.xml"); } else { PasswordBox.IsEnabled = false; System.Windows.MessageBox.Show("You entered wrong password!!"); } }
public Settings(MainWindow mw) { this.mw = mw; mw.Settings.IsEnabled = false; InitializeComponent(); General.IsExpanded = true; // sharedFiles = new Dictionary<CheckBox,string>(); VirtualName = new Dictionary <string, string>(); childs = new Dictionary <string, List <string> >(); if (File.Exists(mainPath + "UserSettings.xml") == true) { String key = NickName.Text; XmlDocument settings = new XmlDocument(); settings.Load(mainPath + "UserSettings.xml"); NickName.Text = settings.SelectSingleNode("UserProfile/General/NickName").InnerText; GroupName.Text = settings.SelectSingleNode("UserProfile/General/GroupName").InnerText; if (settings.SelectSingleNode("UserProfile/General/passwordenabled").InnerText == "yes") { PasswordCheck.IsChecked = true; ChangePassword.IsEnabled = true; security = new SecurityPW(); PasswordBox.Password = security.Decryptstring(settings.SelectSingleNode("UserProfile/General/Password").InnerText); PasswordBox.IsEnabled = false; } else { PasswordCheck.IsChecked = false; ChangePassword.IsEnabled = false; PasswordBox.IsEnabled = false; } Camera.SelectedItem = settings.SelectSingleNode("UserProfile/Conference/Camera").InnerText; Microphone.SelectedItem = settings.SelectSingleNode("UserProfile/Conference/Microphone").InnerText; pic_path.Text = settings.SelectSingleNode("UserProfile/Appearance/ProfilepicPath").InnerText; AudioSave_path.Text = settings.SelectSingleNode("UserProfile/Conference/Audiosavepath").InnerText; if (pic_path.Text != null & pic_path.Text != "") { try { Uri uri = new Uri(@pic_path.Text, UriKind.Absolute); ImageSource imgSource = new BitmapImage(uri); Profile_pic.Source = imgSource; } catch (Exception e) { MessageBox.Show(e.Message); } } else { string strUri2 = "pack://application:,,,/Images/user-icon.png"; Profile_pic.Source = new BitmapImage(new Uri(strUri2)); } String colour = settings.SelectSingleNode("UserProfile/Appearance/Colour").InnerText; Color color = (Color)ColorConverter.ConvertFromString(colour); ColorPicker.SelectedColor = color; BrushConverter bc = new BrushConverter(); this.Background = (Brush)bc.ConvertFrom(colour); RadialGradientBrush rgb = new RadialGradientBrush(); rgb.RadiusY = 0.75; Point p = new Point(0.5, 0); rgb.Center = p; rgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString(colour), 1)); rgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#BFFFFFFF"), 0)); this.Background = rgb; if (settings.SelectSingleNode("UserProfile/BlockedList/Block_Games").InnerText == "Yes") { Receive_Games.IsChecked = true; } else { Receive_Games.IsChecked = false; } if (settings.SelectSingleNode("UserProfile/BlockedList/Block_Study").InnerText == "Yes") { Receive_Study.IsChecked = true; } else { Receive_Study.IsChecked = false; } if (settings.SelectSingleNode("UserProfile/BlockedList/Block_Others").InnerText == "Yes") { Receive_others.IsChecked = true; } else { Receive_others.IsChecked = false; } if (settings.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Games") { Send_Games.IsChecked = true; } else if (settings.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Study") { Send_Study.IsChecked = true; } else if (settings.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Others") { Send_Others.IsChecked = true; } else { Send_Games.IsChecked = false; Send_Study.IsChecked = false; Send_Others.IsChecked = false; } foreach (XmlNode user in settings.SelectNodes("UserProfile/BlockedList/Users/Blockeduser")) { BlockedList.Items.Add(user.InnerText); listOfBlock.Add(IPAddress.Parse(user.InnerText)); } } else { NickName.Text = ""; GroupName.Text = ""; PasswordCheck.IsChecked = false; PasswordBox.IsEnabled = false; ChangePassword.IsEnabled = false; Camera.Text = ""; Microphone.Text = ""; Recording.IsChecked = true; AudioSave_path.Text = ""; ColorPicker.SelectedColor = (Color)ColorConverter.ConvertFromString("#FF6E6969"); string strUri2 = "pack://application:,,,/Images/user-icon.png"; Profile_pic.Source = new BitmapImage(new Uri(strUri2)); RadialGradientBrush rgb = new RadialGradientBrush(); rgb.RadiusY = 0.75; Point p = new Point(0.5, 0); rgb.Center = p; rgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#BF919191"), 1)); rgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#BFFFFFFF"), 0)); this.Background = rgb; } FilterInfoCollection cam = new FilterInfoCollection(FilterCategory.VideoInputDevice); { foreach (FilterInfo info in cam) { Camera.Items.Add(info.Name); } } Audio aw = new Audio(); foreach (var i in aw.sources) { Microphone.Items.Add(i.ProductName); } foreach (var i in UserList.GroupList.Values.Distinct()) { GroupName.Items.Add(i); } if (File.Exists("Sharing.xml")) { loadSharedFolders(); } loadUser(); }
private void Write_to_XML() { XmlDocument xd = new XmlDocument(); xd.Load(mainPath + "UserSettings.xml"); #region General xd.SelectSingleNode("UserProfile/General/NickName").InnerText = NickName.Text; xd.SelectSingleNode("UserProfile/General/GroupName").InnerText = GroupName.Text; if (PasswordCheck.IsChecked == true) { xd.SelectSingleNode("UserProfile/General/passwordenabled").InnerText = "yes"; } else { xd.SelectSingleNode("UserProfile/General/passwordenabled").InnerText = "no"; } string key = NickName.Text; security = new SecurityPW(); storedpassword = security.Encryptstring(PasswordBox.Password); xd.SelectSingleNode("UserProfile/General/Password").InnerText = storedpassword; #endregion #region Confernce xd.SelectSingleNode("UserProfile/Conference/Camera").InnerText = Camera.Text; xd.SelectSingleNode("UserProfile/Conference/Microphone").InnerText = Microphone.Text; if (Recording.IsChecked == true) { xd.SelectSingleNode("UserProfile/Conference/Recordingenabled").InnerText = "yes"; } else { xd.SelectSingleNode("UserProfile/Conference/Recordingenabled").InnerText = "no"; } xd.SelectSingleNode("UserProfile/Conference/Audiosavepath").InnerText = AudioSave_path.Text; #endregion #region Appearance xd.SelectSingleNode("UserProfile/Appearance/Colour").InnerText = ColorPicker.SelectedColor.ToString(); String colour = xd.SelectSingleNode("UserProfile/Appearance/Colour").InnerText; Color color = (Color)ColorConverter.ConvertFromString(colour); ColorPicker.SelectedColor = color; RadialGradientBrush rgb = new RadialGradientBrush(); rgb.RadiusY = 0.75; Point p = new Point(0.5, 0); rgb.Center = p; rgb.GradientStops.Add(new GradientStop(color, 1)); rgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#BFFFFFFF"), 0)); this.Background = rgb; mw.Background = rgb; MainWindow.brushColor = rgb; //System.Diagnostics.Debug.WriteLine(pic_path.Text); xd.SelectSingleNode("UserProfile/Appearance/ProfilepicPath").InnerText = pic_path.Text; System.Diagnostics.Debug.WriteLine(xd.SelectSingleNode("UserProfile/Appearance/ProfilepicPath")); #endregion #region Blocking #region Category if (Send_Games.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText = "Games"; } else if (Send_Study.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText = "Study"; } else if (Send_Others.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText = "Others"; } if (Receive_Games.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Block_Games").InnerText = "Yes"; } else { xd.SelectSingleNode("UserProfile/BlockedList/Block_Games").InnerText = "No"; } if (Receive_Study.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Block_Study").InnerText = "Yes"; } else { xd.SelectSingleNode("UserProfile/BlockedList/Block_Study").InnerText = "No"; } if (Receive_others.IsChecked == true) { xd.SelectSingleNode("UserProfile/BlockedList/Block_Others").InnerText = "Yes"; } else { xd.SelectSingleNode("UserProfile/BlockedList/Block_Others").InnerText = "No"; } #endregion xd.Save("UserSettings.xml"); if (xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Games") { mw.change_category("Games"); } else if (xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Study") { mw.change_category("Study"); } else if (xd.SelectSingleNode("UserProfile/BlockedList/Send_Default").InnerText == "Others") { mw.change_category("Others"); } #region IP xd.SelectSingleNode("UserProfile/BlockedList/Users").RemoveAll(); foreach (var i in BlockedList.Items) { XmlElement xm = xd.CreateElement("Blockeduser"); xd.SelectSingleNode("UserProfile/BlockedList/Users").AppendChild(xm).InnerText = i.ToString(); } #endregion #endregion string path = AppDomain.CurrentDomain.BaseDirectory + "\\UserSettings.xml"; xd.Save(path); //UserList.Get(MainWindow.hostIP).userView.u_nick = NickName.Text; }