/// <summary> /// Handles the Click event of the DeleteLayout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param> protected void DeleteLayout_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e) { RockTransactionScope.WrapTransaction(() => { LayoutService layoutService = new LayoutService(); Layout layout = layoutService.Get(e.RowKeyId); if (layout != null) { string errorMessage; if (!layoutService.CanDelete(layout, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } int siteId = layout.SiteId; layoutService.Delete(layout, CurrentPersonId); layoutService.Save(layout, CurrentPersonId); LayoutCache.Flush(e.RowKeyId); } }); BindLayoutsGrid(); }
internal static void BeginWindow(int windowID, GUIStyle style, GUILayoutOption[] options) { LayoutCache cache = SelectIDList(windowID, true); // Make a vertical group to encompass the whole thing if (Event.current.type == EventType.Layout) { current.topLevel = cache.topLevel = new GUILayoutGroup(); current.topLevel.style = style; current.topLevel.windowID = windowID; if (options != null) { current.topLevel.ApplyOptions(options); } current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = cache.windows = new GUILayoutGroup(); } else { current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; } }
/// <summary> /// Binds the group members grid. /// </summary> protected void BindLayoutBlocksGrid() { pnlBlocks.Visible = false; int layoutId = PageParameter("layoutId").AsInteger(); if (layoutId == 0) { pnlContent.Visible = false; return; } var rockContext = new RockContext(); var layout = LayoutCache.Read(layoutId, rockContext); if (layout == null) { pnlContent.Visible = false; return; } hfLayoutId.SetValue(layoutId); pnlBlocks.Visible = true; BlockService blockService = new BlockService(new RockContext()); gLayoutBlocks.DataSource = blockService.GetByLayout(layoutId).ToList(); gLayoutBlocks.DataBind(); }
/// <summary>Clears the layout cache.</summary> public static void ClearCache() { lock (LayoutCache) { LayoutCache.Clear(); } }
public LayoutCacheState(LayoutCache cache) { id = cache.id; topLevel = cache.topLevel; layoutGroups = cache.layoutGroups; windows = cache.windows; }
internal static void CleanupRoots() { s_SpaceStyle = null; s_StoredLayouts = null; s_StoredWindows = null; current = null; }
/// <summary> /// Handles the Click event of the DeleteLayout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param> protected void DeleteLayout_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e) { bool canDelete = false; var rockContext = new RockContext(); LayoutService layoutService = new LayoutService(rockContext); Layout layout = layoutService.Get(e.RowKeyId); if (layout != null) { string errorMessage; canDelete = layoutService.CanDelete(layout, out errorMessage); if (!canDelete) { mdGridWarning.Show(errorMessage, ModalAlertType.Alert); return; } int siteId = layout.SiteId; layoutService.Delete(layout); rockContext.SaveChanges(); LayoutCache.Flush(e.RowKeyId); } BindLayoutsGrid(); }
public void Teardown() { if (Marshal.IsComObject(m_cda)) { Marshal.ReleaseComObject(m_cda); } m_cda = null; if (Marshal.IsComObject(m_mdc)) { Marshal.ReleaseComObject(m_mdc); } m_mdc = null; if (Marshal.IsComObject(m_sda)) { Marshal.ReleaseComObject(m_sda); } m_sda = null; m_layoutInventory = null; m_columnList = null; m_layouts = null; m_partInventory = null; m_wsManager = null; }
public void Teardown() { if (m_wsf != null && Marshal.IsComObject(m_wsf)) { m_wsf.Shutdown(); Marshal.ReleaseComObject(m_wsf); } m_wsf = null; if (Marshal.IsComObject(m_cda)) { Marshal.ReleaseComObject(m_cda); } m_cda = null; if (Marshal.IsComObject(m_mdc)) { Marshal.ReleaseComObject(m_mdc); } m_mdc = null; if (Marshal.IsComObject(m_sda)) { Marshal.ReleaseComObject(m_sda); } m_sda = null; m_layoutInventory = null; m_columnList = null; m_layouts = null; m_partInventory = null; }
internal LayoutCache(LayoutCache other) { id = other.id; topLevel = other.topLevel; layoutGroups = other.layoutGroups; windows = other.windows; }
internal static void CleanupRoots() { // See GUI.CleanupRoots s_SpaceStyle = null; s_StoredLayouts.Clear(); s_StoredWindows.Clear(); current = new LayoutCache(); }
public override void FixtureSetup() { base.FixtureSetup(); SetupTestModel(Resources.TextCacheModel_xml); m_sda = new RealDataCache(); m_sda.MetaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml"); //m_cache.ParaContentsFlid = kflidParaContents; //m_cache.ParaPropertiesFlid = kflidParaProperties; //m_cache.TextParagraphsFlid = kflidTextParas; Debug.Assert(m_wsManager == null); m_wsManager = Cache.ServiceLocator.GetInstance <IWritingSystemManager>(); m_sda.WritingSystemFactory = m_wsManager; m_wsAnal = Cache.DefaultAnalWs; m_wsVern = Cache.DefaultVernWs; //IWritingSystem deWs; //m_wsManager.GetOrSet("de", out deWs); //m_wsDeu = deWs.Handle; //m_wsManager.UserWs = m_wsEng; //m_wsUser = m_wsManager.UserWs; m_tsf = TsStrFactoryClass.Create(); m_hvoLexDb = m_sda.MakeNewObject(kclsidLexDb, 0, -1, -1); kflidLexDb_Entries = m_sda.MetaDataCache.GetFieldId("LexDb", "Entries", false); kflidEntry_Form = m_sda.MetaDataCache.GetFieldId("Entry", "Form", false); kflidEntry_Summary = m_sda.MetaDataCache.GetFieldId("Entry", "Summary", false); m_hvoKick = m_sda.MakeNewObject(kclsidEntry, m_hvoLexDb, kflidLexDb_Entries, 0); m_sda.SetMultiStringAlt(m_hvoKick, kflidEntry_Form, m_wsVern, m_tsf.MakeString("kick", m_wsVern)); m_sda.SetString(m_hvoKick, kflidEntry_Summary, m_tsf.MakeString("strike with foot", m_wsAnal)); var keyAttrs = new Dictionary <string, string[]>(); keyAttrs["layout"] = new[] { "class", "type", "name", "choiceGuid" }; keyAttrs["group"] = new[] { "label" }; keyAttrs["part"] = new[] { "ref" }; var layoutInventory = new Inventory("*.fwlayout", "/LayoutInventory/*", keyAttrs, "test", "nowhere"); layoutInventory.LoadElements(Resources.Layouts_xml, 1); keyAttrs = new Dictionary <string, string[]>(); keyAttrs["part"] = new[] { "id" }; var partInventory = new Inventory("*Parts.xml", "/PartInventory/bin/*", keyAttrs, "test", "nowhere"); partInventory.LoadElements(Resources.Parts_xml, 1); m_layouts = new LayoutCache(m_sda.MetaDataCache, layoutInventory, partInventory); }
/// <summary> /// Gets the Guid for the Layout that has the specified Id /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public override Guid?GetGuid(int id) { var cacheItem = LayoutCache.Get(id); if (cacheItem != null) { return(cacheItem.Guid); } return(null); }
internal static LayoutCache SelectIDList(int instanceID, bool isWindow) { Dictionary <int, LayoutCache> dictionary = (!isWindow) ? s_StoredLayouts : s_StoredWindows; if (!dictionary.TryGetValue(instanceID, out LayoutCache value)) { value = (dictionary[instanceID] = new LayoutCache()); } current.topLevel = value.topLevel; current.layoutGroups = value.layoutGroups; current.windows = value.windows; return(value); }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { LayoutService layoutService = new LayoutService(); Layout layout; int layoutId = int.Parse(hfLayoutId.Value); // if adding a new layout if (layoutId.Equals(0)) { layout = new Layout { Id = 0 }; layout.SiteId = hfSiteId.ValueAsInt(); } else { //load existing group member layout = layoutService.Get(layoutId); } layout.Name = tbLayoutName.Text; layout.Description = tbDescription.Text; layout.FileName = ddlLayout.SelectedValue; if (!layout.IsValid) { return; } RockTransactionScope.WrapTransaction(() => { if (layout.Id.Equals(0)) { layoutService.Add(layout, CurrentPersonId); } layoutService.Save(layout, CurrentPersonId); }); LayoutCache.Flush(layout.Id); Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["siteId"] = hfSiteId.Value; NavigateToParentPage(qryString); } }
internal static LayoutCache SelectIDList(int instanceID, bool isWindow) { LayoutCache cache; Dictionary <int, LayoutCache> dictionary = !isWindow ? s_StoredLayouts : s_StoredWindows; if (!dictionary.TryGetValue(instanceID, out cache)) { cache = new LayoutCache(); dictionary[instanceID] = cache; } current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; return(cache); }
internal static LayoutCache SelectIDList(int instanceID, bool isWindow) { Dictionary <int, LayoutCache> store = isWindow ? s_StoredWindows : s_StoredLayouts; LayoutCache cache; if (store.TryGetValue(instanceID, out cache) == false) { cache = new LayoutCache(instanceID); store[instanceID] = cache; } current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; return(cache); }
internal static void BeginContainer(LayoutCache cache) { // Make a vertical group to encompass the whole thing if (Event.current.type == EventType.Layout) { // Make sure to update all the cached values of the LayoutCache when doing a Layout cache.topLevel = new GUILayoutGroup(); cache.layoutGroups.Clear(); cache.layoutGroups.Push(cache.topLevel); cache.windows = new GUILayoutGroup(); } // Make sure to use the actual cache. current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; }
public override void FixtureSetup() { base.FixtureSetup(); Cache.ProjectId.Path = Path.Combine(Path.GetTempPath(), Cache.ProjectId.Name, Cache.ProjectId.Name + @".junk"); FwRegistrySettings.Init(); m_application = new MockFwXApp(new MockFwManager { Cache = Cache }, null, null); m_configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname); m_window = new MockFwXWindow(m_application, m_configFilePath); m_window.Init(Cache); // initializes Mediator values m_mediator = m_window.Mediator; m_mediator.AddColleague(new StubContentControlProvider()); m_window.LoadUI(m_configFilePath); // actually loads UI here; needed for non-null stylesheet LayoutCache.InitializePartInventories(Cache.ProjectId.Name, m_application, Cache.ProjectId.Path); }
internal static void BeginContainer(LayoutCache cache) { if (Event.current.type == EventType.Layout) { current.topLevel = (cache.topLevel = new GUILayoutGroup()); current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = (cache.windows = new GUILayoutGroup()); } else { current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { var rockContext = new RockContext(); LayoutService layoutService = new LayoutService(rockContext); Layout layout; int layoutId = int.Parse(hfLayoutId.Value); // if adding a new layout if (layoutId.Equals(0)) { layout = new Layout { Id = 0 }; layout.SiteId = hfSiteId.ValueAsInt(); } else { //load existing group member layout = layoutService.Get(layoutId); } layout.Name = tbLayoutName.Text; layout.Description = tbDescription.Text; layout.FileName = ddlLayout.SelectedValue; if (!layout.IsValid) { return; } if (layout.Id.Equals(0)) { layoutService.Add(layout); } rockContext.SaveChanges(); LayoutCache.Flush(layout.Id); Dictionary <string, string> qryParams = new Dictionary <string, string>(); qryParams["layoutId"] = layout.Id.ToString(); NavigateToPage(RockPage.Guid, qryParams); } }
internal static void BeginContainer(LayoutCache cache) { // Make a vertical group to encompass the whole thing if (Event.current.type == EventType.Layout) { current.topLevel = cache.topLevel = new GUILayoutGroup(); current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = cache.windows = new GUILayoutGroup(); } else { current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; } }
/// <summary> /// Initialize the required inventories. /// </summary> private void InitializePartInventories(FdoCache cache, bool fLoadUserOverrides) { WriteSplashScreen(LexTextStrings.ksInitializingLayouts_); LayoutCache.InitializePartInventories(false, cache.DatabaseName, fLoadUserOverrides); int flid = BaseVirtualHandler.GetInstalledHandlerTag(cache, "LexDb", "CurrentReversalIndices"); if (flid == 0) { flid = (int)LexDb.LexDbTags.kflidReversalIndexes; } int[] rghvoIndexes = cache.GetVectorProperty(cache.LangProject.LexDbOA.Hvo, flid, false); foreach (int hvoIndex in rghvoIndexes) { int ws = cache.GetObjProperty(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem); string sWs = cache.GetUnicodeProperty(ws, (int)LgWritingSystem.LgWritingSystemTags.kflidICULocale); LayoutCache.InitializeLayoutsForWsTag(sWs, cache.DatabaseName); } }
internal static void Begin(int instanceID) { LayoutCache layoutCache = SelectIDList(instanceID, isWindow: false); if (Event.current.type == EventType.Layout) { current.topLevel = (layoutCache.topLevel = new GUILayoutGroup()); current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = (layoutCache.windows = new GUILayoutGroup()); } else { current.topLevel = layoutCache.topLevel; current.layoutGroups = layoutCache.layoutGroups; current.windows = layoutCache.windows; } }
// Set up the internal GUILayouting // Called by the main GUI class automatically (from GUI.Begin) internal static void Begin(int instanceID) { LayoutCache cache = SelectIDList(instanceID, false); // Make a vertical group to encompass the whole thing if (Event.current.type == EventType.Layout) { current.topLevel = cache.topLevel = new GUILayoutGroup(); current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = cache.windows = new GUILayoutGroup(); } else { current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; } }
internal static LayoutCache SelectIDList(int instanceID, bool isWindow) { Dictionary <int, LayoutCache> store = isWindow ? s_StoredWindows : s_StoredLayouts; LayoutCache cache; if (store.TryGetValue(instanceID, out cache) == false) { // Debug.Log ("Creating ID " +instanceID + " " + Event.current.type); cache = new LayoutCache(); store[instanceID] = cache; } else { // Debug.Log ("reusing ID " +instanceID + " " + Event.current.type); } current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; return(cache); }
/// <summary> /// Gets the HTML document for the layout. /// </summary> /// <param name="layout">The layout whose Html Document is to be retrieved.</param> /// <param name="rockPage">The rock page associated with the layout. TODO: Maybe should be changed to a mergeFields dictionary?</param> /// <returns>An IHtmlDocument that contains the DOM.</returns> public static async Task <IHtmlDocument> GetHtmlDocumentAsync(this LayoutCache layout, RockWebCore.UI.RockPage rockPage) { var mergeFields = new Dictionary <string, object> { { "CurrentPage", rockPage } }; var themeFilename = $"wwwroot/Themes/{layout.Site.Theme}/Layouts/{layout.FileName}.lava"; var layoutContent = await File.ReadAllTextAsync(themeFilename); var resolveTask = layoutContent.ResolveMergeFieldsAsync(mergeFields); // // Generate custom configuration to use our own Html Element Factory. // var configuration = Configuration.Default .Without <IElementFactory <Document, HtmlElement> >() .With(new RockHtmlElementFactory()); var context = BrowsingContext.New(configuration); return(await new HtmlParser(new HtmlParserOptions(), context).ParseDocumentAsync(await resolveTask)); }
/// <summary> /// Initialize the required inventories. /// </summary> private void InitializePartInventories(IProgress progressDlg, bool fLoadUserOverrides) { if (progressDlg != null) { progressDlg.Message = LexTextStrings.ksInitializingLayouts_; } LayoutCache.InitializePartInventories(Cache.ProjectId.Name, this, fLoadUserOverrides, Cache.ProjectId.ProjectFolder); var currentReversalIndices = Cache.LanguageProject.LexDbOA.CurrentReversalIndices; if (currentReversalIndices.Count == 0) { currentReversalIndices = new List <IReversalIndex>(Cache.LanguageProject.LexDbOA.ReversalIndexesOC.ToArray()); } foreach (var reversalIndex in currentReversalIndices) { LayoutCache.InitializeLayoutsForWsTag( reversalIndex.WritingSystem, Cache.ProjectId.Name); } }
internal static void BeginWindow(int windowID, GUIStyle style, GUILayoutOption[] options) { LayoutCache layoutCache = SelectIDList(windowID, isWindow: true); if (Event.current.type == EventType.Layout) { current.topLevel = (layoutCache.topLevel = new GUILayoutGroup()); current.topLevel.style = style; current.topLevel.windowID = windowID; if (options != null) { current.topLevel.ApplyOptions(options); } current.layoutGroups.Clear(); current.layoutGroups.Push(current.topLevel); current.windows = (layoutCache.windows = new GUILayoutGroup()); } else { current.topLevel = layoutCache.topLevel; current.layoutGroups = layoutCache.layoutGroups; current.windows = layoutCache.windows; } }
internal static LayoutCache SelectIDList(int instanceID, bool isWindow) { LayoutCache cache; Dictionary<int, LayoutCache> dictionary = !isWindow ? s_StoredLayouts : s_StoredWindows; if (!dictionary.TryGetValue(instanceID, out cache)) { cache = new LayoutCache(); dictionary[instanceID] = cache; } current.topLevel = cache.topLevel; current.layoutGroups = cache.layoutGroups; current.windows = cache.windows; return cache; }
/// <summary> /// Shows the page edit. /// </summary> /// <param name="pageId">The page identifier.</param> private void ShowPageEdit(int pageId) { var page = new PageService(new RockContext()).Get(pageId); // // Ensure the page is valid. // if (pageId != 0) { var pageCache = PageCache.Get(pageId); if (!CheckIsValidMobilePage(pageCache)) { return; } } if (page == null) { page = new Rock.Model.Page { DisplayInNavWhen = DisplayInNavWhen.WhenAllowed }; } // // Ensure user has access to edit this page. // if (!page.IsAuthorized(Authorization.EDIT, CurrentPerson)) { nbError.Text = Rock.Constants.EditModeMessage.NotAuthorizedToEdit(typeof(Rock.Model.Page).GetFriendlyTypeName()); pnlEditPage.Visible = false; return; } var additionalSettings = page.AdditionalSettings.FromJsonOrNull <Rock.Mobile.AdditionalPageSettings>() ?? new Rock.Mobile.AdditionalPageSettings(); // // Set the basic fields of the page. // tbName.Text = page.PageTitle; tbInternalName.Text = page.InternalName; tbDescription.Text = page.Description; cbDisplayInNavigation.Checked = page.DisplayInNavWhen == DisplayInNavWhen.WhenAllowed; tbCssClass.Text = page.BodyCssClass; ceEventHandler.Text = additionalSettings.LavaEventHandler; ceCssStyles.Text = additionalSettings.CssStyles; imgPageIcon.BinaryFileId = page.IconBinaryFileId; // // Configure the layout options. // var siteId = PageParameter("SiteId").AsInteger(); ddlLayout.Items.Add(new ListItem()); foreach (var layout in LayoutCache.All().Where(l => l.SiteId == siteId)) { ddlLayout.Items.Add(new ListItem(layout.Name, layout.Id.ToString())); } ddlLayout.SetValue(page.LayoutId); pnlEditPage.Visible = true; pnlDetails.Visible = false; pnlBlocks.Visible = false; }