示例#1
0
        public static string[] GetSeparators(this SeparatorType s, string[] other)
        {
            if (s == SeparatorType.Comma)
            {
                return new string[] { "," }
            }
            ;
            if (s == SeparatorType.Tab)
            {
                return new string[] { "\t" }
            }
            ;
            if (s == SeparatorType.Space)
            {
                return new string[] { " " }
            }
            ;
            if (s == SeparatorType.Br_Tag)
            {
                return new string[] { "<br>", "<br />", "<BR>", "<BR />" }
            }
            ;
            return(other);
        }
    }
}
示例#2
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 50, Configuration.FieldSeparator),
                       Id,
                       ExternalAccessionIdentifier?.ToDelimitedString(),
                       AccessionIdentifier?.ToDelimitedString(),
                       ContainerIdentifier?.ToDelimitedString(),
                       PrimaryParentContainerIdentifier?.ToDelimitedString(),
                       EquipmentContainerIdentifier?.ToDelimitedString(),
                       SpecimenSource,
                       RegistrationDateTime.HasValue ? RegistrationDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ContainerStatus?.ToDelimitedString(),
                       CarrierType?.ToDelimitedString(),
                       CarrierIdentifier?.ToDelimitedString(),
                       PositionInCarrier?.ToDelimitedString(),
                       TrayTypeSac?.ToDelimitedString(),
                       TrayIdentifier?.ToDelimitedString(),
                       PositionInTray?.ToDelimitedString(),
                       Location != null ? string.Join(Configuration.FieldRepeatSeparator, Location.Select(x => x.ToDelimitedString())) : null,
                       ContainerHeight.HasValue ? ContainerHeight.Value.ToString(Consts.NumericFormat, culture) : null,
                       ContainerDiameter.HasValue ? ContainerDiameter.Value.ToString(Consts.NumericFormat, culture) : null,
                       BarrierDelta.HasValue ? BarrierDelta.Value.ToString(Consts.NumericFormat, culture) : null,
                       BottomDelta.HasValue ? BottomDelta.Value.ToString(Consts.NumericFormat, culture) : null,
                       ContainerHeightDiameterDeltaUnits?.ToDelimitedString(),
                       ContainerVolume.HasValue ? ContainerVolume.Value.ToString(Consts.NumericFormat, culture) : null,
                       AvailableSpecimenVolume.HasValue ? AvailableSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null,
                       InitialSpecimenVolume.HasValue ? InitialSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null,
                       VolumeUnits?.ToDelimitedString(),
                       SeparatorType?.ToDelimitedString(),
                       CapType?.ToDelimitedString(),
                       Additive != null ? string.Join(Configuration.FieldRepeatSeparator, Additive.Select(x => x.ToDelimitedString())) : null,
                       SpecimenComponent?.ToDelimitedString(),
                       DilutionFactor?.ToDelimitedString(),
                       Treatment?.ToDelimitedString(),
                       Temperature?.ToDelimitedString(),
                       HemolysisIndex.HasValue ? HemolysisIndex.Value.ToString(Consts.NumericFormat, culture) : null,
                       HemolysisIndexUnits?.ToDelimitedString(),
                       LipemiaIndex.HasValue ? LipemiaIndex.Value.ToString(Consts.NumericFormat, culture) : null,
                       LipemiaIndexUnits?.ToDelimitedString(),
                       IcterusIndex.HasValue ? IcterusIndex.Value.ToString(Consts.NumericFormat, culture) : null,
                       IcterusIndexUnits?.ToDelimitedString(),
                       FibrinIndex.HasValue ? FibrinIndex.Value.ToString(Consts.NumericFormat, culture) : null,
                       FibrinIndexUnits?.ToDelimitedString(),
                       SystemInducedContaminants != null ? string.Join(Configuration.FieldRepeatSeparator, SystemInducedContaminants.Select(x => x.ToDelimitedString())) : null,
                       DrugInterference != null ? string.Join(Configuration.FieldRepeatSeparator, DrugInterference.Select(x => x.ToDelimitedString())) : null,
                       ArtificialBlood?.ToDelimitedString(),
                       SpecialHandlingCode != null ? string.Join(Configuration.FieldRepeatSeparator, SpecialHandlingCode.Select(x => x.ToDelimitedString())) : null,
                       OtherEnvironmentalFactors != null ? string.Join(Configuration.FieldRepeatSeparator, OtherEnvironmentalFactors.Select(x => x.ToDelimitedString())) : null,
                       ContainerLength?.ToDelimitedString(),
                       ContainerWidth?.ToDelimitedString(),
                       ContainerForm?.ToDelimitedString(),
                       ContainerMaterial?.ToDelimitedString(),
                       ContainerCommonName?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
 public CommandLineBuilder AppendDoubleDashIfNotNull(
     string arg,
     string val,
     SeparatorType separatorType,
     QuoteValue quoteVal)
 {
     return((val == null) ? this : AppendDoubleDash(arg, val, separatorType, quoteVal));
 }
示例#4
0
 private static Task GenerateAndComparePngBill(Bill bill, SeparatorType separatorType)
 {
     bill.Format.SeparatorType = separatorType;
     using PNGCanvas canvas    =
               new PNGCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight, 288, "Arial,Helvetica");
     QRBill.Draw(bill, canvas);
     return(VerifyImages.VerifyPng(canvas.ToByteArray()));
 }
 private void GenerateAndComparePngBill(Bill bill, SeparatorType separatorType,
                                        string expectedFileName)
 {
     bill.Format.SeparatorType = separatorType;
     using (PNGCanvas canvas =
                new PNGCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight, 288, "Arial,Helvetica"))
     {
         QRBill.Draw(bill, canvas);
         FileComparison.AssertGrayscaleImageContentsEqual(canvas.ToByteArray(), expectedFileName);
     }
 }
示例#6
0
 /// <summary>
 /// Tests if the graph can be separated with a separator of size 1. If so, the separator is saved in the "separator" member variable
 /// </summary>
 /// <returns>true iff a size 1 separator exists</returns>
 private bool FindSize1Separator()
 {
     foreach (int a in ArticulationPoints(graph))
     {
         separator     = new BitSet(graph.vertexCount);
         separator[a]  = true;
         separatorType = SeparatorType.Size1;
         return(true);
     }
     return(false);
 }
        public CommandLineBuilder AppendDash(string arg,
                                             string val,
                                             SeparatorType separatorType,
                                             QuoteValue quoteVal = QuoteValue.Yes)
        {
            _builder.Append("-").Append(arg).Append(GetSeparatorString(separatorType));
            AppendQuoted(val, quoteVal);
            _builder.Append(" ");

            return(this);
        }
示例#8
0
        /// <summary>Gets the hash code for this instance.</summary>
        /// <returns>A hash code for the current object.</returns>
        public override int GetHashCode()
        {
            int hashCode = 43802783;

            hashCode = hashCode * -1521134295 + OutputSize.GetHashCode();
            hashCode = hashCode * -1521134295 + Language.GetHashCode();
            hashCode = hashCode * -1521134295 + SeparatorType.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FontFamily);

            hashCode = hashCode * -1521134295 + GraphicsFormat.GetHashCode();
            return(hashCode);
        }
