public override void Init(Kernel kernel) { try { kernel.AddTheme("Chocolate", "resx://Chocolate/Chocolate.Resources/Page#PageChocolate", "resx://Chocolate/Chocolate.Resources/DetailMovieView#ChocolateMovieView"); if (AppDomain.CurrentDomain.FriendlyName.Contains("ehExtHost")) { this.config = new MyConfig(); kernel.AddConfigPanel("Chocolate General", "resx://Chocolate/Chocolate.Resources/ConfigPanel#ConfigPanel", this.config); kernel.AddConfigPanel("Chocolate Views", "resx://Chocolate/Chocolate.Resources/ConfigPanelViews#ConfigPanelViews", this.config); } else { Logger.ReportInfo("Not creating menus for Chocolate. Appear to not be in MediaCenter. AppDomain is: " + AppDomain.CurrentDomain.FriendlyName); } kernel.StringData.AddStringData(MyStrings.FromFile(LocalizedStringData.GetFileName("Chocolate-"))); CustomResourceManager.AppendFonts("Chocolate", Resources.Fonts, Resources.FontsSmall); CustomResourceManager.AppendStyles("Chocolate", Resources.Colors, Resources.Colors); Logger.ReportInfo("Chocolate Theme (version " + this.Version + ") Loaded."); } catch (Exception exception) { Logger.ReportException("Error adding theme - probably incompatable MB version", exception); } }
/// <summary> /// The Init method is called when the plug-in is loaded by MediaBrowser. You should perform all your specific initializations /// here - including adding your theme to the list of available themes. /// </summary> /// <param name="kernel"></param> public override void Init(Kernel kernel) { try { kernel.AddTheme("Diamond", "resx://Diamond/Diamond.Resources/Page#PageDiamond", "resx://Diamond/Diamond.Resources/DetailMovieView#DiamondMovieView"); isMC = AppDomain.CurrentDomain.FriendlyName.Contains("ehExtHost"); if (isMC) { config = new Config(); kernel.AddConfigPanel("Diamond Options", "resx://Diamond/Diamond.Resources/ConfigPanel#ConfigPanel", config); kernel.AddInternalIconTheme("Diamond"); //tells core that we want to use icons in our resource file //Tell the log we loaded. Logger.ReportInfo("Diamond Theme Loaded."); //Thread t = new Thread(new ThreadStart(Display)); //t.Start(); } else { Logger.ReportInfo("Not creating menus for Diamond. Appear to not be in MediaCenter. AppDomain is: " + AppDomain.CurrentDomain.FriendlyName); } kernel.StringData.AddStringData(MyStrings.FromFile(MyStrings.GetFileName("Diamond-"))); CustomResourceManager.AppendFonts("Diamond", Resources.DiamondFontsDefault, Resources.DiamondFontsSmall); CustomResourceManager.AppendStyles("Diamond", Resources.DiamondStylesDefault, Resources.DiamondStylesDefault); } catch (Exception ex) { Logger.ReportException("Error adding theme - probably incompatable MB version", ex); } }
/// <summary> /// Common program initialization function that can also be /// used by applications that use KeePass as a library /// (like e.g. KPScript). /// </summary> public static bool CommonInit() { m_bDesignMode = false; // Again, for the ones not calling Main m_rndGlobal = CryptoRandom.NewWeakRandom(); InitEnvSecurity(); MonoWorkarounds.Initialize(); // try { NativeMethods.SetProcessDPIAware(); } // catch(Exception) { } // Do not run as AppX, because of compatibility problems // (unless we're a special compatibility build) if (WinUtil.IsAppX && !IsBuildType( "CDE75CF0D4CA04D577A5A2E6BF5D19BFD5DDBBCF89D340FBBB0E4592C04496F1")) { return(false); } try { SelfTest.TestFipsComplianceProblems(); } catch (Exception exFips) { MessageService.ShowWarning(KPRes.SelfTestFailed, exFips); return(false); } // Set global localized strings PwDatabase.LocalizedAppName = PwDefs.ShortProductName; KdbxFile.DetermineLanguageId(); m_appConfig = AppConfigSerializer.Load(); if (m_appConfig.Logging.Enabled) { AppLogEx.Open(PwDefs.ShortProductName); } AppPolicy.Current = m_appConfig.Security.Policy.CloneDeep(); if (m_appConfig.Security.ProtectProcessWithDacl) { KeePassLib.Native.NativeMethods.ProtectProcessWithDacl(); } m_appConfig.Apply(AceApplyFlags.All); m_ecasTriggers = m_appConfig.Application.TriggerSystem; m_ecasTriggers.SetToInitialState(); string strHelpFile = UrlUtil.StripExtension(WinUtil.GetExecutable()) + ".chm"; AppHelp.LocalHelpFile = strHelpFile; // InitEnvWorkarounds(); LoadTranslation(); CustomResourceManager.Override(typeof(KeePass.Properties.Resources)); return(true); }
private static bool InitializeCustom(string langId) { var found = false; var googleSheets = GetGoogleSheetsFilename(); if (File.Exists(googleSheets)) { try { var loaded = SharedLocaleReader.Read(googleSheets, langId); if (loaded.Any()) { CustomResourceManager.SetCustomSource(loaded); found = true; } } catch (Exception e) { Logging.Warning(e); } } if (SettingsHolder.Locale.ResxLocalesMode) { var localeDirectory = FilesStorage.Instance.Combine("Locales", langId); if (Directory.Exists(localeDirectory)) { Logging.Write(localeDirectory); CustomResourceManager.SetCustomSource(localeDirectory); found = true; } } return(found); }
/// <summary> /// Common program initialization function that can also be /// used by applications that use KeePass as a library /// (like e.g. KPScript). /// </summary> public static bool CommonInit() { m_bDesignMode = false; // Again, for the ones not calling Main int nRandomSeed = (int)DateTime.UtcNow.Ticks; // Prevent overflow (see Random class constructor) if (nRandomSeed == int.MinValue) { nRandomSeed = 17; } m_rndGlobal = new Random(nRandomSeed); InitEnvSecurity(); MonoWorkarounds.Initialize(); // try { NativeMethods.SetProcessDPIAware(); } // catch(Exception) { } try { SelfTest.TestFipsComplianceProblems(); } catch (Exception exFips) { MessageService.ShowWarning(KPRes.SelfTestFailed, exFips); return(false); } // Set global localized strings PwDatabase.LocalizedAppName = PwDefs.ShortProductName; KdbxFile.DetermineLanguageId(); m_appConfig = AppConfigSerializer.Load(); if (m_appConfig.Logging.Enabled) { AppLogEx.Open(PwDefs.ShortProductName); } AppPolicy.Current = m_appConfig.Security.Policy.CloneDeep(); m_appConfig.Apply(AceApplyFlags.All); m_ecasTriggers = m_appConfig.Application.TriggerSystem; m_ecasTriggers.SetToInitialState(); string strHelpFile = UrlUtil.StripExtension(WinUtil.GetExecutable()) + ".chm"; AppHelp.LocalHelpFile = strHelpFile; // InitEnvWorkarounds(); LoadTranslation(); CustomResourceManager.Override(typeof(KeePass.Properties.Resources)); return(true); }
public void AppendFontsTest1() { string prefix = "Vanilla"; byte[] stdFontResource = Resources.TestFonts; // just test with an mcml resource that is available bool expected = true; bool actual; actual = CustomResourceManager.AppendFonts(prefix, stdFontResource); Assert.AreEqual(expected, actual); }
public void AppendFontsTest() { string prefix = "Vanilla"; byte[] stdFontResource = Resources.TestFonts; // just test with an mcml resource that is available byte[] smallFontResource = Resources.TestFontsSmall; //again, just something to verify against bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = CustomResourceManager.AppendFonts(prefix, stdFontResource, smallFontResource); Assert.AreEqual(expected, actual); }
// todo: patch lootdistribution jsonmapper to insert my own loot data, patch entitycell deserializer to insert new entities into new cells, patch worldentityinfo to make loot work correctly, patch PDAData to insert my own pda entries public static void Patch() { if (!Directory.Exists("Mods")) { Debug.Log("ModLoader: Folder \"Mods\" not found! Creating..."); Directory.CreateDirectory("Mods"); return; } MainThread = Thread.CurrentThread; var instance = HarmonyInstance.Create("com.railway.modloader"); DLLFinder.FindDLLs("Mods"); Application.runInBackground = true; AlternativeSerializer.RegisterCustomSerializer(-5, typeof(ScaleFixer), new ScaleFixerSerializer()); DLLFinder.PrepatchDLLs(); AssetBundleLoader.Unload(); TechTypePatcher.Patch(instance); DLLFinder.PatchDLLs(); CustomResourceManager.Patch(instance); ProtobufSerializerPatcher.Patch(instance); CustomSpriteManager.Patch(instance); CraftDataPatchHelper.Patch(); LootPatcher.Patch(instance); WorldEntityInfoPatcher.Patch(instance); DLLFinder.PostPatchDLLs(); }
/// <summary> /// Common program initialization function that can also be /// used by applications that use KeePass as a library /// (like e.g. KPScript). /// </summary> public static bool CommonInit() { m_bDesignMode = false; // Again, for the ones not calling Main m_rndGlobal = CryptoRandom.NewWeakRandom(); InitEnvSecurity(); MonoWorkarounds.Initialize(); // Do not run as AppX, because of compatibility problems if (WinUtil.IsAppX) { return(false); } try { SelfTest.TestFipsComplianceProblems(); } catch (Exception exFips) { MessageService.ShowWarning(KPRes.SelfTestFailed, exFips); return(false); } // Set global localized strings PwDatabase.LocalizedAppName = PwDefs.ShortProductName; KdbxFile.DetermineLanguageId(); m_appConfig = AppConfigSerializer.Load(); if (m_appConfig.Logging.Enabled) { AppLogEx.Open(PwDefs.ShortProductName); } AppPolicy.Current = m_appConfig.Security.Policy.CloneDeep(); AppPolicy.ApplyToConfig(); if (m_appConfig.Security.ProtectProcessWithDacl) { KeePassLib.Native.NativeMethods.ProtectProcessWithDacl(); } m_appConfig.Apply(AceApplyFlags.All); m_ecasTriggers = m_appConfig.Application.TriggerSystem; m_ecasTriggers.SetToInitialState(); // InitEnvWorkarounds(); LoadTranslation(); CustomResourceManager.Override(typeof(KeePass.Properties.Resources)); #if KP_DEVSNAP if (!m_bAsmResReg) { AppDomain.CurrentDomain.AssemblyResolve += Program.AssemblyResolve; m_bAsmResReg = true; } else { Debug.Assert(false); } #endif return(true); }
public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif using (Mutex mutex = new Mutex(false, Kernel.MBCLIENT_MUTEX_ID)) { //set up so everyone can access var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); var securitySettings = new MutexSecurity(); try { //don't bomb if this fails securitySettings.AddAccessRule(allowEveryoneRule); mutex.SetAccessControl(securitySettings); } catch (Exception) { //we don't want to die here and we don't have a logger yet so just go on } try { if (mutex.WaitOne(100, false)) { var config = GetConfig(); if (config == null) { Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } Environment.CurrentDirectory = ApplicationPaths.AppConfigPath; try { CustomResourceManager.SetupStylesMcml(host); CustomResourceManager.SetupFontsMcml(host); } catch (Exception ex) { host.MediaCenterEnvironment.Dialog(ex.Message, Application.CurrentInstance.StringData("CustomErrorDial"), DialogButtons.Ok, 100, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } using (new MediaBrowser.Util.Profiler("Total Kernel Init")) { Kernel.Init(config); } using (new MediaBrowser.Util.Profiler("Application Init")) { Application app = new Application(new MyHistoryOrientedPageSession(), host); app.GoToMenu(); } mutex.ReleaseMutex(); } else { //another instance running and in initialization - just blow out of here Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } } catch (AbandonedMutexException) { // Log the fact the mutex was abandoned in another process, it will still get acquired Logger.ReportWarning("Previous instance of core ended abnormally..."); mutex.ReleaseMutex(); } } }