public void InfoBarManager_DetachInfoBar_ArgChecks() { // Setup var testSubject = new InfoBarManager(this.serviceProvider); Exceptions.Expect <ArgumentNullException>(() => testSubject.DetachInfoBar(null)); Exceptions.Expect <ArgumentException>(() => testSubject.DetachInfoBar(new InvalidInfoBar())); }
public void InfoBarManager_AttachInfoBar_ArgChecks() { // Arrange var testSubject = new InfoBarManager(this.serviceProvider); // Simple checks Exceptions.Expect <ArgumentNullException>(() => testSubject.AttachInfoBar(Guid.Empty, null, CreateFromVsMoniker(KnownMonikers.EventError))); Exceptions.Expect <ArgumentNullException>(() => testSubject.AttachInfoBar(Guid.Empty, "", CreateFromVsMoniker(KnownMonikers.EventError))); // Actually checking if the frame exists Exceptions.Expect <ArgumentException>(() => testSubject.AttachInfoBarWithButton(Guid.Empty, "message", "button text", CreateFromVsMoniker(KnownMonikers.EventError))); }
public InfoBarBuilderControl(InfoBarItem item) { infoLabel = new StbTextBox(0xFF, 10, 80) { X = 5, Y = 0, Width = 130, Height = 26 }; infoLabel.SetText(item.label); string[] dataVars = InfoBarManager.GetVars(); varStat = new Combobox(200, 0, 170, dataVars, (int)item.var); uint color = 0xFF7F7F7F; if (item.hue != 0xFFFF) { color = HuesLoader.Instance.GetPolygoneColor(12, item.hue); } labelColor = new ClickableColorBox(150, 0, 13, 14, item.hue, color); NiceButton deleteButton = new NiceButton(390, 0, 60, 25, ButtonAction.Activate, ResGumps.Delete) { ButtonParameter = 999 }; deleteButton.MouseUp += (sender, e) => { Dispose(); ((DataBox)Parent)?.ReArrangeChildren(); }; Add ( new ResizePic(0x0BB8) { X = infoLabel.X - 5, Y = 0, Width = infoLabel.Width + 10, Height = infoLabel.Height } ); Add(infoLabel); Add(varStat); Add(labelColor); Add(deleteButton); Width = infoLabel.Width + 10; Height = infoLabel.Height; }
public void InfoBarManager_AttachInfoBar_Failures() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); var testSubject = new InfoBarManager(this.serviceProvider); // Case 1: No service this.serviceProvider.AssertOnUnexpectedServiceRequest = false; // Act + Verify Assert.IsNull(testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker))); frame.AssertShowNoActivateCalled(0); // Case 2: Service exists, no host for frame this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); // Act + Verify Assert.IsNull(testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker))); frame.AssertShowNoActivateCalled(0); }
public void InfoBarManager_AttachInfoBar_Failures() { // Arrange Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); var testSubject = new InfoBarManager(this.serviceProvider); // Case 1: No service this.serviceProvider.AssertOnUnexpectedServiceRequest = false; // Act + Assert testSubject.AttachInfoBarWithButton(windowGuid, "Hello", "world", default).Should().BeNull(); frame.ShowNoActivateCalledCount.Should().Be(0); // Case 2: Service exists, no host for frame this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); // Act + Assert testSubject.AttachInfoBarWithButton(windowGuid, "Hello", "world", default).Should().BeNull(); frame.ShowNoActivateCalledCount.Should().Be(0); }
public InfoBarBuilderControl(InfoBarItem item) { infoLabel = new TextBox(0xFF, 10, 80, 80) { X = 5, Y = 0, Width = 130, Height = 30, Text = item.label }; string[] dataVars = InfoBarManager.GetVars(Settings.GlobalSettings.ShardType); varStat = new Combobox(200, 0, 170, dataVars, (int)item.var); uint color = 0xFF7F7F7F; if (item.hue != 0xFFFF) { color = UOFileManager.Hues.GetPolygoneColor(12, item.hue); } labelColor = new ClickableColorBox(150, 0, 13, 14, item.hue, color); NiceButton deleteButton = new NiceButton(390, 0, 60, 25, ButtonAction.Activate, "Delete") { ButtonParameter = 999 }; deleteButton.MouseUp += (sender, e) => { Dispose(); }; Add(new ResizePic(0x0BB8) { X = infoLabel.X - 5, Y = 0, Width = infoLabel.Width + 10, Height = infoLabel.Height - 6 }); Add(infoLabel); Add(varStat); Add(labelColor); Add(deleteButton); }
public void InfoBarManager_DetachInfoBar() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); var testSubject = new InfoBarManager(this.serviceProvider); ConfigurableVsInfoBarHost host = RegisterFrameInfoBarHost(frame); IInfoBar infoBarWrapper = testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker)); bool closed = false; infoBarWrapper.Closed += (s, e) => closed = true; // Sanity host.AssertInfoBars(1); // Act testSubject.DetachInfoBar(infoBarWrapper); // Verify Assert.IsTrue(closed, "Expected to auto-close"); host.AssertInfoBars(0); }
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; }
public void InfoBarManager_AttachInfoBar() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); var testSubject = new InfoBarManager(this.serviceProvider); ConfigurableVsInfoBarHost host = RegisterFrameInfoBarHost(frame); // Sanity host.AssertInfoBars(0); // Act IInfoBar infoBarWrapper = testSubject.AttachInfoBar(windowGuid, "Hello", "world", KnownMonikers.UserWarning); frame.AssertShowNoActivateCalled(1); bool actionClicked = false; bool closed = false; infoBarWrapper.ButtonClick += (s, e) => actionClicked = true; infoBarWrapper.Closed += (s, e) => closed = true; // Verify Assert.IsNotNull(infoBarWrapper); host.AssertInfoBars(1); var infoBarUI = host.MockedElements.Single(); Assert.AreEqual(1, infoBarUI.Model.TextSpans.Count); Assert.AreEqual("Hello", infoBarUI.Model.TextSpans.GetSpan(0).Text); Assert.AreEqual(1, infoBarUI.Model.ActionItems.Count); Assert.AreEqual("world", infoBarUI.Model.ActionItems.GetItem(0).Text); // Sanity Assert.IsFalse(actionClicked); Assert.IsFalse(closed); // Act (check if close event is fired) infoBarUI.SimulateClickEvent(); // Verify Assert.IsTrue(actionClicked); Assert.IsFalse(closed); // Act (check if close event is fired) infoBarUI.SimulateClosedEvent(); // Verify Assert.IsTrue(closed); // Act (check that events won't fire once closed) actionClicked = false; closed = false; infoBarUI.SimulateClickEvent(); infoBarWrapper.Close(); infoBarUI.SimulateClosedEvent(); // Verify Assert.IsFalse(actionClicked); Assert.IsFalse(closed); frame.AssertShowNoActivateCalled(1); // Should only be called once in all this flow }