Esempio n. 1
0
        public static void GetResourceSet_NonStringsIgnoreCase(string key, object expectedValue, bool requiresBinaryFormatter)
        {
            _ = requiresBinaryFormatter;
            var         manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
            var         culture = new CultureInfo("en-US");
            ResourceSet set     = manager.GetResourceSet(culture, true, true);

            Assert.Equal(expectedValue, set.GetObject(key.ToLower(), true));
            Assert.Equal(expectedValue, set.GetObject(key.ToLower(), true));
        }
Esempio n. 2
0
        public void GetObject()
        {
            var rs = new ResourceSet(new SimpleResourceReader());

            Assert.Null(rs.GetObject("DoesNotExist"));
            Assert.Null(rs.GetObject("1"));

            Assert.Equal(5, rs.GetObject("Int32"));
            Assert.Equal(5, rs.GetObject("int32", true));
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            CultureInfo culture = CultureInfo.InvariantCulture;

            foreach (string arg in args)
            {
                string basename = Path.GetFileNameWithoutExtension(arg);

                string basedir = Path.GetDirectoryName(arg);

                Console.WriteLine("");

                Console.WriteLine("[*] ------ Processing " + basename + " ------");

                ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(basename, basedir, null);

                ResourceSet rs = rm.GetResourceSet(culture, true, true);

                if (rs != null)
                {
                    IDictionaryEnumerator dict = rs.GetEnumerator();

                    while (dict.MoveNext())
                    {
                        string key = (string)dict.Key;

                        if (dict.Value is byte[])
                        {
                            Console.WriteLine("[i] Extracting resource '{0}' as bytes", key);

                            storeContent(basedir, basename, key, "bin", (byte [])rs.GetObject(key));
                        }

                        else if (dict.Value is System.Drawing.Bitmap)
                        {
                            Console.WriteLine("[i] Extracting resource '{0}' as image data", key);

                            System.Drawing.Bitmap img = (Bitmap)rs.GetObject(key);

                            ImageConverter converter = new ImageConverter();

                            storeContent(basedir, basename, key, "img", (byte [])converter.ConvertTo(img, typeof(byte [])));
                        }

                        else
                        {
                            Console.WriteLine("[!] Unhandled resource type for '{0}': {1}", key, dict.Value);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 public static void File_GetResourceSet_NonStrings(string key, object expectedValue, bool requiresBinaryFormatter = false)
 {
     var manager = ResourceManager.CreateFileBasedResourceManager("TestResx.netstandard17", Directory.GetCurrentDirectory(), null);
     var culture = new CultureInfo("en-US");
     ResourceSet set = manager.GetResourceSet(culture, true, true);
     if (requiresBinaryFormatter && !PlatformDetection.IsFullFramework)
     {
         Assert.Throws<NotSupportedException>(() => set.GetObject(key));
     }
     else
     {
         Assert.Equal(expectedValue, set.GetObject(key));
     }
 }
        public object GetResource(string name, bool ignoreCase, bool isString, bool asSafe, bool cloneValue)
        {
            ResXResourceSet resx     = resxResourceSet;
            ResourceSet     compiled = compiledResourceSet;

            if (resx == null || compiled == null)
            {
                Throw.ObjectDisposedException();
            }

            object result = resx.GetResourceInternal(name, ignoreCase, isString, asSafe, cloneValue);

            if (result != null)
            {
                return(result);
            }

            // if the null result is because it is explicitly stored, hiding the compiled value
            if (resx.ContainsResource(name, ignoreCase))
            {
                return(null);
            }

            return(isString ? compiled.GetString(name, ignoreCase) : compiled.GetObject(name, ignoreCase));
        }
Esempio n. 6
0
        public void Resources_HasEquivalents()
        {
            IEnumerable <CultureInfo> languages = new[] { new CultureInfo("en-GB"), new CultureInfo("lt-LT") };
            IEnumerable <Type>        types     = Assembly
                                                  .Load("MvcTemplate.Resources")
                                                  .GetTypes()
                                                  .Where(type => type.Namespace.StartsWith("MvcTemplate.Resources."));

            foreach (Type type in types)
            {
                IEnumerable <String> keys    = new String[0];
                ResourceManager      manager = new ResourceManager(type);

                foreach (ResourceSet set in languages.Select(language => manager.GetResourceSet(language, true, true)))
                {
                    keys = keys.Union(set.Cast <DictionaryEntry>().Select(resource => resource.Key.ToString()));
                    keys = keys.Distinct();
                }

                foreach (CultureInfo language in languages)
                {
                    ResourceSet set = manager.GetResourceSet(language, true, true);
                    foreach (String key in keys)
                    {
                        Assert.True((set.GetObject(key) ?? "").ToString() != "",
                                    $"{type.FullName}, does not have translation for '{key}' in {language.EnglishName} language.");
                    }
                }
            }
        }
 static Stream GetResourceStreamCore(Assembly assembly, string path, bool pathIsFull)
 {
     if (pathIsFull)
     {
         ResourceSet resources = GetResources(assembly);
         if (resources == null)
         {
             return(null);
         }
         return(resources.GetObject(path, false) as Stream);
     }
     else
     {
         IDictionaryEnumerator enumerator = GetResourcesEnumerator(assembly);
         if (enumerator == null)
         {
             return(null);
         }
         while (enumerator.MoveNext())
         {
             string resourceName = (string)enumerator.Key;
             if (resourceName == path || resourceName.EndsWith("/" + path, StringComparison.Ordinal))
             {
                 return(enumerator.Value as Stream);
             }
         }
         return(null);
     }
 }
Esempio n. 8
0
        protected void Load3dCube()
        {
            // This is coming from our resources
            //StreamResourceInfo stri =Application.GetResourceStream (new Uri (
            //	@"Autodesk.ADN.Toolkit.Wpf.Viewer;3dCube\3dCube.zip",
            //	UriKind.Relative
            //)) ;
            //LoadModel (stri.Stream) ;
            Assembly        assembly     = Assembly.GetCallingAssembly();
            string          resourceName = assembly.GetName().Name + ".g";
            ResourceManager rm           = new ResourceManager(resourceName, assembly);

            using (ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true)) {
                UnmanagedMemoryStream s    = (UnmanagedMemoryStream)set.GetObject(@"3dCube/3dCube.zip", true);
                StreamResourceInfo    stri = new StreamResourceInfo(s, "");
                using (ZipArchive zip = new ZipArchive(stri.Stream)) {
                    ZipArchiveEntry mesh    = zip.GetEntry("mesh.obj");
                    ZipArchiveEntry mtl     = zip.GetEntry("mesh.mtl");
                    ZipArchiveEntry texture = zip.GetEntry("tex_0.jpg");

                    using (new CursorSwitcher(null)) {
                        var objLoaderFactory = new ObjLoaderFactory();
                        var objLoader        = objLoaderFactory.Create(new ObjMaterialStreamProvider(mtl));
                        var result           = objLoader.Load(mesh.Open());
                        _3dCubeMesh         = ObjTriangleMeshAdapater.BuildVisualModel(result, texture);
                        _3dCubeMeshMatGroup = (_3dCubeMesh.Content as GeometryModel3D).Material;
                        // Reset the model & transform(s)
                        this.cubeModel.Children.Clear();
                        this.cubeModel.Children.Add(_3dCubeMesh);
                    }
                }
            }
        }
        public LocalizationExtenderProvider(ISite serviceProvider, IComponent baseComponent)
        {
            this.serviceProvider = serviceProvider;
            this.baseComponent   = baseComponent;
            if (serviceProvider != null)
            {
                IExtenderProviderService service = (IExtenderProviderService)serviceProvider.GetService(typeof(IExtenderProviderService));
                if (service != null)
                {
                    service.AddExtenderProvider(this);
                }
            }
            this.language = CultureInfo.InvariantCulture;
            ResourceManager manager = new ResourceManager(baseComponent.GetType());

            if (manager != null)
            {
                ResourceSet set = manager.GetResourceSet(this.language, true, false);
                if (set != null)
                {
                    object obj2 = set.GetObject("$this.Localizable");
                    if (obj2 is bool)
                    {
                        this.defaultLocalizable = (bool)obj2;
                        this.localizable        = this.defaultLocalizable;
                    }
                }
            }
        }
Esempio n. 10
0
        public void DrawExpressions(PXCMFaceData.Face face)
        {
            Debug.Assert(face != null);
            if (m_bitmap == null || !Expressions.Checked)
            {
                return;
            }

            PXCMFaceData.ExpressionsData expressionsOutput = face.QueryExpressions();

            if (expressionsOutput == null)
            {
                return;
            }

            lock (m_bitmapLock)
            {
                using (Graphics graphics = Graphics.FromImage(m_bitmap))
                    using (var brush = new SolidBrush(m_faceTextOrganizer.Colour))
                    {
                        const int imageSizeWidth  = 18;
                        const int imageSizeHeight = 18;

                        int positionX     = m_faceTextOrganizer.ExpressionsLocation.X;
                        int positionXText = positionX + imageSizeWidth;
                        int positionY     = m_faceTextOrganizer.ExpressionsLocation.Y;
                        int positionYText = positionY + imageSizeHeight / 4;

                        foreach (var expressionEntry in m_expressionDictionary)
                        {
                            PXCMFaceData.ExpressionsData.FaceExpression       expression = expressionEntry.Key;
                            PXCMFaceData.ExpressionsData.FaceExpressionResult result;
                            bool status = expressionsOutput.QueryExpression(expression, out result);
                            if (!status)
                            {
                                continue;
                            }

                            Bitmap cachedExpressionBitmap;
                            bool   hasCachedExpressionBitmap = m_cachedExpressions.TryGetValue(expression, out cachedExpressionBitmap);
                            if (!hasCachedExpressionBitmap)
                            {
                                cachedExpressionBitmap = (Bitmap)m_resources.GetObject(expressionEntry.Value);
                                m_cachedExpressions.Add(expression, cachedExpressionBitmap);
                            }

                            using (var font = new Font(FontFamily.GenericMonospace, m_faceTextOrganizer.FontSize, FontStyle.Bold))
                            {
                                Debug.Assert(cachedExpressionBitmap != null, "cachedExpressionBitmap != null");
                                graphics.DrawImage(cachedExpressionBitmap, new Rectangle(positionX, positionY, imageSizeWidth, imageSizeHeight));
                                var expressionText = String.Format("= {0}", result.intensity);
                                graphics.DrawString(expressionText, font, brush, positionXText, positionYText);

                                positionY     += imageSizeHeight;
                                positionYText += imageSizeHeight;
                            }
                        }
                    }
            }
        }
Esempio n. 11
0
        public void Resources_HasEquivalents()
        {
            IEnumerable <CultureInfo> languages = XDocument
                                                  .Load("../../../../src/MvcTemplate.Web/Languages.config")
                                                  .Descendants("language")
                                                  .Select(language => new CultureInfo(language.Attribute("culture").Value));

            IEnumerable <Type> types = Assembly
                                       .Load("MvcTemplate.Resources")
                                       .GetTypes()
                                       .Where(type => type.Namespace.StartsWith("MvcTemplate.Resources."));

            foreach (Type type in types)
            {
                IEnumerable <String> keys    = new String[0];
                ResourceManager      manager = new ResourceManager(type);

                foreach (ResourceSet set in languages.Select(language => manager.GetResourceSet(language, true, true)))
                {
                    keys = keys.Union(set.Cast <DictionaryEntry>().Select(resource => resource.Key.ToString()));
                }

                foreach (CultureInfo language in languages)
                {
                    ResourceSet set = manager.GetResourceSet(language, true, true);
                    foreach (String key in keys)
                    {
                        Assert.True((set.GetObject(key) ?? "").ToString() != "",
                                    $"{type.FullName}, does not have translation for '{key}' in {language.EnglishName} language.");
                    }
                }
            }
        }
Esempio n. 12
0
 public static void GetResourceSet_Images(string key, object expectedValue)
 {
     var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
     var culture = new CultureInfo("en-US");
     ResourceSet set = manager.GetResourceSet(culture, true, true);
     Assert.Equal(GetImageData(expectedValue), GetImageData(set.GetObject(key)));
 }
Esempio n. 13
0
        public static void GetResourceSet_Strings(string key, string expectedValue)
        {
            var         manager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
            var         culture = new CultureInfo("en-US");
            ResourceSet set     = manager.GetResourceSet(culture, true, true);

            Assert.Equal(expectedValue, set.GetString(key));
            Assert.Equal(expectedValue, set.GetObject(key));
            Assert.Equal(expectedValue, set.GetString(key));
        }
Esempio n. 14
0

        
Esempio n. 15
0
    public static void Main(String[] args)
    {
        String assemblyFilename = "testserialization.dll";
        String assemblyName = "testserialization";

        AssemblyName aName = new AssemblyName();
        aName.Name = assemblyName;
        String fqNamespace = "Newmoon.CompiledModules."+assemblyName;

        AssemblyBuilder assemblyBuilder =
        AppDomain.CurrentDomain.DefineDynamicAssembly(aName,
                              AssemblyBuilderAccess.Save,
                              ".");

        assemblyBuilder.DefineDynamicModule(fqNamespace + "." + assemblyName,
                        assemblyFilename,
                        false);

        IResourceWriter rw = assemblyBuilder.DefineResource("literals",
                                "Literal Scheme Data",
                                "testserialization.resource");

        StringReader sr = new StringReader("(hello #(world 1 2) 3 4 \"five\" #t)");
        object o = Newmoon.Reader.Read(sr);
        o = new Pair(o, o);

        rw.AddResource("literal data", o);

        assemblyBuilder.Save(assemblyFilename);

        System.Console.WriteLine(o);

        FileStream fs = new FileStream("testserialization.output", FileMode.OpenOrCreate);
        BinaryFormatter bf = new BinaryFormatter();

        bf.Serialize(fs, o);
        fs.Close();

        fs = new FileStream("testserialization.output", FileMode.Open);
        bf = new BinaryFormatter();
        object p = bf.Deserialize(fs);

        System.Console.WriteLine(p);
        System.Console.WriteLine(p is Pair);
        System.Console.WriteLine(p == o);
        System.Console.WriteLine(((Pair) p).Car == ((Pair) p).Cdr);

        Assembly na = Assembly.LoadFrom(assemblyFilename);
        Stream rrs = na.GetManifestResourceStream("literals");
        ResourceSet rr = new ResourceSet(rrs);
        System.Console.WriteLine("p2 "+rr.GetObject("literal data"));
    }
Esempio n. 16
0
        static void Main(string[] args)
        {
            // Имя ресурсного файла (файлов)
            string [] resNames = Assembly.GetCallingAssembly().GetManifestResourceNames();
            resource = resNames[0];

            // Загружаем
            string          baseName        = resource.Substring(0, resource.LastIndexOf('.'));
            ResourceManager resourceManager = new ResourceManager(baseName, Assembly.GetExecutingAssembly());

            // Hashtable ресурсов
            ResourceSet resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

            // Доступ к ресурсам
            //   Строка
            Console.WriteLine(resourceSet.GetString("Str1"));
            //   Тип System.Int32
            Console.WriteLine(resourceSet.GetObject("Int1").GetType());
            Console.WriteLine((Int32)resourceSet.GetObject("Int1"));

            Console.ReadLine();
        }
        // 将资源中的驱动文件写入到指定目录
        private static void WriteDrverFile(string resname, string dir)
        {
            Assembly ass = Assembly.GetExecutingAssembly();
            ResourceManager rm = new ResourceManager(resourceMgrName, ass);

            ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            byte[] buf = (byte[])set.GetObject(resname);

            Stream w = File.OpenWrite(Path.Combine(dir, resname));
            w.Write(buf, 0, buf.Length);
            w.Flush();
            w.Close();
        }
        object GetResource(CallExpression callExpression)
        {
            IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);

            if (reader != null)
            {
                using (ResourceSet resources = new ResourceSet(reader)) {
                    List <object> args = deserializer.GetArguments(callExpression);
                    return(resources.GetObject(args[0] as String));
                }
            }
            return(null);
        }
Esempio n. 19
0
        /// <summary>
        /// Loads a dictionary of string to string with the given name from the given resource manager.
        /// </summary>
        /// <param name="source">The <see cref="ResourceSet"/> to load from.</param>
        /// <param name="name">The resource name.</param>
        /// <returns>The <see cref="IDictionary{TKey,TValue}"/> or null if there is no such resource.</returns>
        private static IDictionary <string, string> LoadDictionary(ResourceSet source, string name)
        {
            Preconditions.CheckNotNull(source, "source");
            var bytes = source.GetObject(name) as byte[];

            if (bytes != null)
            {
                using (var stream = new MemoryStream(bytes))
                {
                    var reader = new LegacyDateTimeZoneReader(stream, null);
                    return(reader.ReadDictionary());
                }
            }
            return(null);
        }
Esempio n. 20
0
 /// <summary>
 /// Gets the localized value for the specified key
 /// </summary>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public object GetValue(string key)
 {
     try
     {
         if (_resourceSet != null)
         {
             return(_resourceSet.GetObject(key));
         }
         return(null);
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 21
0
        /// <summary>Loads the installer setting from the resource.</summary>
        /// <typeparam name="T">The type.</typeparam>
        /// <param name="name">The name.</param>
        /// <param name="ignoreCase">Indicates whether the case of the specified name should be ignored.</param>
        /// <returns>
        ///     <see cref="object" />
        /// </returns>
        internal static T LoadInstallerSetting <T>(string name, bool ignoreCase = false)
        {
            ResourceManager _settingsResourceManager = new ResourceManager("CometSettings", Assembly.GetExecutingAssembly());
            ResourceSet     _settingsResourceSet     = _settingsResourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

            object _settingValue = _settingsResourceSet.GetObject(name, ignoreCase);
            T      _settingType  = (T)Convert.ChangeType(_settingValue, typeof(T));

            StringBuilder _loadedSetting = new StringBuilder();

            _loadedSetting.AppendLine("Name: " + name);
            _loadedSetting.AppendLine("Value: " + _settingValue);
            _loadedSetting.AppendLine("Type: " + typeof(T));
            Console.WriteLine(_loadedSetting.ToString());

            return((T)_settingValue);
        }
Esempio n. 22
0
        /// <inheritdoc />
        public DateTimeZone CreateZone(string id, string canonicalId)
        {
            object obj = source.GetObject(NormalizeAsResourceName(canonicalId));

            // We should never be asked for time zones which don't exist.
            Preconditions.CheckArgument(obj != null, "canonicalId", "ID is not one of the recognized time zone identifiers within this resource");
            if (!(obj is byte[]))
            {
                throw new InvalidNodaDataException("Resource key for time zone for ID " + canonicalId + " is not a byte array");
            }
            byte[] bytes = (byte[])obj;
            using (var stream = new MemoryStream(bytes))
            {
                var reader = new LegacyDateTimeZoneReader(stream, null);
                return(reader.ReadTimeZone(id));
            }
        }
Esempio n. 23
0
        private byte[] GetEmbeddedImage(string name)
        {
            ResourceSet images = Properties.Resources.ResourceManager
                                 .GetResourceSet(CultureInfo.CurrentCulture, true, true);

            if (images != null)
            {
                var obj = images.GetObject(name);
                if (obj is byte[] data)
                {
                    Assert.NotNull(data);
                    Assert.True(data.Length > 0);
                    return(data);
                }
            }
            return(null);
        }
Esempio n. 24
0
        static void SetIcon(string path)
        {
            try
            {
                var assembly = typeof(ProjectApplication).Assembly;
                var n        = assembly.GetName().Name + ".g";
                var rm       = new ResourceManager(n, assembly);

                using (ResourceSet rs = rm.GetResourceSet(CultureInfo.InvariantCulture, true, true))
                {
                    var stream = (UnmanagedMemoryStream)rs.GetObject(path, true);
                    trayIcon.Icon = new WDraw.Icon(stream);
                }
            }
            catch
            {
            }
        }
Esempio n. 25
0
        public static StreamResourceInfo GetResourceStream(Uri uriResource)
        {
            if (uriResource == null)
            {
                throw new ArgumentNullException("uriResource");
            }

            if (uriResource.OriginalString == null)
            {
                throw new ArgumentException("uriResource.OriginalString is null.");
            }

            if (uriResource.IsAbsoluteUri)
            {
                if (uriResource.Scheme == "pack")
                {
                    throw new NotSupportedException("pack: resources not yet supported.");
                }
                else
                {
                    throw new ArgumentException("uriResource is not relative and doesn't use the pack: scheme.");
                }
            }

            PackUri         pack         = new PackUri(uriResource);
            string          assemblyName = pack.Assembly;
            Assembly        assembly     = (assemblyName != null) ? Assembly.Load(assemblyName) : Assembly.GetEntryAssembly();
            string          resourceName = assembly.GetName().Name + ".g";
            ResourceManager manager      = new ResourceManager(resourceName, assembly);

            using (ResourceSet resourceSet = manager.GetResourceSet(CultureInfo.CurrentCulture, true, true))
            {
                Stream s = (Stream)resourceSet.GetObject(pack.GetAbsolutePath(), true);

                if (s == null)
                {
                    throw new IOException(
                              "The requested resource could not be found: " +
                              uriResource.OriginalString);
                }

                return(new StreamResourceInfo(s, null));
            }
        }
Esempio n. 26
0
 /// <summary>
 /// Retourne une resource en fonction de sa clé
 /// </summary>
 /// <param name="key">clé de la resource</param>
 /// <param name="resourceProviderKey">la clé du fournisseur, inutile pour ce fournisseur</param>
 /// <param name="defaultValue">valeur par défaut si la resource n'est pas trouvée</param>
 /// <returns>la valeur de la resource dans la culture courante</returns>
 public object GetValue(string key, string resourceProviderKey = null, object defaultValue = null)
 {
     try
     {
         // Effectue la recherche en ignorant la casse de la clé
         return(_resourceSet.GetObject(key, true));
     }
     catch
     {
         if (defaultValue != null)
         {
             return(defaultValue);
         }
         else
         {
             throw new KeyNotFoundException($"Resource key '{key}' not found");
         }
     }
 }
Esempio n. 27
0
        public override ImageSource GetIcon()
        {
            // 获取当前程序集
            Assembly assembly = Assembly.GetAssembly(GetType());
            // 获取程序集中资源名称
            string resourceName = assembly.GetName().Name + ".g";
            // 资源管理器
            ResourceManager rm     = new ResourceManager(resourceName, assembly);
            BitmapImage     bitmap = new BitmapImage();

            using (ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true))
            {
                UnmanagedMemoryStream s;
                s = (UnmanagedMemoryStream)set.GetObject("Image/keyboard_white.png", true);

                // img在XAML声明的空间
                return(BitmapFrame.Create(s, BitmapCreateOptions.None, BitmapCacheOption.OnLoad));
            }
        }
Esempio n. 28
0
        private List <Image> differentImages()
        {
            ResourceManager resourceManager = new ResourceManager(typeof(Properties.Resources));
            ResourceSet     resourceSet     = resourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);

            List <string> imageResourceKeys = new List <string>();

            foreach (DictionaryEntry entry in resourceSet)
            {
                string resourceKey = entry.Key.ToString();
                if (!resourceKey.Equals("closed") && !resourceKey.Equals("empty"))
                {
                    imageResourceKeys.Add(resourceKey);
                }
            }

            List <int> randomies = new List <int>();
            Random     r         = new Random();

            for (int i = 0; i < differentImageCount; i++)
            {
                int num;
                while (randomies.Contains(num = r.Next(0, imageResourceKeys.Count)))
                {
                    ;
                }
                randomies.Add(num);
            }

            List <Image> images = new List <Image>();

            foreach (int c in randomies)
            {
                Image toAdd = resourceSet.GetObject(imageResourceKeys[c]) as Image;
                if (toAdd != null)
                {
                    toAdd.Tag = imageResourceKeys[c];
                }
                images.Add(toAdd);
            }
            return(images);
        }
Esempio n. 29
0
        public MainWindow()
        {
            resources = new ResourceSet(typeof(Resources).Assembly.GetManifestResourceStream("MarsRover.Properties.Resources.resources"));

            controller = new RoverController(worldSize);

            InitializeComponent();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 16);
            timer.Tick    += Update;
            timer.Start();

            CreateImageFields(controller.GetWorld());

            Rover.Instance.image.Source = BitmapUtil.BitmapToImageSource(resources.GetObject("Curiousity2") as Bitmap);
            Rover.Instance.image.Width  = 50;
            Rover.Instance.image.Height = 50;
            WorldMap.Children.Add(Rover.Instance.image);
            Canvas.SetTop(Rover.Instance.image, Rover.Instance.x * gridSize);
            Canvas.SetLeft(Rover.Instance.image, Rover.Instance.y * gridSize);
            Rover.Instance.image = Rover.Instance.image;

            KeyDown += Keyboard;
        }
Esempio n. 30
0
 public override Stream OpenRead()
 {
     return(_source.GetObject(_name, true) as Stream);
 }
Esempio n. 31
0
 public static T Get <T>(string name)
 {
     return((T)resourceSet.GetObject(name));
 }