示例#1
0
        ////////// Used to make form draggable

        public CandySettingsFileViewerWindow()
        {
            InitializeComponent();

            var file =
                $"{Application.StartupPath}\\CandyGalleryUserSettings\\{Program.CandyGalleryWindow.UserSettings.UserName.ToLower()}_CandyGalleryUserSettings.xml";

            if (File.Exists(file))
            {
                var xmlDocument = new XmlDocument {
                    PreserveWhitespace = true
                };
                xmlDocument.LoadXml(File.ReadAllText(file));
                var decryptedContents = SaveLoadSettingsHandler.DecryptUserSettingsDirectFromContent(xmlDocument);
                richTextBox.Text = decryptedContents;
            }
            else
            {
                MessageBox.Show($"Unable to read settings file for: \n\n\"file\"",
                                @"Error Reading Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Dispose();
                Close();
            }

            lblCandySettingsFileViewer.ForeColor =
                CandyInterfaceColors.GetInterfaceColorByName(Program.CandyGalleryWindow.UserSettings.UserInterfaceColorName);
            btnCopySettingsText.ForeColor =
                CandyInterfaceColors.GetInterfaceColorByName(Program.CandyGalleryWindow.UserSettings.UserInterfaceColorName);
            btnSaveSettings.BackColor =
                CandyInterfaceColors.GetInterfaceColorByName(Program.CandyGalleryWindow.UserSettings.UserInterfaceColorName);
        }
示例#2
0
 private void SaveSettings_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you wish to overwrite your existing settings file?" +
                         "\n\nIf improper changes have been added, you may corrupt all settings for this user. This cannot be undone!" +
                         "\n\n*Saving will close down Candy Gallery*",
                         @"Overwrite User Settings", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         var xmlDocument = new XmlDocument();
         xmlDocument.LoadXml(richTextBox.Text);
         SaveLoadSettingsHandler.EncryptAndSaveUserSettingsDirectToFile(xmlDocument);
         Close();
     }
 }
示例#3
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtUsername.Text) && !string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                txtUsername.BackColor = Color.Linen;
                txtPassword.BackColor = Color.Linen;

                var userSettings = SaveLoadSettingsHandler.TryLoadUserSettings(txtUsername.Text, txtPassword.Text);
                if (userSettings.Pass != txtPassword.Text)
                {
                    if (MessageBox.Show($"The provided password was incorrect for user \"{txtUsername.Text}\"... \nPlease try again.", "Incorrect Credentials", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand) != DialogResult.OK)
                    {
                        Close();
                        Dispose();
                    }

                    txtUsername.BackColor = Color.Linen;
                    txtPassword.Text      = "";
                    txtPassword.BackColor = Color.Red;
                }

                else
                {
                    Hide();
                    Program.CandyGalleryWindow = new CandyGalleryWindow(userSettings);
                    try
                    {
                        Program.CandyGalleryWindow.Show();
                    }
                    catch (Exception) { Close(); }
                }
            }
            else
            {
                txtUsername.BackColor = Color.Linen;
                txtPassword.BackColor = Color.Linen;
                if (string.IsNullOrWhiteSpace(txtUsername.Text))
                {
                    txtUsername.Text      = "";
                    txtUsername.BackColor = Color.Red;
                }
                if (string.IsNullOrWhiteSpace(txtPassword.Text))
                {
                    txtPassword.Text      = "";
                    txtPassword.BackColor = Color.Red;
                }
            }
        }