public override void Dispose() { base.Dispose(); if (!CUIUtility.IsNullOrUndefined(_menu)) { _menu.Dispose(); } if (!CUIUtility.IsNullOrUndefined(_cachedMenuVersions)) { // This may have gotten called before if this is the current menu that we are // holding but it won't hurt to call it twice. foreach (string key in _cachedMenuVersions.Keys) { _cachedMenuVersions[key].Dispose(); } _cachedMenuVersions.Clear(); _cachedMenuVersions = null; } _selectedControl = null; _menu = null; _elmBackFrame = null; }
/// <summary> /// ContextMenuControl /// </summary> internal ContextMenuControl(Root root, string id, ContextMenuControlProperties properties, MenuType menu) : base(root, id, properties, menu) { AddDisplayMode("Menu"); }
/// <summary> /// Creates a FlyoutAnchor control /// </summary> /// <param name="root">The Root that this control is part of</param> /// <param name="id">A unique identifier for this control</param> /// <param name="properties">The set of FlyoutAnchorProperties for this control</param> /// <param name="menu">The Menu control to launch from this FlyoutAnchor</param> /// <owner alias="JKern" /> public FlyoutAnchor(Root root, string id, FlyoutAnchorProperties properties, MenuType menu) : base(root, id, properties, menu) { AddDisplayMode("Menu"); AddDisplayMode("Menu16"); AddDisplayMode("Menu32"); AddDisplayMode("Small"); AddDisplayMode("Medium"); AddDisplayMode("Large"); AddDisplayMode("Thin"); }
/// <summary> /// ContextMenuLauncher constructor /// </summary> /// <param name="root">The Root that this MenuLauncher was created by and is part of.</param> /// <param name="id">The Component id of this MenuLauncher.</param> /// <param name="properties">Dictionary of Control properties</param> /// <param name="menu">The Menu that this MenuLauncher should launch.</param> internal ContextMenuLauncher(Root root, string id, ControlProperties properties, MenuType menu) : base(root, id, properties, menu) { //base class sets the Menu property on menu }
public override void Dispose() { base.Dispose(); if (!CUIUtility.IsNullOrUndefined(_menu)) _menu.Dispose(); if (!CUIUtility.IsNullOrUndefined(_cachedMenuVersions)) { // This may have gotten called before if this is the current menu that we are // holding but it won't hurt to call it twice. foreach (string key in _cachedMenuVersions.Keys) _cachedMenuVersions[key].Dispose(); _cachedMenuVersions.Clear(); _cachedMenuVersions = null; } _selectedControl = null; _menu = null; _elmBackFrame = null; }
protected void PollForDynamicMenu(bool launchMenu, Action onDelayedLoadSucceeded) { // If this menu should only be populated once and it has been // populated then we have nothing to do. if (_polledOnce && Utility.IsTrue(Properties.PopulateOnlyOnce)) return; // If there is no dynamic menu creation command, then we can't create // the menu dynamically. if (string.IsNullOrEmpty(Properties.PopulateQueryCommand)) return; // REVIEW(josefl): How should we handle errors here? Should we just fail // silently or just let them throw like we are now? Dictionary<string, string> menuProperties = new Dictionary<string, string>(); // If this control caches its menu versions, then we send the versions that we have cached // out with the property bag. Dictionary<string, bool> menuVersions; if (Utility.IsTrue(Properties.CacheMenuVersions)) { menuVersions = new Dictionary<string, bool>(); foreach (string key in _cachedMenuVersions.Keys) menuProperties[key] = "true"; } // Poll for the menu bool commandEnabled = Root.PollForCommandState(Properties.PopulateQueryCommand, Properties.PopulateQueryCommand, menuProperties); if (commandEnabled) { Menu menu = null; string data = ""; // If the poll answerer sent XML then we use it and build a menu from it if (menuProperties.ContainsKey(PopulationJSON) && !string.IsNullOrEmpty(menuProperties[PopulationJSON])) { data = menuProperties[PopulationJSON]; } else if (menuProperties.ContainsKey(PopulationXML) && !string.IsNullOrEmpty(menuProperties[PopulationXML])) { data = Builder.ConvertXMLStringToJSON(menuProperties[PopulationXML]); } string pVersion = menuProperties.ContainsKey(PopulationVersion) ? menuProperties[PopulationVersion] : string.Empty; int pInterval = menuProperties.ContainsKey(PollAgainInterval) ? Int32.Parse(menuProperties[PollAgainInterval]) : -1; if (!string.IsNullOrEmpty(data)) { // Build the Menu from the xml and then cache it if we are suppose to menu = Root.Builder.BuildMenu(Browser.Window.Eval(data), new BuildContext(), false); if (!CUIUtility.IsNullOrUndefined(menu)) { // Store the fact that we have successfully polled for the menu once _polledOnce = true; // Store the menu in the cache of menus if need if we should if (Utility.IsTrue(Properties.CacheMenuVersions) && !string.IsNullOrEmpty(pVersion)) { CachedMenuVersions[pVersion] = menu; } } } // If the PopulationVersion was set, then we try to use a stored menu. else if (!string.IsNullOrEmpty(pVersion)) { menu = CachedMenuVersions[pVersion]; } else if (launchMenu && -1 != pInterval) { // This is used if the answering component needs to issue an asynchronous // request to get the data needed to construct the menu. PollAgainInterval // then holds the number of milliseconds until this MenuLauncher should try // polling for the Menu again. _onDelayLoadSucceeded = onDelayedLoadSucceeded; // So, in this case, we set up a timout so that we can try to poll for the menu // again in a specified number of milliseconds. Browser.Window.SetTimeout(new Action(OnTryDelayedDynamicPopulation), pInterval); // We also make sure the the _menu member is null since we are now waiting for a new one _menu = null; } if (!CUIUtility.IsNullOrUndefined(menu)) { _menu = menu; OnDynamicMenuPopulated(); } } }
/// <summary> /// MenuLauncher contructor. /// </summary> /// <param name="root">The Root that this MenuLauncher was created by and is part of.</param> /// <param name="id">The Component id of this MenuLauncher.</param> /// <param name="properties">Dictionary of Control parameters</param> /// <param name="menu">The Menu that this MenuLauncher should launch.</param> public MenuLauncher(Root root, string id, ControlProperties properties, MenuType menu) : base(root, id, properties) { _menu = menu; }
protected void PollForDynamicMenu(bool launchMenu, Action onDelayedLoadSucceeded) { // If this menu should only be populated once and it has been // populated then we have nothing to do. if (_polledOnce && Utility.IsTrue(Properties.PopulateOnlyOnce)) { return; } // If there is no dynamic menu creation command, then we can't create // the menu dynamically. if (string.IsNullOrEmpty(Properties.PopulateQueryCommand)) { return; } // REVIEW(josefl): How should we handle errors here? Should we just fail // silently or just let them throw like we are now? Dictionary <string, string> menuProperties = new Dictionary <string, string>(); // If this control caches its menu versions, then we send the versions that we have cached // out with the property bag. Dictionary <string, bool> menuVersions; if (Utility.IsTrue(Properties.CacheMenuVersions)) { menuVersions = new Dictionary <string, bool>(); foreach (string key in _cachedMenuVersions.Keys) { menuProperties[key] = "true"; } } // Poll for the menu bool commandEnabled = Root.PollForCommandState(Properties.PopulateQueryCommand, Properties.PopulateQueryCommand, menuProperties); if (commandEnabled) { Menu menu = null; string data = ""; // If the poll answerer sent XML then we use it and build a menu from it if (menuProperties.ContainsKey(PopulationJSON) && !string.IsNullOrEmpty(menuProperties[PopulationJSON])) { data = menuProperties[PopulationJSON]; } else if (menuProperties.ContainsKey(PopulationXML) && !string.IsNullOrEmpty(menuProperties[PopulationXML])) { data = Builder.ConvertXMLStringToJSON(menuProperties[PopulationXML]); } string pVersion = menuProperties.ContainsKey(PopulationVersion) ? menuProperties[PopulationVersion] : string.Empty; int pInterval = menuProperties.ContainsKey(PollAgainInterval) ? Int32.Parse(menuProperties[PollAgainInterval]) : -1; if (!string.IsNullOrEmpty(data)) { // Build the Menu from the xml and then cache it if we are suppose to menu = Root.Builder.BuildMenu(Browser.Window.Eval(data), new BuildContext(), false); if (!CUIUtility.IsNullOrUndefined(menu)) { // Store the fact that we have successfully polled for the menu once _polledOnce = true; // Store the menu in the cache of menus if need if we should if (Utility.IsTrue(Properties.CacheMenuVersions) && !string.IsNullOrEmpty(pVersion)) { CachedMenuVersions[pVersion] = menu; } } } // If the PopulationVersion was set, then we try to use a stored menu. else if (!string.IsNullOrEmpty(pVersion)) { menu = CachedMenuVersions[pVersion]; } else if (launchMenu && -1 != pInterval) { // This is used if the answering component needs to issue an asynchronous // request to get the data needed to construct the menu. PollAgainInterval // then holds the number of milliseconds until this MenuLauncher should try // polling for the Menu again. _onDelayLoadSucceeded = onDelayedLoadSucceeded; // So, in this case, we set up a timout so that we can try to poll for the menu // again in a specified number of milliseconds. Browser.Window.SetTimeout(new Action(OnTryDelayedDynamicPopulation), pInterval); // We also make sure the the _menu member is null since we are now waiting for a new one _menu = null; } if (!CUIUtility.IsNullOrUndefined(menu)) { _menu = menu; OnDynamicMenuPopulated(); } } }