예제 #1
0
 internal override void Update()
 {
     if (m_ResourceUpdater)
     {
         m_ResourceUpdater.Update();
     }
     m_ResourceUpdater.Update();
 }
예제 #2
0
        /// <summary>
        /// Create a ComHost with an embedded CLSIDMap file to map CLSIDs to .NET Classes.
        /// </summary>
        /// <param name="comHostSourceFilePath">The path of Apphost template, which has the place holder</param>
        /// <param name="comHostDestinationFilePath">The destination path for desired location to place, including the file name</param>
        /// <param name="clsidmapFilePath">The path to the *.clsidmap file.</param>
        public static void Create(
            string comHostSourceFilePath,
            string comHostDestinationFilePath,
            string clsidmapFilePath)
        {
            var destinationDirectory = new FileInfo(comHostDestinationFilePath).Directory.FullName;

            if (!Directory.Exists(destinationDirectory))
            {
                Directory.CreateDirectory(destinationDirectory);
            }

            // Copy apphost to destination path so it inherits the same attributes/permissions.
            File.Copy(comHostSourceFilePath, comHostDestinationFilePath, overwrite: true);

            if (!ResourceUpdater.IsSupportedOS())
            {
                throw new ComHostCustomizationUnsupportedOSException();
            }

            string clsidMap = File.ReadAllText(clsidmapFilePath);

            byte[] clsidMapBytes = Encoding.UTF8.GetBytes(clsidMap);

            using (ResourceUpdater updater = new ResourceUpdater(comHostDestinationFilePath))
            {
                updater.AddResource(clsidMapBytes, (IntPtr)ClsidmapResourceType, (IntPtr)ClsidmapResourceId);
                updater.Update();
            }
        }
