Пример #1
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            base.SetControlProperties(writer, ctrl);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                writer.SetControlProperty(ctrl,
                                          "Text",
                                          "\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue") + "\"");
            }

            if ((TYml2Xml.HasAttribute(ctrl.xmlNode, "Multiline")) && (TYml2Xml.GetAttribute(ctrl.xmlNode, "Multiline") == "true"))
            {
                writer.SetControlProperty(ctrl, "Multiline", "true");

                if ((TYml2Xml.HasAttribute(ctrl.xmlNode, "WordWrap")) && (TYml2Xml.GetAttribute(ctrl.xmlNode, "WordWrap") == "false"))
                {
                    writer.SetControlProperty(ctrl, "WordWrap", "false");
                }

                if (TYml2Xml.HasAttribute(ctrl.xmlNode, "ScrollBars"))
                {
                    writer.SetControlProperty(ctrl, "ScrollBars", "ScrollBars." + TYml2Xml.GetAttribute(ctrl.xmlNode, "ScrollBars"));
                }
            }

            writer.Template.AddToCodelet("ASSIGNFONTATTRIBUTES",
                                         "this." + ctrl.controlName + ".Font = TAppSettingsManager.GetDefaultBoldFont();" + Environment.NewLine);

            return(writer.FTemplate);
        }
Пример #2
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            // Support NoLabel=true
            FGenerateLabel = true;

            if (GenerateLabel(ctrl))
            {
                writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(ctrl.Label) + 30).ToString());
            }
            else
            {
                ctrl.SetAttribute("Width", "15");
            }

            base.SetControlProperties(writer, ctrl);

            FGenerateLabel = false;

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "RadioChecked"))
            {
                writer.SetControlProperty(ctrl,
                                          "Checked",
                                          TYml2Xml.GetAttribute(ctrl.xmlNode, "RadioChecked"));
            }

            return(writer.FTemplate);
        }
Пример #3
0
 /// <summary>
 /// check if the control has an attribute with the property name in the xml definition
 /// if such an attribute exists, then set it
 /// </summary>
 /// <param name="ACtrl"></param>
 /// <param name="APropertyName"></param>
 public virtual void SetControlProperty(TControlDef ACtrl, string APropertyName)
 {
     if (TYml2Xml.HasAttribute(ACtrl.xmlNode, APropertyName))
     {
         SetControlProperty(ACtrl, APropertyName, TYml2Xml.GetAttribute(ACtrl.xmlNode, APropertyName));
     }
 }
Пример #4
0
        /// <summary>
        /// add a folder to the list
        /// </summary>
        public void AddFolder(XmlNode AFolderNode, string AUserId, CheckAccessPermissionDelegate AHasAccessPermission)
        {
            TRbtNavigationButton rbt = new TRbtNavigationButton(FolderCheckChanging);

            this.sptNavigation.Panel2.Controls.Add(rbt);
            rbt.Dock = System.Windows.Forms.DockStyle.Bottom;
            rbt.Tag  = AFolderNode;
            rbt.Name = "rbt" + AFolderNode.Name;
            rbt.Text = GetLabel(AFolderNode);

            // TODO: pick up icon from within the resx file, if it is available?
            if (TYml2Xml.HasAttribute(AFolderNode,
                                      "Icon") &&
                System.IO.File.Exists(ResourceDirectory + System.IO.Path.DirectorySeparatorChar +
                                      TYml2Xml.GetAttribute(AFolderNode, "Icon")))
            {
                rbt.Icon = ResourceDirectory + System.IO.Path.DirectorySeparatorChar + TYml2Xml.GetAttribute(AFolderNode, "Icon");
            }

            rbt.CheckedChanged += new System.EventHandler(this.FolderCheckedChanged);

            if ((TYml2Xml.HasAttribute(AFolderNode, "Enabled")) &&
                (TYml2Xml.GetAttribute(AFolderNode, "Enabled").ToLower() == "false"))
            {
                rbt.Enabled = false;
            }
            else
            {
                rbt.Enabled = AHasAccessPermission(AFolderNode, AUserId, false);
            }
        }
