Exemplo n.º 1
0
        /// <summary>
        /// Traverses the specified path, inserting <see cref="BranchNode"/>s as necessary, until the end of the path
        /// is reached, at which point the <paramref name="leafNodeProvider"/> is called to provide a leaf node to insert.
        /// </summary>
        protected void Insert(Path path, int pathDepth, Converter <PathSegment, ActionModelNode> leafNodeProvider)
        {
            int segmentCount = path.Segments.Count;

            if (segmentCount < 2)
            {
                throw new ArgumentException(SR.ExceptionInvalidActionPath);
            }

            PathSegment segment = path.Segments[pathDepth];

            if (pathDepth + 1 == segmentCount)
            {
                // this is the last path segment -> leaf node
                _childNodes.Add(leafNodeProvider(segment));
            }
            else
            {
                ActionModelNode child = FindChild(segment);
                if (child == null)
                {
                    child = new BranchNode(segment);
                    _childNodes.Add(child);
                }
                child.Insert(path, pathDepth + 1, leafNodeProvider);
            }
        }
Exemplo n.º 2
0
        public static void BuildMenu(MenuShell menu, ActionModelNode node)
        {
            if (node.PathSegment != null)
            {
				
                MenuItem menuItem;
                if (node.Action != null)
                {
                    // this is a leaf node (terminal menu item)
                    menuItem = new ActiveMenuItem((IClickAction)node.Action);
                }
                else
                {
                    // this menu item has a sub menu
					string menuText = node.PathSegment.LocalizedText.Replace('&', '_');
					menuItem = new MenuItem(menuText);
                    menuItem.Submenu = new Menu();
                }

                menu.Append(menuItem);
                menu = (MenuShell)menuItem.Submenu;
            }

            foreach (ActionModelNode child in node.ChildNodes)
            {
                BuildMenu(menu, child);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a copy of the subtree beginning at this node.
        /// </summary>
        protected ActionModelNode CloneTree()
        {
            ActionModelNode clone = CloneNode(this.PathSegment);

            foreach (ActionModelNode child in _childNodes)
            {
                clone._childNodes.Add(child.CloneTree());
            }
            return(clone);
        }
Exemplo n.º 4
0
		private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight)
		{
			ToolStripBuilder.Clear(contextMenuStrip.Items);
			if (actionModel != null)
			{
				ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes);
				if (alignRight)
					screenPoint.Offset(-contextMenuStrip.Width, 0);
				contextMenuStrip.Show(screenPoint);
			}
		}
Exemplo n.º 5
0
        /// <summary>
        /// Persists an in-memory abstract action model to the XML model.
        /// </summary>
        /// <remarks>
        /// This method functions as a counterpart to <see cref="BuildAbstractActionModel"/>. The specified abstract action model
        /// (created by <see cref="BuildAbstractActionModel"/>, or potentially modified further) is flattened and its nodes
        /// written out to the XML mode, replacing any existing model at the same qualified site. This allows action model
        /// configuration interfaces to make changes to the action model.
        /// </remarks>
        /// <param name="namespace">A namespace to qualify the site.</param>
        /// <param name="site">The site.</param>
        /// <param name="abstractActionModel">The abstract action model to be persisted.</param>
        /// <returns>An <see cref="ActionModelNode"/> representing the root of the action model.</returns>
        public void PersistAbstractActionModel(string @namespace, string site, ActionModelRoot abstractActionModel)
        {
            // do one time initialization
            if (_actionModelXmlDoc == null)
            {
                Initialize();
            }

            XmlElement separatorTemplate = _actionModelXmlDoc.CreateElement("separator");

            string actionModelId = string.Format("{0}:{1}", @namespace, site);

            XmlElement xmlActionModel = FindXmlActionModel(actionModelId);

            if (xmlActionModel != null)
            {
                // clear the action model
                List <XmlNode> childrenToClear = CollectionUtils.Cast <XmlNode>(xmlActionModel.ChildNodes);
                foreach (XmlNode childNode in childrenToClear)
                {
                    xmlActionModel.RemoveChild(childNode);
                }
            }
            else
            {
                // add a new action model
                this.GetActionModelsNode().AppendChild(xmlActionModel = CreateXmlActionModel(actionModelId));
            }

            ActionModelNode[] leafNodes = abstractActionModel.GetLeafNodesInOrder();
            for (int n = 0; n < leafNodes.Length; n++)
            {
                ActionModelNode leafNode = leafNodes[n];
                if (leafNode is ActionNode)
                {
                    xmlActionModel.AppendChild(CreateXmlAction(_actionModelXmlDoc, ((ActionNode)leafNode).Action));
                }
                else if (leafNode is SeparatorNode)
                {
                    xmlActionModel.AppendChild(separatorTemplate.Clone());
                }
            }

            if (!_temporary)
            {
                this.ActionModelsXml = _actionModelXmlDoc;
                this.Save();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Merges the specified model into this model.
 /// </summary>
 public void Merge(ActionModelNode other)
 {
     foreach (ActionModelNode otherChild in other._childNodes)
     {
         ActionModelNode thisChild = FindChild(otherChild.PathSegment);
         if (thisChild != null)
         {
             thisChild.Merge(otherChild);
         }
         else
         {
             _childNodes.Add(otherChild.CloneTree());
         }
     }
 }
        /// <summary>
        /// Searches <paramref name="actionNode"/> and returns the action (represented as HTML) whose label matches
        /// <paramref name="labelSearch"/>.
        /// </summary>
        /// <param name="actionNode">The node to be searched.</param>
        /// <param name="labelSearch">The label to match on.</param>
        /// <param name="actionLabel">The new label to be applied to the action in the returned HTML.</param>
        /// <returns>The found action represented as HTML, otherwise an empty string.</returns>
        public string GetHTML(ActionModelNode actionNode, string labelSearch, string actionLabel)
        {
            IAction[] actions = actionNode.GetActionsInOrder();
            if (actions.Length == 0)
                return "";

            // find the action corresponding to the action label, if exist
            foreach (var action in actions)
            {
                if (action.Label == labelSearch)
                    return GetHTML(action.Path.LocalizedPath, actionLabel);
            }

            return "";
        }
Exemplo n.º 8
0
        public static void BuildToolbar(Toolbar toolbar, Tooltips tooltips, ActionModelNode node, int depth)
        {
            if (node.Action != null)
            {

                // create the tool button
				ToolButton button = new ActiveToolbarButton((IClickAction)node.Action, tooltips);
                toolbar.Insert(button, toolbar.NItems);
            }
            else
            {
                foreach (ActionModelNode child in node.ChildNodes)
                {
                    BuildToolbar(toolbar, tooltips, child, depth + 1);
                }
            }
        }
		/// <summary>
		/// Constructor.
		/// </summary>
		public BiographyOrderReportsComponentControl(BiographyOrderReportsComponent component)
			: base(component)
		{
			_component = component;
			InitializeComponent();

			Control reportPreview = (Control) _component.ReportPreviewComponentHost.ComponentView.GuiElement;
			reportPreview.Dock = DockStyle.Fill;
			_reportPreviewPanel.Controls.Add(reportPreview);

			_reports.DataSource = _component.Reports;
			_reports.DataBindings.Add("Value", _component, "SelectedReport", true, DataSourceUpdateMode.OnPropertyChanged);
			_reports.Format += delegate(object sender, ListControlConvertEventArgs e) { e.Value = _component.FormatReportListItem(e.ListItem); };

			_toolbarActionModel = _component.ActionModel;
			ToolStripBuilder.BuildToolbar(_toolstrip.Items, _toolbarActionModel.ChildNodes);

			_component.AllPropertiesChanged += AllPropertiesChangedEventHandler;
		}
Exemplo n.º 10
0
		////TODO (CR May 2010): We should add in the capability for handler extensions,
		/// much like the applicationcomponent views.
		public static ActionNodeEntityHandler Create(ActionModelNode modelNode)
		{
			if (modelNode is ActionNode)
			{
				IAction action = ((ActionNode)modelNode).Action;
				if (action is DropDownButtonAction)
				{
					IEntityHandler handler = Create<DropDownButtonActionEntityHandler>();
					handler.SetModelObject(action);
					return (ActionNodeEntityHandler)handler;
				}
				if (action is DropDownAction)
				{
					IEntityHandler handler = Create<DropDownActionEntityHandler>();
					handler.SetModelObject(action);
					return (ActionNodeEntityHandler)handler;
				}
				if (action is LayoutChangerAction)
				{
					IEntityHandler handler = Create<LayoutChangerActionEntityHandler>();
					handler.SetModelObject(action);
					return (ActionNodeEntityHandler)handler;
				}
				if (action is IClickAction)
				{
					IEntityHandler handler = Create<ClickActionEntityHandler>();
					handler.SetModelObject(action);
					return (ActionNodeEntityHandler)handler;
				}
			}
			else if (modelNode.ChildNodes.Count > 0)
			{
				IEntityHandler handler = Create<BranchActionEntityHandler>();
				handler.SetModelObject(modelNode);
				return (ActionNodeEntityHandler)handler;
			}

			//TODO (CR May 2010): although we won't get here, if we did, we should throw
			return null;
		}
Exemplo n.º 11
0
 /// <summary>
 /// Sets the toolbar model, causing the toolbar displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetToolbarModel(ActionModelNode model)
 {
 }
Exemplo n.º 12
0
        private void AppendActionModel(TableView table, ActionModelNode model)
        {
            if (table.ToolbarModel == null) 
                table.ToolbarModel = model;
            else 
                table.ToolbarModel.Merge(model);

            if (table.MenuModel == null)
                table.MenuModel = model;
            else
                table.MenuModel.Merge(model);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Called to build menus and toolbars.  Override this method to customize menu and toolbar building.
        /// </summary>
        /// <remarks>
        /// The default implementation simply clears and re-creates the toolstrip using methods on the
        /// utility class <see cref="ToolStripBuilder"/>.
        /// </remarks>
        /// <param name="kind"></param>
        /// <param name="toolStrip"></param>
        /// <param name="actionModel"></param>
        protected virtual void BuildToolStrip(ToolStripBuilder.ToolStripKind kind, ToolStrip toolStrip, ActionModelNode actionModel)
        {
            // avoid flicker
            toolStrip.SuspendLayout();
            // very important to clean up the existing ones first
            ToolStripBuilder.Clear(toolStrip.Items);

            if (actionModel != null)
            {
				if (actionModel.ChildNodes.Count > 0)
				{
					// Toolstrip should only be visible if there are items on it
					if (kind == ToolStripBuilder.ToolStripKind.Toolbar)
						ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes, ToolStripBuilder.ToolStripBuilderStyle.GetDefault(), ToolStripSettings.Default.IconSize);
					else
						ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes);
                }
            }

            toolStrip.ResumeLayout();
        }
Exemplo n.º 14
0
 public void AppendToAvailableItemsActionModel(ActionModelNode model)
 {
     AppendActionModel(_availableItems, model);
 }
Exemplo n.º 15
0
	    private void ProcessExplicitContextMenuRequest(Point? location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
                ReleaseCapture(true);

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
                location = _currentMousePoint;

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType<IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs<Point>(location.Value));

            ContextMenuProvider = null;
        }
Exemplo n.º 16
0
 public static void BuildToolbar(Toolbar toolbar, Tooltips tooltips, ActionModelNode node)
 {
    BuildToolbar(toolbar, tooltips, node, 0);
 }
Exemplo n.º 17
0
			public ItemTag(ActionModelNode node, IActionView view)
			{
				_node = node;
				_view = view;
			}
Exemplo n.º 18
0
 /// <summary>
 /// Merges the specified model into this model.
 /// </summary>
 public void Merge(ActionModelNode other)
 {
     foreach (ActionModelNode otherChild in other._childNodes)
     {
         ActionModelNode thisChild = FindChild(otherChild.PathSegment);
         if (thisChild != null)
         {
             thisChild.Merge(otherChild);
         }
         else
         {
             _childNodes.Add(otherChild.CloneTree());
         }
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Sets the menu model, causing the menu displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetMenuModel(ActionModelNode model)
 {
 }
Exemplo n.º 20
0
 /// <summary>
 /// Sets the menu model, causing the menu displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// The default implementation just sets the <see cref="DesktopForm.MenuModel"/> property.
 /// Override this method if you need to perform custom processing.
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetMenuModel(ActionModelNode model)
 {
     _form.MenuModel = model;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Sets the toolbar model, causing the toolbar displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// The default implementation just sets the <see cref="DesktopForm.ToolbarModel"/> property.
 /// Override this method if you need to perform custom processing.
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetToolbarModel(ActionModelNode model)
 {
     _form.ToolbarModel = model;
 }
Exemplo n.º 22
0
 public ActionModelProvider(ActionModelNode actionModel)
 {
     _actionModel = actionModel;
 }
Exemplo n.º 23
0
 public void AppendToSelectedItemsActionModel(ActionModelNode model)
 {
     AppendActionModel(_selectedItems, model);
 }