예제 #3
0
        protected override void OnClick()
        {
            try
            {
                if (MessageBox.Show("Are you sure you want to update the RAVE AddIn resources?", "Update Resources", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                    == DialogResult.Yes)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    ResourceUpdater rru = new ResourceUpdater(Properties.Resources.ResourcesURL, Properties.Resources.BusinessLogicXMLFolder, Properties.Resources.AppDataSymbologyFolder);

                    string appDataResources = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Properties.Resources.AppDataFolder);
                    ResourceUpdater.UpdateResults results = rru.Update(appDataResources);

                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(string.Format("The RAVE resources were updated successfully.\n{0} resource files were updated.", results.TotalDownloads), "Resources Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                ErrorHandling.frmException.HandleException(ex, "Error Showing RAVE About Form", string.Empty);
            }

            ArcMap.Application.CurrentTool = null;
        }
예제 #4
0
        public static void Main(string[] args)
        {
            try
            {
                if (args.Length != 3)
                {
                    Console.Error.WriteLine("Wrong parameter count specified!");
                    Console.Error.WriteLine("Usage: ResourcePatcher.exe <APPHOST.exe> <ASSEMBLY.dll> <IS_WINEXE: 0 or 1>");
                    return;
                }

                var fnTarget  = args[0];
                var fnOrig    = args[1];
                var winExeBit = args[2];
                if (!File.Exists(fnTarget) || !PEUtils.IsPEImage(fnTarget))
                {
                    Console.Error.WriteLine("Non-existant or invalid PE target file specified!");
                    return;
                }

                if (!File.Exists(fnOrig) || !PEUtils.IsPEImage(fnOrig))
                {
                    Console.Error.WriteLine("Non-existant or invalid PE source file specified!");
                    return;
                }

                if (winExeBit.Trim() == "1")
                {
                    Console.Write("Setting Windows GUI bit... ");
                    try
                    {
                        PEUtils.SetWindowsGraphicalUserInterfaceBit(fnTarget);
                        Console.WriteLine("Done!");
                    }
                    catch (AppHostNotCUIException)
                    {
                        Console.Write("Already has bit set!");
                    }
                }
                else
                {
                    Console.WriteLine("Skipped setting WinExe bit...");
                }

                Console.Write("Writing resources... ");
                using (var ru = new ResourceUpdater(fnTarget))
                {
                    ru.AddResourcesFromPEImage(fnOrig);
                    ru.Update();
                }

                Console.WriteLine("Done!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandles exception: " + ex.Message);
                Environment.Exit(1);
            }
        }
예제 #5
0
        /// <summary>
        /// 资源管理器轮询。
        /// </summary>
        /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
        /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
        internal override void Update(float elapseSeconds, float realElapseSeconds)
        {
            if (m_ResourceUpdater != null)
            {
                m_ResourceUpdater.Update(elapseSeconds, realElapseSeconds);
            }

            m_ResourceLoader.Update(elapseSeconds, realElapseSeconds);
        }
예제 #6
0
파일: ComHost.cs 프로젝트: z77ma/runtime
        /// <summary>
        /// Create a ComHost with an embedded CLSIDMap file to map CLSIDs to .NET Classes.
        /// </summary>
        /// <param name="comHostSourceFilePath">The path of Apphost template, which has the place holder</param>
        /// <param name="comHostDestinationFilePath">The destination path for desired location to place, including the file name</param>
        /// <param name="clsidmapFilePath">The path to the *.clsidmap file.</param>
        /// <param name="typeLibraries">Resource ids for tlbs and paths to the tlb files to be embedded.</param>
        public static void Create(
            string comHostSourceFilePath,
            string comHostDestinationFilePath,
            string clsidmapFilePath,
            IReadOnlyDictionary <int, string> typeLibraries = null)
        {
            var destinationDirectory = new FileInfo(comHostDestinationFilePath).Directory.FullName;

            if (!Directory.Exists(destinationDirectory))
            {
                Directory.CreateDirectory(destinationDirectory);
            }

            // Copy apphost to destination path so it inherits the same attributes/permissions.
            File.Copy(comHostSourceFilePath, comHostDestinationFilePath, overwrite: true);

            if (!ResourceUpdater.IsSupportedOS())
            {
                throw new ComHostCustomizationUnsupportedOSException();
            }

            string clsidMap = File.ReadAllText(clsidmapFilePath);

            byte[] clsidMapBytes = Encoding.UTF8.GetBytes(clsidMap);

            using (ResourceUpdater updater = new ResourceUpdater(comHostDestinationFilePath))
            {
                updater.AddResource(clsidMapBytes, (IntPtr)ClsidmapResourceType, (IntPtr)ClsidmapResourceId);
                if (typeLibraries is not null)
                {
                    foreach (var typeLibrary in typeLibraries)
                    {
                        if (!ResourceUpdater.IsIntResource((IntPtr)typeLibrary.Key))
                        {
                            throw new InvalidTypeLibraryIdException(typeLibrary.Value, typeLibrary.Key);
                        }

                        try
                        {
                            byte[] tlbFileBytes = File.ReadAllBytes(typeLibrary.Value);
                            updater.AddResource(tlbFileBytes, "typelib", (IntPtr)typeLibrary.Key);
                        }
                        catch (FileNotFoundException ex)
                        {
                            throw new TypeLibraryDoesNotExistException(typeLibrary.Value, ex);
                        }
                        catch (HResultException hr) when(hr.Win32HResult == E_INVALIDARG)
                        {
                            throw new InvalidTypeLibraryException(typeLibrary.Value, hr);
                        }
                    }
                }
                updater.Update();
            }
        }
예제 #7
0
        public void ResourceUpdaterTest()
        {
            var r = new ResourceDictionary();
            var mergedDictionaries = r.MergedDictionaries;

            var reader  = new CacheableResourceReader <Theme>();
            var updater = new ResourceUpdater <Theme>(reader, mergedDictionaries);

            Assert.AreEqual(0, mergedDictionaries.Count);

            // General to General (update, merge)
            updater.Update(_generalTheme, _generalTheme);
            Assert.AreEqual(1, mergedDictionaries.Count);

            // General to Solarized (update, merge, remove)
            updater.Update(_generalTheme, _solarizedTheme);
            Assert.AreEqual(1, mergedDictionaries.Count);
            Assert.AreEqual("Solarized theme", mergedDictionaries[0]["ThemeName"] as string);

            // Solarized to General2 (update, merge, remove)
            updater.Update(_solarizedTheme, _general2Theme);
            Assert.AreEqual(1, mergedDictionaries.Count);
            Assert.AreEqual("General2 theme", mergedDictionaries[0]["ThemeName"] as string);
        }