public void SetFromTemplate(G3DPlotStyleCollection from, PlotGroupStrictness strictness) { if (strictness == PlotGroupStrictness.Strict) { CopyFromTemplateCollection(from); // take the whole style collection as is from the template, but try to reuse the additionally needed data columns from the old style } else if (strictness == PlotGroupStrictness.Exact) { // note one sub style in the 'from' collection can update only one item in the 'this' collection using (var suspendToken = SuspendGetToken()) { var indicesFrom = new SortedSet <int>(System.Linq.Enumerable.Range(0, from.Count)); for (int i = 0; i < Count; ++i) { var thisStyleType = this[i].GetType(); // search in from for a style with the same name foreach (var fromIndex in indicesFrom) { if (thisStyleType == from[fromIndex].GetType()) { this[i].CopyFrom(from[fromIndex], false); indicesFrom.Remove(fromIndex); // this from style was used, thus remove it break; } } } suspendToken.Resume(); } } }
public void SetFromTemplate(G2DPlotStyleCollection from, PlotGroupStrictness strictness) { if (strictness == PlotGroupStrictness.Strict) { CopyFrom(from); } else if (strictness == PlotGroupStrictness.Exact) { // note one sub style in the 'from' collection can update only one item in the 'this' collection Suspend(); int myidx = 0; foreach (IG2DPlotStyle style in from) { for (int i = myidx; i < this.Count; i++) { if (this[i].GetType() == style.GetType()) { Replace((IG2DPlotStyle)from[i].Clone(), i, false); myidx = i + 1; break; } } } Resume(); } }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DensityImagePlotItem)) { return; } DensityImagePlotItem from = (DensityImagePlotItem)template; // m_PlotStyle.CopyFrom(from.m_PlotStyle); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DataMeshPlotItem)) { return; } var from = (DataMeshPlotItem)template; _plotStyle.CopyFrom(from._plotStyle); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is G2DPlotItem) || object.ReferenceEquals(this, template)) { return; } var from = (G2DPlotItem)template; _plotStyles.SetFromTemplate(from._plotStyles, strictness); }
/// <summary> /// Sets the plot style (or sub plot styles) of all plot items in this collection according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public void DistributePlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { foreach (IGPlotItem pi in this._plotItems) { if (!object.ReferenceEquals(pi, template)) { pi.SetPlotStyleFromTemplate(template, strictness); } } }
public virtual void CopyFrom(PlotGroupStyleCollectionBase from) { _typeToInstance = new Dictionary <Type, IPlotGroupStyle>(); _typeToInfo = new Dictionary <Type, GroupInfo>(); foreach (KeyValuePair <System.Type, IPlotGroupStyle> entry in from._typeToInstance) { this._typeToInstance.Add(entry.Key, (IPlotGroupStyle)entry.Value.Clone()); } foreach (KeyValuePair <System.Type, GroupInfo> entry in from._typeToInfo) { this._typeToInfo.Add(entry.Key, entry.Value.Clone()); } _plotGroupStrictness = from._plotGroupStrictness; this._inheritFromParentGroups = from._inheritFromParentGroups; this._distributeToChildGroups = from._distributeToChildGroups; }
public virtual bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } var from = obj as PlotGroupStyleCollectionBase; if (null == from) { return(false); } using (var suspendToken = SuspendGetToken()) { _typeToInstance = new Dictionary <Type, IPlotGroupStyle>(); _typeToInfo = new Dictionary <Type, GroupInfo>(); foreach (KeyValuePair <System.Type, IPlotGroupStyle> entry in from._typeToInstance) { _typeToInstance.Add(entry.Key, ChildCloneFrom(entry.Value)); } foreach (KeyValuePair <System.Type, GroupInfo> entry in from._typeToInfo) { _typeToInfo.Add(entry.Key, entry.Value.Clone()); } _plotGroupStrictness = from._plotGroupStrictness; _inheritFromParentGroups = from._inheritFromParentGroups; _distributeToChildGroups = from._distributeToChildGroups; suspendToken.Resume(); } return(true); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public abstract void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness);
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is G2DPlotItem) || object.ReferenceEquals(this, template)) return; G2DPlotItem from = (G2DPlotItem)template; this._plotStyles.SetFromTemplate(from._plotStyles, strictness); }
public virtual bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) return true; var from = obj as PlotGroupStyleCollectionBase; if (null == from) return false; using (var suspendToken = SuspendGetToken()) { _typeToInstance = new Dictionary<Type, IPlotGroupStyle>(); _typeToInfo = new Dictionary<Type, GroupInfo>(); foreach (KeyValuePair<System.Type, IPlotGroupStyle> entry in from._typeToInstance) { this._typeToInstance.Add(entry.Key, ChildCloneFrom(entry.Value)); } foreach (KeyValuePair<System.Type, GroupInfo> entry in from._typeToInfo) this._typeToInfo.Add(entry.Key, entry.Value.Clone()); _plotGroupStrictness = from._plotGroupStrictness; this._inheritFromParentGroups = from._inheritFromParentGroups; this._distributeToChildGroups = from._distributeToChildGroups; suspendToken.Resume(); } return true; }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DensityImagePlotItem)) return; DensityImagePlotItem from = (DensityImagePlotItem)template; _plotStyle.CopyFrom(from._plotStyle); }