コード例 #1
0
        /// <summary>
        /// Extract image text using specific language.
        /// </summary>
        /// <param name="fileName">The image file name.</param>
        /// <param name="language">The language.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries or not.</param>
        /// <param name="folder">The image folder.</param>
        /// <returns><see cref="OCRResponse"/> with the operation result.</returns>
        public OCRResponse ExtractText(string imageFileName, LanguageName language, bool useDefaultDictionaries = false, string folder = null)
        {
            //build URI to extract text
            string strURI = "";
            if (string.IsNullOrEmpty(folder))
                strURI = Product.BaseProductUri + "/ocr/" + imageFileName + "/recognize?language=" + language + "&useDefaultDictionaries=" + useDefaultDictionaries;
            else
                strURI = Product.BaseProductUri + "/ocr/" + imageFileName + "/recognize?language=" + language + "&useDefaultDictionaries=" + useDefaultDictionaries + "&folder=" + folder;

            //sign URI
            string signedURI = Utils.Sign(strURI);

            //execute signed URI request and get response
            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            StreamReader reader = new StreamReader(responseStream);
            string strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);

            //Deserializes the JSON to a object. 
            OCRResponse ocrResponse = JsonConvert.DeserializeObject<OCRResponse>(parsedJSON.ToString());

            return ocrResponse;
        }
コード例 #2
0
 private void Start()
 {
     if (FindObjectsOfType(GetType()).Length > 1)
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
     }
     language = LanguageName.en;
 }
コード例 #3
0
        public virtual string LoadString(string path, LanguageName language, object sub1)
        {
            string format = this.LoadString(path, language);

            try
            {
                return(string.Format(format, sub1));
            }
            catch { }

            return(format);
        }
コード例 #4
0
        /// <summary>Loads an XNB file from StardewValley/Content</summary>
        public string LoadXNBFile(string xnbFileName, string key, LanguageName language)
        {
            string xnb = xnbFileName + this.getFileExtentionForTranslation(language);
            Dictionary <string, string> loadedDict = Game1.content.Load <Dictionary <string, string> >(xnb);

            if (!loadedDict.TryGetValue(key, out string loaded))
            {
                Vocalization.ModMonitor.Log("Big issue: Key not found in file:" + xnb + " " + key);
                return("");
            }
            return(loaded);
        }
コード例 #5
0
        /// <summary>Loads an XNB file from StardewValley/Content</summary>
        public string LoadStringFromXNBFile(string xnbFileName, string key, LanguageName language)
        {
            string xnb = xnbFileName + this.getFileExtentionForTranslation(language, FileType.XNB);
            Dictionary <string, string> loadedDict = Game1.content.Load <Dictionary <string, string> >(xnb);

            if (!loadedDict.TryGetValue(key, out string loaded))
            {
                Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log("Big issue: Key not found in file:" + xnb + " " + key);
                return("");
            }
            return(loaded);
        }
コード例 #6
0
 public static string[] getRandomDeliciousAdjectives(LanguageName language, NPC n = null)
 {
     string[] strArray;
     if (n != null && n.Age == 2)
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective_Child"), language).Split('#');
     }
     else
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective"), language).Split('#');
     }
     return(strArray);
 }
コード例 #7
0
 /// <summary>Gets the proper file extension for the current translation.</summary>
 /// <param name="language">The translation language name.</param>
 public string getFileExtentionForTranslation(LanguageName language)
 {
     try
     {
         return(this.TranslationFileExtensions[language]);
     }
     catch (Exception err)
     {
         Vocalization.ModMonitor.Log(err.ToString());
         Vocalization.ModMonitor.Log($"Attempted to get translation: {language}");
         return(".xnb");
     }
 }
コード例 #8
0
ファイル: Language.cs プロジェクト: chidokun/ShutdownTimer
 /// <summary>
 /// Initialize language content
 /// </summary>
 /// <param name="langName"></param>
 public Language(LanguageName langName)
 {
     Items = new Dictionary<string, string>();
     switch (langName)
     {
         case LanguageName.Vietnamese:
             Vietnamese();
             break;
         case LanguageName.English:
             English();
             break;
     }
 }
