public void Remove() { if (WidgetContainer != null) { WidgetContainer.Remove(this); } }
protected WidgetContainer FindTheControl(string ControlName, Control control) { if (control is Page) { bFound = false; widgetCtrl = new WidgetContainer(); } foreach (Control c in control.Controls) { if (c.ID == ControlName && c is WidgetContainer) { bFound = true; widgetCtrl = (WidgetContainer)c; return(widgetCtrl); } else { if (!bFound) { FindTheControl(ControlName, c); } } } return(widgetCtrl); }
public AlertUi() { var doc = WidgetDoc.Load("ui/alert_ui.json"); _mainWindow = doc.GetRootContainer(); _mainWindow.ZIndex = 99800; _mainWindow.Name = "alert_main_window"; _mainWindow.Visible = false; _titleLabel = doc.GetTextContent("title"); _okButton = doc.GetButton("alert_ok_button"); _okButton.Name = "alert_ok_button"; _okButton.SetClickHandler(OkButtonClicked); _mainWindow.Add(_okButton); ScrollBoxSettings settings = new ScrollBoxSettings(); settings.TextArea = new Rectangle(6, 16, 287, 208); settings.ScrollBarPos = new Point(297, 1); settings.ScrollBarHeight = 224; settings.Indent = 7; settings.Font = PredefinedFont.ARIAL_10; _scrollBox = new ScrollBox(new Rectangle(20, 36, 310, 226), settings); _scrollBox.ZIndex = 99950; _scrollBox.Name = "scrollbox_main_window"; _mainWindow.Add(_scrollBox); }
public override void AddTo(WidgetContainer container) { container.Add(_slider); container.AddContent(_minLabel); container.AddContent(_maxLabel); container.AddContent(_valueLabel); }
public static void SetContainerComponents(WidgetContainer widgets) { widgets.ClearComponents(); if (ThemeHelper.HasToShowErrorPopup(out var type)) { widgets.Push <PatchErrorPopup>(); } /*else if (ThemeHelper.HasToSetProjectName()) * { * widgets.Push<PatchProjectSettings>(); * }*/ else if (ThemeHelper.HasToShowTutorial()) { widgets.Push <PatchTutorial>(); } else { widgets.Push <PatchTopbar>(); widgets.Push <PatchWindow>(); widgets.Push <PatchSidebar>(); widgets.Push <PatchTipPopup>(); widgets.Push <PatchPopup>(); widgets.Push <PatchErrorPopup>(); } }
private void InitDefaultContainer(Guid containerId, ColumnSchemaType schema, IEnumerable <Widget> widgets) { if (DefaultContainers.ContainsKey(containerId)) { return; } lock (DefaultContainers) { if (DefaultContainers.ContainsKey(containerId)) { return; } var widgetContainer = new WidgetContainer(Guid.Empty, containerId) { ColumnSchemaType = columnSchemaType, }; foreach (var widget in widgets) { var state = new WidgetState(widget.WidgetID, widgetContainer.ID) { X = widget.Position.X, Y = widget.Position.Y }; widgetContainer.States.Add(state); } DefaultContainers[containerId] = widgetContainer; } }
// Methods #region Overrides of Scene public override void LoadContent() { IsLoading = true; Container = new WidgetContainer(); Container.Widgets.Add(new Label(Container)); var label = (Label)Container.Widgets[0]; label.AutoSize = false; label.TextAlignment = TextAlignment.Center; label.Position = new GameLibrary.Math.Vector2(5, 200); label.Size = new GameLibrary.Math.Vector2(100, 25); label.BackgroundColor = System.Drawing.Color.FromArgb(50, 0, 0, 0); Container.Widgets.Add(new Box(Container)); var box = (Box)Container.Widgets[2]; box.Position = new GameLibrary.Math.Vector2(5, 240); box.Size = new GameLibrary.Math.Vector2(400, 100); box.MouseEnter += (sender, e) => { box.BackgroundColor = System.Drawing.Color.DimGray; }; box.MouseLeave += (sender, e) => { box.BackgroundColor = System.Drawing.Color.Black; }; box.MouseDown += (sender, e) => { box.BackgroundColor = System.Drawing.Color.LightGray; }; box.MouseUp += (sender, e) => { box.BackgroundColor = System.Drawing.Color.DimGray; }; Container.Widgets.Add(new Box(Container)); var boxx = (Box)Container.Widgets[4]; boxx.Position = new GameLibrary.Math.Vector2(5, 150); boxx.Size = new GameLibrary.Math.Vector2(40, 40); boxx.Click += (sender, e) => { box.ToggleVisibility(); }; Container.Widgets.Add(new Label(Container)); var labell = (Label)Container.Widgets[6]; labell.AutoSize = false; labell.Text = "Exit"; labell.TextAlignment = TextAlignment.Center; labell.Position = new GameLibrary.Math.Vector2(200, 200); labell.Size = new GameLibrary.Math.Vector2(100, 25); labell.BackgroundColor = System.Drawing.Color.FromArgb(50, 0, 0, 0); labell.MouseEnter += (sender, e) => { labell.BackgroundColor = System.Drawing.Color.FromArgb(75, 0, 0, 0); }; labell.MouseLeave += (sender, e) => { labell.BackgroundColor = System.Drawing.Color.FromArgb(50, 0, 0, 0); }; labell.Click += (sender, e) => { GraphicsDevice.Window.Close(); }; Container.Widgets.Add(new ContextMenu(Container)); var contextMenu = (ContextMenu)Container.Widgets[8]; contextMenu.Position = new GameLibrary.Math.Vector2(400, 400); contextMenu.Size = new GameLibrary.Math.Vector2(120, 20); LargeFont = new Font("Verdana", 24); MediumFont = new Font("Verdana", 18); PosX = 1000; PosY = 5; IsLoading = false; IsLoaded = true; }
protected WidgetContainer FindTheControl(string ControlName, Control X) { if (X is Page) { bFound = false; x = new WidgetContainer(); } foreach (Control c in X.Controls) { if (c.ID == ControlName && c is WidgetContainer) { bFound = true; x = (WidgetContainer)c; return(x); } else { if (!bFound) { FindTheControl(ControlName, c); } } } return(x); }
public DeitySystem() { var doc = WidgetDoc.Load("ui/pc_creation/deity_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _deityButtons = new Dictionary <DeityId, WidgetButton>(); foreach (var deityId in GameSystems.Deity.PlayerSelectableDeities) { var buttonIndex = _deityButtons.Count; var button = new WidgetButton(new Rectangle( 48 + 171 * (buttonIndex / 10), 25 + 21 * (buttonIndex % 10), 162, 12 )); button.SetStyle("deity-button"); button.Text = GameSystems.Deity.GetName(deityId).ToUpper(); button.OnMouseEnter += msg => ShowDeityHelp(deityId); button.OnMouseExit += msg => UpdateDescriptionBox(); button.SetClickHandler(() => SelectDeity(deityId)); Container.Add(button); _deityButtons[deityId] = button; } }
public CharSheetStatsUi(Rectangle mainWindowRectangle) { Stub.TODO(); var uiParams = new StatsUiParams( mainWindowRectangle, Tig.FS.ReadMesFile("art/interface/char_ui/char_stats_ui/1_char_stats_ui.mes"), Tig.FS.ReadMesFile("art/interface/char_ui/char_stats_ui/1_char_stats_ui_textures.mes"), Tig.FS.ReadMesFile("mes/1_char_stats_ui_text.mes") ); Container = new WidgetContainer(uiParams.MainWindow); Container.Visible = false; CreateMoneyLabels(uiParams); CreateXpAndLevelLabels(uiParams); CreateAbilityScoreLabels(uiParams); CreateDefensiveLabels(uiParams); CreateSavingThrowLabels(uiParams); CreatePhysicalAppearanceLabels(uiParams); CreateCombatLabels(uiParams); }
public AlignmentSystem() { var doc = WidgetDoc.Load("ui/pc_creation/alignment_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _partyAlignmentLabel = doc.GetTextContent("partyAlignmentLabel"); _alignmentButtons = new Dictionary <Alignment, WidgetButton> { { Alignment.LAWFUL_GOOD, doc.GetButton("lawfulGood") }, { Alignment.NEUTRAL_GOOD, doc.GetButton("neutralGood") }, { Alignment.CHAOTIC_GOOD, doc.GetButton("chaoticGood") }, { Alignment.LAWFUL_NEUTRAL, doc.GetButton("lawfulNeutral") }, { Alignment.NEUTRAL, doc.GetButton("neutral") }, { Alignment.CHAOTIC_NEUTRAL, doc.GetButton("chaoticNeutral") }, { Alignment.LAWFUL_EVIL, doc.GetButton("lawfulEvil") }, { Alignment.NEUTRAL_EVIL, doc.GetButton("neutralEvil") }, { Alignment.CHAOTIC_EVIL, doc.GetButton("chaoticEvil") }, }; foreach (var(alignment, button) in _alignmentButtons) { button.OnMouseEnter += msg => ShowAlignmentHelp(alignment); button.OnMouseExit += msg => UpdateDescriptionBox(); button.SetClickHandler(() => SelectAlignment(alignment)); } }
private void LoadWidgets() { foreach (Panel panel in columnPanels) { List <WidgetContainer> widgets = panel.Controls.OfType <WidgetContainer>().ToList(); foreach (var widget in widgets) { panel.Controls.Remove(widget); } } var widgetInstances = currentPage.hitbl_WidgetInstance_INs.OrderBy(x => x.INS_OrderNo).ToList(); foreach (var widgetInstance in widgetInstances) { if (widgetInstance.INS_ColumnNo < columnPanels.Length) { Panel panel = columnPanels[widgetInstance.INS_ColumnNo]; WidgetContainer widgetContainer = (WidgetContainer)LoadControl(Constants.WIDGET_CONTAINER); if (!isReadOnly) { widgetContainer.ID = "WidgetContainer" + widgetInstance.INS_ID.ToString().Replace("-", "_"); } else { widgetContainer.ID = "WC" + currentPage.PAG_OrderNr + widgetInstance.INS_ColumnNo + widgetInstance.INS_OrderNo; } widgetContainer.WidgetInstance = widgetInstance; widgetContainer.IsReadOnly = isReadOnly; widgetContainer.ColumnWidth = columnWidths[widgetInstance.INS_ColumnNo]; widgetContainer.ParentCommunityID = pageOrCommunity.CommunityID.Value; widgetContainer.ParentObjectType = pageOrCommunity.ObjectType; widgetContainer.ParentPageType = parentPageType; widgetContainer.SiteContext = SiteConfig.GetSiteContext(UserProfile.Current); widgetContainer.OnWidgetDeleted += OnDeleteWidget; try { panel.Controls.Add(widgetContainer); } catch (Exception exception) { panel.Controls.Add(new LiteralControl(exception.Message)); } } } if (isReadOnly) { foreach (Panel panel in columnPanels) { if (panel.Controls.Count == 0) { panel.Visible = false; } } } }
public ActionBarUi() { _pulseAnimation = GameSystems.Vagrant.AllocateActionBar(); // These values were configurable in a MES file before GameSystems.Vagrant.ActionBarSetPulseValues(_pulseAnimation, 64, 255, 0.125f); _combatBarFill = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill.tga", false); _combatBarHighlight = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight.tga", false); _combatBarHighlight2 = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight2.tga", false); _combatBarGrey = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_GREY.tga", false); _combatBarFillInvalid = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill_INVALID.tga", false); _window = new WidgetContainer(8, 117, 50, 260); _window.Name = "combat_ui_debug_output_window"; // Hide or show the entire action bar based on combat status _window.Visible = false; GameSystems.Combat.OnCombatStatusChanged += combatStatus => { _window.Visible = combatStatus; }; var actionBarImage = new WidgetImage("art/interface/COMBAT_UI/combatbar.img"); _window.AddContent(actionBarImage); var actionBar = new WidgetContainer(new Rectangle(13, 15, 22, 170)); _window.Add(actionBar); actionBar.Name = "action bar"; actionBar.OnBeforeRender += () => UiCombatActionBarRender(actionBar); // Add a full sized button on top of the action bar to handle tooltips and help requests var actionBarButton = new WidgetButton(); actionBarButton.SetStyle(new WidgetButtonStyle()); actionBarButton.SetSizeToParent(true); actionBarButton.SetClickHandler(OnActionBarButtonClick); actionBarButton.TooltipStyle = "action-bar-tooltip"; actionBarButton.OnBeforeRender += () => { // Use the time update message (one per frame) to update the tooltip text actionBarButton.TooltipText = GetActionBarTooltipText(); }; actionBar.Add(actionBarButton); var nextTurn = new WidgetButton(new Rectangle(0, 194, 50, 50)); nextTurn.SetStyle(new WidgetButtonStyle { NormalImagePath = "art/interface/COMBAT_UI/Action-End-Turn.tga", HoverImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Hover.tga", PressedImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Click.tga", DisabledImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Disabled.tga", }); nextTurn.Name = "next_turn"; nextTurn.OnBeforeRender += () => OnBeforeRenderNextTurn(nextTurn); nextTurn.SetClickHandler(OnNextTurnClick); _window.Add(nextTurn); }
public PortraitRecord(GameObject combatant, WidgetContainer container, InitiativePortraitButton button, bool smallPortrait) { Combatant = combatant; Container = container; Button = button; SmallPortrait = smallPortrait; }
private void CreatePopupWidget(UiPromptListEntry uiPopup) { var window = new WidgetContainer(new Rectangle(0, 0, 0, 0)); // popup_ui_main_window1.OnBeforeRender += 0x10170a90; window.Name = "popup_ui_main_window"; window.Visible = false; window.SetMouseMsgHandler(msg => true); // Swallow mouse clicks and such uiPopup.wnd = window; uiPopup.background = new WidgetImage(); window.AddContent(uiPopup.background); uiPopup.titleLabel = new WidgetText("", "popupTitle"); uiPopup.titleLabel.X = 30; uiPopup.titleLabel.Y = 13; uiPopup.titleLabel.FixedSize = new Size(230, 26); uiPopup.titleLabel.SetCenterVertically(true); window.AddContent(uiPopup.titleLabel); uiPopup.bodyLabel = new WidgetText("", "popupBody"); window.AddContent(uiPopup.bodyLabel); var okButton = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button1.OnHandleMessage += 0x10171b50; // popup_ui_button1.OnBeforeRender += 0x10170c30; // popup_ui_button1.OnRenderTooltip += 0x100027f0; okButton.Name = "popup_ok_button"; okButton.Visible = false; window.Add(okButton); uiPopup.btn1 = okButton; okButton.SetClickHandler(() => OnClickButton(uiPopup, 0)); var cancelButton = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button2.OnHandleMessage += 0x10171b50; // popup_ui_button2.OnBeforeRender += 0x10170e40; // popup_ui_button2.OnRenderTooltip += 0x100027f0; cancelButton.Name = "popup_cancel_button"; cancelButton.Visible = false; window.Add(cancelButton); uiPopup.btn2 = cancelButton; cancelButton.SetClickHandler(() => OnClickButton(uiPopup, 1)); var popup_ui_button3 = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button3.OnHandleMessage += 0x10171b50; // popup_ui_button3.OnBeforeRender += 0x10171a90; // popup_ui_button3.OnRenderTooltip += 0x100027f0; popup_ui_button3.Name = "popup_ui_button"; popup_ui_button3.Visible = false; window.Add(popup_ui_button3); uiPopup.btn3 = popup_ui_button3; }
public CharSheetSkillsUi() { var detailsDoc = WidgetDoc.Load("ui/char_skills.json"); Container = detailsDoc.GetRootContainer(); Container.SetMouseMsgHandler(msg => { // Forward mouse wheel messages to the scrollbar if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0) { _scrollbar.HandleMouseMessage(msg); } return(true); }); Container.Name = "char_skills_ui_main_window"; Container.Visible = false; _skillRanks = detailsDoc.GetTextContent("skill-ranks-label"); _attributeBonus = detailsDoc.GetTextContent("skill-attribute-bonus-label"); _attributeType = detailsDoc.GetTextContent("skill-attribute-type-label"); _miscBonus = detailsDoc.GetTextContent("skill-misc-bonus-label"); _total = detailsDoc.GetTextContent("skill-total-label"); HideSkillDetails(); for (var i = 0; i < 20; i++) { var button = new SkillButton(new Rectangle(1, 1 + 13 * i, 156, 13)); button.OnMouseEnter += _ => ShowSkillDetails(button); button.OnMouseExit += _ => HideSkillDetails(); button.SetMouseMsgHandler(msg => { if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0) { return(_scrollbar.HandleMouseMessage(msg)); } return(false); }); Container.Add(button); _skillButtons[i] = button; } if (VisibleSkills.Length > _skillButtons.Length) { _scrollbar = new WidgetScrollBar(new Rectangle(160, -4, 13, 267)); _scrollbar.SetMin(0); _scrollbar.Max = VisibleSkills.Length - _skillButtons.Length; Container.Add(_scrollbar); _scrollbar.SetValueChangeHandler((value) => UpdateSkillButtons()); } UpdateSkillButtons(); }
public static void InitializeContent(WidgetContainer container) { WindowContents = new Dictionary <string, Widget>() { { "Builds", WidgetFactory.CreateWidget <PatchBuildsContent>(container) }, { "Patches", WidgetFactory.CreateWidget <PatchPatchesContent>(container) }, { "Launcher", WidgetFactory.CreateWidget <PatchLauncherContent>(container) }, { "Options", WidgetFactory.CreateWidget <PatchOptionsContent>(container) }, { "Info", WidgetFactory.CreateWidget <PatchInfoContent>(container) }, }; }
public WidgetSink(IReadOnlyObservableListBinding <WidgetAndConstraint <TConstraint> > sourceList, WidgetContainer <TConstraint> target) : base(sourceList, target) { if (target.Count != 0) { throw new InvalidOperationException("Cannot bind to a widget that already contains other content."); } target.ChildrenChanged += OnValidateChildrenChanged; SourceList.CollectionChanged += CheckedChangeHandler; }
public LogbookKeyAcquiredPopup(LogbookKeyTranslations translations) { var doc = WidgetDoc.Load("ui/key_acquired_popup.json"); _window = doc.GetRootContainer(); doc.GetTextContent("title").Text = translations.NotificationPopupTitle; var textContainer = doc.GetContainer("textContainer"); var text = new WidgetText(); text.FixedWidth = 237; text.Text = translations.NotificationPopupText; textContainer.AddContent(text); var prompt = new WidgetText(); prompt.FixedWidth = 237; prompt.Text = translations.NotificationPopupPrompt; prompt.Y = text.GetPreferredSize().Height + 13; textContainer.AddContent(prompt); // Created @ 0x1019727c // _window.OnHandleMessage += 0x101f5850; // _window.OnBeforeRender += 0x10196a10; _window.ZIndex = 100051; _window.Name = "logbook_ui_keys_key_entry_window"; _window.Visible = false; // Created @ 0x10197385 var acceptButton = doc.GetButton("accept"); // logbook_ui_key_entry_accept_butn1.OnHandleMessage += 0x10197070; // logbook_ui_key_entry_accept_butn1.OnBeforeRender += 0x10196d70; acceptButton.Text = translations.NotificationPopupYes; acceptButton.Name = "logbook_ui_key_entry_accept_butn"; acceptButton.SetClickHandler(() => { OnChangeNotificationSetting?.Invoke(false); Hide(); }); // Created @ 0x101974c2 var declineButton = doc.GetButton("decline"); // logbook_ui_key_entry_decline_butn1.OnHandleMessage += 0x10197070; // logbook_ui_key_entry_decline_butn1.OnBeforeRender += 0x10196d70; declineButton.Text = translations.NotificationPopupNo; declineButton.Name = "logbook_ui_key_entry_decline_butn"; declineButton.SetClickHandler(Hide); }
/* * public MainWindow(float _PercentX, float _PercentY) * { * MainWindow( (int)Math.Round(UnityEngine.Screen.width*_PercentX), (int)Math.Round(UnityEngine.Screen.width*_PercentY)); * } */ //public MainWindow(Rect _ScreenPosition, WidgetContainer _MainHost ) :base("MainWindow") public MainWindow(Rect _ScreenPosition, WidgetContainer _MainHost) { //this.WidthOnScreen = _SizeX; //this.HeightOnScreen = _SizeY; //this.ScreenPosition = _ScreenPosition; this.MainHost = _MainHost; //this.MainHost.WidthOnScreen = this.WidthOnScreen; //this.MainHost.HeightOnScreen = this.HeightOnScreen; this.MainHost.ScreenPosition = _ScreenPosition; this.MainHost.placeContained(); }
public CharSheetHelpUi() { var widgetDoc = WidgetDoc.Load("ui/char_help.json"); _scrollView = (WidgetScrollView)widgetDoc.TakeRootWidget(); _textContainer = new WidgetContainer(0, 0, _scrollView.GetInnerWidth(), _scrollView.GetInnerHeight()); _textLabel = new WidgetText(); _textContainer.AddContent(_textLabel); _scrollView.Add(_textContainer); _scrollView.AddStyle("char-help-text"); }
private void InitializeInterface() { _widgets = WidgetContainer.Create(this); _widgets.MinSize = _currentWindow.minSize; _widgets.AddSkin(ThemeHelper.MainColorName, Resources.Load <GUISkin>("PatchMainGUISkin")); _widgets.AddSkin(ThemeHelper.SecondaryColorName, Resources.Load <GUISkin>("PatchSecondaryGUISkin")); _widgets.AddSkin(ThemeHelper.DarkColorName, Resources.Load <GUISkin>("PatchDarkGUISkin")); _widgets.AddSkin(ThemeHelper.PopupColorName, Resources.Load <GUISkin>("PatchPopupGUISkin")); ThemeHelper.InitializeContent(_widgets); SetContainerComponents(_widgets); }
public GenderSystem() { var doc = WidgetDoc.Load("ui/pc_creation/gender_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _maleButton = doc.GetButton("maleButton"); _maleButton.SetClickHandler(() => ChooseGender(Gender.Male)); _femaleButton = doc.GetButton("femaleButton"); _femaleButton.SetClickHandler(() => ChooseGender(Gender.Female)); // NOTE: Vanilla previously tried showing gender-specific help texts, but those texts actually don't exist }
public HeightSystem() { var doc = WidgetDoc.Load("ui/pc_creation/height_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _minHeightLabel = doc.GetTextContent("minHeightLabel"); _maxHeightLabel = doc.GetTextContent("maxHeightLabel"); _currentHeightLabel = doc.GetTextContent("currentHeightLabel"); _slider = new HeightSlider(); _slider.SetPos(doc.GetContainer("sliderContainer").GetPos()); Container.Add(_slider); _slider.OnValueChanged += (newValue) => { UpdateModelScale(); }; }
public void MarkWidgets(Control control, bool bAdmin) { //add the command click event to the link buttons on the datagrid heading foreach (Control c in control.Controls) { if (c is WidgetContainer) { WidgetContainer ph = (WidgetContainer)c; ph.IsAdminMode = bAdmin; } else { MarkWidgets(c, bAdmin); } } }
public TextEntryUi() { var doc = WidgetDoc.Load("ui/text_entry_ui.json"); _dialog = doc.GetRootContainer(); _dialog.Visible = false; _dialog.SetKeyStateChangeHandler(HandleShortcut); _dialog.OnHandleMessage += HandleMessage; _okButton = doc.GetButton("okButton"); _okButton.SetClickHandler(Confirm); _cancelButton = doc.GetButton("cancelButton"); _cancelButton.SetClickHandler(Cancel); _titleLabel = doc.GetTextContent("titleLabel"); _currentInputLabel = doc.GetTextContent("currentInputLabel"); }
private static WidgetContainer GetDefaultContainer(Guid defaultId, Guid newId) { var template = DefaultContainers[defaultId]; var newContainer = new WidgetContainer(newId, template.ContainerID) { ColumnSchemaType = template.ColumnSchemaType, TenantID = TenantProvider.CurrentTenantID, UserID = SecurityContext.CurrentAccount.ID, }; template.States.ForEach(s => newContainer.States.Add(new WidgetState(s.ID, newContainer.ID) { X = s.X, Y = s.Y })); return(newContainer); }
public WidgetScrollView(int width, int height) : base(width, height) { var scrollBar = new WidgetScrollBar(); scrollBar.Height = height; scrollBar.X = width - scrollBar.Width; scrollBar.SetValueChangeHandler(newValue => { mContainer.SetScrollOffsetY(newValue); }); mScrollBar = scrollBar; base.Add(scrollBar); var scrollView = new WidgetContainer(GetInnerWidth(), height); mContainer = scrollView; base.Add(scrollView); UpdateInnerContainer(); }
/// <summary> /// Adds a widget of the specified type. /// </summary> /// <param name="type"> /// The type of widget. /// </param> /// <param name="zone"> /// The zone a widget is being added to. /// </param> private void AddWidget(string type, string zone) { var widget = (WidgetBase)LoadControl(string.Format("{0}widgets/{1}/widget.ascx", Utils.ApplicationRelativeWebRoot, type)); widget.WidgetId = Guid.NewGuid(); widget.ID = widget.WidgetId.ToString().Replace("-", string.Empty); widget.Title = type; widget.Zone = zone; widget.ShowTitle = widget.DisplayHeader; widget.LoadWidget(); // Load a widget container for this new widget. This will return the WidgetContainer // with the new widget in it. var widgetContainer = WidgetContainer.GetWidgetContainer(widget); widgetContainer.RenderContainer(); // need to manually invoke the loading process, since the Loading process for this Http Request // page lifecycle has already fired. widgetContainer.ProcessLoad(); Response.Clear(); try { using (var sw = new StringWriter()) { widgetContainer.RenderControl(new HtmlTextWriter(sw)); // Using ? as a delimiter. ? is a safe delimiter because it cannot appear in a // zonename because ? is one of the characters removed by Utils.RemoveIllegalCharacters(). Response.Write(string.Format("{0}?{1}", zone, sw)); } } catch (HttpException) { Response.Write("reload"); } SaveNewWidget(widget, zone); WidgetEditBase.OnSaved(); Response.End(); }
private void LoadWidgetContainerFromXML(XElement containerElement, Dictionary <string, SpriteFont> fonts, ContentManager content, GUIManager parent) { string containerName = containerElement.Attribute("name")?.Value.ToString(); string texturePath = containerElement.Element("texture")?.Value.ToString(); var position = parent.ParsePosition(containerElement.Element("position")?.Element("x")?.Value.ToString(), containerElement.Element("position")?.Element("y")?.Value.ToString()); float.TryParse(containerElement.Element("origin")?.Element("x")?.Value.ToString(), out float originX); float.TryParse(containerElement.Element("origin")?.Element("y")?.Value.ToString(), out float originY); Vector2 origin = new Vector2(originX, originY); Texture2D texture = content.LoadTexture2D(Constants.FILEPATH_DATA + texturePath); Vector2 size = this.ParseSize(containerElement.Element("size")?.Element("x")?.Value.ToString(), containerElement.Element("size")?.Element("y")?.Value.ToString(), texture); int.TryParse(containerElement.Element("zorder")?.Value.ToString(), out int zOrder); bool.TryParse(containerElement.Element("draggable")?.Value, out bool draggable); if (!bool.TryParse(containerElement.Element("visible")?.Value, out bool visible)) { visible = true; } var container = new WidgetContainer(texture) { Position = position, Origin = origin, ZOrder = zOrder, Draggable = draggable, Visible = visible, Size = size }; // load its children if it has them this.LoadWidgets(containerElement.Element("Widgets"), fonts, content, container); parent.AddWidget(container, containerName); }