/* * helper for clearing controls from container, such that it gets un-registered */ private void ClearControls(DynamicPanel dynamic) { foreach (Control idx in dynamic.Controls) { ActiveEvents.Instance.RemoveListener(idx); } dynamic.ClearControls(); }
private void magix_forms_controls_dynamic(object sender, ActiveEventArgs e) { Node ip = Ip(e.Params); if (ShouldInspect(ip)) { Inspect(ip); return; } DynamicPanel ret = new DynamicPanel(); FillOutParameters(e.Params, ret); Node node = ip["_code"].Get <Node>(); if (node.ContainsValue("tag")) { ret.Tag = node["tag"].Get <string>(); } if (node.ContainsValue("default")) { ret.Default = node["default"].Get <string>(); } ret.Reload += delegate(object sender2, DynamicPanel.ReloadEventArgs e2) { DynamicPanel dynamic = sender2 as DynamicPanel; Control ctrl = ModuleControllerLoader.Instance.LoadActiveModule(e2.Key); if (e2.FirstReload) { // Since this is the Initial Loading of our module // We'll need to make sure our Initial Loading procedure is being // called, if Module is of type ActiveModule Node nn = e2.Extra as Node; ctrl.Init += delegate { ActiveModule module = ctrl as ActiveModule; if (module != null) { module.InitialLoading(nn); } }; } dynamic.Controls.Add(ctrl); }; ip["_ctrl"].Value = ret; }
/* * reloading controls upon postbacks */ protected void dynamic_LoadControls(object sender, DynamicPanel.ReloadEventArgs e) { DynamicPanel dynamic = sender as DynamicPanel; Control ctrl = ModuleControllerLoader.Instance.LoadActiveModule(e.Key); if (e.FirstReload) { ActiveModule module = ctrl as ActiveModule; if (module != null) { Node nn = e.Extra as Node; ctrl.Init += delegate { module.InitialLoading(nn); }; } } dynamic.Controls.Add(ctrl); }
public override void InitializeGUI() { base.InitializeGUI(); _topPanel = new DynamicPanel(guiManager, Rect.FromBox(topPanelPos.X, topPanelPos.Y, topPanelSize.Width, topPanelSize.Height)); _topPanel.SetBackgroundSprite(ResourcesManager.Instance.ResourceImageSheet.Sprites["guiPanel3"]); _topPanel.Alpha = 200; _topPanel.MouseRelease += TopPanelMouseRelease; _topPanel.MouseOver += TopPanelMouseOver; _btnAlphaCut = new Button(guiManager, "Alpha Cut") { Left = 15, Top = 20, Width = 100, Height = 30, }; _btnAlphaCut.MouseRelease += _btnAlphaCut_MouseRelease; _btnSelectAllFrames = new Button(guiManager, "Select all Frames") { Left = _btnAlphaCut.Left + _btnAlphaCut.Width + 5, Top = 20, Width = 130, Height = 30 }; _btnSelectAllFrames.MouseRelease += BtnSelectAllFramesMouseRelease; _btnResetView = new Button(guiManager, "Reset View") { Left = _btnSelectAllFrames.Left + _btnSelectAllFrames.Width + 5, Top = 20, Width = 110, Height = 30 }; _btnResetView.MouseRelease += BtnResetViewMouseRelease; _btnFitViewToContent = new Button(guiManager, "Fit View") { Left = _btnResetView.Left + _btnResetView.Width + 5, Top = 20, Width = 100, Height = 30 }; _btnFitViewToContent.MouseRelease += BtnFitViewToContentMouseRelease; _btnPickColorToClear = new Button(guiManager, "Pick Color to Clear") { Left = _btnFitViewToContent.Left + _btnFitViewToContent.Width + 5, Top = 20, Width = 125, Height = 30 }; _btnPickColorToClear.MouseRelease += _btnPickColorToClear_MouseRelease; _topPanel.Add(_btnAlphaCut); _topPanel.Add(_btnSelectAllFrames); _topPanel.Add(_btnResetView); _topPanel.Add(_btnFitViewToContent); _topPanel.Add(_btnPickColorToClear); _bottomPanel = new DynamicPanel(guiManager, Rect.FromBox(bottomPanelPos.X, bottomPanelPos.Y, bottomPanelSize.Width, bottomPanelSize.Height)); _bottomPanel.SetBackgroundSprite(ResourcesManager.Instance.ResourceImageSheet.Sprites["guipanel"]); _bottomPanel.Color = ColorU.Black; _bottomPanel.Alpha = 128; _bottomPanel.MouseOver += BottomPanelMouseOver; _btnAddFramesToAnimation = new Button(guiManager, "Add Selected to Animation") { Left = 10, Top = 10, Width = 176, Height = 30 }; _btnAddFramesToAnimation.MouseRelease += _btnAddFramesToAnimation_MouseRelease; _bottomPanel.Add(_btnAddFramesToAnimation); guiManager.Add(_topPanel); guiManager.Add(_bottomPanel); }
protected virtual void magix_viewport_load_module(object sender, ActiveEventArgs e) { Node ip = Ip(e.Params); if (ShouldInspect(ip)) { AppendInspectFromResource( ip["inspect"], "Magix.Core", "Magix.Core.hyperlisp.inspect.hl", "[magix.viewport.load-module-dox].value"); AppendCodeFromResource( ip, "Magix.Core", "Magix.Core.hyperlisp.inspect.hl", "[magix.viewport.load-module-sample]"); return; } Node dp = Dp(e.Params); string container = GetDefaultContainer(); if (ip.ContainsValue("container")) { container = Expressions.GetExpressionValue <string>(ip["container"].Get <string>(), dp, ip, false); } DynamicPanel dyn = Selector.FindControl <DynamicPanel>( this, container); if (dyn == null && ip.ContainsValue("container")) { return; } string moduleName = Expressions.GetExpressionValue <string>(ip["name"].Get <string>(), dp, ip, false); ClearControls(dyn); if (ip.ContainsValue("class")) { dyn.Class = Expressions.GetExpressionValue <string>(ip["class"].Get <string>(), dp, ip, false); } if (ip.ContainsValue("style")) { // clearing old styles foreach (string idx in dyn.Style.Keys) { dyn.Style[idx] = ""; } // setting new styles string[] styles = ip["style"].Get <string>().Replace("\n", "").Replace("\r", "").Split( new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string idxStyle in styles) { dyn.Style[idxStyle.Split(':')[0]] = idxStyle.Split(':')[1]; } } dyn.LoadControl(moduleName, e.Params); }
protected virtual void magix_viewport_clear_controls(object sender, ActiveEventArgs e) { Node ip = Ip(e.Params); if (ShouldInspect(ip)) { AppendInspectFromResource( ip["inspect"], "Magix.Core", "Magix.Core.hyperlisp.inspect.hl", "[magix.viewport.clear-controls-dox].value"); AppendCodeFromResource( ip, "Magix.Core", "Magix.Core.hyperlisp.inspect.hl", "[magix.viewport.clear-controls-sample]"); return; } Node dp = Dp(e.Params); string container = Expressions.GetExpressionValue <string>(ip.GetValue("container", ""), dp, ip, false); bool resetClass = ip.ContainsValue("reset-class") ? Expressions.GetExpressionValue <bool>(ip["reset-class"].Get <string>(), dp, ip, false) : false; string resetClassNewClass = null; if (ip.Contains("reset-class") && ip["reset-class"].Contains("new-class")) { resetClassNewClass = ip["reset-class"]["new-class"].Get <string>(""); } if (ip.ContainsValue("all") && ip["all"].Get <bool>()) { foreach (string idx in GetAllDefaultContainers()) { DynamicPanel dyn = Selector.FindControl <DynamicPanel>( this, idx); ClearControls(dyn); if (resetClass || !string.IsNullOrEmpty(resetClassNewClass)) { if (!string.IsNullOrEmpty(resetClassNewClass)) { dyn.Class = resetClassNewClass; } else { dyn.Class = ""; } } } } else { DynamicPanel dyn = Selector.FindControl <DynamicPanel>( this, container); if (dyn == null) { return; } ClearControls(dyn); if (resetClass || !string.IsNullOrEmpty(resetClassNewClass)) { if (!string.IsNullOrEmpty(resetClassNewClass)) { dyn.Class = resetClassNewClass; } else { dyn.Class = ""; } } } }