コード例 #1
0
        public string getAttachmentPath()
        {
            string s = path;

            IOUtil.inLocalizedEnviroment(this.lang, () => s = Path.Combine(path, Localization.FileKeywords.Filename_Directory_Attachment));
            return(s);
        }
コード例 #2
0
        public static string getIndexingText(BoxIndexing bi, string locale)
        {
            if (!IO.IOUtil.isSupportedLanguage(locale))
            {
                return(null);
            }
            string s = "";

            IOUtil.inLocalizedEnviroment(locale, () => s = getIndexingText(bi));
            return(s);
        }
コード例 #3
0
        public static BoxIndexing getIndexingEnum(string text, string locale)
        {
            if (!IO.IOUtil.isSupportedLanguage(locale))
            {
                return(BoxIndexing.INVALID);
            }
            BoxIndexing result = BoxIndexing.INVALID;

            IOUtil.inLocalizedEnviroment(locale, () => result = getIndexingEnum(text));
            return(result);
        }
コード例 #4
0
        public void writeFile(string absolutePath, CultureInfo lang)
        {
            IOUtil.inLocalizedEnviroment(lang, () =>
            {
                string sep   = Localization.Settings.Symbol_NameContent_Seperator;
                string fname = Localization.FileKeywords.FileName_CardBoxInfo + "." + lang.Name + "." + SystemResources.Postfix_File;

                List <KeyValuePair <string, string> > odata = new List <KeyValuePair <string, string> >();
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_Title, title));
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_Creater, creator));
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_DateCreated, dateCreated));
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_Index, zu.OtherIfNull(BoxIndexingHandler.getIndexingText(indexing), getDefaults(lang.Name)[Localization.FileKeywords.CardBox_Index])));
                string schapters = "";
                for (int i = 0; i < chapters.Count; i++)
                {
                    schapters += chapters[i] + sep;
                }
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_ChapterNames, schapters));
                string scategories = "";
                foreach (string s in categories)
                {
                    scategories += s + sep;
                }
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_CategoryNames, scategories));
                string skeywords = "";
                foreach (string s in keywords)
                {
                    skeywords += s + sep;
                }
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_KeywordNames, skeywords));
                odata.Add(new KeyValuePair <string, string>(Localization.FileKeywords.CardBox_Description, description));

                //first deal with file's date, if the file is newly created. Else leave it to default handling
                if (dateCreated.Trim() == "" && !File.Exists(Path.Combine(absolutePath, fname)))
                {
                    dateCreated = IOUtil.formatNow();
                }

                //ensures there's a default for this language
                getDefaults(lang.Name);

                for (int i = 0; i < odata.Count; i++)
                {//add defaults to empy attributes
                    KeyValuePair <string, string> p = odata[i];
                    if (langDefaults[lang.Name].ContainsKey(p.Key) && p.Value == "")
                    {
                        odata[i] = new KeyValuePair <string, string>(p.Key, langDefaults[lang.Name][p.Key]);
                    }
                }

                ZDictionaryFileIO.writeFile(odata, sep, absolutePath, fname);
            });
        }
コード例 #5
0
        public List <string> getAttachmentFiles()
        {
            var attachs = new List <string>();

            IOUtil.inLocalizedEnviroment(this.lang, () =>
            {
                foreach (var s in Directory.GetFiles(Path.Combine(this.path, Localization.FileKeywords.Filename_Directory_Attachment)))
                {
                    attachs.Add(s);
                }
            });
            return(attachs);
        }
コード例 #6
0
        public static string getCardParentFolderName(CardBoxFileData box, CardFileData card)
        {
            switch (box.indexing)
            {
            case BoxIndexing.CATEGORY:
                return(card.category);

            case BoxIndexing.CHAPTERS:
                return(string.Format(IOUtil.inLocalizedEnviroment(box.lang,
                                                                  () => Localization.FileKeywords.FileName_ChapterFolderPrefix +
                                                                  Localization.Settings.Symbol_NameContent_Seperator),
                                     box.chapters.IndexOf(card.chapterName) + 1) + card.chapterName);//cause it starts at 0!

            case BoxIndexing.CHRONOLOGICAL:
                return(card.dateCreated);
            }
            return(null);
        }
コード例 #7
0
 private static Dictionary <string, string> getDefaults(string lang)
 {
     IOUtil.inLocalizedEnviroment(lang, () =>
     {
         if (!langDefaults.ContainsKey(lang))
         {
             Dictionary <string, string> fldefault = new Dictionary <string, string>();
             langDefaults.Add(lang, fldefault);
             fldefault.Add(Localization.FileKeywords.Card_Name, Localization.Settings.Defaults_CardName);
             fldefault.Add(Localization.FileKeywords.Card_Text, "");
             fldefault.Add(Localization.FileKeywords.Card_Creater, Localization.Settings.Defaults_UsersName);
             fldefault.Add(Localization.FileKeywords.Card_DateCreated, Localization.Settings.Defaults_UnknownDate);
             fldefault.Add(Localization.FileKeywords.Card_Category, Localization.Settings.Defaults_CardCategory);
             fldefault.Add(Localization.FileKeywords.Card_ChapterName, Localization.Settings.Defaults_ChapterName);
             fldefault.Add(Localization.FileKeywords.Card_Keywords, "");
         }
     });
     return(langDefaults[lang]);
 }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>null if invalid indexing found.</returns>
        public string getLocalizedDefaultFolder()
        {
            string s = null;

            IOUtil.inLocalizedEnviroment(lang, () =>
            {
                switch (indexing)
                {
                case BoxIndexing.CATEGORY:
                    s = Localization.Settings.Defaults_CardCategory; break;

                case BoxIndexing.CHAPTERS:
                    s = Localization.Settings.Defaults_ChapterName; break;

                case BoxIndexing.CHRONOLOGICAL:
                    s = Localization.Settings.Defaults_UnknownDate; break;
                }
            });
            return(s);
        }
コード例 #9
0
 private static Dictionary <string, string> getDefaults(string lang)
 {
     IOUtil.inLocalizedEnviroment(lang, () =>
     {
         //construct langdefault if we dont have it yet
         if (!langDefaults.ContainsKey(lang))
         {
             Dictionary <string, string> fldefault = new Dictionary <string, string>();
             langDefaults.Add(lang, fldefault);
             fldefault.Add(Localization.FileKeywords.CardBox_Title, Localization.Settings.Defaults_CardBoxName);
             fldefault.Add(Localization.FileKeywords.CardBox_Description, "");
             fldefault.Add(Localization.FileKeywords.CardBox_Creater, Localization.Settings.Defaults_UsersName);
             fldefault.Add(Localization.FileKeywords.CardBox_DateCreated, Localization.Settings.Defaults_UnknownDate);
             fldefault.Add(Localization.FileKeywords.CardBox_Index, SettingsFileData.DEFAULT_INDEXING);
             fldefault.Add(Localization.FileKeywords.CardBox_CategoryNames, "");
             fldefault.Add(Localization.FileKeywords.CardBox_ChapterNames, "");
             fldefault.Add(Localization.FileKeywords.CardBox_KeywordNames, "");
         }
     });
     return(langDefaults[lang]);
 }