Example #1
0
        /// <summary>
        /// Writes the component parameter information.
        /// </summary>
        /// <param name="componentStorage">Component footprint storage key.</param>
        /// <param name="component">Component instance to have its parameters serialized.</param>
        private void WriteFootprintParameters(CFStorage componentStorage, PcbComponent component)
        {
            var parameters = component.ExportToParameters();

            componentStorage.GetOrAddStream("Parameters").Write(writer =>
            {
                WriteBlock(writer, w => WriteParameters(w, parameters));
            });
        }
Example #2
0
        /// <summary>
        /// Writes the library data from the current file which contains the PCB library
        /// header information parameters and also a list of the existing components.
        /// </summary>
        /// <param name="library"></param>
        private void WriteLibraryData(CFStorage library)
        {
            library.GetOrAddStream("Data").Write(writer =>
            {
                var parameters = Data.Header.ExportToParameters();
                WriteBlock(writer, w => WriteParameters(w, parameters));

                writer.Write(Data.Items.Count);
                foreach (var component in Data.Items)
                {
                    WriteStringBlock(writer, component.Pattern);
                    WriteFootprint(component);
                }
            });
        }
Example #3
0
        /// <summary>
        /// Writes a list of strings from the <paramref name="component"/> to the "WideStrings"
        /// stream inside of the specified <paramref name="storage"/> key.
        /// <para>
        /// Each string entry is encoded inside a parameter string value with a comma separated
        /// list of integers that represent UTF-16 code-points.
        /// </para>
        /// <para>
        /// These strings are used as Unicode variants of the texts existing in text string
        /// binary records.
        /// </para>
        /// </summary>
        /// <param name="storage">
        /// Storage key where to write to "WideStrings" stream.
        /// </param>
        /// <param name="component">
        /// Component to have its list of strings serialized.
        /// </param>
        internal static void WriteWideStrings(CFStorage storage, PcbComponent component)
        {
            var texts = component.Primitives.OfType <PcbText>().ToList();

            storage.GetOrAddStream("WideStrings").Write(writer =>
            {
                var parameters = new ParameterCollection();
                for (var i = 0; i < texts.Count; ++i)
                {
                    var text = texts[i];
                    text.WideStringsIndex = i;

                    var data       = text.Text ?? "";
                    var codepoints = data.Select(c => Convert.ToInt32(c));
                    var intList    = string.Join(",", codepoints);
                    parameters.Add($"ENCODEDTEXT{i}", intList);
                }
                WriteBlock(writer, w => WriteParameters(w, parameters));
            });
        }
Example #4
0
 /// <summary>
 /// Writes the header record containing the size of the data.
 /// </summary>
 /// <param name="storage">
 /// Storage key where to write for the Header stream.
 /// </param>
 /// <param name="recordCount">
 /// Size of the Data section.
 /// </param>
 internal static void WriteHeader(CFStorage storage, int recordCount)
 {
     storage.GetOrAddStream("Header").Write(writer => writer.Write(recordCount));
 }