Exemplo n.º 1
0
        public SharpPrivacyTray()
        {
            DateTime dtStart = DateTime.Now;
            SplashScreen ssSplash = new SplashScreen();
            ssSplash.Show();
            Application.DoEvents();

            // check if private and public keyring exists
            bool bMessageShowed = false;
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            if (!System.IO.File.Exists(strPath + "/SharpPrivacy/pub_keyring.txt")) {
                MessageBox.Show("SharpPrivacy was unable to find a keyring. This might be due to you starting this program for the first time. A new keyring will be created in your home directory.", "Keyring...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                bMessageShowed = true;
                try {
                    System.IO.Directory.CreateDirectory(strPath + "/SharpPrivacy");
                } catch (Exception e) {
                    MessageBox.Show("Error creating the SharpPrivacy home directory:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
                try {
                    FileStream fsTmp = System.IO.File.Create(strPath + "/SharpPrivacy/pub_keyring.txt");
                    fsTmp.Close();
                } catch (Exception e) {
                    MessageBox.Show("Error creating the public keyring file:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }

            if (!System.IO.File.Exists(strPath + "/SharpPrivacy/sec_keyring.txt")) {
                if (!bMessageShowed)
                    MessageBox.Show("SharpPrivacy was unable to find a keyring. This might be due to you starting this program for the first time. A new keyring will be created in your home directory.", "Keyring...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                bMessageShowed = true;
                try {
                    FileStream fsTmp = System.IO.File.Create(strPath + "/SharpPrivacy/sec_keyring.txt");
                    fsTmp.Close();
                } catch (Exception e) {
                    MessageBox.Show("Error creating the secret keyring file:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }

            SharpPrivacy.ReloadKeyRing();

            InitializeComponent();
            InitializeCustomComponents();
            this.WindowState = FormWindowState.Minimized;
            this.ResumeLayout(false);

            int iCount = 0;
            while (dtStart.AddSeconds(5) > DateTime.Now) {
                if (iCount % 10 == 0)
                    Application.DoEvents();
                iCount++;
                System.Threading.Thread.Sleep(50);
            }
            ssSplash.Hide();
        }
Exemplo n.º 2
0
        public SharpPrivacyTray()
        {
            DateTime     dtStart  = DateTime.Now;
            SplashScreen ssSplash = new SplashScreen();

            ssSplash.Show();
            Application.DoEvents();

            // check if private and public keyring exists
            bool   bMessageShowed = false;
            string strPath        = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            if (!System.IO.File.Exists(strPath + "/SharpPrivacy/pub_keyring.txt"))
            {
                MessageBox.Show("SharpPrivacy was unable to find a keyring. This might be due to you starting this program for the first time. A new keyring will be created in your home directory.", "Keyring...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                bMessageShowed = true;
                try {
                    System.IO.Directory.CreateDirectory(strPath + "/SharpPrivacy");
                } catch (Exception e) {
                    MessageBox.Show("Error creating the SharpPrivacy home directory:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
                try {
                    FileStream fsTmp = System.IO.File.Create(strPath + "/SharpPrivacy/pub_keyring.txt");
                    fsTmp.Close();
                } catch (Exception e) {
                    MessageBox.Show("Error creating the public keyring file:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }

            if (!System.IO.File.Exists(strPath + "/SharpPrivacy/sec_keyring.txt"))
            {
                if (!bMessageShowed)
                {
                    MessageBox.Show("SharpPrivacy was unable to find a keyring. This might be due to you starting this program for the first time. A new keyring will be created in your home directory.", "Keyring...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
                bMessageShowed = true;
                try {
                    FileStream fsTmp = System.IO.File.Create(strPath + "/SharpPrivacy/sec_keyring.txt");
                    fsTmp.Close();
                } catch (Exception e) {
                    MessageBox.Show("Error creating the secret keyring file:" + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }

            SharpPrivacy.ReloadKeyRing();

            InitializeComponent();
            InitializeCustomComponents();
            this.WindowState = FormWindowState.Minimized;
            this.ResumeLayout(false);

            int iCount = 0;

            while (dtStart.AddSeconds(5) > DateTime.Now)
            {
                if (iCount % 10 == 0)
                {
                    Application.DoEvents();
                }
                iCount++;
                System.Threading.Thread.Sleep(50);
            }
            ssSplash.Hide();
        }