Пример #5
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            // TODO this does not work yet. see EventRole Maintain screen
            if ((!ctrl.HasAttribute("Align")) &&
                (!ctrl.HasAttribute("Width")))
            {
                ctrl.SetAttribute("Stretch", "horizontally");
            }

            base.SetControlProperties(writer, ctrl);

            TControlDef parentCtrl = writer.FCodeStorage.GetControl(ctrl.parentName);

            // We need to over-ride any Anchor requests in the YAML to anchor an attached label to anything other than top-left
            // But pure label controls can be anchored to, say, left-top-right
            if ((ctrl.controlName.Substring(ctrl.controlTypePrefix.Length) == parentCtrl.controlName.Substring(parentCtrl.controlTypePrefix.Length)) ||
                ((ctrl.HasAttribute("Dock") == false) && (ctrl.HasAttribute("Align") == false)))
            {
                // stretch at design time, but do not align to the right
                writer.SetControlProperty(ctrl, "Anchor",
                                          "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)))");
            }

            string labelText = "";

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "Text"))
            {
                labelText = TYml2Xml.GetAttribute(ctrl.xmlNode, "Text");
            }
            else
            {
                labelText = ctrl.Label + ":";
            }

            if (ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", ctrl.GetAttribute("Width"));
            }
            else
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(labelText) + 5).ToString());
            }

            if (ctrl.HasAttribute("Height"))
            {
                ctrl.SetAttribute("Height", ctrl.GetAttribute("Height"));
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + labelText + "\"");
            writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 5, 0, 0)");

            if (FRightAlign)
            {
                writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.TopRight");
            }

            return(writer.FTemplate);
        }
Пример #6
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            Int32 buttonWidth  = 40;
            Int32 textBoxWidth = 80;

            // seems to be hardcoded in csharp\ICT\Petra\Client\CommonControls\Gui\txtAutoPopulatedButtonLabel.Designer.cs
            Int32 controlWidth = 390;

            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
                controlWidth = 120;
            }

            // Note: the control defaults to 'ShowLabel' true, so this doesn't need to be set to 'true' in code.

            writer.SetControlProperty(ctrl, "ASpecialSetting", "true");
            writer.SetControlProperty(ctrl, "ButtonTextAlign", "System.Drawing.ContentAlignment.MiddleCenter");
            writer.SetControlProperty(ctrl, "ListTable", "TtxtAutoPopulatedButtonLabel.TListTableEnum." +
                                      FButtonLabelType);
            writer.SetControlProperty(ctrl, "PartnerClass", "\"" + ctrl.GetAttribute("PartnerClass") + "\"");
            writer.SetControlProperty(ctrl, "MaxLength", "32767");
            writer.SetControlProperty(ctrl, "Tag", "\"CustomDisableAlthoughInvisible\"");
            writer.SetControlProperty(ctrl, "TextBoxWidth", textBoxWidth.ToString());

            if (!(ctrl.HasAttribute("ReadOnly") && (ctrl.GetAttribute("ReadOnly").ToLower() == "true")))
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", buttonWidth.ToString());
                writer.SetControlProperty(ctrl, "ReadOnly", "false");
                writer.SetControlProperty(ctrl,
                                          "Font",
                                          "new System.Drawing.Font(\"Verdana\", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)0)");
                writer.SetControlProperty(ctrl, "ButtonText", "\"Find\"");
            }
            else
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", "0");
                writer.SetControlProperty(ctrl, "BorderStyle", "System.Windows.Forms.BorderStyle.None");
                writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 4, 0, 0)");
            }

            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", controlWidth.ToString());
            }

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                writer.SetControlProperty(ctrl,
                                          "Text",
                                          "\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue") + "\"");
            }

            return(writer.FTemplate);
        }
Пример #7
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (SimplePrefixMatch(curNode))
            {
                return(TYml2Xml.HasAttribute(curNode, "List"));
            }

            return(false);
        }
