private void ButtonLoadXml_Click(object sender, RoutedEventArgs e)
        {
            using (System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog())
            {
                dialog.Title = "Select File...";
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string selected = dialog.FileName;
                    try
                    {
                        SerializableDictionary <string, Fic> tempDisp = XmlOperator.DeserializeFile <SerializableDictionary <string, Fic> >(selected);
                        // Resources["ficList"] = tempDisp;

                        Dictionary <string, Fic> actualDict = new Dictionary <string, Fic>(tempDisp);
                        //ficList = tempDisp;
                        //Resources["ficList"] = ficList;
                        SetDisplayContent(actualDict);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }
 private void MatchKindleObjectsFromFile()
 {
     using (System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog())
     {
         dialog.Title = "Select File...";
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string selected = dialog.FileName;
             try
             {
                 List <string> kindleIds = new List <string>();
                 SerializableDictionary <string, string> tempDisp = XmlOperator.DeserializeFile <SerializableDictionary <string, string> >(selected);
                 if (kindleFiles != null)
                 {
                     foreach (KeyValuePair <string, string> pair in tempDisp)
                     {
                         try
                         {
                             if (kindleFiles.ContainsKey(pair.Value))
                             {
                                 kindleIds.Add(pair.Key);
                             }
                         }
                         catch (Exception)
                         {
                             throw;
                         }
                     }
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Example #3
0
        public static void XmlToLdb()
        {
            SerializableDictionary <string, Fic> fics;
            List <string> lib = new List <string>();
            SerializableDictionary <string, string> libHash;
            SerializableDictionary <string, string> kindleFiles;

            Dictionary <string, Fic>    nDictFics    = new Dictionary <string, Fic>();
            Dictionary <string, string> nDictLibHash = new Dictionary <string, string>();
            Dictionary <string, string> nDictKindle  = new Dictionary <string, string>();

            bool success = false;

            try
            {
                fics      = XmlOperator.LoadFics();
                nDictFics = new Dictionary <string, Fic>(fics);
                success   = true;
            }
            catch (Exception)
            {
            }

            try
            {
                lib = XmlOperator.GetFolders();
            }
            catch (Exception)
            {
            }

            try
            {
                libHash      = XmlOperator.DeserializeFile <SerializableDictionary <string, string> >(Constants.LibHashList);
                nDictLibHash = new Dictionary <string, string>(libHash);
                success      = true;
            }
            catch (Exception)
            {
            }

            try
            {
                kindleFiles = XmlOperator.DeserializeFile <SerializableDictionary <string, string> >(Constants.KindleList);
                nDictKindle = new Dictionary <string, string>(kindleFiles);
                success     = true;
            }
            catch (Exception)
            {
            }

            if (success)
            {
                try
                {
                    Liter.StoreFics(nDictFics);
                }
                catch (Exception)
                {
                }

                try
                {
                    foreach (string fldrpath in lib)
                    {
                        Liter.AddLib(fldrpath);
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                try
                {
                    // LibHash
                    // Not implemented
                }
                catch (Exception)
                {
                }

                try
                {
                    //Kindle
                    Liter.StoreKindleHashes(nDictKindle);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Example #4
0
 public static T LoadGeneric <T>(string filepath)
 {
     return(XmlOperator.DeserializeFile <T>(filepath));
 }
 private static SerializableDictionary <string, string> ImportHashes(string filepath)  // Allows for importing a list of ID : [hashes] file. Designed to import XML for now.
 {
     return(XmlOperator.DeserializeFile <SerializableDictionary <string, string> >(filepath));
 }