public void SavedTagsTest() { Tag t1 = new Tag() { TagValue = "TestTag1", ContentValue = "TestContent1", ControlType = "TextBoxControl" }; Tag t2 = new Tag() { TagValue = "TestTag2", ContentValue = "TestContent2", ControlType = "TextBoxControl" }; DefaultControlFactory dcf = new DefaultControlFactory(); MacroManager input = new MacroManager(); MacroControlBase2 control1 = dcf.CreateMacroControl(t1); MacroControlBase2 control2 = dcf.CreateMacroControl(t2); input.SavedTags.Add(control1.TagSettings); input.SavedTags.Add(control2.TagSettings); MacroManager.Save("test.xml", input); MacroManager output = MacroManager.Load("test.xml"); for (int i = 0; i < input.SavedTags.Count; i++) { Tag expected = input.SavedTags[i]; Tag actual = output.SavedTags[i]; TagHelper.CompareTag(expected, actual); } }
public void PopulateTest() { Tag t1 = new Tag() { TagValue = "TestTag1", ContentValue = "TestContent1", ControlType = "TextBoxControl" }; Tag t2 = new Tag() { TagValue = "TestTag2", ContentValue = "TestContent2", ControlType = "TextBoxControl" }; DefaultControlFactory dcf = new DefaultControlFactory(); MacroManager input = new MacroManager(); MacroControlBase2 control1 = dcf.CreateMacroControl(t1); MacroControlBase2 control2 = dcf.CreateMacroControl(t2); FlowLayoutPanel panel1 = new FlowLayoutPanel(); panel1.Controls.Add(control1); panel1.Controls.Add(control2); input.Populate(panel1); MacroManager.Save("test.xml", input); MacroManager output = MacroManager.Load("test.xml"); FlowLayoutPanel panel2 = new FlowLayoutPanel(); output.ExtractControls(panel2); for (int i = 0; i < panel2.Controls.Count; i++) { Tag expected = (panel1.Controls[i] as MacroControlBase2).TagSettings; Tag actual = (panel2.Controls[i] as MacroControlBase2).TagSettings; TagHelper.CompareTag(expected, actual); } }
private static void LoadConfigFiles(string dir, InitialAction act) { if (Win32.WaitForSingleObject(_globalMutex, 10000) != Win32.WAIT_OBJECT_0) { throw new Exception("Global mutex lock error"); } try { string optionfile = dir + "options.conf"; bool config_loaded = false; bool macro_loaded = false; TextReader reader = null; try { if (File.Exists(optionfile)) { reader = new StreamReader(File.Open(optionfile, FileMode.Open, FileAccess.Read), Encoding.Default); if (VerifyConfigHeader(reader)) { ConfigNode root = new ConfigNode("root", reader).FindChildConfigNode("poderosa"); if (root != null) { _options.Load(root); config_loaded = true; _history.Load(root); _macroManager.Load(root); macro_loaded = true; } } } } catch (Exception ex) { //_errorOccurredOnBoot = true; Debug.WriteLine(ex.StackTrace); GUtil.WriteDebugLog(ex.StackTrace); act.AddMessage("Failed to read the configuration file.\n" + ex.Message); } finally { if (!config_loaded) { _options.Init(); } if (!macro_loaded) { _macroManager.SetDefault(); } if (reader != null) { reader.Close(); } } GEnv.Options = _options; //これでDefaultRenderProfileが初期化される string kh = dir + "ssh_known_hosts"; if (File.Exists(kh)) { try { _sshKnownHosts.Load(kh); } catch (Exception ex) { _sshKnownHosts.Clear(); act.AddMessage("Failed to read the 'ssh_known_hosts' file.\n" + ex.Message); } } } finally { Win32.ReleaseMutex(_globalMutex); } }
public override void Load() { base.Load(); ItemHold.Clear(); Hotkeys = new HotkeysManager(); Macros = new MacroManager(); // ######################################################### // [FILE_FIX] // TODO: this code is a workaround to port old macros to the new xml system. if (ProfileManager.CurrentProfile.Macros != null) { for (int i = 0; i < ProfileManager.CurrentProfile.Macros.Length; i++) { Macros.PushToBack(ProfileManager.CurrentProfile.Macros[i]); } Macros.Save(); ProfileManager.CurrentProfile.Macros = null; } // ######################################################### Macros.Load(); InfoBars = new InfoBarManager(); InfoBars.Load(); _healthLinesManager = new HealthLinesManager(); Weather = new Weather(); WorldViewportGump viewport = new WorldViewportGump(this); UIManager.Add(viewport, false); if (!ProfileManager.CurrentProfile.TopbarGumpIsDisabled) { TopBarGump.Create(); } CommandManager.Initialize(); NetClient.Socket.Disconnected += SocketOnDisconnected; MessageManager.MessageReceived += ChatOnMessageReceived; UIManager.ContainerScale = ProfileManager.CurrentProfile.ContainersScale / 100f; SDL.SDL_SetWindowMinimumSize(Client.Game.Window.Handle, 640, 480); if (ProfileManager.CurrentProfile.WindowBorderless) { Client.Game.SetWindowBorderless(true); } else if (Settings.GlobalSettings.IsWindowMaximized) { Client.Game.MaximizeWindow(); } else if (Settings.GlobalSettings.WindowSize.HasValue) { int w = Settings.GlobalSettings.WindowSize.Value.X; int h = Settings.GlobalSettings.WindowSize.Value.Y; w = Math.Max(640, w); h = Math.Max(480, h); Client.Game.SetWindowSize(w, h); } CircleOfTransparency.Create(ProfileManager.CurrentProfile.CircleOfTransparencyRadius); Plugin.OnConnected(); Camera.SetZoomValues ( new[] { .5f, .6f, .7f, .8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f } ); Camera.Zoom = ProfileManager.CurrentProfile.DefaultScale; }