Esempio n. 1
0
        public Form1(string[] args)
        {
            InitializeComponent();

            DataChanged += Set_Unsaved_Flag;
            DataChanged += Enable_Save_Button;

            SaveTableButton.BringToFront();
            CopyButton.BringToFront();

            Read_Settings_File();
            Apply_Settings();

            try
            {
                FormTranslationDictionary = Read_Translation_File(Settings[TRANSLATION_DIRECTORY_PARAMETR]);
                Apply_Translation(this, FormTranslationDictionary[this.GetType().Name]);
            }
            catch
            { }

            programName = Text;

            string tmp;

            try
            {
                StreamReader SR = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "/" + DICTIONARY_FILE_NAME);
                tmp = SR.ReadToEnd();
                SR.Close();
            }
            catch
            {
                tmp = Properties.Resources.defaultDictionary;
                StreamWriter SW = new StreamWriter("dictionary.json");
                SW.Write(tmp);
                SW.Close();
            }

            GeneratorDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(tmp);

            if (args != null && args.Length > 0)
            {
                Open_File(args[0]);
            }

            AddToTableButton.Enabled     = false;
            EditSelectedButton.Enabled   = false;
            DeleteSelectedButton.Enabled = false;
            SaveTableButton.Enabled      = false;
            UpButton.Enabled             = false;
            DownButton.Enabled           = false;
            SortButton.Enabled           = false;
            URLButton.Enabled            = false;
            LoginButton.Enabled          = false;
            CopyButton.Enabled           = false;
        }
Esempio n. 2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (hasUnsavedData)
     {
         DialogResult DR = MessageBox.Show(UnsavedChangesLabel.Text, WarningLabel.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
         if (DR == DialogResult.Cancel)
         {
             e.Cancel = true;
         }
         else
         {
             if (DR == DialogResult.Yes)
             {
                 SaveTableButton.PerformClick();
             }
         }
     }
     Write_Settings();
 }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool unsaved = false;

                if (hasUnsavedData)
                {
                    DialogResult DR = MessageBox.Show(SaveChangesLabel.Text, WarningLabel.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (DR == DialogResult.Yes)
                    {
                        SaveTableButton.PerformClick();
                        unsaved = false;
                    }
                    else
                    {
                        if (DR == DialogResult.No)
                        {
                            unsaved = false;
                        }
                        else
                        {
                            unsaved = true;
                        }
                    }
                }

                if (!unsaved)
                {
                    openFileDialog1.Filter = "Encrypted Password Manager Files (*.EPM)|*.EPM|" + "All files (*.*)|*.*";
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        Open_File(openFileDialog1.FileName);
                    }
                }
            }
            catch
            {
                MessageBox.Show(CouldntOpenLabel.Text, ErrorLabel.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }