Exemplo n.º 1
0
        /// <summary>
        /// The menu items for this tree node
        /// </summary>
        /// <returns></returns>
        protected override List <MenuItem> GetMenuItems()
        {
            List <MenuItem> retVal;

            if (!IsASubVariable)
            {
                retVal = base.GetMenuItems();
                retVal.Add(new MenuItem("Delete", new EventHandler(DeleteHandler)));
            }
            else
            {
                retVal = new List <MenuItem>();
                retVal.Add(new MenuItem("Refresh", new EventHandler(RefreshNodeHandler)));
            }

            DataDictionary.Functions.Function function = Item.Value as DataDictionary.Functions.Function;
            if (function != null)
            {
                DataDictionary.Interpreter.InterpretationContext context = new DataDictionary.Interpreter.InterpretationContext(Item);
                if (function.FormalParameters.Count == 1)
                {
                    Parameter parameter = (Parameter)function.FormalParameters[0];
                    DataDictionary.Functions.Graph graph = function.createGraph(context, parameter);
                    if (graph != null && graph.Segments.Count != 0)
                    {
                        retVal.Add(new MenuItem("-"));
                        retVal.Add(new MenuItem("Display", new EventHandler(DisplayHandler)));
                    }
                }
                else if (function.FormalParameters.Count == 2)
                {
                    DataDictionary.Functions.Surface surface = function.createSurface(context);
                    if (surface != null && surface.Segments.Count != 0)
                    {
                        retVal.Add(new MenuItem("-"));
                        retVal.Add(new MenuItem("Display", new EventHandler(DisplayHandler)));
                    }
                }
            }

            if (Item.Type is StateMachine)
            {
                retVal.Add(new MenuItem("-"));
                retVal.Add(new MenuItem("View state diagram", new EventHandler(ViewStateDiagramHandler)));
            }

            return(retVal);
        }