Ejemplo n.º 1
0
        public string Open(string path)
        {
            byte[] data;
            if (path.StartsWith("dropbox://"))
            {
                string url = path.Substring(path.LastIndexOf("://") + 3);
                data = DropboxMgr.ReadFileFromCloud(url);
            }
            else
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "KCF Documents (*.kcf)|*.kcf";
                if (d.ShowDialog() != DialogResult.OK)
                    return "";
                data = File.ReadAllBytes(d.FileName);
            }

            DataContractSerializer serializer = new DataContractSerializer(typeof(KeyChain));
            MemoryStream ms = new MemoryStream(data);
            KeyChain keychain = (KeyChain)serializer.ReadObject(ms);
            if (keychain.Password != null && keychain.Password != "")
            {
                PasswordDialog pd = new PasswordDialog();
                pd.Filename = path;
                pd.RealPassword = keychain.Password;
                if (pd.ShowDialog() == DialogResult.Abort)
                {
                    return KeyChain.WrongPassword;
                }
            }
            _keyChain = keychain;
            _keyChain.Filename = path;
            _keyChain.Saved = true;
            int limit = PreferencesMgr.Preference.RecentFileLimit;
            if (!PreferencesMgr.Preference.RecentFiles.Contains(path))
            {
                if (limit > PreferencesMgr.Preference.RecentFiles.Count)
                {
                    PreferencesMgr.Preference.RecentFiles.Add(path);
                }
                else
                {
                    PreferencesMgr.Preference.RecentFiles.Add(path);
                    PreferencesMgr.Preference.RecentFiles.RemoveAt(0);
                }
            }
            PreferencesMgr.SaveFile();
            return path;
        }
Ejemplo n.º 2
0
 public KeyChainMgr()
 {
     _keyChain = new KeyChain();
     Histories = new List<History>();
     _printFont = PreferencesMgr.Preference.Font;
 }
Ejemplo n.º 3
0
 public KeyChain NewKeyChain()
 {
     _keyChain = new KeyChain();
     _keyChain.Saved = true;
     return _keyChain;
 }