Ejemplo n.º 1
0
 /// <summary>
 /// Set the value of this property from a string.
 /// </summary>
 /// <param name="column"></param>
 /// <param name="value"></param>
 public void setValueStr(int column, string value)
 {
     if (column == NAME_COL)
     {
         simElementManager = subScene.getSimElementManager(value);
     }
 }
Ejemplo n.º 2
0
 public void setValue(int column, Object value)
 {
     if (column == NAME_COL)
     {
         simElementManager = subScene.getSimElementManager((String)value);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Remove a SimElementManagerDefinition.
 /// </summary>
 /// <param name="def">The definition to remove.</param>
 public void removeSimElementManagerDefinition(SimElementManagerDefinition def)
 {
     elementManagers.Remove(def);
     if (editInterface != null)
     {
         simElementEditor.removeSubInterface(def);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Add a SimElementManagerDefinition.
 /// </summary>
 /// <param name="def">The definition to add.</param>
 public void addSimElementManagerDefinition(SimElementManagerDefinition def)
 {
     elementManagers.Add(def);
     if (editInterface != null)
     {
         createEditInterface(def);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Add a binding.
        /// </summary>
        /// <param name="toBind">The SimElementManagerDefinition to bind to this SimSubScene</param>
        public void addBinding(SimElementManagerDefinition toBind)
        {
            SimSubSceneBinding binding = new SimSubSceneBinding(this, toBind.Name);

            bindings.AddLast(binding);
            if (editInterface != null)
            {
                editInterface.addEditableProperty(binding);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Determine if the given SimElementManager type is already contained
 /// in this SimSubSceneDefinition. SimSubScenes can only have one of
 /// each type of SimElementManager in them.
 /// </summary>
 /// <param name="check">The SimElementManagerDefinition to check types of.</param>
 /// <returns>True if this definition already contains a SimElementManagerDefinition of the given type.</returns>
 public bool hasTypeBindings(SimElementManagerDefinition check)
 {
     foreach (SimSubSceneBinding binding in bindings)
     {
         if (binding.SimElementManager != null && binding.SimElementManager.getSimElementManagerType() == check.getSimElementManagerType())
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Remove a binding.
        /// </summary>
        /// <param name="toBind">The SimElementManagerDefinition to remove from this SimSubScene</param>
        public void removeBinding(SimElementManagerDefinition toBind)
        {
            SimSubSceneBinding found = null;

            foreach (SimSubSceneBinding binding in bindings)
            {
                if (binding.SimElementManager == toBind)
                {
                    found = binding;
                    break;
                }
            }
            if (found != null)
            {
                bindings.Remove(found);
                if (editInterface != null)
                {
                    editInterface.removeEditableProperty(found);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Determine if the given string is in the correct format for this
 /// property to parse.
 /// </summary>
 /// <param name="column"></param>
 /// <param name="value">The value to try to parse.</param>
 /// <param name="errorMessage">An error message if the function returns false.</param>
 /// <returns>True if the string can be parsed.</returns>
 public bool canParseString(int column, string value, out string errorMessage)
 {
     if (column == NAME_COL && value != null && value != String.Empty)
     {
         SimElementManagerDefinition def = subScene.getSimElementManager(value);
         if (simElementManager == null || def != simElementManager)
         {
             if (def == null)
             {
                 errorMessage = String.Format("Could not find a SimElementManagerDefinition named {0}", value);
                 return(false);
             }
             if (subScene.hasTypeBindings(def))
             {
                 errorMessage = String.Format("This SubSceneDefinition already has a binding for the type {0}", def.GetType().Name);
                 return(false);
             }
         }
     }
     errorMessage = null;
     return(true);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor takes a SubScene and a SimElementManagerDefinition.
 /// </summary>
 /// <param name="subScene">The SubSceneDefinition.</param>
 /// <param name="simElementManager">The SimElementManagerDefinition.</param>
 public SimSubSceneBinding(SimSubSceneDefinition subScene, SimElementManagerDefinition simElementManager)
 {
     this.subScene          = subScene;
     this.simElementManager = simElementManager;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor takes a name and a subScene.
 /// </summary>
 /// <param name="subScene">The SubScene to add bindings to.</param>
 /// <param name="managerName">The name of the SimElementManager.</param>
 public SimSubSceneBinding(SimSubSceneDefinition subScene, String managerName)
 {
     this.subScene     = subScene;
     simElementManager = subScene.getSimElementManager(managerName);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Helper function to create an edit interface.
 /// </summary>
 /// <param name="def"></param>
 private void createEditInterface(SimElementManagerDefinition def)
 {
     simElementEditor.addSubInterface(def, def.getEditInterface());
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Get the EditInterface for this SimSceneDefinition.
        /// </summary>
        /// <returns>The EditInterface for this SimSceneDefinition.</returns>
        public EditInterface getEditInterface()
        {
            if (editInterface == null)
            {
                editInterface = ReflectedEditInterface.createEditInterface(this, ReflectedEditInterface.DefaultScanner, "Sim Scene", () =>
                {
                    if (hasSimSubSceneDefinitions())
                    {
                        if (DefaultSubScene == null)
                        {
                            throw new ValidationException("Please specify one of the Subscenes as the default.");
                        }
                        if (!hasSimSubSceneDefinition(DefaultSubScene))
                        {
                            throw new ValidationException("{0} is not a valid Subscene. Please specify an existing scene.", DefaultSubScene);
                        }
                    }
                });
                editInterface.IconReferenceTag = EngineIcons.Scene;

                simElementEditor = new EditInterface("Sim Element Managers");
                var elementManagerInterfaces = simElementEditor.createEditInterfaceManager <SimElementManagerDefinition>();
                elementManagerInterfaces.addCommand(new EditInterfaceCommand("Destroy", destroySimElementManagerDefinition));
                foreach (AddSimElementManagerCommand command in PluginManager.Instance.getCreateSimElementManagerCommands())
                {
                    simElementEditor.addCommand(new EditInterfaceCommand(command.Name, callback =>
                    {
                        callback.getInputString("Enter a name.", delegate(String input, ref String errorPrompt)
                        {
                            if (input == null || input == "")
                            {
                                errorPrompt = "Please enter a non empty name.";
                                return(false);
                            }
                            if (this.hasSimElementManagerDefinition(input))
                            {
                                errorPrompt = "That name is already in use. Please provide another.";
                                return(false);
                            }

                            SimElementManagerDefinition def = command.execute(input, callback);
                            this.addSimElementManagerDefinition(def);

                            return(true);
                        });
                    }));
                }
                editInterface.addSubInterface(simElementEditor);

                subScenes = new EditInterface("Subscenes");
                var subSceneInterfaces = subScenes.createEditInterfaceManager <SimSubSceneDefinition>();
                subSceneInterfaces.addCommand(new EditInterfaceCommand("Destroy", destroySimSubSceneDefinition));
                EditInterfaceCommand createSubSceneCommand = new EditInterfaceCommand("Create Subscene", createSimSubSceneDefinition);
                subScenes.addCommand(createSubSceneCommand);
                editInterface.addSubInterface(subScenes);

                foreach (SimElementManagerDefinition elementDef in elementManagers)
                {
                    createEditInterface(elementDef);
                }
                foreach (SimSubSceneDefinition subSceneDef in subSceneDefinitions.Values)
                {
                    createEditInterface(subSceneDef);
                }
            }
            return(editInterface);
        }