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


C# Component.FindProperty方法代码示例

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


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

示例1: Format

        public string Format(Component component)
        {
            Regex variable = new Regex("\\$[a-zA-z]+ ");
            string plainVars = variable.Replace(Value, new MatchEvaluator(delegate(Match match)
            {
                string propertyName = match.Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                    return component.GetProperty(propertyInfo).ToString();
                return "";
            }));

            variable = new Regex("\\$[a-zA-Z]+[\\(\\)a-z_0-9]+ ");
            string formattedVars = variable.Replace(plainVars, new MatchEvaluator(delegate(Match match)
            {
                Regex propertyNameRegex = new Regex("\\$[a-zA-z]+");
                string propertyName = propertyNameRegex.Match(match.Value).Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                {
                    return ApplySpecialFormatting(component.GetProperty(propertyInfo), match.Value.Replace(propertyNameRegex.Match(match.Value).Value, "").Trim());
                }
                return "";
            }));

            Regex regex = new Regex(@"\\[uU]([0-9A-F]{4})");
            return regex.Replace(formattedVars, match => ((char)Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString());
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:28,代码来源:ComponentPropertyFormat.cs

示例2: IsMet

        public bool IsMet(Component component)
        {
            if (Type == ConditionType.Empty)
            {
                return true;
            }
            else if (Type == ConditionType.State)
            {
                if (VariableName.ToLower() == "horizontal")
                {
                    if (Comparison == ConditionComparison.Equal)
                        return (component.Orientation == Orientation.Horizontal) == (bool)CompareTo.Value;
                    else
                        return (component.Orientation == Orientation.Horizontal) != (bool)CompareTo.Value;
                }
            }
            else
            {
                var propertyValue = component.GetProperty(component.FindProperty(VariableName));

                if (Comparison == ConditionComparison.Empty)
                    return propertyValue.IsEmpty();
                else if (Comparison == ConditionComparison.NotEmpty)
                    return !propertyValue.IsEmpty();

                int cv = propertyValue.CompareTo(CompareTo);
                switch (Comparison)
                {
                    case ConditionComparison.Equal:
                        return cv == 0;
                    case ConditionComparison.Greater:
                        return cv == 1;
                    case ConditionComparison.GreaterOrEqual:
                        return cv >= 0;
                    case ConditionComparison.Less:
                        return cv == -1;
                    case ConditionComparison.LessOrEqual:
                        return cv <= 0;
                    case ConditionComparison.NotEqual:
                        return cv != 0;
                }
            }

            return false;
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:45,代码来源:ConditionTreeLeaf.cs

示例3: Render

        public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute)
        {
            Point renderLocation = Location.Resolve(component);

            TextAlignment tempAlignment = Alignment;
            if (component.IsFlipped && component.Orientation == Orientation.Horizontal)
            {
                switch (Alignment)
                {
                    case TextAlignment.BottomLeft:
                        tempAlignment = TextAlignment.BottomRight;
                        break;
                    case TextAlignment.BottomRight:
                        tempAlignment = TextAlignment.BottomLeft;
                        break;
                    case TextAlignment.CentreLeft:
                        tempAlignment = TextAlignment.CentreRight;
                        break;
                    case TextAlignment.CentreRight:
                        tempAlignment = TextAlignment.CentreLeft;
                        break;
                    case TextAlignment.TopLeft:
                        tempAlignment = TextAlignment.TopRight;
                        break;
                    case TextAlignment.TopRight:
                        tempAlignment = TextAlignment.TopLeft;
                        break;
                }
            }
            else if (component.IsFlipped && component.Orientation == Orientation.Vertical)
            {
                switch (Alignment)
                {
                    case TextAlignment.BottomCentre:
                        tempAlignment = TextAlignment.TopCentre;
                        break;
                    case TextAlignment.BottomLeft:
                        tempAlignment = TextAlignment.TopLeft;
                        break;
                    case TextAlignment.BottomRight:
                        tempAlignment = TextAlignment.TopRight;
                        break;
                    case TextAlignment.TopCentre:
                        tempAlignment = TextAlignment.BottomCentre;
                        break;
                    case TextAlignment.TopLeft:
                        tempAlignment = TextAlignment.BottomLeft;
                        break;
                    case TextAlignment.TopRight:
                        tempAlignment = TextAlignment.BottomRight;
                        break;
                }
            }

            List<TextRun> renderTextRuns = new List<TextRun>(TextRuns.Count);
            // Build runs
            foreach (TextRun run in TextRuns)
            {
                // Resolve value
                string renderValue;
                if (run.Text.StartsWith("$"))
                {
                    ComponentProperty property = component.FindProperty(run.Text);
                    renderValue = component.GetFormattedProperty(property);
                }
                else
                    renderValue = run.Text;

                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\\[uU]([0-9A-F]{4})");
                renderValue = regex.Replace(renderValue, match => ((char)Int32.Parse(match.Value.Substring(2), System.Globalization.NumberStyles.HexNumber)).ToString());

                renderTextRuns.Add(new TextRun(renderValue, run.Formatting));
            }

            if (absolute)
                dc.DrawText(Point.Add(renderLocation, component.Location), tempAlignment, renderTextRuns);
            else
                dc.DrawText(renderLocation, tempAlignment, renderTextRuns);
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:79,代码来源:Text.cs


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