public void Dispose_CanBeCalledMultipleTimes() { StringWriter writer = new StringWriter(); WidgetBox widgetBox = new WidgetBox(writer, "Icon", "Title", "Buttons"); writer.Write("Test"); widgetBox.Dispose(); widgetBox.Dispose(); String actual = writer.GetStringBuilder().ToString(); String expected = GetExpectedWidgetBoxHtml(); Assert.AreEqual(expected, actual); }
// Screen_Popup public Screen_Popup(E_PopupType type) : base("Popup") { Type = type; int layer = _UI.Sprite.TopLayer - 1; WidgetGraphic black = new WidgetGraphic(); black.Layer = layer; black.Size = new Vector3(_UI.SX, _UI.SY, 0.0f); black.AddTexture("null", 0.0f, 0.0f, 1.0f, 1.0f); black.ColorBase = Color.Black; black.Alpha = 0.0f; Add(black); Timeline blackT = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start); blackT.AddEffect(new TimelineEffect_Alpha(0.0f, 0.85f, E_LerpType.SmoothStep)); black.AddTimeline(blackT); WidgetText text = new WidgetText(); text.Layer = layer; text.Size = new Vector3(600.0f, 40.0f, 0.0f); text.Align = E_Align.MiddleCentre; text.FontStyle = _UI.Store_FontStyle.Get("Default"); text.String = Messages[(int)Type]; text.ColorBase = Color.Yellow; text.FlagClear(E_WidgetFlag.InheritAlpha); text.Parent(black); text.ParentAttach = E_Align.MiddleCentre; Timeline textT = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start); textT.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep)); text.AddTimeline(textT); Vector2 stringSize = _UI.Font.StringSize(text.String, text.FontStyle, text.Size.Y, text.Size.X); float border = 80.0f; WidgetBox back = new WidgetBox(); back.Layer = layer; back.Size = new Vector3(stringSize.X + border, stringSize.Y + border, 0.0f); back.Align = E_Align.MiddleCentre; back.AddTexture("box", 0.0f, 0.0f, 1.0f, 1.0f); back.ColorBase = Color.DarkBlue; back.Parent(text); back.ParentAttach = E_Align.MiddleCentre; back.CornerSize = new Vector2(border / 2.0f); back.CornerPuv01 = new Vector2(0.0f); back.CornerSuv01 = new Vector2(0.25f); Add(back); Add(text); WidgetText textButtons = new WidgetText(); textButtons.Layer = layer; textButtons.Position = new Vector3(0.0f, 20.0f, 0.0f); textButtons.Size = new Vector3(0.0f, 30.0f, 0.0f); textButtons.Align = E_Align.MiddleCentre; textButtons.FontStyleName = "Default"; textButtons.String = "[[A]] YES [[B]] NO"; textButtons.ColorBase = Color.White; textButtons.Parent(back); textButtons.ParentAttach = E_Align.BottomCentre; Add(textButtons); }