Пример #8
0
        /// <summary>
        /// get value of attribute from yaml
        /// </summary>
        public string GetAttribute(string name, string ADefaultValue)
        {
            if (!TYml2Xml.HasAttribute(xmlNode, name))
            {
                return(ADefaultValue);
            }

            return(TYml2Xml.GetAttribute(xmlNode, name));
        }
        /// <summary>
        /// add Catalog.GetString for each label and description in the UINavigation file to the dummy file to prepare the translation files
        /// </summary>
        /// <param name="UINavigationFilename">yml file</param>
        /// <param name="ATranslationWriter">dummy cs file that is used to provide the strings to gettext</param>
        public static void AddTranslationUINavigation(string UINavigationFilename, StreamWriter ATranslationWriter)
        {
            TYml2Xml    parser = new TYml2Xml(UINavigationFilename);
            XmlDocument doc    = parser.ParseYML2XML();

            XmlNode OpenPetraNode   = doc.FirstChild.NextSibling.FirstChild;
            XmlNode SearchBoxesNode = OpenPetraNode.FirstChild;
            XmlNode MainMenuNode    = SearchBoxesNode.NextSibling;
            XmlNode DepartmentNode  = MainMenuNode.FirstChild;

            while (DepartmentNode != null)
            {
                ATranslationWriter.WriteLine("Catalog.GetString(\"" + GetLabelOrName(DepartmentNode) + "\");");

                XmlNode ModuleNode = DepartmentNode.FirstChild;

                while (ModuleNode != null)
                {
                    ATranslationWriter.WriteLine("Catalog.GetString(\"" + GetLabelOrName(ModuleNode) + "\");");

                    XmlNode SubModuleNode = ModuleNode.FirstChild;

                    while (SubModuleNode != null)
                    {
                        ATranslationWriter.WriteLine("Catalog.GetString(\"" + GetLabelOrName(SubModuleNode) + "\");");
                        XmlNode TaskGroupNode = SubModuleNode.FirstChild;

                        while (TaskGroupNode != null)
                        {
                            ATranslationWriter.WriteLine("Catalog.GetString(\"" + GetLabelOrName(TaskGroupNode) + "\");");
                            XmlNode TaskNode = TaskGroupNode.FirstChild;

                            while (TaskNode != null)
                            {
                                ATranslationWriter.WriteLine("Catalog.GetString(\"" + GetLabelOrName(TaskNode) + "\");");

                                if (TYml2Xml.HasAttribute(TaskNode, "Description"))
                                {
                                    ATranslationWriter.WriteLine("Catalog.GetString(\"" + TYml2Xml.GetAttribute(TaskNode, "Description") + "\");");
                                }

                                TaskNode = TaskNode.NextSibling;
                            }

                            TaskGroupNode = TaskGroupNode.NextSibling;
                        }

                        SubModuleNode = SubModuleNode.NextSibling;
                    }

                    ModuleNode = ModuleNode.NextSibling;
                }

                DepartmentNode = DepartmentNode.NextSibling;
            }
        }
Пример #10
0
        /// <summary>
        /// set the orientation based on the attribute: ControlsOrientation;
        /// the default is vertical
        /// </summary>
        /// <param name="ACtrl"></param>
        public void SetOrientation(TControlDef ACtrl)
        {
            FOrientation = eOrientation.Vertical;

            if (TYml2Xml.HasAttribute(ACtrl.xmlNode, "ControlsOrientation") &&
                (TYml2Xml.GetAttribute(ACtrl.xmlNode, "ControlsOrientation").ToLower() == "horizontal"))
            {
                FOrientation = eOrientation.Horizontal;
            }
        }
Пример #11
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (base.ControlFitsNode(curNode))
            {
                return(!TYml2Xml.HasAttribute(curNode, "List") &&
                       !TYml2Xml.HasAttribute(curNode, "AutoComplete") &&
                       !TYml2Xml.HasAttribute(curNode, "MultiColumn"));
            }

            return(false);
        }
Пример #12
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            base.SetControlProperties(writer, ctrl);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                writer.SetControlProperty(ctrl,
                                          "Text",
                                          "\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue") + "\"");
            }

            if ((TYml2Xml.HasAttribute(ctrl.xmlNode, "Multiline")) && (TYml2Xml.GetAttribute(ctrl.xmlNode, "Multiline") == "true"))
            {
                writer.SetControlProperty(ctrl, "Multiline", "true");

                if ((TYml2Xml.HasAttribute(ctrl.xmlNode, "WordWrap")) && (TYml2Xml.GetAttribute(ctrl.xmlNode, "WordWrap") == "false"))
                {
                    writer.SetControlProperty(ctrl, "WordWrap", "false");
                }

                if (TYml2Xml.HasAttribute(ctrl.xmlNode, "ScrollBars"))
                {
                    writer.SetControlProperty(ctrl, "ScrollBars", "ScrollBars." + TYml2Xml.GetAttribute(ctrl.xmlNode, "ScrollBars"));
                }

                if (TYml2Xml.HasAttribute(ctrl.xmlNode, "MinimumSize"))
                {
                    writer.SetControlProperty(ctrl, "MinimumSize", "new System.Drawing.Size(" + TYml2Xml.GetAttribute(ctrl.xmlNode,
                                                                                                                      "MinimumSize") + ")");
                }
            }

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "TextAlign"))
            {
                writer.SetControlProperty(ctrl, "TextAlign", "HorizontalAlignment." + TYml2Xml.GetAttribute(ctrl.xmlNode, "TextAlign"));
            }

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "CharacterCasing"))
            {
                writer.SetControlProperty(ctrl, "CharacterCasing", "CharacterCasing." +
                                          TYml2Xml.GetAttribute(ctrl.xmlNode, "CharacterCasing"));
            }

            if ((TYml2Xml.HasAttribute(ctrl.xmlNode, "PasswordEntry")) && (TYml2Xml.GetAttribute(ctrl.xmlNode, "PasswordEntry") == "true"))
            {
                writer.SetControlProperty(ctrl, "UseSystemPasswordChar", "true");
            }

            writer.Template.AddToCodelet("ASSIGNFONTATTRIBUTES",
                                         "this." + ctrl.controlName + ".Font = TAppSettingsManager.GetDefaultBoldFont();" + Environment.NewLine);

            return(writer.FTemplate);
        }
Пример #13
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (base.ControlFitsNode(curNode))
            {
                if (TXMLParser.GetChild(curNode, "OptionalValues") != null)
                {
                    return(!TYml2Xml.HasAttribute(curNode, "BorderVisible") ||
                           TYml2Xml.GetAttribute(curNode, "BorderVisible").ToLower() != "false");
                }
            }

            return(false);
        }
Пример #14
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            // TODO this does not work yet. see EventRole Maintain screen
            if ((!ctrl.HasAttribute("Align")) &&
                (!ctrl.HasAttribute("Width")))
            {
                ctrl.SetAttribute("Stretch", "horizontally");
            }

            base.SetControlProperties(writer, ctrl);

            // stretch at design time, but do not align to the right
            writer.SetControlProperty(ctrl, "Anchor",
                                      "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)))");

            string labelText = "";

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "Text"))
            {
                labelText = TYml2Xml.GetAttribute(ctrl.xmlNode, "Text");
            }
            else
            {
                labelText = ctrl.Label + ":";
            }

            if (ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", ctrl.GetAttribute("Width"));
            }
            else
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(labelText) + 5).ToString());
            }

            if (ctrl.HasAttribute("Height"))
            {
                ctrl.SetAttribute("Height", ctrl.GetAttribute("Height"));
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + labelText + "\"");
            writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 5, 0, 0)");

            if (FRightAlign)
            {
                writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.TopRight");
            }

            return(writer.FTemplate);
        }
Пример #15
0
        //
        // Get the Icon for this task. If none was supplied, I'll return my parent's icon.
        private string DetermineIconForTask(XmlNode TaskNode)
        {
            if (TYml2Xml.HasAttribute(TaskNode, "Icon"))
            {
                return(FResourceDirectory + System.IO.Path.DirectorySeparatorChar +
                       TaskNode.Attributes["Icon"].Value);
            }

            if (TaskNode.ParentNode != null)
            {
                return(DetermineIconForTask(TaskNode.ParentNode));
            }

            return(null);
        }
Пример #16
0
        /// <summary>
        /// form the name of a parameter
        /// </summary>
        public static string GetParameterName(XmlNode curNode)
        {
            if (TYml2Xml.HasAttribute(curNode, "NoParameter") && (TYml2Xml.GetAttribute(curNode, "NoParameter").ToLower() == "true"))
            {
                return(null);
            }

            string result = "param_" + curNode.Name;

            if (TYml2Xml.HasAttribute(curNode, "ParameterName"))
            {
                result = TYml2Xml.GetAttribute(curNode, "ParameterName");
            }

            return(result);
        }
Пример #17
0
        /// <summary>
        /// give information if a value should be cleared if there is no value in the settings file
        /// </summary>
        public static bool GetClearIfSettingEmpty(XmlNode curNode)
        {
            if (TYml2Xml.HasAttribute(curNode, "ClearIfSettingEmpty"))
            {
                if (TYml2Xml.GetAttribute(curNode, "ClearIfSettingEmpty").ToLower() == "true")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #18
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (base.ControlFitsNode(curNode))
            {
                if (TYml2Xml.HasAttribute(curNode, "Type"))
                {
                    if ((TYml2Xml.GetAttribute(curNode, "Type") == "Hyperlink"))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }
Пример #19
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            bool   ReturnValue = false;
            string NumberFormat;
            string PotentialNullValue;

//Console.WriteLine("TTxtCurrencyTextBoxGenerator ControlFitsNode");
            if (base.ControlFitsNode(curNode))
            {
                FDefaultWidth = 80;

                NumberFormat = TYml2Xml.GetAttribute(curNode, "Format");

//Console.WriteLine("TTxtCurrencyTextBoxGenerator Format: '" + NumberFormat + "'");
                if ((NumberFormat == "Currency") ||
                    (NumberFormat.StartsWith("Currency(")))
                {
                    FDefaultWidth = 150;
                    ReturnValue   = true;
                }

                if (ReturnValue)
                {
                    if (TYml2Xml.HasAttribute(curNode, "NullValueAllowed"))
                    {
                        PotentialNullValue = TYml2Xml.GetAttribute(curNode, "NullValueAllowed");

                        if ((PotentialNullValue == "true") ||
                            (PotentialNullValue == "false"))
                        {
                            FNullValueAllowed = Convert.ToBoolean(PotentialNullValue);
                        }
                        else
                        {
                            throw new ApplicationException(
                                      "TextBox with currency formatting: Value for 'NullValueAllowed' needs to be either 'true' or 'false', but is '" +
                                      PotentialNullValue + "'.");
                        }
                    }
                }

                return(ReturnValue);
            }

            return(false);
        }
Пример #20
0
        /// <summary>check if the generator fits the given control by checking the prefix and perhaps some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (base.ControlFitsNode(curNode))
            {
                if ((TYml2Xml.GetAttribute(curNode, "Format") != String.Empty))
                {
                    return(false);
                }

//Console.WriteLine("TTxtLinkTextBoxGenerator ControlFitsNode");
                if (TYml2Xml.GetAttribute(curNode, "Type") == "Hyperlink")
                {
                    if (TYml2Xml.HasAttribute(curNode, "LinkType"))
                    {
//Console.WriteLine("TTxtLinkTextBoxGenerator: LinkType=" + TYml2Xml.GetAttribute(curNode, "LinkType"));
                        string LinkTypeStr = TYml2Xml.GetAttribute(curNode, "LinkType").ToLower();

                        if (LinkTypeStr == "http")
                        {
                            FLinkType = "Http";
                        }
                        else if (LinkTypeStr == "ftp")
                        {
                            FLinkType = "Ftp";
                        }
                        else if (LinkTypeStr == "email")
                        {
                            FLinkType = "Email";
                        }
                        else if (LinkTypeStr == "ftp")
                        {
                            FLinkType = "Ftp";
                        }
                        else if (LinkTypeStr == "skype")
                        {
                            FLinkType = "Skype";
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
Пример #21
0
        /// <summary>check if the generator fits the given control by checking the prefix and some of the attributes</summary>
        public override bool ControlFitsNode(XmlNode curNode)
        {
            if (SimplePrefixMatch(curNode))
            {
                if (TYml2Xml.HasAttribute(curNode, "Label"))
                {
                    base.FGenerateLabel = true;
                }

                if (TXMLParser.GetChild(curNode, "Controls") == null)
                {
                    return(TYml2Xml.HasAttribute(curNode, "BorderVisible") &&
                           TYml2Xml.GetAttribute(curNode, "BorderVisible").ToLower() == "false");
                }
            }

            return(false);
        }
Пример #22
0
        /// <summary>
        /// get the correct control generator for the control, depending on the prefix of the name, and other parameters
        /// </summary>
        /// <param name="ACtrlDef"></param>
        /// <returns></returns>
        public IControlGenerator FindControlGenerator(TControlDef ACtrlDef)
        {
            IControlGenerator fittingGenerator = null;

            if (ACtrlDef.controlGenerator != null)
            {
                return(ACtrlDef.controlGenerator);
            }

            foreach (IControlGenerator generator in AvailableControlGenerators)
            {
                if (generator.ControlFitsNode(ACtrlDef.xmlNode))
                {
                    if (fittingGenerator != null)
                    {
                        throw new Exception(
                                  "Error: control with name " + ACtrlDef.xmlNode.Name + " does fit both control generators " +
                                  fittingGenerator.ControlType +
                                  " and " +
                                  generator.ControlType);
                    }

                    fittingGenerator = generator;
                }
            }

            if ((fittingGenerator == null) &&
                (!ACtrlDef.controlName.StartsWith("Empty")))
            {
                if (TYml2Xml.HasAttribute(ACtrlDef.xmlNode, "Type") && (FBaseControlGeneratorType != null))
                {
                    return((IControlGenerator)Activator.CreateInstance(FBaseControlGeneratorType, new Object[] { ACtrlDef.xmlNode.Name.Substring(0,
                                                                                                                                                 3),
                                                                                                                 TYml2Xml.GetAttribute(ACtrlDef.
                                                                                                                                       xmlNode, "Type") }));
                }

                throw new Exception("Error: cannot find a generator for control with name " + ACtrlDef.xmlNode.Name);
            }

            ACtrlDef.controlGenerator = fittingGenerator;

            return(fittingGenerator);
        }
Пример #23
0
        private static Dictionary <string, object> AddFolder(XmlNode AFolderNode, string AUserId)
        {
            // TODO icon?

            // enabled/disabled based on permissions
            bool enabled = true;

            if ((TYml2Xml.HasAttribute(AFolderNode, "Enabled")) &&
                (TYml2Xml.GetAttribute(AFolderNode, "Enabled").ToLower() == "false"))
            {
                enabled = false;
            }
            else
            {
                enabled = HasAccessPermission(AFolderNode, AUserId, false);
            }

            Dictionary <string, object> folder = new Dictionary <string, object>();

            folder.Add("caption", GetCaption(AFolderNode, true));
            folder.Add("icon", TYml2Xml.GetAttribute(AFolderNode, "fa-icon"));

            if (!enabled)
            {
                folder.Add("enabled", "false");
            }

            Dictionary <string, object> items = new Dictionary <string, object>();

            foreach (XmlNode child in AFolderNode.ChildNodes)
            {
                Dictionary <string, object> item = new Dictionary <string, object>();
                item.Add("caption", GetCaption(child, true));
                if (child.ChildNodes.Count == 1 && child.ChildNodes[0].ChildNodes.Count == 0)
                {
                    item.Add("form", child.ChildNodes[0].Name);
                }
                items.Add(child.Name, item);
            }

            folder.Add("items", items);

            return(folder);
        }
Пример #24
0
        private static StringBuilder AddFolder(XmlNode AFolderNode, string AUserId)
        {
            // TODO icon?

            // TODO enabled/disabled based on permissions
#if TODO
            if ((TYml2Xml.HasAttribute(AFolderNode, "Enabled")) &&
                (TYml2Xml.GetAttribute(AFolderNode, "Enabled").ToLower() == "false"))
            {
                rbt.Enabled = false;
            }
            else
            {
                rbt.Enabled = AHasAccessPermission(AFolderNode, AUserId, false);
            }
#endif

            StringBuilder JavascriptCode = new StringBuilder();
            JavascriptCode.Append("AddMenuGroup('" + AFolderNode.Name + "', '" + GetCaption(
                                      AFolderNode) + "', function(parent) " + Environment.NewLine);
            JavascriptCode.Append("{" + Environment.NewLine);

            foreach (XmlNode child in AFolderNode.ChildNodes)
            {
                if (TYml2Xml.GetAttribute(child, "SkipThisLevel") == "true")
                {
                    foreach (XmlNode child2 in child.ChildNodes)
                    {
                        JavascriptCode.Append("AddMenuItem(parent, '" + AFolderNode.Name + "_" + child2.Name + "', '" +
                                              GetCaption(child2) + "', '" + GetCaption(AFolderNode) + ": " + GetCaption(child2) + "');" + Environment.NewLine);
                    }
                }
                else
                {
                    JavascriptCode.Append("AddMenuItem(parent, '" + AFolderNode.Name + "_" + child.Name + "', '" +
                                          GetCaption(child) + "', '" + GetCaption(AFolderNode) + " " + GetCaption(child) + "');" + Environment.NewLine);
                }
            }

            JavascriptCode.Append("});" + Environment.NewLine);

            return(JavascriptCode);
        }
Пример #25
0
        /// parse basic things: BaseClass, FormTitle, Namespace
        public void LoadFormProperties(XmlNode formNode)
        {
            FCodeStorage.FBaseClass       = TYml2Xml.GetAttribute(formNode, "BaseClass");
            FCodeStorage.FInterfaceName   = TYml2Xml.GetAttribute(formNode, "InterfaceName");
            FCodeStorage.FUtilObjectClass = TYml2Xml.GetAttribute(formNode, "UtilObjectClass");
            FCodeStorage.FFormTitle       = TYml2Xml.GetAttribute(formNode, "FormTitle");
            FCodeStorage.FNamespace       = TYml2Xml.GetAttribute(formNode, "Namespace");
            FCodeStorage.FTemplate        = TYml2Xml.GetAttribute(formNode, "Template");

            if ((FCodeStorage.FBaseClass == "System.Windows.Forms.UserControl") ||
                (FCodeStorage.FBaseClass == "TGrpCollapsible"))
            {
                FCodeStorage.FClassName = "T" + Path.GetFileNameWithoutExtension(FCodeStorage.FFilename);
            }
            else
            {
                FCodeStorage.FClassName = "TFrm" + Path.GetFileNameWithoutExtension(FCodeStorage.FFilename);
            }

            if (FCodeStorage.HasAttribute("ClassName"))
            {
                FCodeStorage.FClassName = FCodeStorage.GetAttribute("ClassName");
            }

            if (TYml2Xml.HasAttribute(formNode, "WindowHeight"))
            {
                FCodeStorage.FHeight = Convert.ToInt32(TYml2Xml.GetAttribute(formNode, "WindowHeight"));
            }

            if (TYml2Xml.HasAttribute(formNode, "WindowWidth"))
            {
                FCodeStorage.FWidth = Convert.ToInt32(TYml2Xml.GetAttribute(formNode, "WindowWidth"));
            }

            if (TYml2Xml.HasAttribute(formNode, "Height") || TYml2Xml.HasAttribute(formNode, "Width"))
            {
                TLogging.Log("Warning: Please use WindowWidth and WindowHeight, because Width and Height for the root node are invalid");
            }
        }
Пример #26
0
        private Dictionary <string, object> AddFolder(XmlNode AFolderNode, TPetraPrincipal AUserInfo)
        {
            // enabled/disabled based on permissions
            bool enabled = true;

            if ((TYml2Xml.HasAttribute(AFolderNode, "Enabled")) &&
                (TYml2Xml.GetAttribute(AFolderNode, "Enabled").ToLower() == "false"))
            {
                enabled = false;
            }
            else
            {
                enabled = HasAccessPermission(AFolderNode, AUserInfo);
            }

            if (!enabled)
            {
                return(null);
            }

            Dictionary <string, object> folder = new Dictionary <string, object>();

            folder.Add("caption", GetCaption(AFolderNode, true));
            folder.Add("icon", TYml2Xml.GetAttribute(AFolderNode, "fa-icon"));

            if (!enabled)
            {
                folder.Add("enabled", "false");
            }

            folder.Add("items", GetChildItems(AFolderNode, AFolderNode.Name, AUserInfo));

            if (File.Exists(TAppSettingsManager.GetValue("Forms.Path") + "/" + AFolderNode.Name + ".html"))
            {
                folder["htmlexists"] = true;
            }

            return(folder);
        }
Пример #27
0
        /// only to be called by TParseXAML when loading the controls from the file
        /// don't call this for creating new nodes; use FindOrCreateControl instead
        public TControlDef AddControl(XmlNode AParsedNode)
        {
            if (AParsedNode.Name == "base")
            {
                throw new Exception("should not parse the 'base' node this way");
            }

            string parsedNodeName = AParsedNode.Name;

            if (TYml2Xml.HasAttribute(AParsedNode, "UniqueName"))
            {
                parsedNodeName = TYml2Xml.GetAttribute(AParsedNode, "UniqueName");
            }

            TControlDef result = GetControl(parsedNodeName);

            if (result != null)
            {
                // this node already existed in a base yaml and is now being overwritten

                // this should never happen
                string  nameDetails = AParsedNode.Name;
                XmlNode parentNode  = AParsedNode.ParentNode;

                while ((parentNode != null) && (parentNode.Name != "AutoConvertedYML2XML"))
                {
                    nameDetails = parentNode.Name + "." + nameDetails;
                    parentNode  = parentNode.ParentNode;
                }

                throw new Exception("please use FindOrCreateControl(XmlNode) only when loading from the XAML file (" +
                                    nameDetails + ")");
            }

            result = new TControlDef(AParsedNode, this);
            FControlList.Add(parsedNodeName, result);
            FSortedControlList.Add(FSortedControlList.Count, result);
            return(result);
        }
Пример #28
0
        /// <summary>add GeneratedReadSetControls</summary>
        public override void ApplyDerivedFunctionality(TFormWriter writer, TControlDef control)
        {
            string controlName = control.xmlNode.Name;

            writer.Template.AddToCodelet("INITIALISESCREEN",
                                         controlName + ".InitialiseData(FPetraUtilsObject);" +
                                         Environment.NewLine);

            if (!(TYml2Xml.HasAttribute(control.xmlNode, "NoParameter") && (TYml2Xml.GetAttribute(control.xmlNode, "NoParameter").ToLower() == "true")))
            {
                writer.Template.AddToCodelet("READCONTROLS",
                                             controlName + ".ReadControls(ACalc, AReportAction);" +
                                             Environment.NewLine);

                writer.Template.AddToCodelet("SETCONTROLS",
                                             controlName + ".SetControls(AParameters);" +
                                             Environment.NewLine);
            }

            writer.Template.AddToCodelet("SETAVAILABLEFUNCTIONS",
                                         controlName + ".SetAvailableFunctions(FPetraUtilsObject.GetAvailableFunctions());" +
                                         Environment.NewLine);
        }
Пример #29
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            base.SetControlProperties(writer, ctrl);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "PositiveValueActivates"))
            {
                if (ctrl.HasAttribute("OnChange"))
                {
                    throw new Exception(ctrl.controlName + " cannot have OnChange and PositiveValueActivates at the same time");
                }

                AssignEventHandlerToControl(writer, ctrl, "ValueChanged", ctrl.controlName + "ValueChanged");
                writer.CodeStorage.FEventHandlersImplementation +=
                    "private void " + ctrl.controlName + "ValueChanged" +
                    "(object sender, EventArgs e)" + Environment.NewLine +
                    "{" + Environment.NewLine +
                    "    ActionEnabledEvent(null, new ActionEventArgs(\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "PositiveValueActivates") +
                    "\", " + ctrl.controlName + ".Value > 0));" + Environment.NewLine +
                    "}" + Environment.NewLine + Environment.NewLine;
            }

            return(writer.FTemplate);
        }
Пример #30
0
        /// <summary>
        /// get the radio buttons
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            StringCollection Controls =
                TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls"));
            string DefaultValue = Controls[0];

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                DefaultValue = TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue");
            }

            foreach (string controlName in Controls)
            {
                TControlDef radioButton = writer.CodeStorage.GetControl(controlName);

                if (StringHelper.IsSame(DefaultValue, controlName))
                {
                    radioButton.SetAttribute("RadioChecked", "true");
                }
            }

            base.ProcessChildren(writer, ctrl);
        }