/// <summary>
        /// Sets the properties of a control which are defined under "Actions:" in the .yaml file
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="ctrl"></param>
        /// <param name="AActionHandler"></param>
        public virtual void SetControlActionProperties(TFormWriter writer, TControlDef ctrl, TActionHandler AActionHandler)
        {
            if (AActionHandler.actionImage.Length > 0)
            {
                /* Get the name of the image for the toolbar button
                 * and put it into the resources.
                 * The images must be in the directory specified by the ResourceDir command line parameter
                 */
                writer.SetControlProperty(ctrl, "Image",
                    "((System.Drawing.Bitmap)resources" + ctrl.controlType + ".GetObject(\"" + ctrl.controlName + ".Glyph\"))");
                writer.AddImageToResource(ctrl.controlName, AActionHandler.actionImage, "Bitmap");
            }

            if ((AActionHandler.actionTooltip.Length > 0) && (ctrl.controlTypePrefix != "btn"))
            {
                writer.SetControlProperty(ctrl, "ToolTipText", "\"" + AActionHandler.actionTooltip + "\"");
            }
        }
示例#2
0
        private void AddActionHandlerImplementation(TActionHandler AAction)
        {
            // the actual call what happens when the action is executed
            // only create an action handler for calls to FPetraUtilsObject, because that would not work in the designer
            if (AAction.actionId.Length > 0)
            {
                string ActionHandler =
                    "/// auto generated" + Environment.NewLine +
                    "protected void " + AAction.actionName + "(object sender, EventArgs e)" + Environment.NewLine +
                    "{" + Environment.NewLine;
                ActionHandler += "    FPetraUtilsObject.ExecuteAction(eActionId." + AAction.actionId + ");" + Environment.NewLine;
                ActionHandler += "}" + Environment.NewLine + Environment.NewLine;

                FCodeStorage.FActionHandlers += ActionHandler;
            }
            else if (AAction.actionClick.StartsWith("FPetraUtilsObject"))
            {
                string ActionHandler =
                    "/// auto generated" + Environment.NewLine +
                    "protected void " + AAction.actionName + "(object sender, EventArgs e)" + Environment.NewLine +
                    "{" + Environment.NewLine;
                ActionHandler += "    " + AAction.actionClick + "(sender, e);" + Environment.NewLine;
                ActionHandler += "}" + Environment.NewLine + Environment.NewLine;

                FCodeStorage.FActionHandlers += ActionHandler;
            }
        }