示例#1
0
        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!!");
            }
        }
示例#2
0
        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;
        }