コード例 #9
0
ファイル: SettingsState.cs プロジェクト: uzoko1/Memoria
    public void SetMenuLanguage(string language, Action callback)
    {
        ISharedDataSerializer.OnSetSelectedLanguage func = errNo =>
        {
            //if (errNo != DataSerializerErrorCode.Success)
            //    ;
            CurrentLanguage       = language;
            Localization.language = language;
            UIManager.Field.InitializeATEText();
            StartCoroutine(PersistenSingleton <FF9TextTool> .Instance.UpdateTextLocalization(callback));
        };

        FF9StateSystem.Serializer.SetSelectedLanguage(LanguageName.ConvertToLanguageCode(language), func);
    }
コード例 #10
0
        /// <summary>
        /// Gets the display name of the language.
        /// </summary>
        /// <param name="cultureInfo">The culture info.</param>
        /// <param name="languageName">The language name type.</param>
        /// <returns>The display name.</returns>
        public static string GetLanguageDisplayName(CultureInfo cultureInfo, LanguageName languageName)
        {
            switch (languageName)
            {
            case LanguageName.English:
                return(cultureInfo.EnglishName);

            case LanguageName.Native:
                return(cultureInfo.NativeName);

            default:
                return(cultureInfo.NativeName + " - " + cultureInfo.EnglishName);
            }
        }
コード例 #11
0
 public string getFileExtentionForDirectory(LanguageName language)
 {
     try
     {
         string s = this.TranslationFileExtensions[language];
         return(s);
     }
     catch (Exception err)
     {
         Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log(err.ToString());
         Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log($"Attempted to get translation: {language}");
         return("");
     }
 }
コード例 #12
0
        public virtual string LoadString(string path, LanguageName language, params object[] substitutions)
        {
            string format = this.LoadString(path, language);

            if (substitutions.Length != 0)
            {
                try
                {
                    return(string.Format(format, substitutions));
                }
                catch { }
            }
            return(format);
        }
コード例 #13
0
        /// <summary>
        /// Sets up the combo box for current language selection from the settings file app.config
        /// </summary>
        private void PopulateTranslationLanguage()
        {
            foreach (string LanguageName in Settings.Default.TranslationLanguages.Split(','))
            {
                TranslationLanguageComboBox.Items.Add(LanguageName.Trim());
            }

            //Set to saved state preferred language
            if (!String.IsNullOrWhiteSpace(UserSavedStatePreferredLanguage))
            {
                var IndexOfUserPreferredLanguage = TranslationLanguageComboBox.Items.IndexOf(UserSavedStatePreferredLanguage);
                TranslationLanguageComboBox.SelectedItem = TranslationLanguageComboBox.Items[IndexOfUserPreferredLanguage];
            }
        }
コード例 #14
0
        /// <summary>Change all of the files to the ones that are appropriate for that translation version.</summary>
        /// <param name="language">The translation language name.</param>
        public void initializeForTranslation(LanguageName language)
        {
            string extension = Vocalization.config.translationInfo.getFileExtentionForTranslation(language);

            for (int i = 0; i < this.dataFileNames.Count; i++)
            {
                Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
                string s = this.dataFileNames.ElementAt(i);
                s = this.dataFileNames.ElementAt(i).Replace(".xnb", extension);
                this.dataFileNames[i] = s;
                Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
            }

            for (int i = 0; i < this.dialogueFileNames.Count; i++)
            {
                Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
                string s = this.dialogueFileNames.ElementAt(i);
                s = this.dialogueFileNames.ElementAt(i).Replace(".xnb", extension);
                this.dialogueFileNames[i] = s;
                Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
            }

            for (int i = 0; i < this.stringsFileNames.Count; i++)
            {
                Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
                string s = this.stringsFileNames.ElementAt(i);
                s = this.stringsFileNames.ElementAt(i).Replace(".xnb", extension);
                this.stringsFileNames[i] = s;
                Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
            }

            for (int i = 0; i < this.festivalFileNames.Count; i++)
            {
                Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
                string s = this.festivalFileNames.ElementAt(i);
                s = this.festivalFileNames.ElementAt(i).Replace(".xnb", extension);
                this.festivalFileNames[i] = s;
                Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
            }

            for (int i = 0; i < this.eventFileNames.Count; i++)
            {
                Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
                string s = this.eventFileNames.ElementAt(i);
                s = this.eventFileNames.ElementAt(i).Replace(".xnb", extension);
                this.eventFileNames[i] = s;
                Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
            }
        }
コード例 #15
0
ファイル: Locale.cs プロジェクト: vic910/ChessSoul
        /// <summary>
        /// 改变系统语言
        /// </summary>
        /// <param name="_lang"></param>
        /// <param name="_preload_only"></param>
        public Boolean ChangeLanguage(LanguageName _lang)
        {
            m_locale.Clear();
            Language = _lang;
            LoadOneLanguageConfig("preload");
            LoadOneLanguageConfig("login");
            LoadAllLanguageConfig();
            if (null != eventOnLanguageChanged)
            {
                eventOnLanguageChanged(Language);
            }

            Log.Info("成功切换语言: {0} -->{1}", Language, _lang);
            return(true);
        }
コード例 #16
0
 public string GetLine(LanguageName language)
 {
     if (language == LanguageName.en)
     {
         return(EnglishText);
     }
     if (language == LanguageName.fr)
     {
         return(FrenchText);
     }
     if (language == LanguageName.nl)
     {
         return(DutchText);
     }
     return(null);
 }
コード例 #17
0
ファイル: SelectLanguage.cs プロジェクト: soluling/I18N
        /// <summary>
        /// Shows language dialog that users can use to select a new language. If the user selects a language and clicks OK the method translates all current user interface (e.g. all forms) to the new language.
        /// </summary>
        /// <param name="displayLanguage">The type of the display language.</param>
        /// <returns><b>true</b> is user has selected a new language. <b>false</b> is user has clicked Cancel button.</returns>
        /// <example>
        /// <para>
        /// The following example shows the language dialog when user clicks the language button.
        /// </para>
        /// <code>
        /// private void languageButton_Click(object sender, EventArgs e)
        /// {
        ///   SelectLanguage.Select();
        /// }
        /// </code>
        /// </example>
        static public bool Select(LanguageName displayLanguage = LanguageName.Both)
        {
            SelectLanguage dialog = new SelectLanguage();

            dialog.DisplayLanguage = displayLanguage;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Translator.SetUserInterfaceLanguage(dialog.SelectedLanguage);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #18
0
ファイル: Locale.cs プロジェクト: vic910/ChessSoul
        private Boolean _loadLocaleFile(LanguageName _lang, String _file_name)
        {
            //StringBuilder string_builder = new StringBuilder( 128 );
            Utility.SheetLite.SheetReader reader = new Utility.SheetLite.SheetReader();

            if (!reader.OpenSheet("language", String.Format("{0}/{1}", _lang, _file_name)))
            {
                Log.Error("[Locale]语言包文件: {0} 加载失败!", _file_name);
                return(false);
            }
            for (Int32 i = 0; i < reader.Count; ++i)
            {
                SheetRow row = reader[i];
                String   key = row["Key"];

                String category = row["Category"];
                if (!String.IsNullOrEmpty(category))
                {
                    key = String.Format("{0}@{1}", category, key);
                }

                if (m_locale.ContainsKey(key))
                {
                    Utility.Log.Error("[Loclae]:语言包中包含重复键值:{0} {1}", _lang, key);
                    continue;
                }
                String value = row["Value"];

                // 颜色值转换
                //string_builder.Length = 0;
                //Int32 pos = 0;
                //while( pos < value.Length )
                //{
                //	if( '[' == value[pos] )
                //	{
                //		if( UnityEngine.UI.Text.ProcessColor( value, pos, string_builder, out pos ) )
                //			continue;
                //	}
                //	string_builder.Append( value[pos++] );
                //}

                //value = string_builder.ToString().Trim();
                m_locale.Add(key, value);
            }
            return(true);
        }
コード例 #19
0
        public static string GetLanguageCode(this LanguageName name)
        {
            switch (name)
            {
            case LanguageName.En:
                return(en);

            case LanguageName.Fr:
                return(fr);

            case LanguageName.Ru:
                return(ru);

            default:
                throw new ArgumentOutOfRangeException(nameof(name), name, null);
            }
        }
コード例 #20
0
 /// <summary>Gets the proper file extension for the current translation.</summary>
 /// <param name="language">The translation language name.</param>
 public string getFileExtentionForTranslation(LanguageName language, FileType File)
 {
     try
     {
         if (language == LanguageName.English)
         {
             return(this.getFileExtensionForFileType(File));
         }
         return("." + this.TranslationFileExtensions[language] + this.getFileExtensionForFileType(File));
     }
     catch (Exception err)
     {
         Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log(err.ToString());
         Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log($"Attempted to get translation: {language}");
         return(".xnb");
     }
 }
コード例 #21
0
        public override int GetHashCode()
        {
            var hashCode = 0;

            foreach (var processExclusion in ProcessExclusions)
            {
                hashCode ^= processExclusion.GetHashCode();
            }

            foreach (var item in MenuItems.WindowSizeItems)
            {
                hashCode ^= item.Title.GetHashCode() ^ item.Left.GetHashCode() ^ item.Top.GetHashCode() ^ item.Width.GetHashCode() ^ item.Height.GetHashCode() ^ item.Key1.GetHashCode() ^ item.Key2.GetHashCode() ^ item.Key3.GetHashCode();
            }

            foreach (var item in MenuItems.StartProgramItems)
            {
                hashCode ^= item.Title.GetHashCode() ^ item.FileName.GetHashCode() ^ item.Arguments.GetHashCode() ^ item.UseWindowWorkingDirectory.GetHashCode() ^ item.RunAs.GetHashCode() ^ item.BeginParameter.GetHashCode() ^ item.EndParameter.GetHashCode();
            }

            foreach (var item in MenuItems.Items)
            {
                hashCode ^= item.Show.GetHashCode() ^ item.Type.GetHashCode() ^ item.Name.GetHashCode() ^ item.Key1.GetHashCode() ^ item.Key2.GetHashCode() ^ item.Key3.GetHashCode();
                foreach (var subItem in item.Items)
                {
                    hashCode ^= subItem.Show.GetHashCode() ^ subItem.Type.GetHashCode() ^ subItem.Name.GetHashCode() ^ subItem.Key1.GetHashCode() ^ subItem.Key2.GetHashCode() ^ subItem.Key3.GetHashCode();
                }
            }

            hashCode ^= Closer.Type.GetHashCode();
            hashCode ^= Closer.Key1.GetHashCode();
            hashCode ^= Closer.Key2.GetHashCode();
            hashCode ^= Closer.MouseButton.GetHashCode();
            hashCode ^= SaveSelectedItems.AeroGlass.GetHashCode();
            hashCode ^= SaveSelectedItems.AlwaysOnTop.GetHashCode();
            hashCode ^= SaveSelectedItems.HideForAltTab.GetHashCode();
            hashCode ^= SaveSelectedItems.Alignment.GetHashCode();
            hashCode ^= SaveSelectedItems.Transparency.GetHashCode();
            hashCode ^= SaveSelectedItems.Priority.GetHashCode();
            hashCode ^= SaveSelectedItems.MinimizeToTrayAlways.GetHashCode();
            hashCode ^= Sizer.GetHashCode();
            hashCode ^= LanguageName.GetHashCode();
            hashCode ^= ShowSystemTrayIcon.GetHashCode();
            hashCode ^= EnableHighDPI.GetHashCode();
            return(hashCode);
        }
コード例 #22
0
        public static List <string> getCarpenterStock(LanguageName language)
        {
            List <string> stock = new List <string>();

            Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(language);

            for (int i = 0; i <= 1854; i++)
            {
                try
                {
                    Furniture f = new Furniture(i, Vector2.Zero);
                    stock.Add(f.DisplayName);
                }
                catch { }
            }
            Vocalization.config.translationInfo.resetLocalizationCode();
            return(stock);
        }
コード例 #23
0
        public static List <string> getMerchantStock(LanguageName language)
        {
            List <string>            stock   = new List <string>();
            Dictionary <int, string> objDict = Game1.content.Load <Dictionary <int, string> >(Path.Combine("Data", Vocalization.config.translationInfo.getXNBForTranslation("ObjectInformation", language)));

            //Vocalization.ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert);
            foreach (KeyValuePair <int, string> pair in objDict)
            {
                for (int i = 0; i <= 3; i++)
                {
                    StardewValley.Object obj = new StardewValley.Object(pair.Key, 1, false, -1, i);
                    stock.Add(obj.DisplayName);
                }
            }
            foreach (string item in getCarpenterStock(language))
            {
                stock.Add(item);
            }
            return(stock);
        }
コード例 #24
0
        /// <summary>
        /// Extract Text from remote image URL.
        /// </summary>
        /// <param name="url">The image url.</param>
        /// <param name="language">The specific language.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries or not.</param>
        /// <returns><see cref="OCRResponse"/> with the operation result.</returns>
        public OCRResponse ExtractTextFromURL(string url, LanguageName language, bool useDefaultDictionaries = false)
        {
            //build URI to extract text
            string strURI = Product.BaseProductUri + "/ocr/recognize?url=" + url + "&language=" + language + "&useDefaultDictionaries=" + useDefaultDictionaries;

            //sign URI
            string signedURI = Utils.Sign(strURI);

            //execute signed URI request and get response
            Stream responseStream = Utils.ProcessCommand(signedURI, "POST");

            StreamReader reader  = new StreamReader(responseStream);
            string       strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);

            //Deserializes the JSON to a object.
            OCRResponse ocrResponse = JsonConvert.DeserializeObject <OCRResponse>(parsedJSON.ToString());

            return(ocrResponse);
        }
