SIL.FieldWorks.XWorks.DTMenuHandler.MakeSliceContextMenu C# (CSharp) Method

MakeSliceContextMenu() protected method

protected MakeSliceContextMenu ( Slice slice, bool fHotLinkOnly ) : ContextMenu
slice Slice
fHotLinkOnly bool
return System.Windows.Forms.ContextMenu
		protected ContextMenu MakeSliceContextMenu(Slice slice, bool fHotLinkOnly)//, bool retrieveDoNotShow)
		{
			XmlNode configuration =slice.ConfigurationNode;
			XmlNode caller = slice.CallerNode;
			string menuId = null;
			if (caller != null)
				menuId = ShowContextMenu2Id(caller, fHotLinkOnly);
			if (menuId == null || menuId.Length == 0)
				menuId = ShowContextMenu2Id(configuration, fHotLinkOnly);

			XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");

			//an empty menu attribute means no menu
			if (menuId != null && menuId.Length== 0)
				return null;

			/*			//a missing menu attribute means "figure out a default"
						if (menuId == null)
						{
							//todo: this is probably too simplistic
							//we are trying to select out just atomic objects
							//of this will currently also select "place keeping" nodes
							if(slice.IsObjectNode)
								//					configuration.HasChildNodes /*<-- that's dumb
								//					&& configuration.SelectSingleNode("seq")== null
								//					&& !(e.Slice.Object.Hvo == slice.Container.RootObjectHvo))
							{
								menuId="mnuDataTree-Object";
							}
							else //we could not figure out a default menu for this item, so fall back on the auto menu
							{	//todo: this must not be used in the final product!
								// return m_dataEntryForm.GetAutoMenu(sender, e);
								return null;
							}
						}
						if (menuId == "")
							return null;	//explicitly stated that there should not be a menu

			*/
			//ChoiceGroup group;
			if(fHotLinkOnly)
			{
				return	window.GetWindowsFormsContextMenu(menuId);
			}
			else
			{
				//string[] menus = new string[2];
				List<string> menus = new List<string>();
				menus.Add(menuId);
				if (slice is MultiStringSlice)
					menus.Add("mnuDataTree-MultiStringSlice");
				else
					menus.Add("mnuDataTree-Object");
				window.ShowContextMenu(menus.ToArray(),
					new Point(Cursor.Position.X, Cursor.Position.Y),
					null, // Don't care about a temporary colleague
					null); // or MessageSequencer
				return null;
			}

			//			group.ConfigurationNode.AppendChild(group.ConfigurationNode.OwnerDocument.ImportNode(addon,true));
			// This causes the menu to be actually populated with the items. It's a rather
			// ugly way to do it...happens all over again when the menu pops up...but we
			// need to know the actual items for various purposes, such as populating a
			// summary slice's command list. Refactoring is complicated because part of
			// the code is in a DotNetBar UiAdapter class that I can't easily modify.
			//			group.OnDisplay(null, new EventArgs());
			//			return menu;
		}