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


C# IStyle.?.ToString方法代码示例

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


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

示例1: Apply

        /// <summary>
        /// Applies the setter to the control.
        /// </summary>
        /// <param name="style">The style that is being applied.</param>
        /// <param name="control">The control.</param>
        /// <param name="activator">An optional activator.</param>
        public void Apply(IStyle style, IStyleable control, IObservable<bool> activator)
        {
            Contract.Requires<ArgumentNullException>(control != null);

            var description = style?.ToString();

            if (Property == null)
            {
                throw new InvalidOperationException("Setter.Property must be set.");
            }

            var binding = Value as IBinding;

            if (binding != null)
            {
                if (activator == null)
                {
                    control.Bind(Property, binding);
                }
                else
                {
                    var subject = binding.CreateSubject(control, Property);
                    var activated = new ActivatedSubject(activator, subject, description);
                    Bind(control, Property, binding, activated);
                }
            }
            else
            {
                if (activator == null)
                {
                    control.SetValue(Property, Value, BindingPriority.Style);
                }
                else
                {
                    var activated = new ActivatedValue(activator, Value, description);
                    control.Bind(Property, activated, BindingPriority.StyleTrigger);
                }
            }
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:45,代码来源:Setter.cs

示例2: Clone

        private InstancedBinding Clone(InstancedBinding sourceInstance, IStyle style, IObservable<bool> activator)
        {
            InstancedBinding cloned;

            if (activator != null)
            {
                var description = style?.ToString();

                if (sourceInstance.Subject != null)
                {
                    var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
                    cloned = new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
                }
                else if (sourceInstance.Observable != null)
                {
                    var activated = new ActivatedObservable(activator, sourceInstance.Observable, description);
                    cloned = new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
                }
                else
                {
                    var activated = new ActivatedValue(activator, sourceInstance.Value, description);
                    cloned = new InstancedBinding(activated, BindingMode.OneWay, BindingPriority.StyleTrigger);
                }
            }
            else
            {
                if (sourceInstance.Subject != null)
                {
                    cloned = new InstancedBinding(sourceInstance.Subject, sourceInstance.Mode, BindingPriority.Style);
                }
                else if (sourceInstance.Observable != null)
                {
                    cloned = new InstancedBinding(sourceInstance.Observable, sourceInstance.Mode, BindingPriority.Style);
                }
                else
                {
                    cloned = new InstancedBinding(sourceInstance.Value, BindingPriority.Style);
                }
            }

            return cloned;
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:42,代码来源:Setter.cs

示例3: Apply

        /// <summary>
        /// Applies the setter to a control.
        /// </summary>
        /// <param name="style">The style that is being applied.</param>
        /// <param name="control">The control.</param>
        /// <param name="activator">An optional activator.</param>
        public IDisposable Apply(IStyle style, IStyleable control, IObservable<bool> activator)
        {
            Contract.Requires<ArgumentNullException>(control != null);

            var description = style?.ToString();

            if (Property == null)
            {
                throw new InvalidOperationException("Setter.Property must be set.");
            }

            var value = Value;
            var binding = value as IBinding;

            if (binding == null)
            {
                var template = value as ITemplate;

                if (template != null)
                {
                    var materialized = template.Build();
                    NameScope.SetNameScope((Visual)materialized, new NameScope());
                    value = materialized;
                }

                if (activator == null)
                {
                    return control.Bind(Property, ObservableEx.SingleValue(value), BindingPriority.Style);
                }
                else
                {
                    var activated = new ActivatedValue(activator, value, description);
                    return control.Bind(Property, activated, BindingPriority.StyleTrigger);
                }
            }
            else
            {
                var source = binding.Initiate(control, Property);

                if (source != null)
                {
                    var cloned = Clone(source, style, activator);
                    return BindingOperations.Apply(control, Property, cloned, null);
                }
            }

            return Disposable.Empty;
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:54,代码来源:Setter.cs


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