コード例 #25
0
        public override int GetHashCode()
        {
            var hashCode = 0;

            foreach (var processExclusion in ProcessExclusions)
            {
                hashCode ^= processExclusion.GetHashCode();
            }

            foreach (var item in MenuItems.StartProgramItems)
            {
                hashCode ^= item.Title.GetHashCode() ^ item.FileName.GetHashCode() ^ item.Arguments.GetHashCode();
            }

            foreach (var item in MenuItems.Items)
            {
                hashCode ^= item.Name.GetHashCode() ^ item.Key1.GetHashCode() ^ item.Key2.GetHashCode() ^ item.Key3.GetHashCode();
            }

            hashCode ^= LanguageName.GetHashCode();
            return(hashCode);
        }
コード例 #26
0
 public static string[] getRandomPositiveAdjectivesForEventOrPerson(LanguageName language, NPC n = null)
 {
     //Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2);
     string[] strArray;
     if (n != null && n.Age != 0)
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_Child"), language).Split('#');
     }
     else if (n != null && n.Gender == 0)
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultMale"), language).Split('#');
     }
     else if (n != null && n.Gender == 1)
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultFemale"), language).Split('#');
     }
     else
     {
         strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_PlaceOrEvent"), language).Split('#');
     }
     return(strArray);
 }
コード例 #27
0
        /// <summary>
        /// Extract image text from local file.
        /// </summary>
        /// <param name="localFile">The local file.</param>
        /// <param name="language">The text language.</param>
        /// <param name="useDefaultDictionaries">Use default dictionaries or not.</param>
        /// <returns><see cref="OCRResponse"/> with the operation result.</returns>
        public OCRResponse ExtractText(string localFile, LanguageName language, bool useDefaultDictionaries = false)
        {
            //build URI to extract text
            string strURI = strURI = Product.BaseProductUri + "/ocr/recognize?language=" + language + "&useDefaultDictionaries=" + useDefaultDictionaries;

            //sign URI
            string signedURI = Utils.Sign(strURI);
            FileStream stream = new FileStream(localFile, FileMode.Open, FileAccess.Read);

            //execute signed URI request and get response
            Stream responseStream = Utils.ProcessCommand(signedURI, "POST", stream);

            StreamReader reader = new StreamReader(responseStream);
            string strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);

            //Deserializes the JSON to a object. 
            OCRResponse ocrResponse = JsonConvert.DeserializeObject<OCRResponse>(parsedJSON.ToString());

            return ocrResponse;
        }
コード例 #28
0
        /// <summary>Gets a list of all of the possible cooking recipes in Stardew Valley.</summary>
        public static List <string> getAllCookingRecipes(LanguageName language)
        {
            List <string> recipes = new List <string>();
            Dictionary <string, string> cookingDict = Game1.content.Load <Dictionary <string, string> >(Path.Combine("Data", "TV", Vocalization.config.translationInfo.getXNBForTranslation("CookingChannel", language)));

            if (language == LanguageName.English)
            {
                foreach (KeyValuePair <string, string> pair in cookingDict)
                {
                    string name = pair.Value.Split('/').ElementAt(0);
                    recipes.Add(name);
                }
            }
            else
            {
                foreach (KeyValuePair <string, string> pair in cookingDict)
                {
                    string[] data = pair.Value.Split('/');
                    string   name = data.ElementAt(data.Length - 1);
                    recipes.Add(name);
                }
            }
            return(recipes);
        }
コード例 #29
0
 public Language(LanguageName name, string dictionaryLocation)
 {
     _name = name;
     _dictionaryLocation = dictionaryLocation;
 }
コード例 #30
0
 public void RemoveNamespace(string namespaceName)
 {
     var existingNamespace = new LanguageName(namespaceName);
     if (namespaces.Contains(existingNamespace)) namespaces.Remove(existingNamespace);
 }
コード例 #31
0
 public void AddNamespace(string namespaceName)
 {
     var newNamespace = new LanguageName(namespaceName);
     if (!namespaces.Contains(newNamespace)) namespaces.Add(newNamespace);
 }
コード例 #32
0
 private bool IsRegistered(string namespaceString)
 {
     var existingNamespace = new LanguageName(namespaceString);
     return namespaces.Contains(existingNamespace);
 }
コード例 #33
0
        protected override void OnWriteProject(ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject)
        {
            if (projItemsPath == FilePath.Null)
            {
                projItemsPath = Path.ChangeExtension(FileName, ".projitems");
            }

            if (projitemsProject == null)
            {
                projitemsProject          = new MSBuildProject(msproject.EngineManager);
                projitemsProject.FileName = projItemsPath;
                var grp = projitemsProject.GetGlobalPropertyGroup();
                if (grp == null)
                {
                    grp = projitemsProject.AddNewPropertyGroup(false);
                }
                grp.SetValue("MSBuildAllProjects", "$(MSBuildAllProjects);$(MSBuildThisFileFullPath)");
                grp.SetValue("HasSharedItems", true);
                grp.SetValue("SharedGUID", ItemId, preserveExistingCase: true);
            }

            IMSBuildPropertySet configGrp = projitemsProject.PropertyGroups.FirstOrDefault(g => g.Label == "Configuration");

            if (configGrp == null)
            {
                configGrp       = projitemsProject.AddNewPropertyGroup(true);
                configGrp.Label = "Configuration";
            }
            configGrp.SetValue("Import_RootNamespace", DefaultNamespace);

            base.OnWriteProject(monitor, msproject);

            var newProject = FileName == null || !File.Exists(FileName);

            if (newProject)
            {
                var grp = msproject.GetGlobalPropertyGroup();
                if (grp == null)
                {
                    grp = msproject.AddNewPropertyGroup(false);
                }
                grp.SetValue("ProjectGuid", ItemId, preserveExistingCase: true);
                var import = msproject.AddNewImport(@"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props");
                import.Condition = @"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')";
                msproject.AddNewImport(@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props");
                msproject.AddNewImport(@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props");
                import       = msproject.AddNewImport(Path.ChangeExtension(FileName.FileName, ".projitems"));
                import.Label = "Shared";
                if (LanguageName.Equals("C#", StringComparison.OrdinalIgnoreCase))
                {
                    msproject.AddNewImport(CSharptargets);
                }
                else if (LanguageName.Equals("F#", StringComparison.OrdinalIgnoreCase))
                {
                    msproject.AddNewImport(FSharptargets);
                }
            }
            else
            {
                msproject.Load(FileName);
            }

            // having no ToolsVersion is equivalent to 2.0, roundtrip that correctly
            if (ToolsVersion != "2.0")
            {
                msproject.ToolsVersion = ToolsVersion;
            }
            else if (string.IsNullOrEmpty(msproject.ToolsVersion))
            {
                msproject.ToolsVersion = null;
            }
            else
            {
                msproject.ToolsVersion = "2.0";
            }

            projitemsProject.Save(projItemsPath);
        }
コード例 #34
0
        public virtual string LoadString(string path, LanguageName language)
        {
            this.parseStringPath(path, out string assetName, out string key);

            return(this.LoadStringFromXNBFile(assetName, key, language));
        }
コード例 #35
0
ファイル: LanguageName.cs プロジェクト: unclebob/nslim
 public bool Equals(LanguageName other)
 {
     return other != null && Matches(other.MatchName);
 }
コード例 #36
0
        /// <summary>
        /// Scans whole or part of images and extracts OCR text
        /// </summary>
        /// <param name="imageFileName">Name of the image file</param>
        /// <param name="language">Language of document to recognize</param>
        /// /// <param name="useDefaultDictionaries">Allows to correct text after recognition using default dictionaries</param>
        /// /// <param name="x">Start x of the rectangle: Recognition of text inside specified Rectangle region</param>
        /// /// <param name="y">Start y of the rectangle: Recognition of text inside specified Rectangle region</param>
        /// /// <param name="width">Width of the rectangle: Recognition of text inside specified Rectangle region</param>
        /// /// <param name="height">Height of the rectangle: Recognition of text inside specified Rectangle region</param>
        /// /// <param name="folder">Folder with images to recognize</param>
        /// <returns></returns>
        public OCRResponse ExtractText(string imageFileName, LanguageName language, bool useDefaultDictionaries, int x, int y,
            int width, int height, string folder)
        {
            //build URI to extract text
            string strURI = Product.BaseProductUri + "/ocr/" + imageFileName + "/recognize?language=" + language +
                ((x >= 0 && y >= 0 && width > 0 && height > 0) ? "&rectX=" + x + "&rectY=" + y + "&rectWidth=" + width + "&rectHeight=" + height : "") +
             "&useDefaultDictionaries=" + ((useDefaultDictionaries) ? "true" : "false") +
             ((string.IsNullOrEmpty(folder)) ? "" : "&folder=" + folder);

            //sign URI
            string signedURI = Utils.Sign(strURI);

            //execute signed URI request and get response
            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            StreamReader reader = new StreamReader(responseStream);
            string strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);

            //Deserializes the JSON to a object. 
            OCRResponse ocrResponse = JsonConvert.DeserializeObject<OCRResponse>(parsedJSON.ToString());

            return ocrResponse;
        }
コード例 #37
0
 public string GetTitle(string name, LanguageName language)
 {
     return(GetString($"{name}Title", language));
 }
コード例 #38
0
 public string GetBody(string name, LanguageName language)
 {
     return(GetString($"{name}Body", language));
 }