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


C# TFormWriter.GetControlProperty方法代码示例

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


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

示例1: ProcessButtonsForMaxWidthDetermination

        private void ProcessButtonsForMaxWidthDetermination(TFormWriter writer, TControlDef ctrl,
            SortedSet <int>AButtonWidths, SortedSet <int>AButtonTops, List <TControlDef>AButtons)
        {
            if (ctrl.controlName.StartsWith("btn"))
            {
                TLogging.LogAtLevel(1, "Found Button: " + ctrl.controlName + ", Width: " + ctrl.Width.ToString());

                if (ctrl.GetAttribute("Visible") != "false")
                {
                    AButtons.Add(ctrl);
                    AButtonWidths.Add(ctrl.Width);


                    string ControlLocation = writer.GetControlProperty(ctrl.controlName, "Location");
//                TLogging.LogAtLevel(1, "ControlLocation '" + Button.controlName + "' ControlLocation: " + ControlLocation);
                    string StrY = ControlLocation.Substring(ControlLocation.IndexOf(',') + 1, ControlLocation.Length - ControlLocation.IndexOf(
                            ',') - 2);
//                TLogging.LogAtLevel(1, "ControlLocation '" + Button.controlName + "' StrY: " + StrY);
                    int Y = Convert.ToInt32(StrY);

                    AButtonTops.Add(Y);
                }
                else
                {
                    TLogging.LogAtLevel(1, "Button isn't visible, therefore ignoring it for max. Width determination!");
                }
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:28,代码来源:ControlGeneratorContainer.cs

示例2: WriteTableLayout


//.........这里部分代码省略.........
                                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)
                        {
                            string[] values = padding.Substring(padding.IndexOf("(") + 1).Replace(")", "").Split(new char[] { ',' });
                            ControlLeftPosition += Convert.ToInt32(values[0]);
                            ControlTopPosition += Convert.ToInt32(values[1]);
                            TLogging.LogAtLevel(1, "Removing Padding Property from Control '" + childctrl.controlName + "'!");
                            writer.ClearControlProperty(childctrl.controlName, "Padding");
                        }

                        string margin = writer.GetControlProperty(childctrl.controlName, "Margin");

                        if (margin.Length > 0)
                        {
                            string[] values = margin.Substring(margin.IndexOf("(") + 1).Replace(")", "").Split(new char[] { ',' });
                            ControlLeftPosition += Convert.ToInt32(values[0]);
                            ControlTopPosition += Convert.ToInt32(values[1]);
                            writer.ClearControlProperty(childctrl.controlName, "Margin");
                        }

                        if ((childctrl.IsOnHorizontalGridButtonPanel)
                            && (columnCounter != 0)
                            && !((childctrl.HasAttribute("StartNewButtonGroup"))
                                 && (childctrl.GetAttribute("StartNewButtonGroup").ToLower() == "true")))
                        {
                            TLogging.LogAtLevel(1,
                                "Adjusted ControlLeftPosition for Control '" + childctrl.controlName +
                                "' as it is on a horizontal Grid Button Panel.");
                            ControlLeftPosition -= 8;
                        }

                        writer.SetControlProperty(childctrl.controlName,
开发者ID:Davincier,项目名称:openpetra,代码行数:67,代码来源:ControlGeneratorLayout.cs

示例3: 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)
        {
            bool OverrideImageAlign = false;
            bool OverrideTextAlign = false;
            bool NoLabel = false;

            TLogging.LogAtLevel(1, "ButtonGenerator.SetControlProperties for Control " + ctrl.controlName);

            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(ctrl.Label) + 15).ToString());
            }

            if (ctrl.HasAttribute("NoLabel") && (ctrl.GetAttribute("NoLabel").ToLower() == "true"))
            {
                writer.SetControlProperty(ctrl, "Text", "\"\"");

                NoLabel = true;
            }
            else
            {
                writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                    ctrl.GetAttribute("Width").ToString() + ", " + ctrl.GetAttribute("Height").ToString() + ")");
                writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
            }

            if (ctrl.IsOnHorizontalGridButtonPanel)
            {
                TLogging.LogAtLevel(1, "Setting Height for Control '" + ctrl.controlName + "' to 23 as it is on a horizontal Grid Button Panel");
                FDefaultHeight = 23;

                if (!ctrl.HasAttribute("ImageAlign"))
                {
                    if (NoLabel)
                    {
                        //TLogging.LogAtLevel(1, "Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.BottomCenter as it is on a horizontal Grid Button Panel (no Text)");
                        writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.BottomCenter");
                    }
                    else
                    {
                        //TLogging.LogAtLevel(1, "Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.BottomLeft as it is on a horizontal Grid Button Panel");
                        writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.BottomLeft");

                        // Note: In this case want the text centered on the Button, which the TextAlign Property will achieve.
                        // However, its default value is System.Drawing.ContentAlignment.MiddleCenter which means we don't need to explicitly write this out into the Designer file...
                        //TLogging.LogAtLevel(1, "Setting TextAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleCenter as it is on a horizontal Grid Button Panel");
//                        writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.MiddleCenter");
                    }

                    OverrideImageAlign = true;
                    OverrideTextAlign = true;
                }
            }
            else
            {
                if (!ctrl.HasAttribute("Height"))
                {
                    ctrl.SetAttribute("Height", FDefaultHeight.ToString());
                }
            }

            base.SetControlProperties(writer, ctrl);

            if (ctrl.GetAttribute("AcceptButton").ToLower() == "true")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "this.AcceptButton = " + ctrl.controlName + ";" + Environment.NewLine);
            }

            if (ctrl.GetAction() != null)
            {
                string img = ctrl.GetAction().actionImage;

                if (img.Length > 0)
                {
                    ctrl.SetAttribute("Width", (Convert.ToInt32(ctrl.GetAttribute("Width")) +
                                                Convert.ToInt32(ctrl.GetAttribute("IconWidth", "15"))).ToString());
                    writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                        ctrl.GetAttribute("Width").ToString() + ", " + ctrl.GetAttribute("Height").ToString() + ")");

                    if (writer.GetControlProperty(ctrl.controlName, "Text") == "\"\"")
                    {
                        if ((!ctrl.HasAttribute("ImageAlign"))
                            && !OverrideImageAlign)
                        {
                            // Note: In this case we want the Image centered on the Button, which the ImageAlign Property will achieve.
                            // However, its default value is System.Drawing.ContentAlignment.MiddleCenter which means we don't need to explicitly write this out into the Designer file...

//Console.WriteLine("Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleCenter as it is NOT on a horizontal Grid Button Panel (no Text)");
//                            writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.MiddleCenter");
                        }
                    }
                    else
                    {
                        if ((!ctrl.HasAttribute("ImageAlign"))
                            && !OverrideImageAlign)
                        {
//Console.WriteLine("Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleLeft as it is NOT on a horizontal Grid Button Panel");
                            writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.MiddleLeft");
                        }
//.........这里部分代码省略.........
开发者ID:Davincier,项目名称:openpetra,代码行数:101,代码来源:ControlGenerator.cs


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