Esempio n. 1
0
        public static void TransferFromToIfBothSteppingEnabled(PlotGroupStyleCollectionBase from, PlotGroupStyleCollectionBase tothis)
        {
            foreach (KeyValuePair <Type, IPlotGroupStyle> entry in from._typeToInstance)
            {
                Type groupType = entry.Key;
                if (!tothis.ContainsType(groupType))
                {
                    continue;
                }

                IPlotGroupStyle fromGroupStyle = entry.Value;
                if (false == fromGroupStyle.IsStepEnabled)
                {
                    continue;
                }

                IPlotGroupStyle tothisGroupStyle = tothis.GetPlotGroupStyle(groupType);
                if (false == tothisGroupStyle.IsStepEnabled)
                {
                    continue;
                }

                tothisGroupStyle.TransferFrom(fromGroupStyle);
            }
        }
Esempio n. 2
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                PlotGroupStyleCollectionBase s = null != o ? (PlotGroupStyleCollectionBase)o : new PlotGroupStyleCollectionBase();

                SDeserialize(s, info, parent);
                return(s);
            }
Esempio n. 3
0
        /// <summary>
        /// Executes a step only on those items, where in the own collection the stepping is enabled, but in the foreign collection it is present, but is not enabled.
        /// </summary>
        /// <param name="step"></param>
        /// <param name="foreignStyles"></param>
        public void StepIfForeignSteppingFalse(int step, PlotGroupStyleCollectionBase foreignStyles)
        {
            foreach (KeyValuePair <Type, IPlotGroupStyle> entry in _typeToInstance)
            {
                Type            groupType  = entry.Key;
                IPlotGroupStyle groupStyle = entry.Value;
                GroupInfo       groupInfo  = _typeToInfo[groupType];

                if (groupInfo.ParentGroupType == null &&
                    groupInfo.WasApplied &&
                    groupStyle.IsStepEnabled &&
                    foreignStyles.ContainsType(groupType) &&
                    !(foreignStyles.GetPlotGroupStyle(groupType).IsStepEnabled)
                    )
                {
                    int       subStep      = groupStyle.Step(step);
                    GroupInfo subGroupInfo = groupInfo;
                    for (Type subGroupType = subGroupInfo.ChildGroupType; subGroupType != null && subStep != 0; subGroupType = subGroupInfo.ChildGroupType)
                    {
                        subGroupInfo = _typeToInfo[subGroupType];
                        IPlotGroupStyle subGroupStyle = _typeToInstance[subGroupType];
                        subStep = subGroupStyle.IsStepEnabled ? subGroupStyle.Step(subStep) : 0;
                    }
                }
                groupInfo.WasApplied = false;
            }
        }
            public override void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                base.Serialize(obj, info);
                PlotGroupStyleCollectionBase s = (PlotGroupStyleCollectionBase)obj;

                info.AddValue("InheritFromParent", s._inheritFromParentGroups);
                info.AddValue("DistributeToChilds", s._distributeToChildGroups);
            }
Esempio n. 5
0
            public virtual void SDeserialize(PlotGroupStyleCollectionBase s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                Type parentStyleType = null;
                int  count           = info.OpenArray();

                for (int i = 0; i < count; i++)
                {
                    var  style    = (IPlotGroupStyle)info.GetValue("Style", s);
                    bool hasChild = info.GetBoolean("HasChild");
                    s.Add(style, parentStyleType);
                    parentStyleType = hasChild ? style.GetType() : null;
                }
                info.CloseArray(count);

                s._plotGroupStrictness = (PlotGroupStrictness)info.GetEnum("Strictness", typeof(PlotGroupStrictness));
            }
Esempio n. 6
0
        /// <summary>
        /// Executes a prepare step only on those items, where in the own collection the stepping is enabled, but in the foreign collection it is present, but is not enabled.
        /// </summary>
        /// <param name="foreignStyles"></param>
        public void PrepareStepIfForeignSteppingFalse(PlotGroupStyleCollectionBase foreignStyles)
        {
            foreach (KeyValuePair <Type, IPlotGroupStyle> entry in _typeToInstance)
            {
                Type            groupType  = entry.Key;
                IPlotGroupStyle groupStyle = entry.Value;
                GroupInfo       groupInfo  = _typeToInfo[groupType];

                if (groupInfo.ParentGroupType == null &&
                    groupInfo.WasApplied &&
                    groupStyle.IsStepEnabled &&
                    foreignStyles.ContainsType(groupType) &&
                    !(foreignStyles.GetPlotGroupStyle(groupType).IsStepEnabled)
                    )
                {
                    groupStyle.PrepareStep();
                }
            }
        }
        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 void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                PlotGroupStyleCollectionBase s = (PlotGroupStyleCollectionBase)obj;

                int savedStyles = 0; // for test of consistency

                info.CreateArray("Styles", s.Count);

                foreach (System.Type t in s._typeToInstance.Keys)
                {
                    if (s._typeToInfo[t].ParentGroupType != null)
                    {
                        continue;
                    }

                    info.AddValue("Style", s._typeToInstance[t]);
                    info.AddValue("HasChild", null != s._typeToInfo[t].ChildGroupType);
                    savedStyles++;

                    System.Type childtype = t;
                    while (null != (childtype = s._typeToInfo[childtype].ChildGroupType))
                    {
                        info.AddValue("Style", s._typeToInstance[childtype]);
                        info.AddValue("HasChild", null != s._typeToInfo[childtype].ChildGroupType);
                        savedStyles++;
                    }
                }

                info.CommitArray();

                if (s.Count != savedStyles)
                {
                    throw new ApplicationException("Inconsistency in parent-child relationship in this PlotGroupStyleCollection. Please inform the author");
                }

                info.AddEnum("Strictness", s._plotGroupStrictness);
            }
