コード例 #1
0
 /// <summary>
 /// Boilerplate for assigning a "local property" from a "reference value" while applying <see cref="IChartErrorInfo"/>.
 /// </summary>
 /// <param name="icei">For error reporting; MAY be NULL.</param>
 /// <param name="vsource">Validation source in error reports.</param>
 /// <param name="localprop">Local property in error reports.</param>
 /// <param name="refprop">Reference property in error reports.</param>
 /// <param name="localcheck">The local check; True to proceed to sourcecheck.</param>
 /// <param name="sourcecheck">The source check; True to proceed to refcheck.</param>
 /// <param name="refcheck">The reference check; True to proceed to action.</param>
 /// <param name="applyvalue">Execute if everything returned True.</param>
 protected static void AssignFromRef(IChartErrorInfo icei, String vsource, String localprop, String refprop, bool localcheck, bool sourcecheck, bool refcheck, Action applyvalue)
 {
     if (!localcheck)
     {
         return;
     }
     if (sourcecheck)
     {
         if (refcheck)
         {
             applyvalue();
         }
         else
         {
             if (icei != null)
             {
                 icei.Report(new ChartValidationResult(vsource, $"{localprop} not found and {refprop} not found", new[] { localprop, refprop }));
             }
         }
     }
     else
     {
         if (icei != null)
         {
             icei.Report(new ChartValidationResult(vsource, $"{localprop} not found and no Theme was found", new[] { localprop, refprop }));
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Resolve axis references with error info.
        /// </summary>
        /// <param name="icrc">The context.</param>
        protected void EnsureAxes(IChartComponentContext icrc)
        {
            IChartErrorInfo icei = icrc as IChartErrorInfo;

            if (CategoryAxis2 == null)
            {
                if (!String.IsNullOrEmpty(CategoryAxis2Name))
                {
                    CategoryAxis2 = icrc.Find(CategoryAxis2Name) as IChartAxis;
                    if (CategoryAxis2 == null)
                    {
                        icei?.Report(new ChartValidationResult(NameOrType(), $"Value axis '{CategoryAxis2Name}' was not found", new[] { nameof(CategoryAxis2), nameof(CategoryAxis2Name) }));
                    }
                }
                else
                {
                    icei?.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(CategoryAxis2)}' was not set", new[] { nameof(CategoryAxis2), nameof(CategoryAxis2) }));
                }
            }
            if (CategoryAxis1 == null)
            {
                if (!String.IsNullOrEmpty(CategoryAxisName))
                {
                    CategoryAxis1 = icrc.Find(CategoryAxisName) as IChartAxis;
                    if (CategoryAxis1 == null)
                    {
                        icei?.Report(new ChartValidationResult(NameOrType(), $"Value axis '{CategoryAxisName}' was not found", new[] { nameof(CategoryAxis1), nameof(CategoryAxisName) }));
                    }
                }
                else
                {
                    icei?.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(CategoryAxisName)}' was not set", new[] { nameof(CategoryAxis1), nameof(CategoryAxisName) }));
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initialize the LabelStyle from the Theme, if it is NULL.
        /// Provide error reporting.
        /// </summary>
        /// <param name="icei">For error reporting.</param>
        protected void ApplyLabelStyle(IChartErrorInfo icei)
        {
            if (LabelStyle != null)
            {
                return;
            }
            if (LabelStyle == null && Theme != null)
            {
                switch (Side)
                {
                case Side.Left:
                    if (Theme.LabelAxisLeft != null)
                    {
                        LabelStyle = Theme.LabelAxisLeft;
                    }
                    break;

                case Side.Right:
                    if (Theme.LabelAxisRight != null)
                    {
                        LabelStyle = Theme.LabelAxisRight;
                    }
                    break;

                case Side.Top:
                    if (Theme.LabelAxisTop != null)
                    {
                        LabelStyle = Theme.LabelAxisTop;
                    }
                    break;

                case Side.Bottom:
                    if (Theme.LabelAxisBottom != null)
                    {
                        LabelStyle = Theme.LabelAxisBottom;
                    }
                    break;
                }
                if (LabelStyle == null)
                {
                    if (icei != null)
                    {
                        var sidex = $"LabelAxis{Side}";
                        icei.Report(new ChartValidationResult(NameOrType(), $"{nameof(LabelStyle)} not found and {sidex} not found", new[] { nameof(LabelStyle), sidex }));
                    }
                }
            }
            else
            {
                if (icei != null)
                {
                    var sidex = $"LabelAxis{Side}";
                    icei.Report(new ChartValidationResult(NameOrType(), $"{nameof(LabelStyle)} not found and no Theme was found for {sidex}", new[] { nameof(LabelStyle), sidex }));
                }
            }
        }