/// <summary> /// Common logic for leaving the chart. /// SHOULD be strict dual of ComponentEnter sequence. /// </summary> /// <param name="icelc">The context.</param> /// <param name="cc">The component leaving chart.</param> protected void ComponentLeave(IChartEnterLeaveContext icelc, ChartComponent cc) { foreach (var px in AllPhases) { px.Leave(cc); } if (cc is IProvideDataSourceRenderer ipdsr) { Unregister(ipdsr.Renderer); } else if (cc is IDataSourceRenderer idsr) { Unregister(idsr); } if (cc is IChartAxis ica) { Axes.Remove(ica); } if (cc is IProvideLegendDynamic ipld) { // detach the event ipld.LegendChanged -= Ipld_LegendChanged; } if (cc is IProvideLegend ipl) { foreach (var li in ipl.LegendItems) { LegendItems.Remove(li); } } if (cc is IRequireEnterLeave irel) { irel.Leave(icelc); } if (cc is IRequireChartTheme irct) { irct.Theme = null; } }
/// <summary> /// Initialize after entering VT. /// </summary> /// <param name="icelc"></param> public void Enter(IChartEnterLeaveContext icelc) { EnsureAxes(icelc as IChartComponentContext); Layer = icelc.CreateLayer(); _trace.Verbose($"enter v:{ValueAxisName}:{ValueAxis} c:{CategoryAxisName}:{CategoryAxis} d:{DataSourceName}"); AssignFromRef(icelc as IChartErrorInfo, NameOrType(), nameof(PathStyle), nameof(Theme.PathMarkerSeries), PathStyle == null, Theme != null, Theme.PathMarkerSeries != null, () => PathStyle = Theme.PathMarkerSeries ); AssignFromRef(icelc as IChartErrorInfo, NameOrType(), nameof(ReversePathStyle), nameof(PathStyle), ReversePathStyle == null, true, PathStyle != null, () => ReversePathStyle = PathStyle ); BindPaths = new Evaluators(CategoryPath, OpenValuePath, HighValuePath, LowValuePath, CloseValuePath, ValueLabelPath); if (!BindPaths.IsValid) { if (icelc is IChartErrorInfo icei) { var props = new List <String>(); if (String.IsNullOrEmpty(OpenValuePath)) { props.Add(nameof(OpenValuePath)); } if (String.IsNullOrEmpty(HighValuePath)) { props.Add(nameof(HighValuePath)); } if (String.IsNullOrEmpty(LowValuePath)) { props.Add(nameof(LowValuePath)); } if (String.IsNullOrEmpty(CloseValuePath)) { props.Add(nameof(CloseValuePath)); } icei.Report(new ChartValidationResult(NameOrType(), $"{String.Join(",", props)}: must be specified", props)); } } }
/// <summary> /// Reverse effect of Enter. /// </summary> /// <param name="icelc">The context.</param> void IRequireEnterLeave.Leave(IChartEnterLeaveContext icelc) { icelc.DeleteLayer(Layer); Layer = null; }
/// <summary> /// Undo effects of Enter(). /// </summary> /// <param name="icelc"></param> void IRequireEnterLeave.Leave(IChartEnterLeaveContext icelc) { _trace.Verbose($"leave"); icelc.DeleteLayer(Layer); Layer = null; }
void DoBindings(IChartEnterLeaveContext icelc) { BindTo(this, nameof(PathStyle), Axis, FrameworkElement.StyleProperty); }
void IRequireEnterLeave.Enter(IChartEnterLeaveContext icelc) { EnsureAxes(icelc as IChartComponentContext); Layer = icelc.CreateLayer(); DoBindings(icelc); }
/// <summary> /// Component is entering the chart. /// </summary> /// <param name="icelc">Context.</param> void IRequireEnterLeave.Enter(IChartEnterLeaveContext icelc) { Layer = icelc.CreateLayer(Path); DoBindings(icelc); }