当前位置: 首页>>代码示例>>C#>>正文


C# TControlDef.HasAttribute方法代码示例

本文整理汇总了C#中TControlDef.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TControlDef.HasAttribute方法的具体用法?C# TControlDef.HasAttribute怎么用?C# TControlDef.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TControlDef的用法示例。


在下文中一共展示了TControlDef.HasAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetControlProperties

        /// <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 ((ctrl.HasAttribute("AlwaysHideLabel") && (ctrl.GetAttribute("AlwaysHideLabel").ToLower() == "true")))
            {
                writer.SetControlProperty(ctrl, "AlwaysHideLabel", "true");
            }
            else if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            // Order is important: set Context before ControlMode and before CurrencyCode
            writer.SetControlProperty(ctrl, "Context", "this");
            writer.SetControlProperty(ctrl, "ControlMode", "TTxtNumericTextBox.TNumericTextBoxMode.Currency");
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());
            writer.SetControlProperty(ctrl, "CurrencyCode", "\"###\"");

            return writer.FTemplate;
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:22,代码来源:ControlGeneratorTextboxes.cs

示例2: SetControlProperties

        /// <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, "SelectedRowActivates"))
            {
                // TODO: this function needs to be called by the manual code at the moment when eg a search finishes
                // TODO: call "Activate" + TYml2Xml.GetAttribute(ctrl.xmlNode, "SelectedRowActivates")
            }

            StringCollection Columns = TYml2Xml.GetElements(ctrl.xmlNode, "Columns");

            if (Columns.Count > 0)
            {
                writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Clear();" + Environment.NewLine);

                foreach (string ColumnFieldName in Columns)
                {
                    bool IsDetailNotMaster;
                    TTableField field = null;

                    // customfield, eg. UC_GLTransactions, ATransaction.DateEntered and ATransaction.AnalysisAttributes
                    // there needs to be a list of CustomColumns
                    XmlNode CustomColumnsNode = TYml2Xml.GetChild(ctrl.xmlNode, "CustomColumns");
                    XmlNode CustomColumnNode = null;

                    if (CustomColumnsNode != null)
                    {
                        CustomColumnNode = TYml2Xml.GetChild(CustomColumnsNode, ColumnFieldName);
                    }

                    if (CustomColumnNode != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                            "FMainDS." + ctrl.GetAttribute("TableName") + ".Get" + ColumnFieldName + "DBName(), \"" +
                            TYml2Xml.GetAttribute(CustomColumnNode, "Label") + "\");" + Environment.NewLine);
                    }
                    else if (ctrl.HasAttribute("TableName"))
                    {
                        field =
                            TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + ColumnFieldName,
                                out IsDetailNotMaster,
                                true);
                    }
                    else
                    {
                        field = TDataBinding.GetTableField(null, ColumnFieldName, out IsDetailNotMaster, true);
                    }

                    if (field != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (field.GetDotNetType() == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (field.GetDotNetType() == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                            TTable.NiceTableName(field.strTableName) + "Table.Get" +
                            TTable.NiceFieldName(field.strName) + "DBName(), \"" +
                            field.strLabel + "\");" + Environment.NewLine);
                    }
                }
            }

            if (ctrl.HasAttribute("ActionLeavingRow"))
            {
                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowLeaving", "SourceGrid.RowCancelEventHandler",
                    ctrl.GetAttribute("ActionLeavingRow"));
            }

            if (ctrl.HasAttribute("ActionFocusRow"))
            {
// TODO                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowEntered", "SourceGrid.RowEventHandler",
//                    ctrl.GetAttribute("ActionFocusRow"));
//.........这里部分代码省略.........
开发者ID:js1987,项目名称:openpetragit,代码行数:101,代码来源:ControlGeneratorGrids.cs

示例3: GenerateLabel

        /// <summary>
        /// get the label text for this control
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        public virtual bool GenerateLabel(TControlDef ctrl)
        {
            if (ctrl.HasAttribute("NoLabel") && (ctrl.GetAttribute("NoLabel").ToLower() == "true"))
            {
                ctrl.hasLabel = false;
                return false;
            }

            ctrl.hasLabel = FGenerateLabel;
            return ctrl.hasLabel;
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:16,代码来源:ControlGeneratorBase.cs

示例4: AddControl

        /// <summary>
        /// add controls to the TableLayoutPanel, but don't write yet;
        /// writing is done in WriteTableLayout, when the layout can be optimised
        /// </summary>
        /// <param name="childctrl"></param>
        /// <param name="column"></param>
        /// <param name="row"></param>
        public void AddControl(
            TControlDef childctrl,
            Int32 column, Int32 row)
        {
            FGrid[column, row] = childctrl;

            childctrl.colSpan = childctrl.HasAttribute("ColSpan") ? Convert.ToInt32(childctrl.GetAttribute("ColSpan")) : 1;
            childctrl.rowSpan = childctrl.HasAttribute("RowSpan") ? Convert.ToInt32(childctrl.GetAttribute("RowSpan")) : 1;

            if (!childctrl.hasLabel)
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2;
            }
            else
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2 - 1;
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:25,代码来源:ControlGeneratorLayout.cs

示例5: InsertControl

        /// <summary>
        /// create the code
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="ctrl"></param>
        public void InsertControl(TFormWriter writer, TControlDef ctrl)
        {
            IControlGenerator ctrlGenerator = writer.FindControlGenerator(ctrl);

            string controlName = ctrl.controlName;

            if (FOrientation == eOrientation.TableLayout)
            {
                if (FCurrentRow != ctrl.rowNumber)
                {
                    FCurrentColumn = 0;
                    FCurrentRow = ctrl.rowNumber;
                }
            }

/* this does not work yet; creates endless loop/recursion
 *          if (ctrl.HasAttribute("LabelUnit"))
 *          {
 *              // we need another label after the control
 *              LabelGenerator lblGenerator = new LabelGenerator();
 *              string lblName = lblGenerator.CalculateName(controlName) + "Unit";
 *              TControlDef unitLabel = writer.CodeStorage.FindOrCreateControl(lblName, controlName);
 *              unitLabel.Label = ctrl.GetAttribute("LabelUnit");
 *
 *              TableLayoutPanelGenerator TlpGenerator = new TableLayoutPanelGenerator();
 *              ctrl.SetAttribute("ControlsOrientation", "horizontal");
 *              TlpGenerator.SetOrientation(ctrl);
 *              StringCollection childControls = new StringCollection();
 *              childControls.Add(controlName);
 *              childControls.Add(lblName);
 *              string subTlpControlName = TlpGenerator.CreateLayout(writer, FTlpName, childControls);
 *
 *              TlpGenerator.CreateCode(writer, ctrl);
 *              TlpGenerator.CreateCode(writer, unitLabel);
 *
 *              if (FOrientation == eOrientation.Vertical)
 *              {
 *                  AddControl(writer, FTlpName, subTlpControlName, 1, FCurrentRow);
 *              }
 *              else
 *              {
 *                  AddControl(writer, FTlpName, subTlpControlName, FCurrentColumn * 2 + 1, 0);
 *              }
 *          }
 *          else
 */
            if (ctrl.HasAttribute("GenerateWithOtherControls"))
            {
                // add the checkbox/radiobutton first
                if (FOrientation == eOrientation.Vertical)
                {
                    AddControl(ctrl, 0, FCurrentRow);
                }
                else if (FOrientation == eOrientation.Horizontal)
                {
                    AddControl(ctrl, FCurrentColumn * 2, 0);
                }
                else if (FOrientation == eOrientation.TableLayout)
                {
                    AddControl(ctrl, FCurrentColumn, FCurrentRow);
                }

                StringCollection childControls = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls"));

                if (childControls.Count > 1)
                {
                    // we need another tablelayout to arrange all the controls
                    PanelLayoutGenerator TlpGenerator = new PanelLayoutGenerator();
                    TlpGenerator.SetOrientation(ctrl);

                    Int32 NewHeight = -1;
                    Int32 NewWidth = -1;

                    if (ctrl.HasAttribute("Height"))
                    {
                        NewHeight = Convert.ToInt32(ctrl.GetAttribute("Height"));
                        ctrl.ClearAttribute("Height");
                    }

                    if (ctrl.HasAttribute("Width"))
                    {
                        NewWidth = Convert.ToInt32(ctrl.GetAttribute("Width"));
                        ctrl.ClearAttribute("Width");
                    }

                    TControlDef subTlpControl = TlpGenerator.CreateNewPanel(writer, ctrl);
                    TlpGenerator.CreateLayout(writer, ctrl, subTlpControl, NewWidth, NewHeight);

                    foreach (string ChildControlName in childControls)
                    {
                        TControlDef ChildControl = ctrl.FCodeStorage.GetControl(ChildControlName);
                        TlpGenerator.InsertControl(writer, ChildControl);
                    }

                    TlpGenerator.WriteTableLayout(writer, subTlpControl);
//.........这里部分代码省略.........
开发者ID:Davincier,项目名称:openpetra,代码行数:101,代码来源:ControlGeneratorLayout.cs

示例6: SetControlProperties

        /// <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)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ctrl);

            writer.FTemplate.SetCodelet("ASSISTANT", "true");

            string AssistantHeader = "true";

            if (ctrl.HasAttribute("AssistantHeader"))
            {
                AssistantHeader = ctrl.GetAttribute("AssistantHeader");
            }

            ctrlSnippet.SetCodelet("ASSISTANTHEADER", AssistantHeader);

            return ctrlSnippet;
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:18,代码来源:ControlGenerator.cs

示例7: LayoutCellInForm

        private static void LayoutCellInForm(TControlDef ACtrl,
            Int32 AChildrenCount,
            ProcessTemplate ACtrlSnippet,
            ProcessTemplate ASnippetCellDefinition)
        {
            if (ACtrl.HasAttribute("labelWidth"))
            {
                ASnippetCellDefinition.SetCodelet("LABELWIDTH", ACtrl.GetAttribute("labelWidth"));
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", ACtrl.GetAttribute("columnWidth").Replace(",", "."));
            }
            else
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", (1.0 / AChildrenCount).ToString().Replace(",", "."));
            }

            string Anchor = ANCHOR_DEFAULT_COLUMN;

            if (AChildrenCount == 1)
            {
                Anchor = ANCHOR_SINGLE_COLUMN;
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                Anchor = "94%";
            }

            if (ACtrl.GetAttribute("hideLabel") == "true")
            {
                ACtrlSnippet.SetCodelet("HIDELABEL", "true");
                Anchor = ANCHOR_HIDDEN_LABEL;
            }

            ACtrlSnippet.SetCodelet("ANCHOR", Anchor);
        }
开发者ID:js1987,项目名称:openpetragit,代码行数:39,代码来源:FormWriter.cs

示例8: ProcessChildren

        /// <summary>
        /// generate the children
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            base.ProcessChildren(writer, ctrl);

            XmlNode controlsNode = TXMLParser.GetChild(ctrl.xmlNode, "Controls");

            if ((controlsNode != null) && TYml2Xml.GetChildren(controlsNode, true)[0].Name.StartsWith("Row"))
            {
                // this defines the layout with several rows with several controls per row
                Int32 countRow = 0;

                foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true))
                {
                    StringCollection controls = TYml2Xml.GetElements(row);

                    foreach (string ctrlname in controls)
                    {
                        TControlDef childCtrl = writer.CodeStorage.GetControl(ctrlname);

                        if (ctrlname.StartsWith("Empty"))
                        {
                            childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName);
                        }

                        if (childCtrl == null)
                        {
                            throw new Exception("cannot find control with name " + ctrlname + "; it belongs to " +
                                ctrl.controlName);
                        }

                        // add control itself
                        ctrl.Children.Add(childCtrl);
                        childCtrl.parentName = ctrl.controlName;
                        IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                        ctrlGenerator.GenerateControl(writer, childCtrl);

                        childCtrl.rowNumber = countRow;
                    }

                    countRow++;
                }
            }
            else
            {
                if ((controlsNode != null) && (ctrl.Children.Count == 0))
                {
                    StringCollection controlNamesCollection = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls"));

                    foreach (string childCtrlName in controlNamesCollection)
                    {
                        TControlDef childCtrl = writer.CodeStorage.GetControl(childCtrlName);

                        if (childCtrlName.StartsWith("Empty"))
                        {
                            childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName);
                        }

                        if (childCtrl == null)
                        {
                            throw new Exception("cannot find control with name " + childCtrlName + "; it belongs to " +
                                ctrl.controlName);
                        }

                        childCtrl.parentName = ctrl.controlName;
                        ctrl.Children.Add(childCtrl);
                    }
                }

                foreach (TControlDef childCtrl in ctrl.Children)
                {
                    TLogging.LogAtLevel(1, "foreach (TControlDef childCtrl in ctrl.Children) -- Control: " + childCtrl.controlName);

                    if (!childCtrl.controlName.StartsWith("pnlEmpty"))
                    {
                        // process the control itself
                        IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                        ctrlGenerator.GenerateControl(writer, childCtrl);
                    }
                }
            }

            bool hasDockingChildren = false;

            // don't use a tablelayout for controls where all children have the Dock property set
            foreach (TControlDef ChildControl in ctrl.Children)
            {
                if (!ChildControl.HasAttribute("Dock"))
                {
                    ctrl.SetAttribute("UseTableLayout", "true");
                }
                else
                {
                    hasDockingChildren = true;
                }
            }

            if (ctrl.GetAttribute("UseTableLayout") == "true")