示例#9
0
        public static string Value(this SeparatorType type)
        {
            switch (type)
            {
            case SeparatorType.Comma:
                return(",");

            case SeparatorType.Semicolon:
                return(";");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        static string GetSeparatorString(SeparatorType separatorType)
        {
            switch (separatorType)
            {
            case SeparatorType.Equals:
                return("=");

            case SeparatorType.Space:
                return(" ");

            case SeparatorType.None:
                return("");

            default:
                return(" ");
            }
        }
示例#11
0
        /// <summary>
        /// Tests if the graph is not connected. In that case the empty set is a separator of size 0 and it is saved in the "separator" member variable
        /// </summary>
        /// <returns>true iff the graph is not connected</returns>
        private bool TestNotConnected()
        {
            int    componentCount = 0;
            BitSet nothing        = new BitSet(graph.vertexCount);

            foreach ((BitSet, BitSet)_ in graph.ComponentsAndNeighbors(nothing))
            {
                componentCount++;
                if (componentCount >= 2)
                {
                    separator     = nothing;
                    separatorType = SeparatorType.NotConnected;
                    return(true);
                }
            }
            return(false);
        }
示例#12
0
        private void DrawBorder()
        {
            SeparatorType separatorType = _bill.Format.SeparatorType;
            OutputSize    outputSize    = _bill.Format.OutputSize;

            if (separatorType == SeparatorType.None)
            {
                return;
            }

            _graphics.SetTransformation(0, 0, 0, 1, 1);

            // Draw vertical separator line between receipt and payment part
            _graphics.StartPath();
            _graphics.MoveTo(ReceiptWidth, 0);
            if (separatorType == SeparatorType.SolidLineWithScissors)
            {
                _graphics.LineTo(ReceiptWidth, SlipHeight - 8);
                _graphics.MoveTo(ReceiptWidth, SlipHeight - 5);
            }
            _graphics.LineTo(ReceiptWidth, SlipHeight);

            // Draw horizontal separator line between bill and rest of A4 sheet
            if (outputSize != OutputSize.QrBillOnly)
            {
                _graphics.MoveTo(0, SlipHeight);
                if (separatorType == SeparatorType.SolidLineWithScissors)
                {
                    _graphics.LineTo(5, SlipHeight);
                    _graphics.MoveTo(8, SlipHeight);
                }
                _graphics.LineTo(SlipWidth, SlipHeight);
            }
            _graphics.StrokePath(0.5, 0);

            // Draw scissors
            if (separatorType == SeparatorType.SolidLineWithScissors)
            {
                DrawScissors(ReceiptWidth, SlipHeight - 5, 3, 0);
                if (outputSize != OutputSize.QrBillOnly)
                {
                    DrawScissors(5, SlipHeight, 3, Math.PI / 2.0);
                }
            }
        }
示例#13
0
        /// <summary>
        /// Private handler for getting a string that matches the separator
        /// </summary>
        /// <param name="separatorType">Separator enumeration</param>
        /// <returns></returns>
        private static string GetSeparator(SeparatorType separatorType)
        {
            switch (separatorType)
            {
            case SeparatorType.Space:
                return(new string(" "));

            case SeparatorType.TwoSpaces:
                return(new string("  "));

            case SeparatorType.LineBreak:
                return(new string("\n"));

            case SeparatorType.Tab:
                return(new string("\t"));

            default: return(new string("  "));
            }
        }
示例#14
0
        /// <summary>
        /// Tests if the graph can be separated with a safe separator of size 2. If so, the separator is saved in the "separator" member variable
        /// </summary>
        /// <returns>true iff a size 2 separator exists</returns>
        public bool FindSize2Separator()
        {
            BitSet notIgnoredVertices = BitSet.All(graph.vertexCount);

            // loop over every pair of vertices
            for (int u = 0; u < graph.vertexCount; u++)
            {
                notIgnoredVertices[u] = false;
                foreach (int a in ArticulationPoints(graph, notIgnoredVertices))
                {
                    separator     = new BitSet(graph.vertexCount);
                    separator[u]  = true;
                    separator[a]  = true;
                    separatorType = SeparatorType.Size2;
                    return(true);
                }
                notIgnoredVertices[u] = true;
            }
            return(false);
        }
示例#15
0
 public static string GetSeparator(this SeparatorType s, string other)
 {
     if (s == SeparatorType.Comma)
     {
         return(",");
     }
     if (s == SeparatorType.Tab)
     {
         return("\t");
     }
     if (s == SeparatorType.Space)
     {
         return(" ");
     }
     if (s == SeparatorType.Br_Tag)
     {
         return("<br>");
     }
     return(other);
 }
示例#16
0
        /// <summary>
        /// Draws the separator line(s) to the specified canvas.
        /// <para>
        /// The separator lines are drawn assuming that the QR bill starts at position (0, 0)
        /// and extends the top and right.So position (0, 0) should be in the bottom left corner.
        /// </para>
        /// <para>
        /// This method allows to add separator lines to an existing QR bill,
        /// e.g. on to an archived QR bill document.
        /// </para>
        /// </summary>
        /// <param name="separatorType">The separator type.</param>
        /// <param name="withHorizontalLine"><code>true</code> if both the horizontal and vertical line should be drawn,
        /// <code>false</code> for the vertical line only</param>
        /// <param name="canvas">The canvas to draw to.</param>
        public static void DrawSeparators(SeparatorType separatorType, bool withHorizontalLine, ICanvas canvas)
        {
            Bill bill = new Bill
            {
                Format = new BillFormat
                {
                    SeparatorType = separatorType,
                    OutputSize    = withHorizontalLine ? OutputSize.QrBillWithHorizontalLine : OutputSize.QrBillOnly
                }
            };

            BillLayout layout = new BillLayout(bill, canvas);

            try
            {
                layout.DrawBorder();
            }
            catch (Exception e)
            {
                throw new QRBillGenerationException("Failed drawing separators", e);
            }
        }
示例#17
0
        public override string ToString()
        {
            var currName = name;
            var sb       = new StringBuilder(name);

            if (Derivatives.Any(d => d != 0))
            {
                if (Arguments.Length == 1)
                {
                    sb.Append(new String('\'', Derivatives[0]));
                }
                else
                {
                    sb.Append(DerivativeBracketsType.Open());
                    sb.Append(String.Join(SeparatorType.Value(), Derivatives));
                    sb.Append(DerivativeBracketsType.Close());
                }
            }
            name = sb.ToString();
            var res = base.ToString();

            name = currName;
            return(res);
        }
示例#18
0
 private Task GenerateAndCompareBill(Bill bill, GraphicsFormat graphicsFormat, SeparatorType separatorType)
 {
     bill.Format.GraphicsFormat = graphicsFormat;
     bill.Format.SeparatorType  = separatorType;
     byte[] imageData = QRBill.Generate(bill);
     return(VerifyImages.Verify(imageData, graphicsFormat));
 }
示例#19
0
        private void DrawBorder()
        {
            SeparatorType separatorType = _bill.Format.SeparatorType;
            OutputSize    outputSize    = _bill.Format.OutputSize;

            if (separatorType == SeparatorType.None)
            {
                return;
            }

            bool hasScissors = separatorType == SeparatorType.SolidLineWithScissors ||
                               separatorType == SeparatorType.DashedLineWithScissors ||
                               separatorType == SeparatorType.DottedLineWithScissors;

            LineStyle lineStyle;
            double    lineWidth;

            switch (separatorType)
            {
            case SeparatorType.DashedLine:
            case SeparatorType.DashedLineWithScissors:
                lineStyle = LineStyle.Dashed;
                lineWidth = 0.6;
                break;

            case SeparatorType.DottedLine:
            case SeparatorType.DottedLineWithScissors:
                lineStyle = LineStyle.Dotted;
                lineWidth = 0.75;
                break;

            default:
                lineStyle = LineStyle.Solid;
                lineWidth = 0.5;
                break;
            }


            _graphics.SetTransformation(0, 0, 0, 1, 1);

            // Draw vertical separator line between receipt and payment part
            _graphics.StartPath();
            _graphics.MoveTo(ReceiptWidth, 0);
            if (hasScissors)
            {
                _graphics.LineTo(ReceiptWidth, SlipHeight - 8);
                _graphics.MoveTo(ReceiptWidth, SlipHeight - 5);
            }
            _graphics.LineTo(ReceiptWidth, SlipHeight);

            // Draw horizontal separator line between bill and rest of A4 sheet
            if (outputSize != OutputSize.QrBillOnly)
            {
                _graphics.MoveTo(0, SlipHeight);
                if (hasScissors)
                {
                    _graphics.LineTo(5, SlipHeight);
                    _graphics.MoveTo(8, SlipHeight);
                }
                _graphics.LineTo(SlipWidth, SlipHeight);
            }
            _graphics.StrokePath(lineWidth, 0, lineStyle);

            // Draw scissors
            if (hasScissors)
            {
                DrawScissors(ReceiptWidth, SlipHeight - 5, 3, 0);
                if (outputSize != OutputSize.QrBillOnly)
                {
                    DrawScissors(5, SlipHeight, 3, Math.PI / 2.0);
                }
            }
        }
示例#20
0
 protected DataWithColumns(SeparatorType separator, bool headerRow, bool trailingSpaceInDataRows)
 {
     Separator = separator;
     HeaderRow = headerRow;
     TrailingSpaceInDataRows = trailingSpaceInDataRows;
 }
            // Pass in a string, start index, and you will get a number built from that string
            // up until the separator character (a dash, comma, or end of string),
            // as well as the separator type itself, and a pointer to the separator character
            private static void GetNumberAndSeparatorType(int indexNumberStart, string range, out uint number, out SeparatorType separatorType, out int indexSeparator)
            {
                int index = indexNumberStart;
                separatorType = SeparatorType.Uninitialized;
                // Determine the start and end index of the number represented in the string
                while (index < range.Length)
                {
                    // Determine the type of separator character
                    if (range[index] == '-')
                    {
                        separatorType = SeparatorType.Dash;
                        break;
                    }
                    else if (range[index] == ',')
                    {
                        separatorType = SeparatorType.Comma;
                        break;
                    }
                    index++;
                }
                indexSeparator = index;
                // End of string hit - note that as the type of separator
                if (separatorType == SeparatorType.Uninitialized)
                {
                    separatorType = SeparatorType.End;
                }

                // Build the uint from the string
                if (index != range.Length)
                {
                    number = Convert.ToUInt32(range.Substring(indexNumberStart, index - indexNumberStart));
                }
                else
                {
                    number = Convert.ToUInt32(range.Substring(indexNumberStart));
                }
            }
示例#22
0
 public SeparatorChar(char Char, SeparatorType Type)
 {
     sepChar   = Char;
     this.Type = Type;
 }
示例#23
0
 /// <summary>
 /// Method to print a list of numbers. Would work for strings too but not for objects
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="printThis"></param>
 /// <param name="separatorType"></param>
 private static void PrettyPrintNumber <T>(List <T> printThis, SeparatorType separatorType = SeparatorType.TwoSpaces)
 {
     printThis.ForEach(i => Console.Write("{0}{1}", i, GetSeparator(separatorType)));
     Console.Write('\n');
 }
示例#24
0
 /// <summary>
 /// Pretty prints a list of doubles
 /// </summary>
 /// <param name="printThis">List to print</param>
 /// <param name="separatorType">Separator character to use</param>
 public static void PrettyPrint(List <double> printThis, SeparatorType separatorType = SeparatorType.TwoSpaces)
 {
     PrettyPrintNumber <double>(printThis, separatorType);
 }
示例#25
0
 public SeparatorToken(Point location, SeparatorType type) : base(location) => Type = type;
示例#26
0
 private void GenerateAndCompareBill(Bill bill, GraphicsFormat graphicsFormat, SeparatorType separatorType,
                                     string expectedFileName)
 {
     bill.Format.GraphicsFormat = graphicsFormat;
     bill.Format.SeparatorType  = separatorType;
     byte[] imageData = QRBill.Generate(bill);
     FileComparison.AssertFileContentsEqual(imageData, expectedFileName);
 }
示例#27
0
 /// <summary>
 /// Separates the graph at a separator that has been found after pre-processing during the runtime of the actual algorithm.
 /// (If this function is called, a PTD for exactly one component has always been found already.)
 /// </summary>
 /// <param name="separator">the separator</param>
 /// <param name="separatorType">the type of that separator</param>
 /// <param name="minK">the minimum treewidth parameter. It is set to the maximum of its previous value and the separator size</param>
 /// <param name="alreadyCalculatedComponent">The component whose subgraph has an already calculated PTD.</param>
 /// <param name="alreadyCalculatedComponentIndex">the index in the list of subgraphs of the subgraph corresponding to that component</param>
 /// <returns>a list of the new subgraphs</returns>
 public List <Graph> ApplyExternallyFoundSafeSeparator(BitSet separator, SeparatorType separatorType, ref int minK, out int alreadyCalculatedComponentIndex, BitSet alreadyCalculatedComponent)
 {
     this.separator     = separator;
     this.separatorType = separatorType;
     return(SeparateAtSeparator(ref minK, out alreadyCalculatedComponentIndex, alreadyCalculatedComponent));
 }