public void load_images()
        {
            List<string> resource_paths = new List<string>();
            var assembly = Assembly.GetExecutingAssembly();
            var buffer = new ResourceManager(assembly.GetName().Name + ".g", assembly);
            try
            {
                var list = buffer.GetResourceSet(CultureInfo.CurrentCulture, true, true);
                foreach (DictionaryEntry item in list)
                {
                    resource_paths.Add((string)item.Key);
                }
            }
            finally
            {
                buffer.ReleaseAllResources();
            }

            all_images = new List<photo>();
            foreach (string current_path in resource_paths)
            {
                if (current_path.Contains(".jpg"))
                {
                    BitmapImage another_image = new BitmapImage(new Uri(@"/" + current_path, UriKind.Relative));
                    all_images.Add(new photo(another_image));
                }
            }

            faces_combo_box.ItemsSource = all_images;
            faces_combo_box.SelectedItem = faces_combo_box.Items[0];
        }
Example #2
0
        public Window1()
        {
            InitializeComponent();

            drawing = new Drawing(canvas1);
            Assembly asm = typeof(Window1).Assembly;
            string resourceName = asm.GetName().Name + ".g";
            ResourceManager rm = new ResourceManager(resourceName, asm);
            ResourceSet resourceSet = rm.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true);
            List<string> resources = new List<string>();
            foreach (DictionaryEntry resource in resourceSet)
            {
                Debug.WriteLine(resource.Key);
            }
            rm.ReleaseAllResources();

            toolBar1.ItemsSource = Behavior.Singletons;
        }
		public static IEnumerable<object> GetResourcePaths(Assembly assembly)
		{
			var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
            var resourceName = new System.Reflection.AssemblyName(assembly.FullName).Name + ".g";
			var resourceManager = new ResourceManager(resourceName, assembly);

			try
			{
				var resourceSet = resourceManager.GetResourceSet(culture, true, true);

				foreach (System.Collections.DictionaryEntry resource in resourceSet)
				{
					yield return resource.Key;
				}
			}
			finally
			{
				resourceManager.ReleaseAllResources();
			}
		}
Example #4
0
        /// <summary>Enumerates all resource keys within this assembly.</summary>
        /// <returns>Collection of keys.</returns>
        private static IEnumerable<object> GetResourcePaths()
        {
            var currentAssembly = Assembly.GetExecutingAssembly();

            var culture = Thread.CurrentThread.CurrentCulture;
            var resourceName = currentAssembly.GetName().Name + ".g";
            var resourceManager = new ResourceManager(resourceName, currentAssembly);

            try
            {
                var resourceSet = resourceManager.GetResourceSet(culture, true, true);

                foreach (DictionaryEntry resource in resourceSet)
                {
                    yield return resource.Key;
                }
            }
            finally
            {
                resourceManager.ReleaseAllResources();
            }
        }
Example #5
0
 public static string GetStrInRes(string resdata, string resname)
 {
     ResourceManager resourceManager = new ResourceManager(resname, Form1.asm);
     string result = (string)resourceManager.GetObject(resdata);
     resourceManager.ReleaseAllResources();
     return result;
 }
Example #6
0
		public void GetStream_Name_Null ()
		{
			ResourceManager rm = new ResourceManager (typeof (string));
			try {
				rm.GetStream ((string) null);
				Assert.Fail ("#A1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
				Assert.IsNull (ex.InnerException, "#A3");
				Assert.IsNotNull (ex.Message, "#A4");
				Assert.IsNotNull (ex.ParamName, "#A5");
				Assert.AreEqual ("name", ex.ParamName, "#A6");
			}

			try {
				rm.GetStream ((string) null, CultureInfo.InvariantCulture);
				Assert.Fail ("#A1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
				Assert.IsNull (ex.InnerException, "#A3");
				Assert.IsNotNull (ex.Message, "#A4");
				Assert.IsNotNull (ex.ParamName, "#A5");
				Assert.AreEqual ("name", ex.ParamName, "#A6");
			}
			rm.ReleaseAllResources ();
		}
Example #7
0
		public void GetResourceSet_Culture_Null ()
		{
			ResourceManager rm = new ResourceManager (typeof (string));
			try {
				rm.GetResourceSet ((CultureInfo) null, false, false);
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsNotNull (ex.ParamName, "#5");
				Assert.AreEqual ("culture", ex.ParamName, "#6");
			}
			rm.ReleaseAllResources ();
		}
Example #8
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Loads the resource strings.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		private void LoadMessages()
		{
			string resID = "SIL.WordWorks.GAFAWS.PositionAnalysis.StringsResource";
			ResourceManager LocRM = new ResourceManager(resID, this.GetType().Assembly);

			string stid = "kstidBadPrefixes";
			m_messages.Add(stid, LocRM.GetString(stid));
			stid = "kstidBadSuffixes";
			m_messages.Add(stid, LocRM.GetString(stid));

			LocRM.ReleaseAllResources();
		}
Example #9
0
 private static void CheckDefaultLanguageFile()
 {
     string defaultLanguageFile =
         Path.Combine(LanguageFolder, "language_zh-Hans.xml");
     if(!File.Exists(defaultLanguageFile))
     {
         ResourceManager manager =
             new ResourceManager("DevTools.Language.Resource",
                                 typeof(LanguageManager).Assembly);
         using (StreamWriter writer =
                new StreamWriter(defaultLanguageFile, false, Encoding.UTF8))
         {
             writer.Write(manager.GetString("language_zh-Hans"));
         }
         manager.ReleaseAllResources();
     }
 }