//.........这里部分代码省略.........
开发者ID:Davincier,项目名称:openpetra,代码行数:101,代码来源:ControlGeneratorContainer.cs

示例9: SetControlProperties

        /// <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)
        {
            string CntrlNameWithoutPrefix = ctrl.controlName.Substring(3);
            string CntrlVaribleNameWithoutPrefix;
            StringCollection DynamicControlTypes;

            base.SetControlProperties(writer, ctrl);
            writer.SetControlProperty(ctrl, "Dock", "Fill");

            if (ctrl.HasAttribute("ToolTip"))
            {
                writer.SetControlProperty(ctrl, "ToolTipText", "\"" + ctrl.GetAttribute("ToolTip") + "\"");
            }

            #region Dynamic TabPage UserControl loading ('LoadPageDynamically' attribute and 'DynamicControlTypes' Element)

            if (ctrl.HasAttribute("LoadPageDynamically") && (ctrl.GetAttribute("LoadPageDynamically").ToLower() == "true"))
            {
                if ((!ctrl.HasAttribute("DynamicControlType")
                     && (TYml2Xml.GetElements(ctrl.xmlNode, "DynamicControlTypes").Count == 0)))
                {
                    throw new Exception(
                        "TabPage '" + ctrl.controlName +
                        "': Either the 'DynamicControlType' or the 'DynamicControlTypes' property need to be specified if 'LoadPageDynamically' is specified");
                }
                else if (ctrl.HasAttribute("DynamicControlType"))
                {
                    DynamicControlTypes = new StringCollection();
                    DynamicControlTypes.Add(ctrl.GetAttribute("DynamicControlType"));
                }
                else
                {
                    DynamicControlTypes = TYml2Xml.GetElements(ctrl.xmlNode, "DynamicControlTypes");
                }

                ProcessTemplate snippetUserControlInitialisation = writer.Template.GetSnippet("USERCONTROLINITIALISATION");
                ProcessTemplate snippetUserControlSetupMethod = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHOD");

                for (int Counter = 0; Counter < DynamicControlTypes.Count; Counter = Counter + 2)
                {
                    if (DynamicControlTypes.Count == 1)
                    {
                        CntrlVaribleNameWithoutPrefix = CntrlNameWithoutPrefix;
                    }
                    else
                    {
                        CntrlVaribleNameWithoutPrefix = CntrlNameWithoutPrefix + DynamicControlTypes[Counter + 1];
                    }

//Console.WriteLine("CntrlVaribleNameWithoutPrefix: " + CntrlVaribleNameWithoutPrefix + "; Counter: " + Counter.ToString());
                    writer.Template.AddToCodelet("DYNAMICTABPAGEUSERCONTROLDECLARATION",
                        "private " + DynamicControlTypes[Counter] + " FUco" + CntrlVaribleNameWithoutPrefix + ";" + Environment.NewLine);

                    // Declare an Enum for each dynamically loaded TabPage
                    string DynamicTabPageEnums = "";
                    DynamicTabPageEnums += "///<summary>Denotes dynamic loadable UserControl" + " FUco" + CntrlVaribleNameWithoutPrefix +
                                           "</summary>" + Environment.NewLine;
                    DynamicTabPageEnums += "dluc" + CntrlVaribleNameWithoutPrefix + "," + Environment.NewLine;
                    writer.Template.AddToCodelet("DYNAMICTABPAGEUSERCONTROLENUM", DynamicTabPageEnums);

                    // Dispose UserControl for each dynamically loaded TabPage
                    string CustomDisposingOfControl = "";
                    CustomDisposingOfControl += "if (FUco" + CntrlVaribleNameWithoutPrefix + " != null)" + Environment.NewLine;
                    CustomDisposingOfControl += "{" + Environment.NewLine;
                    CustomDisposingOfControl += "    FUco" + CntrlVaribleNameWithoutPrefix + ".Dispose();" + Environment.NewLine;
                    CustomDisposingOfControl += "}" + Environment.NewLine;
                    writer.Template.AddToCodelet("CUSTOMDISPOSING", CustomDisposingOfControl);


                    // Initialise each dynamically loaded TabPage

                    ProcessTemplate snippetUserControlSetup = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUP");
                    ProcessTemplate snippetTabPageSubseqAct = writer.Template.GetSnippet("DYNAMICTABPAGESUBSEQUENTACTIVATION");

                    if (writer.IsUserControlTemplate)
                    {
                        snippetUserControlSetup.SetCodelet("ISUSERCONTROL", "true");
                    }

                    snippetUserControlInitialisation.SetCodelet("CONTROLNAME", ctrl.controlName);
                    snippetUserControlInitialisation.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix);

                    snippetUserControlSetup.SetCodelet("CONTROLNAME", ctrl.controlName);

                    snippetUserControlInitialisation.SetCodelet("TABCONTROLNAME", TabControlGenerator.TabControlName);
                    snippetUserControlSetup.SetCodelet("DYNAMICCONTROLTYPE", DynamicControlTypes[Counter]);

                    ProcessTemplate snippetUserControlLoading = writer.Template.GetSnippet("USERCONTROLLOADING");

                    if ((ctrl.HasAttribute("SeparateDynamicControlSetupMethod")
                         && (ctrl.GetAttribute("SeparateDynamicControlSetupMethod").ToLower() == "true"))
                        || (DynamicControlTypes.Count > 1))
                    {
                        if (DynamicControlTypes.Count == 1)
                        {
                            snippetUserControlInitialisation.SetCodelet("TABKEY", "TDynamicLoadableUserControls.dluc" + CntrlNameWithoutPrefix + ")");
                            snippetUserControlSetupMethod = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHOD");
                            snippetUserControlSetup.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix);
                            snippetUserControlSetupMethod.SetCodelet("DYNLOADINFO", "UserControl 'FUco" + CntrlNameWithoutPrefix + "'.");
//.........这里部分代码省略.........
开发者ID:Davincier,项目名称:openpetra,代码行数:101,代码来源:ControlGeneratorContainer.cs

示例10: ProcessButtonsForMaxWidthSizing

        private void ProcessButtonsForMaxWidthSizing(TFormWriter writer, TControlDef ctrl, SortedSet <int>ButtonWidths,
            SortedSet <int>ButtonTops, List <TControlDef>Buttons, out int NewButtonWidthForAll)
        {
            const int MIN_BUTTON_WIDTH = 76; // 76 seems to be pretty much a standard width (on the Windows OS)
            int LeftPos = PanelLayoutGenerator.MARGIN_LEFT;
            int ButtonCounter = 0;
            bool EnforceMinimumWidth = false;
            bool RepositionButtonsHorizontally = ButtonTops.Max == ButtonTops.Min;

            NewButtonWidthForAll = MIN_BUTTON_WIDTH;

            TLogging.LogAtLevel(1, "Max. Button Width: " + ButtonWidths.Max.ToString() + ", Number of Buttons: " + Buttons.Count.ToString());

            if ((!ctrl.HasAttribute("AutoButtonMaxWidthsEnforceMinimumWidth")
                 || (ctrl.GetAttribute("AutoButtonMaxWidthsEnforceMinimumWidth").ToLower() == "true")))
            {
                EnforceMinimumWidth = true;
            }

            if ((EnforceMinimumWidth)
                && (ButtonWidths.Max < MIN_BUTTON_WIDTH))
            {
                if (Buttons.Count > 0)
                {
                    NewButtonWidthForAll = MIN_BUTTON_WIDTH;
                    TLogging.LogAtLevel(1,
                        "Max. Button width (" + ButtonWidths.Max.ToString() + ") was smaller than MIN_BUTTON_WIDTH, adjusting to the latter!");
                }
            }
            else
            {
                NewButtonWidthForAll = ButtonWidths.Max;
            }

            foreach (var Button in Buttons)
            {
// TLogging.LogAtLevel(1, "Button ' " + Button.controlName + "': Width = " + Button.GetAttribute("Width"));

                if ((!Button.HasAttribute("NoLabel")
                     || (Button.GetAttribute("NoLabel").ToLower() == "false")))
                {
                    TLogging.LogAtLevel(1, "Applying Width to Button '" + Button.controlName + "'");
                    writer.SetControlProperty(Button, "Size", "new System.Drawing.Size(" +
                        NewButtonWidthForAll.ToString() + ", " + Button.GetAttribute("Height").ToString() + ")");

                    if (ButtonCounter != 0)
                    {
                        LeftPos += NewButtonWidthForAll + PanelLayoutGenerator.HORIZONTAL_SPACE;
                    }
                }
                else
                {
                    TLogging.LogAtLevel(
                        1,
                        "Not applying Width to Button '" + Button.controlName + "' as its 'NoLabel' Element is set to 'true'! (Current Width: " +
                        Button.Width.ToString() + ")");

                    if (ButtonCounter != 0)
                    {
                        LeftPos += Button.Width + PanelLayoutGenerator.HORIZONTAL_SPACE;
                    }
                }

                if (RepositionButtonsHorizontally)
                {
                    writer.SetControlProperty(Button, "Location", String.Format("new System.Drawing.Point({0}, {1})", LeftPos, ButtonTops.Max));
                    TLogging.LogAtLevel(1,
                        "Repositioned Button '" + Button.controlName + "' horizontally. New Location: " + LeftPos.ToString() + "," +
                        ButtonTops.Max.ToString());
                }

                //               TLogging.LogAtLevel(1, "Button '" + Button.controlName + "' Width: " + Button.Width.ToString());

                ButtonCounter++;
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:76,代码来源:ControlGeneratorContainer.cs

示例11: SetControlProperties

        /// <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;
        }
开发者ID:js1987,项目名称:openpetragit,代码行数:58,代码来源:ControlGeneratorTextboxes.cs

示例12: SetControlProperties

        /// <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)
        {
            if (IsMniFilterFindClickAndIgnore(writer, ctrl, false))
            {
                return writer.FTemplate;
            }

            base.SetControlProperties(writer, ctrl);

            // deactivate menu items that have no action assigned yet.
            if ((ctrl.GetAction() == null) && !ctrl.HasAttribute("ActionClick") && !ctrl.HasAttribute("ActionOpenScreen")
                && (ctrl.NumberChildren == 0) && !(this is MenuItemSeparatorGenerator))
            {
                string ActionEnabling = ctrl.controlName + ".Enabled = false;" + Environment.NewLine;
                writer.Template.AddToCodelet("ACTIONENABLINGDISABLEMISSINGFUNCS", ActionEnabling);
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");

            if (ctrl.HasAttribute("ShortcutKeys"))
            {
                writer.SetControlProperty(ctrl, "ShortcutKeys", ctrl.GetAttribute("ShortcutKeys"));
            }

            // todo: this.toolStripMenuItem1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;

            return writer.FTemplate;
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:29,代码来源:ControlGeneratorBars.cs

示例13: WriteTableLayout


//.........这里部分代码省略.........
                else
                {
                    CurrentTopPosition = Convert.ToInt32(LayoutCtrl.GetAttribute("MarginTop", MARGIN_TOP.ToString()));
                }

                // only twice the margin for groupboxes
                if ((LayoutCtrl.controlTypePrefix == "grp") || (LayoutCtrl.controlTypePrefix == "rgr"))
                {
                    CurrentTopPosition += MARGIN_TOP;
                }

                for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                {
                    if (FGrid[columnCounter, rowCounter] != null)
                    {
                        TControlDef childctrl = FGrid[columnCounter, rowCounter];

                        if (childctrl.GetAttribute("Stretch") == "horizontally")
                        {
                            // use the full column width
                            // add up spanning columns
                            int concatenatedColumnWidth = ColumnWidth[columnCounter];

                            for (int colSpanCounter = 1; colSpanCounter < childctrl.colSpanWithLabel; colSpanCounter++)
                            {
                                concatenatedColumnWidth += ColumnWidth[columnCounter + colSpanCounter];
                            }

                            if (concatenatedColumnWidth > 0)
                            {
                                TControlDef ParentControl = childctrl.FCodeStorage.GetControl(childctrl.parentName);
                                System.Windows.Forms.Padding? ParentPad = null;

                                if (ParentControl.HasAttribute("Padding"))
                                {
                                    string ParentPadding = ParentControl.GetAttribute("Padding");
                                    TLogging.LogAtLevel(1, "ParentControl '" + ParentControl.controlName + "' Padding: " + ParentPadding);

                                    if (ParentPadding.IndexOf(',') == -1)
                                    {
                                        ParentPad = new Padding(Convert.ToInt32(ParentPadding));
                                    }
                                    else
                                    {
                                        string[] Paddings = ParentPadding.Split(',');
                                        ParentPad = new Padding(Convert.ToInt32(Paddings[0]), Convert.ToInt32(Paddings[1]),
                                            Convert.ToInt32(Paddings[2]), Convert.ToInt32(Paddings[3]));
                                    }

                                    TLogging.LogAtLevel(1, "ParentControl Padding (parsed): " + ParentPad.ToString());
                                }

                                writer.SetControlProperty(childctrl, "Size",
                                    String.Format("new System.Drawing.Size({0}, {1})", concatenatedColumnWidth -
                                        (ParentPad.HasValue ? ParentPad.Value.Right : 0),
                                        childctrl.Height));
                            }
                        }

                        int ControlTopPosition = CurrentTopPosition;
                        int ControlLeftPosition = CurrentLeftPosition;
                        TLogging.LogAtLevel(1, "WriteTableLayout for Control '" + childctrl.controlName + "'");
                        // add margin or padding
                        string padding = writer.GetControlProperty(childctrl.controlName, "Padding");

                        if (padding.Length > 0)
开发者ID:Davincier,项目名称:openpetra,代码行数:67,代码来源:ControlGeneratorLayout.cs

示例14: GenerateDataValidationCode

        private bool GenerateDataValidationCode(TFormWriter writer, TControlDef ctrl, out bool AAutomDataValidation,
            out string AReasonForAutomValidation)
        {
            AAutomDataValidation = false;
            AReasonForAutomValidation = String.Empty;

            if ((ctrl.HasAttribute("Validation"))
                && (ctrl.GetAttribute("Validation").ToLower() != "false"))
            {
                return true;
            }

            if (TDataValidation.GenerateAutoValidationCodeForControl(ctrl,
                    ctrl.HasAttribute("DataField"),
                    (writer.CodeStorage.HasAttribute("MasterTable")
                     || writer.CodeStorage.HasAttribute("DetailTable")),
                    !((this is LabelGenerator) || (this is LinkLabelGenerator)),
                    TDataValidation.TAutomDataValidationScope.advsAll, out AReasonForAutomValidation)
                )
            {
                AAutomDataValidation = true;

                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:29,代码来源:ControlGeneratorBase.cs

示例15: SetControlProperties

        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public virtual ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            bool AutomDataValidation;
            string ReasonForAutomValidation;
            bool IsDetailNotMaster;

            writer.SetControlProperty(ctrl, "Name", "\"" + ctrl.controlName + "\"");

            if (FLocation && !ctrl.HasAttribute("Dock"))
            {
                writer.SetControlProperty(ctrl, "Location", "new System.Drawing.Point(2,2)");
            }

            #region Aligning and stretching

            if (ctrl.HasAttribute("Align")
                && !(ctrl.HasAttribute("Stretch")))
            {
                if ((ctrl.GetAttribute("Align").ToLower() == "right")
                    || (ctrl.GetAttribute("Align").ToLower() == "top-right"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "middle-right")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Right))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "bottom-right")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "center")
                         || (ctrl.GetAttribute("Align").ToLower() == "top-center"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "middle-center")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.None))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "bottom-center")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "bottom")
                         || (ctrl.GetAttribute("Align").ToLower() == "bottom-left"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom)))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "middle")
                         || (ctrl.GetAttribute("Align").ToLower() == "middle-left"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Left))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "left")
                         || (ctrl.GetAttribute("Align").ToLower() == "top")
                         || (ctrl.GetAttribute("Align").ToLower() == "top-left"))
                {
                    // do nothing (here just to avoid throwing the following Exception)
                    Console.WriteLine(
                        "HINT: Attribute 'Align' with value 'left', 'top' or 'top-left' does not affect the layout since these create the default alignment. Control: '"
                        +
                        ctrl.controlName + "'.");
                }
                else
                {
                    throw new Exception("Invalid value for Attribute 'Align' of Control '" + ctrl.controlName + "': '" + ctrl.GetAttribute(
                            "Align") +
                        "'. Supported values are: Simple: left, right, center; top, middle, bottom; Combined: top-left, middle-left, bottom-left, top-center, middle-center, bottom-center, top-right, middle-right, bottom-right.");
                }
            }

            if (ctrl.HasAttribute("Stretch"))
            {
                if (ctrl.GetAttribute("Stretch").ToLower() == "horizontally")
                {
                    if ((!ctrl.HasAttribute("Align"))
                        || (ctrl.HasAttribute("Align") && (ctrl.GetAttribute("Align").ToLower() == "top")))
                    {
                        // Horizontally stretched, top aligned (=default)
                        writer.SetControlProperty(
                            ctrl,
                            "Anchor",
//.........这里部分代码省略.........
开发者ID:Davincier,项目名称:openpetra,代码行数:101,代码来源:ControlGeneratorBase.cs


注:本文中的TControlDef.HasAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。