コード例 #1
0
        public static ImageSource GetImage(IDashPattern val)
        {
            const double height    = 1;
            const double width     = 2;
            const double lineWidth = height / 5;

            DashStyle dashStyle;

            if (val is Solid)
            {
                dashStyle = DashStyles.Solid;
            }
            else if (val is Dash)
            {
                dashStyle = DashStyles.Dash;
            }
            else if (val is Dot)
            {
                dashStyle = DashStyles.Dot;
            }
            else if (val is DashDot)
            {
                dashStyle = DashStyles.DashDot;
            }
            else if (val is DashDotDot)
            {
                dashStyle = DashStyles.DashDotDot;
            }
            else
            {
                dashStyle = new DashStyle(val, 0);
            }

            // draws a transparent outline to fix the borders
            var drawingGroup = new DrawingGroup();

            var geometryDrawing = new GeometryDrawing
            {
                Geometry = new RectangleGeometry(new Rect(0, 0, width, height)),
                Pen      = new Pen(Brushes.Transparent, 0)
            };

            drawingGroup.Children.Add(geometryDrawing);

            geometryDrawing = new GeometryDrawing()
            {
                Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2))
            };
            geometryDrawing.Pen = new Pen(Brushes.Black, lineWidth)
            {
                DashStyle = dashStyle
            };
            drawingGroup.Children.Add(geometryDrawing);

            var geometryImage = new DrawingImage(drawingGroup);

            // Freeze the DrawingImage for performance benefits.
            geometryImage.Freeze();
            return(geometryImage);
        }
コード例 #2
0
        public void TransferFrom(IPlotGroupStyle fromb)
        {
            var from = (DashPatternGroupStyle)fromb;

            _value        = from._value;
            _listOfValues = from._listOfValues;
        }
コード例 #3
0
        public PenX3D(
            IMaterial material,
            ICrossSectionOfLine crossSection,
            PenLineJoin lineJoin,
            double miterLimit,
            ILineCap lineStartCap, ILineCap lineEndCap, IDashPattern dashPattern, ILineCap dashStartCap, bool dashStartCapSuppressionIfSpaceInsufficient, ILineCap dashEndCap, bool dashEndCapSuppressionIfSpaceInsufficient)
        {
            if (!(miterLimit >= 1))
            {
                throw new ArgumentOutOfRangeException(nameof(miterLimit), "must be >= 1");
            }
            if (null == dashPattern)
            {
                throw new ArgumentNullException(nameof(dashPattern));
            }

            _material     = material;
            _crossSection = crossSection;
            _lineJoin     = lineJoin;
            _miterLimit   = miterLimit;
            _lineStartCap = lineStartCap;
            _lineEndCap   = lineEndCap;
            _dashPattern  = dashPattern;
            _dashStartCap = dashStartCap;
            _dashStartCapSuppressionIfSpaceInsufficient = dashStartCapSuppressionIfSpaceInsufficient;
            _dashEndCap = dashEndCap;
            _dashEndCapSuppressionIfSpaceInsufficient = dashEndCapSuppressionIfSpaceInsufficient;
        }
コード例 #4
0
 private void SetValueCoercedToGroup(IDashPattern value)
 {
     if (_isStepEnabled)
     {
         var idx = Math.Max(0, _listOfValues.IndexOf(value));
         _value = _listOfValues[idx];
     }
     else
     {
         _value = value;
     }
 }
コード例 #5
0
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 1)
            {
                var item = e.AddedItems[0] as ImageComboBoxItem;
                if (null != item)
                {
                    SelectedDashStyle = item.Value as IDashPattern;
                }
                e.Handled = true;
            }

            base.OnSelectionChanged(e);
        }