Esempio n. 9
0
 public PlotGroupStyleCollectionBase(PlotGroupStyleCollectionBase from)
 {
     CopyFrom(from);
 }
Esempio n. 10
0
 public override void SDeserialize(PlotGroupStyleCollectionBase s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
 {
     base.SDeserialize(s, info, parent);
     s._inheritFromParentGroups = info.GetBoolean("InheritFromParent");
     s._distributeToChildGroups = info.GetBoolean("DistributeToChilds");
 }
		public static void TransferFromToIfBothSteppingEnabled(PlotGroupStyleCollectionBase from, PlotGroupStyleCollectionBase tothis)
		{
			foreach (KeyValuePair<Type, IPlotGroupStyle> entry in from._typeToInstance)
			{
				Type groupType = entry.Key;
				if (!tothis.ContainsType(groupType))
					continue;

				IPlotGroupStyle fromGroupStyle = entry.Value;
				if (false == fromGroupStyle.IsStepEnabled)
					continue;

				IPlotGroupStyle tothisGroupStyle = tothis.GetPlotGroupStyle(groupType);
				if (false == tothisGroupStyle.IsStepEnabled)
					continue;

				tothisGroupStyle.TransferFrom(fromGroupStyle);
			}
		}
		/// <summary>
		/// Executes a step only on those items, where in the own collection the stepping is enabled, but in the foreign collection it is present, but is not enabled.
		/// </summary>
		/// <param name="step"></param>
		/// <param name="foreignStyles"></param>
		public void StepIfForeignSteppingFalse(int step, PlotGroupStyleCollectionBase foreignStyles)
		{
			foreach (KeyValuePair<Type, IPlotGroupStyle> entry in _typeToInstance)
			{
				Type groupType = entry.Key;
				IPlotGroupStyle groupStyle = entry.Value;
				GroupInfo groupInfo = _typeToInfo[groupType];

				if (groupInfo.ParentGroupType == null
					&& groupInfo.WasApplied
					&& groupStyle.IsStepEnabled
					&& foreignStyles.ContainsType(groupType)
					&& !(foreignStyles.GetPlotGroupStyle(groupType).IsStepEnabled)
					)
				{
					int subStep = groupStyle.Step(step);
					GroupInfo subGroupInfo = groupInfo;
					for (Type subGroupType = subGroupInfo.ChildGroupType; subGroupType != null && subStep != 0; subGroupType = subGroupInfo.ChildGroupType)
					{
						subGroupInfo = _typeToInfo[subGroupType];
						IPlotGroupStyle subGroupStyle = _typeToInstance[subGroupType];
						subStep = subGroupStyle.IsStepEnabled ? subGroupStyle.Step(subStep) : 0;
					}
				}
				groupInfo.WasApplied = false;
			}
		}
		/// <summary>
		/// Executes a prepare step only on those items, where in the own collection the stepping is enabled, but in the foreign collection it is present, but is not enabled.
		/// </summary>
		/// <param name="foreignStyles"></param>
		public void PrepareStepIfForeignSteppingFalse(PlotGroupStyleCollectionBase foreignStyles)
		{
			foreach (KeyValuePair<Type, IPlotGroupStyle> entry in _typeToInstance)
			{
				Type groupType = entry.Key;
				IPlotGroupStyle groupStyle = entry.Value;
				GroupInfo groupInfo = _typeToInfo[groupType];

				if (groupInfo.ParentGroupType == null
					&& groupInfo.WasApplied
					&& groupStyle.IsStepEnabled
					&& foreignStyles.ContainsType(groupType)
					&& !(foreignStyles.GetPlotGroupStyle(groupType).IsStepEnabled)
					)
				{
					groupStyle.PrepareStep();
				}
			}
		}
		public PlotGroupStyleCollectionBase(PlotGroupStyleCollectionBase from)
		{
			CopyFrom(from);
		}
			public override void SDeserialize(PlotGroupStyleCollectionBase s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				base.SDeserialize(s, info, parent);
				s._inheritFromParentGroups = info.GetBoolean("InheritFromParent");
				s._distributeToChildGroups = info.GetBoolean("DistributeToChilds");
			}
			public virtual void SDeserialize(PlotGroupStyleCollectionBase s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				Type parentStyleType = null;
				int count = info.OpenArray();
				for (int i = 0; i < count; i++)
				{
					IPlotGroupStyle style = (IPlotGroupStyle)info.GetValue("Style", s);
					bool hasChild = info.GetBoolean("HasChild");
					s.Add(style, parentStyleType);
					parentStyleType = hasChild ? style.GetType() : null;
				}
				info.CloseArray(count);

				s._plotGroupStrictness = (PlotGroupStrictness)info.GetEnum("Strictness", typeof(PlotGroupStrictness));
			}