• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 12008475829

25 Nov 2024 10:52AM UTC coverage: 75.339% (-0.3%) from 75.668%
12008475829

push

github

web-flow
Merge pull request #494 from DomCR/Issue-487_DBCOLOR

Issue 487 dbcolor

4956 of 7275 branches covered (68.12%)

Branch coverage included in aggregate %.

116 of 206 new or added lines in 21 files covered. (56.31%)

91 existing lines in 11 files now uncovered.

19811 of 25599 relevant lines covered (77.39%)

36312.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.cs
1
using ACadSharp.Entities;
2
using ACadSharp.Tables;
3
using CSUtilities.Converters;
4
using System;
5
using System.Drawing;
6

7
namespace ACadSharp.IO.DXF
8
{
9
        internal abstract partial class DxfSectionWriterBase
10
        {
11
                public event NotificationEventHandler OnNotification;
12

13
                public abstract string SectionName { get; }
14

15
                public ACadVersion Version { get { return this._document.Header.Version; } }
2,028✔
16

17
                public CadObjectHolder Holder { get; }
12,963✔
18

19
                protected IDxfStreamWriter _writer;
20
                protected CadDocument _document;
21

22
                public DxfSectionWriterBase(
270✔
23
                        IDxfStreamWriter writer,
270✔
24
                        CadDocument document,
270✔
25
                        CadObjectHolder holder)
270✔
26
                {
270✔
27
                        this._writer = writer;
270✔
28
                        this._document = document;
270✔
29
                        this.Holder = holder;
270✔
30
                }
270✔
31

32
                public void Write()
33
                {
270✔
34
                        this._writer.Write(DxfCode.Start, DxfFileToken.BeginSection);
270✔
35
                        this._writer.Write(DxfCode.SymbolTableName, this.SectionName);
270✔
36

37
                        this.writeSection();
270✔
38

39
                        this._writer.Write(DxfCode.Start, DxfFileToken.EndSection);
270✔
40
                }
270✔
41

42
                protected void writeCommonObjectData(CadObject cadObject)
43
                {
9,694✔
44
                        if (cadObject is DimensionStyle)
9,694✔
45
                        {
91✔
46
                                this._writer.Write(DxfCode.DimVarHandle, cadObject.Handle);
91✔
47
                        }
91✔
48
                        else
49
                        {
9,603✔
50
                                this._writer.Write(DxfCode.Handle, cadObject.Handle);
9,603✔
51
                        }
9,603✔
52

53
                        if (cadObject.XDictionary != null)
9,694✔
54
                        {
741✔
55
                                this._writer.Write(DxfCode.ControlString, DxfFileToken.DictionaryToken);
741✔
56
                                this._writer.Write(DxfCode.HardOwnershipId, cadObject.XDictionary.Handle);
741✔
57
                                this._writer.Write(DxfCode.ControlString, "}");
741✔
58

59
                                //Add the dictionary in the object holder
60
                                this.Holder.Objects.Enqueue(cadObject.XDictionary);
741✔
61
                        }
741✔
62

63
                        if (cadObject.Reactors != null && cadObject.Reactors.Count > 0)
9,694!
64
                        {
384✔
65
                                this._writer.Write(DxfCode.ControlString, DxfFileToken.ReactorsToken);
384✔
66
                                foreach (ulong reactorHandle in cadObject.Reactors.Keys)
2,186✔
67
                                {
517✔
68
                                        this._writer.Write(DxfCode.SoftPointerId, reactorHandle);
517✔
69
                                }
517✔
70
                                this._writer.Write(DxfCode.ControlString, "}");
384✔
71
                        }
384✔
72

73
                        this._writer.Write(DxfCode.SoftPointerId, cadObject.Owner.Handle);
9,694✔
74

75
                        //TODO: Write exended data
76
                        if (cadObject.ExtendedData != null)
9,694✔
77
                        {
9,694✔
78
                                //this._writer.Write(DxfCode.ControlString,DxfFileToken.ReactorsToken);
79
                                //this._writer.Write(DxfCode.HardOwnershipId, cadObject.ExtendedData);
80
                                //this._writer.Write(DxfCode.ControlString, "}");
81
                        }
9,694✔
82
                }
9,694✔
83

84
                protected void writeExtendedData(CadObject cadObject)
85
                {
7,157✔
86
                }
7,157✔
87

88
                protected void writeCommonEntityData(Entity entity)
89
                {
5,274✔
90
                        DxfClassMap map = DxfClassMap.Create<Entity>();
5,274✔
91

92
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Entity);
5,274✔
93

94
                        this._writer.Write(8, entity.Layer.Name);
5,274✔
95

96
                        this._writer.Write(6, entity.LineType.Name);
5,274✔
97

98
                        if (entity.BookColor != null)
5,274!
UNCOV
99
                        {
×
NEW
100
                                this._writer.Write(62, entity.BookColor.Color.GetApproxIndex());
×
NEW
101
                                this._writer.WriteTrueColor(420, entity.BookColor.Color);
×
NEW
102
                                this._writer.Write(430, entity.BookColor.Name);
×
NEW
103
                        }
×
104
                        else if (entity.Color.IsTrueColor)
5,274✔
105
                        {
20✔
106
                                this._writer.WriteTrueColor(420, entity.Color);
20✔
107
                        }
20✔
108
                        else
109
                        {
5,254✔
110
                                this._writer.Write(62, entity.Color.Index);
5,254✔
111
                        }
5,254✔
112

113
                        if (entity.Transparency.Value >= 0)
5,274✔
114
                        {
1,457✔
115
                                this._writer.Write(440, Transparency.ToAlphaValue(entity.Transparency));
1,457✔
116
                        }
1,457✔
117

118
                        this._writer.Write(48, entity.LinetypeScale, map);
5,274✔
119

120
                        this._writer.Write(60, entity.IsInvisible ? (short)1 : (short)0, map);
5,274✔
121

122
                        //TODO: Write if the layout is paperspace
123
                        if (false)
5,274✔
124
                        {
125
                                this._writer.Write(67, (short)1);
126
                        }
127

128
                        this._writer.Write(370, entity.LineWeight);
5,274✔
129
                }
5,274✔
130

131
                protected abstract void writeSection();
132

133
                protected void notify(string message, NotificationType notificationType = NotificationType.None, Exception ex = null)
134
                {
×
135
                        this.OnNotification?.Invoke(this, new NotificationEventArgs(message, notificationType, ex));
×
136
                }
×
137
        }
138
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc