コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
ファイル: DataMeshPlotItem.cs プロジェクト: olesar/Altaxo
        /// <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);
        }
コード例 #5
0
ファイル: G2DPlotItem.cs プロジェクト: olesar/Altaxo
        /// <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);
        }
コード例 #6
0
 /// <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);
         }
     }
 }
コード例 #7
0
        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;
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: PlotItem.cs プロジェクト: olesar/Altaxo
 /// <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);
コード例 #10
0
ファイル: G2DPlotItem.cs プロジェクト: Altaxo/Altaxo
		/// <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);
		}
コード例 #11
0
		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;
		}
コード例 #12
0
ファイル: DensityImagePlotItem.cs プロジェクト: Altaxo/Altaxo
		/// <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);
		}
コード例 #13
0
ファイル: PlotItem.cs プロジェクト: xuchuansheng/GenXSource
 /// <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);