コード例 #6
0
        protected static void SerializeV0(IDashPattern obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
        {
            var parent = DashPatternListManager.Instance.GetParentList(obj);

            if (null != parent)
            {
                if (null == info.GetProperty(DashPatternList.GetSerializationRegistrationKey(parent)))
                {
                    info.AddValue("Set", parent);
                }
                else
                {
                    info.AddValue("SetName", parent.Name);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a new instance of this pen, with the dash pattern provided in the argument.
        /// </summary>
        /// <param name="dashPattern">The dash pattern. Can be null to represent a solid line.</param>
        /// <returns>A new instance of this pen, with the dash pattern provided in the argument.</returns>
        public PenX3D WithDashPattern(IDashPattern dashPattern)
        {
            if (null == dashPattern)
            {
                throw new ArgumentNullException(nameof(dashPattern));
            }

            if (object.ReferenceEquals(_dashPattern, dashPattern)) // Reference equality is important, since the parent DashPatternList is determined by reference equality
            {
                return(this);
            }
            else
            {
                var result = (PenX3D)MemberwiseClone();
                result._dashPattern = dashPattern;
                return(result);
            }
        }
コード例 #8
0
        public void Initialize(IDashPattern value)
        {
            if (null == value)
            {
                throw new ArgumentNullException(nameof(value));
            }

            _isInitialized = true;

            var parentList = DashPatternListManager.Instance.GetParentList(value);

            if (null != parentList)
            {
                _listOfValues = parentList;
            }

            SetValueCoercedToGroup(value);
        }
コード例 #9
0
        public int Step(int step)
        {
            if (0 == step)
            {
                return(0); // nothing changed
            }
            var list      = _listOfValues;
            var listcount = list.Count;

            if (listcount == 0)
            {
                return(0);
            }

            int currentIdx = Math.Max(0, _listOfValues.IndexOf(_value));

            var valueIndex = Calc.BasicFunctions.PMod(currentIdx + step, _listOfValues.Count);
            int wraps      = Calc.BasicFunctions.NumberOfWraps(_listOfValues.Count, currentIdx, step);

            _value = _listOfValues[valueIndex];
            return(wraps);
        }
コード例 #10
0
ファイル: PenX3D.cs プロジェクト: Altaxo/Altaxo
		public PenX3D(
			IMaterial material,
			ICrossSectionOfLine crossSection,
			PenLineJoin lineJoin,
			double miterLimit,
			ILineCap lineStartCap, ILineCap lineEndCap, IDashPattern dashPattern, ILineCap dashStartCap, bool dashStartCapSuppressionIfSpaceInsufficient, ILineCap dashEndCap, bool dashEndCapSuppressionIfSpaceInsufficient)
		{
			if (!(miterLimit >= 1))
				throw new ArgumentOutOfRangeException(nameof(miterLimit), "must be >= 1");
			if (null == dashPattern)
				throw new ArgumentNullException(nameof(dashPattern));

			_material = material;
			_crossSection = crossSection;
			_lineJoin = lineJoin;
			_miterLimit = miterLimit;
			_lineStartCap = lineStartCap;
			_lineEndCap = lineEndCap;
			_dashPattern = dashPattern;
			_dashStartCap = dashStartCap;
			_dashStartCapSuppressionIfSpaceInsufficient = dashStartCapSuppressionIfSpaceInsufficient;
			_dashEndCap = dashEndCap;
			_dashEndCapSuppressionIfSpaceInsufficient = dashEndCapSuppressionIfSpaceInsufficient;
		}
コード例 #11
0
 public DashPatternGroupStyle(DashPatternGroupStyle from)
 {
     _isStepEnabled = from._isStepEnabled;
     _value         = from._value;
     _listOfValues  = from._listOfValues;
 }
コード例 #12
0
 public DashPatternGroupStyle()
 {
     _listOfValues = DashPatternListManager.Instance.BuiltinDefault;
     _value        = _listOfValues[0];
 }
コード例 #13
0
ファイル: PenX.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Copies the properties of another instance to this instance.
		/// </summary>
		/// <param name="pen">the PenHolder object to copy</param>
		public void CopyFrom(PenX pen)
		{
			if (object.ReferenceEquals(this, pen))
				return;

			_SetPenVariable(null);

			this._configuredProperties = pen._configuredProperties;
			this._penType = pen.PenType;
			this._alignment = pen.Alignment;

			if (0 != (this._configuredProperties & Configured.Brush))
				this._brush = new BrushX(pen._brush);

			this._color = pen.Color;

			if (null != pen._compoundArray)
				this._compoundArray = (float[])pen.CompoundArray.Clone();
			else
				this._compoundArray = null;

			this._dashPattern = pen._dashPattern; // immutable
			this._dashCap = pen._dashCap;

			this._cachedDashStyle = pen._cachedDashStyle;

			if (null != pen._cachedDashPattern)
				this._cachedDashPattern = (float[])pen._cachedDashPattern.Clone();
			else
				this._cachedDashPattern = null;

			this._cachedDashOffset = pen._cachedDashOffset;

			this._endCap = pen.EndCap;
			this._lineJoin = pen.LineJoin;
			this._miterLimit = pen.MiterLimit;
			this._startCap = pen.StartCap;

			if (null != pen._transformation)
				this._transformation = pen.Transform.Clone();
			else
				this._transformation = null;

			this._width = pen.Width;

			// note: there is an problem with Pen.Clone() : if the Color of the pen
			// was set to a known color, the color of the cloned pen is the same, but no longer a known color
			// therefore we avoid the cloning of the pen here

			// if(m_CachedMode && null!=pen.m_Pen)
			//   _SetPenVariable( (Pen)pen.m_Pen.Clone() );
			// else
			//   _SetPenVariable(null);
		}
コード例 #14
0
		public DashPatternGroupStyle()
		{
			_listOfValues = DashPatternListManager.Instance.BuiltinDefault;
			_value = _listOfValues[0];
		}
コード例 #15
0
 public PenX3D(IMaterial material, ICrossSectionOfLine crossSection)
 {
     _material     = material;
     _crossSection = crossSection;
     _dashPattern  = DashPatternListManager.Instance.BuiltinDefaultSolid;
 }
コード例 #16
0
		public void Initialize(IDashPattern value)
		{
			if (null == value)
				throw new ArgumentNullException(nameof(value));

			_isInitialized = true;

			var parentList = DashPatternListManager.Instance.GetParentList(value);
			if (null != parentList)
			{
				_listOfValues = parentList;
			}

			SetValueCoercedToGroup(value);
		}
コード例 #17
0
		private void SetValueCoercedToGroup(IDashPattern value)
		{
			if (_isStepEnabled)
			{
				var idx = Math.Max(0, _listOfValues.IndexOf(value));
				_value = _listOfValues[idx];
			}
			else
			{
				_value = value;
			}
		}
コード例 #18
0
		public int Step(int step)
		{
			if (0 == step)
				return 0; // nothing changed

			var list = _listOfValues;
			var listcount = list.Count;

			if (listcount == 0)
			{
				return 0;
			}

			int currentIdx = Math.Max(0, _listOfValues.IndexOf(_value));

			var valueIndex = Calc.BasicFunctions.PMod(currentIdx + step, _listOfValues.Count);
			int wraps = Calc.BasicFunctions.NumberOfWraps(_listOfValues.Count, currentIdx, step);
			_value = _listOfValues[valueIndex];
			return wraps;
		}
コード例 #19
0
		public void TransferFrom(IPlotGroupStyle fromb)
		{
			DashPatternGroupStyle from = (DashPatternGroupStyle)fromb;
			this._value = from._value;
			this._listOfValues = from._listOfValues;
		}
コード例 #20
0
		public DashPatternGroupStyle(DashPatternGroupStyle from)
		{
			this._isStepEnabled = from._isStepEnabled;
			this._value = from._value;
			this._listOfValues = from._listOfValues;
		}
コード例 #21
0
		protected override void OnSelectionChanged(SelectionChangedEventArgs e)
		{
			if (e.AddedItems.Count == 1)
			{
				var item = e.AddedItems[0] as ImageComboBoxItem;
				if (null != item)
					SelectedDashStyle = item.Value as IDashPattern;
				e.Handled = true;
			}

			base.OnSelectionChanged(e);
		}
コード例 #22
0
ファイル: PenX3D.cs プロジェクト: Altaxo/Altaxo
		public PenX3D(IMaterial material, ICrossSectionOfLine crossSection)
		{
			_material = material;
			_crossSection = crossSection;
			_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
		}
コード例 #23
0
ファイル: PenX3D.cs プロジェクト: Altaxo/Altaxo
		public PenX3D(NamedColor color, double thickness)
		{
			_material = Materials.GetSolidMaterial(color);
			_crossSection = new CrossSections.Rectangular(thickness, thickness);
			_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
		}
コード例 #24
0
 public PenX3D(NamedColor color, double thickness)
 {
     _material     = Materials.GetSolidMaterial(color);
     _crossSection = new CrossSections.Rectangular(thickness, thickness);
     _dashPattern  = DashPatternListManager.Instance.BuiltinDefaultSolid;
 }
コード例 #25
0
ファイル: PenX.cs プロジェクト: Altaxo/Altaxo
		public PenX(NamedColor c, double width, bool bCachedMode)
		{
			this._penType = PenType.SolidColor;
			_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
			this._color = c;
			this._width = width;

			this._startCap = LineCapExtension.Flat;
			this._endCap = LineCapExtension.Flat;

			_SetProp(PenX.Configured.IsNotNull, true);
			_SetProp(Configured.Color, NamedColors.Black != c);
			_SetProp(Configured.Width, 1 != width);

			if (bCachedMode)
				_SetPenVariable(new Pen(ToGdi(c), (float)width));
		}
コード例 #26
0
		public override string GetDisplayName(IDashPattern item)
		{
			return (string)_itemToItemNameConverter.Convert(item, typeof(string), null, System.Globalization.CultureInfo.InvariantCulture);
		}
コード例 #27
0
ファイル: PenX3D.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Returns a new instance of this pen, with the dash pattern provided in the argument.
		/// </summary>
		/// <param name="dashPattern">The dash pattern. Can be null to represent a solid line.</param>
		/// <returns>A new instance of this pen, with the dash pattern provided in the argument.</returns>
		public PenX3D WithDashPattern(IDashPattern dashPattern)
		{
			if (null == dashPattern)
				throw new ArgumentNullException(nameof(dashPattern));

			if (object.ReferenceEquals(_dashPattern, dashPattern)) // Reference equality is important, since the parent DashPatternList is determined by reference equality
			{
				return this;
			}
			else
			{
				var result = (PenX3D)this.MemberwiseClone();
				result._dashPattern = dashPattern;
				return result;
			}
		}
コード例 #28
0
 public override string GetDisplayName(IDashPattern item)
 {
     return((string)_itemToItemNameConverter.Convert(item, typeof(string), null, System.Globalization.CultureInfo.InvariantCulture));
 }
コード例 #29
0
ファイル: PenX.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Sets the <see cref="_dashPattern"/> member after deserialization of old versions (before 2016-10-10).
		/// </summary>
		private void SetDashPatternFromCachedDashPropertiesAfterOldDeserialization()
		{
			if (!_configuredProperties.HasFlag(Configured.DashStyle))
			{
				_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
			}
			else // DashStyle is configured
			{
				switch (_cachedDashStyle)
				{
					case DashStyle.Solid:
						_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
						break;

					case DashStyle.Dash:
						_dashPattern = DashPatternListManager.Instance.BuiltinDefaultDash;
						break;

					case DashStyle.Dot:
						_dashPattern = DashPatternListManager.Instance.BuiltinDefaultDot;
						break;

					case DashStyle.DashDot:
						_dashPattern = DashPatternListManager.Instance.BuiltinDefaultDashDot;
						break;

					case DashStyle.DashDotDot:
						_dashPattern = DashPatternListManager.Instance.BuiltinDefaultDashDotDot;
						break;

					case DashStyle.Custom:
						_dashPattern = new Drawing.DashPatterns.Custom(_cachedDashPattern.Select(x => (double)x), _cachedDashOffset);
						break;

					default:
						throw new NotImplementedException();
				}
			}
		}
コード例 #30
0
		public static ImageSource GetImage(IDashPattern val)
		{
			const double height = 1;
			const double width = 2;
			const double lineWidth = height / 5;

			DashStyle dashStyle;
			if (val is Solid)
				dashStyle = DashStyles.Solid;
			else if (val is Dash)
				dashStyle = DashStyles.Dash;
			else if (val is Dot)
				dashStyle = DashStyles.Dot;
			else if (val is DashDot)
				dashStyle = DashStyles.DashDot;
			else if (val is DashDotDot)
				dashStyle = DashStyles.DashDotDot;
			else
				dashStyle = new DashStyle(val, 0);

			// draws a transparent outline to fix the borders
			var drawingGroup = new DrawingGroup();

			var geometryDrawing = new GeometryDrawing();
			geometryDrawing.Geometry = new RectangleGeometry(new Rect(0, 0, width, height));
			geometryDrawing.Pen = new Pen(Brushes.Transparent, 0);
			drawingGroup.Children.Add(geometryDrawing);

			geometryDrawing = new GeometryDrawing() { Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2)) };
			geometryDrawing.Pen = new Pen(Brushes.Black, lineWidth) { DashStyle = dashStyle };
			drawingGroup.Children.Add(geometryDrawing);

			var geometryImage = new DrawingImage(drawingGroup);

			// Freeze the DrawingImage for performance benefits.
			geometryImage.Freeze();
			return geometryImage;
		}
コード例 #31
0
ファイル: PenX.cs プロジェクト: Altaxo/Altaxo
		public PenX()
		{
			_dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid;
		}