Esempio n. 1
0
        static void Main(string[] args)
        {
            //Lav generisk liste med tre tal

            List <int> samling = new List <int>();

            samling.Add(5); samling.Add(3); samling.Add(9000);
            foreach (int element in samling)
            {
                Console.WriteLine(element);
            }

            //Løsning med Dictionary

            Dictionary <int, string> samling2 = new Dictionary <int, string>();

            samling2.Add(1, "halløj"); samling2.Add(9000, "hej"); samling2.Add(3, "Javel");

            Console.WriteLine(samling2[9000]);

            //Namespace test

            Console.WriteLine(t());
            Console.WriteLine("De næste to er ens, men den ene gør brug af namespace, og den anden gør ikke!: ");
            Console.WriteLine(test.N1.t());
            Console.WriteLine(N1.t());
            Console.WriteLine("Den sidste er et andet namespace, men funktionen hedder det samme: ");
            Console.WriteLine(test2.N1.t());
        }
Esempio n. 2
0
 private void NameChanger_Tick(object sender, EventArgs e)
 {
     WriteText("^1-- ^5N^7o ^5H^7ost ^5M^7od ^5M^7enu ^5B^7y ^5M^7rNiato  ^1--\n\n^5Simple Mods\nPrestige Menu\nStats Menu\n^2-->^5Name Changer\n\n\n\n^2www.ihax.fr\n^3Facebook : ^1Guillaume ^2MrNiato");
     if (Key_IsDown.DetectKey(Key_IsDown.Key.Cross))
     {
         NameChanger.Stop();
         N1.Start();
         groupBox4.Enabled = true;
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_DOWN))
     {
         NameChanger.Stop();
         HostMainMenu.Start();
         groupBox4.Enabled = false;
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_UP))
     {
         NameChanger.Stop();
         StatsMenu.Start();
         groupBox4.Enabled = false;
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.R3))
     {
         NameChanger.Stop();
         Sleep.Start();
         groupBox4.Enabled = false;
     }
 }
Esempio n. 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (N1 != 0)
            {
                hash ^= N1.GetHashCode();
            }
            if (N2 != 0)
            {
                hash ^= N2.GetHashCode();
            }
            if (Soma != 0)
            {
                hash ^= Soma.GetHashCode();
            }
            if (Subtracao != 0)
            {
                hash ^= Subtracao.GetHashCode();
            }
            if (Multiplicacao != 0)
            {
                hash ^= Multiplicacao.GetHashCode();
            }
            if (Divisao != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Divisao);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 4
0
        public static int Interp(Node <N1> n, Env <int> env = null)
        {
            if (env == null)
            {
                env = new Env <int>();
            }
            if (n == null)
            {
                throw new Exception($"No node to execute");
            }
            N1 type = n.type;

            switch (type)
            {
            case N1.Int: return(int.Parse(n.datas[0]));

            case N1.Add: return(Interp(n.nodes[0], env) + Interp(n.nodes[1], env));

            case N1.Negate: return(-Interp(n.nodes[0], env));

            case N1.Var: return(env.Lookup(n.datas[0]));

            case N1.Let: return(Interp(n.nodes[1], env.Extend(n.datas[0], Interp(n.nodes[0], env))));

            case N1.Read: {
                Console.Write($"Enter Value: ");
                int val = int.Parse(Console.ReadLine());
                Console.WriteLine();
                return(val);
            }
            }
            throw new Exception($"Unknown N1 Type {type}");
        }
Esempio n. 5
0
 /// <summary>
 /// Returns a hash code for this instances.
 /// </summary>
 /// <returns>
 /// A hash code for this instances, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return
         (this.HasValue.GetHashCode()
          ^ (Book == null ? 0 : Book.ToLower().GetHashCode())
          ^ (N1 == null ? 0 : N1.ToLower().GetHashCode() >> 1)
          ^ (N2 == null ? 0 : N2.ToLower().GetHashCode() << 1)
          ^ (NumberCount));
 }
Esempio n. 6
0
        public override bool Equals(object obj)
        {
            var other = obj as SmoothTriangle;

            return(base.Equals(other) &&
                   N1.Equals(other.N1) &&
                   N2.Equals(other.N2) &&
                   N3.Equals(other.N3));
        }
Esempio n. 7
0
        public override string GetEngineValues(string format, IFormatProvider provider, string delimeter)
        {
            string buf;

            buf = N1.ToString(format, provider) + delimeter
                  + N2.ToString(format, provider) + delimeter
                  + thruster.GetThrusterValues(engineNumber, delimeter);

            return(buf);
        }
Esempio n. 8
0
        //Se requiere recibir el Random para evitar la misma informacion
        public clsProceso(Random R)
        {
            decimal       N1, N2, Resultado;
            char          Signo;
            OperacionEnum Op;

            N1 = R.Next(1, 100);
            N2 = R.Next(1, 100);
            Op = (OperacionEnum)R.Next(5);

            switch (Op)
            {
            case OperacionEnum.Suma:
                Signo     = '+';
                Resultado = N1 + N2;
                break;

            case OperacionEnum.Resta:
                Signo     = '-';
                Resultado = N1 - N2;
                break;

            case OperacionEnum.Multiplicacion:
                Signo     = '*';
                Resultado = N1 * N2;
                break;

            case OperacionEnum.Division:
                Signo     = '/';
                Resultado = N1 / N2;
                break;

            case OperacionEnum.Residuo:
                Signo     = '%';
                Resultado = N1 % N2;
                break;

            default:
                Signo     = '?';
                Resultado = 0;
                break;
            }

            this.Operacion = N1.ToString() + Signo + N2.ToString();
            this.Resultado = Math.Round(Resultado, 4).ToString();
            this.TME       = this.TR = this.Servicio = R.Next(7, 18);
            this.Tamano    = R.Next(7, 30);
            this.Estado    = "Nuevo";

            this.Numero    = ++ID;
            this.Respuesta = -1;

            isCompleted = true;
        }
Esempio n. 9
0
        public static void ProvideRandDataSet(RichTextBox RTB)
        {
            int    N1, N2, N3, N4, N5;
            Random random = new Random();

            N1       = random.Next(0, 255);
            N2       = random.Next(0, 255);
            N3       = random.Next(0, 255);
            N4       = random.Next(0, 255);
            N5       = random.Next(0, 255);
            RTB.Text = N1.ToString() + ", " + N2.ToString() + ", " + N3.ToString() + ", " + N4.ToString() + ", " + N5.ToString();
        }
Esempio n. 10
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("RA: " + RA);
            sb.AppendLine("Nome: " + Nome);
            sb.AppendLine("N1: " + N1.ToString("0.0"));
            sb.AppendLine("Média: " + CalcularMedia().ToString("0.0"));
            sb.AppendLine("Frequencia do Aluno: %" + FrequenciaAluno().ToString("0.0"));
            sb.AppendLine("Situação :" + situacao);

            return(sb.ToString());
        }
Esempio n. 11
0
        public bool PerpendicularTo(Point3d P0, Point3d P1, Point3d P2)
        {
            Vector3d V0, V1, V2, N0, N1, N2;

            V0 = P2 - P1;
            V1 = P0 - P2;
            V2 = P1 - P0;
            N0 = Vector3d.CrossProduct(V1, V2);
            if (!N0.Unitize())
            {
                return(false);
            }
            N1 = Vector3d.CrossProduct(V2, V0);
            if (!N1.Unitize())
            {
                return(false);
            }
            N2 = Vector3d.CrossProduct(V0, V1);
            if (!N2.Unitize())
            {
                return(false);
            }
            double s0 = 1.0 / V0.Length;
            double s1 = 1.0 / V1.Length;
            double s2 = 1.0 / V2.Length;
            double e0 = s0 * Math.Abs(Vector3d.DotProduct(N0, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N0, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N0, V2));
            double e1 = s0 * Math.Abs(Vector3d.DotProduct(N1, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N1, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N1, V2));
            double e2 = s0 * Math.Abs(Vector3d.DotProduct(N2, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N2, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N2, V2));

            if (e0 <= e1)
            {
                if (e0 <= e2)
                {
                    this = N0;
                }
                else
                {
                    this = N2;
                }
            }
            else if (e1 <= e2)
            {
                this = N1;
            }
            else
            {
                this = N2;
            }
            return(true);
        }
Esempio n. 12
0
 private void N1_Tick(object sender, EventArgs e)
 {
     WriteText("^1-- ^5N^7o ^5H^7ost ^5M^7od ^5M^7enu ^5B^7y ^5M^7rNiato  ^1--\n\n^2-->^5 Click X to Set The Name in the textBox in the software");
     if (Key_IsDown.DetectKey(Key_IsDown.Key.Cross))
     {
         PS3.Extension.WriteString(0x2A80BE8, textBox1.Text);
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.R3))
     {
         N1.Stop();
         HostMainMenu.Start();
         groupBox4.Enabled = false;
     }
 }
Esempio n. 13
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (N1 != 0)
            {
                hash ^= N1.GetHashCode();
            }
            if (N2 != 0)
            {
                hash ^= N2.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 14
0
 public override bool Equals(object obj)
 {
     return(obj is Triangle triangle &&
            Transform.Equals(triangle.Transform) &&
            Material.Equals(triangle.Material) &&
            Parent == triangle.Parent &&
            HasParent == triangle.HasParent &&
            P1.Equals(triangle.P1) &&
            P2.Equals(triangle.P2) &&
            P3.Equals(triangle.P3) &&
            Edge1.Equals(triangle.Edge1) &&
            Edge2.Equals(triangle.Edge2) &&
            Normal.Equals(triangle.Normal) &&
            N1.Equals(triangle.N1) &&
            N2.Equals(triangle.N2) &&
            N3.Equals(triangle.N3) &&
            IsSmoothed == triangle.IsSmoothed);
 }
Esempio n. 15
0
        public override int GetHashCode()
        {
            int hashCode = -2063967696;

            hashCode = hashCode * -1521134295 + Transform.GetHashCode();
            hashCode = hashCode * -1521134295 + Material.GetHashCode();
            hashCode = hashCode * -1521134295 + SavedRay.GetHashCode();
            hashCode = hashCode * -1521134295 + Parent.GetHashCode();
            hashCode = hashCode * -1521134295 + HasParent.GetHashCode();
            hashCode = hashCode * -1521134295 + P1.GetHashCode();
            hashCode = hashCode * -1521134295 + P2.GetHashCode();
            hashCode = hashCode * -1521134295 + P3.GetHashCode();
            hashCode = hashCode * -1521134295 + Edge1.GetHashCode();
            hashCode = hashCode * -1521134295 + Edge2.GetHashCode();
            hashCode = hashCode * -1521134295 + Normal.GetHashCode();
            hashCode = hashCode * -1521134295 + N1.GetHashCode();
            hashCode = hashCode * -1521134295 + N2.GetHashCode();
            hashCode = hashCode * -1521134295 + N3.GetHashCode();
            hashCode = hashCode * -1521134295 + IsSmoothed.GetHashCode();
            return(hashCode);
        }
Esempio n. 16
0
        /// <summary>
        /// Finalize edge marking
        /// </summary>
        public void MarkNeighborEdges()
        {
            //for (int i = 0; i < 3; i++)
            //{
            //    if (EdgeIsConstrained[i] && Neighbors[i] != null)
            //    {
            //        Neighbors[i].MarkConstrainedEdge(Points[(i + 1) % 3], Points[(i + 2) % 3]);
            //    }

            //}

            //-----------------
            //0
            if (this.C0 && N0 != null)
            {
                //(0 + 1) % 3 => 2
                //(0 + 2) % 3 => 1
                N0.SelectAndMarkConstrainedEdge(2, 1);
            }
            //-----------------
            //1
            if (this.C1 && N1 != null)
            {
                //(1 + 1) % 3 => 1
                //(1 + 2) % 3 => 0
                N1.SelectAndMarkConstrainedEdge(1, 0);
            }
            //-----------------
            //2
            if (this.C2 && N2 != null)
            {
                //(2 + 1) % 3 => 0
                //(2 + 2) % 3 => 1

                N2.SelectAndMarkConstrainedEdge(0, 1);
            }
        }
Esempio n. 17
0
 public void Foo(N1 <int> arg)
 {
 }
        void pruebaCorridas(List <double> Xi)
        {
            int         R, N1, N2;
            double      Media, Desviacion, H, Z0;
            List <bool> Arriba = new List <bool>();

            // Ver si estan arriba o abajo
            foreach (double x in Xi)
            {
                if (x < 0.5)
                {
                    Arriba.Add(false);
                }
                else
                {
                    Arriba.Add(true);
                }
            }

            R  = numDeCorridas(Arriba);
            N1 = Arriba.FindAll(x => x == false).Count;
            N2 = Arriba.FindAll(x => x == true).Count;

            // Calcular media
            Media = 2 * N1 * N2;
            Media = Media / (N1 + N2);
            Media = Media + 1;

            // Calcular desviacion
            Desviacion = (2 * N1 * N2) - N1 - N2;
            Desviacion = 2 * N1 * N2 * Desviacion;
            Desviacion = Desviacion / (Math.Pow(N1 + N2, 2) * (N1 + N2 - 1));
            Desviacion = Math.Sqrt(Desviacion);

            // Corrección para continuidad
            H = R < Media ? 0.5 : -0.5;

            // Valor estadístico Z0
            Z0 = R + H - Media;
            Z0 = Z0 / Desviacion;

            lblR.Text          = "R = " + R.ToString();
            lblN1.Text         = "N1 = " + N1.ToString();
            lblN2.Text         = "N2 = " + N2.ToString();
            lblMedia.Text      = "Media = " + Media.ToString();
            lblDesviacion.Text = "Desviacion = " + Desviacion.ToString();
            lblH.Text          = "H = " + H.ToString();
            lblZ.Text          = "Z0 = " + Z0.ToString();

            if (Z0 < -1.96)
            {
                lblResultado.Text = "Resultado\nZ0 < -1.96\n∴\nNo se comportan de manera aleatoria.";
            }
            else if (Z0 > 1.96)
            {
                lblResultado.Text = "Resultado\n1.96 < Z0\n∴\nNo se comportan de manera aleatoria.";
            }
            else
            {
                lblResultado.Text = "Resultado\n-1.96 ≤ Z0 ≤ 1.96\n∴\nSe comportan de manera aleatoria.";
            }
        }
Esempio n. 19
0
        /// <summary>
        /// overrides the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/> method.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            base.OnDraw(Device);
            if (Transverse == null)
            {
                return;
            }
            if (Transverse.Count == 0)
            {
                return;
            }

            for (int i = 1; i > 0; i--)
            {
                if (Trace[i].dist(Trace[i - 1]) < Utils.epsilon)
                {
                    Trace.RemoveAt(i);
                }
            }
            if ((Trace.Count == 3) && (Trace.Closed()))
            {
                Trace.RemoveAt(2);
            }
            if (Trace.Count <= 1)
            {
                return;
            }
            //    if (Trace.Count <= 1) return;
            xyz Basey = new xyz(0, 0, 0);

            if (Trace.Count == 2)
            {
                Basey = new xyz(0, 0, -1);
                if ((Basey & (Trace[1] - Trace[0])).length() < 0.000001)
                {
                    Basey = new xyz(0, -1, 0);
                }
            }
            else
            {
                Basey = (((Trace[2] - Trace[1]) & (Trace[0] - Trace[1]))).normalized() * (-1);
            }

            for (int i = 0; i < Trace.Count - 1; i++)
            {
                xyz N1, N2;
                if (i == 0)
                {
                    if (Trace.Closed())
                    {
                        N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[Trace.Count - 2] - Trace[i]).normalized();
                    }
                    else
                    {
                        N1 = (Trace[i + 1] - Trace[i]).normalized();
                    }

                    if ((i + 2) == Trace.Count)
                    {
                        N2 = (Trace[i] - Trace[i + 1]).normalized() & Basey;
                    }
                    else
                    {
                        N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized();
                    }
                }
                else
                if (i == (Trace.Count - 2))
                {
                    N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized();
                    if (Trace.Closed())
                    {
                        N2 = (Trace[i] - Trace[0]).normalized() - (Trace[1] - Trace[0]).normalized();
                    }
                    else
                    {
                        N2 = (Trace[i] - Trace[Trace.Count - 1]).normalized();
                    }
                }
                else
                {
                    N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized();
                    N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized();
                }
                if (Trace.Count == 2)
                {
                    N1 = Trace[1] - Trace[0];
                    N2 = Trace[0] - Trace[1];
                }
                Plane P1 = new Plane(Trace[i], N1.normalized());
                Plane P2 = new Plane(Trace[i + 1], N2.normalized());

                if (i > 0)
                {
                    Basey = Matrix.Mirror(P1) * Basey - Matrix.Mirror(P1) * new xyz(0, 0, 0);
                }
                Base B = new Base();
                B.BaseO = Trace[i];
                B.BaseZ = (Trace[i + 1] - Trace[i]).normalized();
                B.BaseY = Basey.normalized();
                B.BaseX = (B.BaseY & B.BaseZ).normalized();
                B.BaseY = B.BaseZ & B.BaseX * (-1);



                Matrix BInvert   = B.ToMatrix().invert();
                Plane  DownPlane = BInvert * P1;
                Plane  UpPlane   = BInvert * P2;
                Device.PushMatrix();
                Device.MulMatrix(B.ToMatrix());
                for (int m = 0; m < Transverse.Count; m++)
                {
                    for (int n = 0; n < Transverse[m].Count; n++)
                    {
                        CurveExtruder CE = new CurveExtruder();
                        CE.Height = -1;


                        CE.DownPlane = BInvert * P1;
                        CE.UpPlane   = BInvert * P2;
                        CE.Curve     = Transverse[m][n];
                        CE.Paint(Device);
                        if (Device.RenderKind == RenderKind.SnapBuffer)
                        {
                            SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1];
                            if (SI != null)
                            {
                                SI.OfObject = this;
                            }
                        }
                    }
                }

                double L = (Trace[i + 1] - Trace[i]).length();

                if ((i == 0) && (CloseFirst))
                {
                    Device.drawPolyPolyCurve(Transverse);
                }
                if ((i == Trace.Count - 2) && (CloseLast))
                {
                    Device.PushMatrix();
                    Device.MulMatrix(Matrix.Translation(new xyz(0, 0, L)));
                    Device.drawPolyPolyCurve(Transverse);
                    Device.PopMatrix();
                }
                Device.PopMatrix();
            }
        }
Esempio n. 20
0
 public int GetInt()
 {
     return(int.Parse(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString()));
 }
Esempio n. 21
0
 public string GetString()
 {
     return(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString());
 }
        public EDI835SchemaModel ParseEDI835(string fileText)
        {
            bool   payerSeg     = false;
            bool   payeeSeg     = false;
            string claimSegment = string.Empty;
            string segmentValue = string.Empty;

            string[] ediTextArray         = fileText.Split("~");
            CLP      clp                  = null;
            SVC      svc                  = null;
            bool     findNextCLP          = false;
            bool     isServiceLineVisited = false;

            foreach (string stringSegment in ediTextArray)
            {
                string[] segmentArray = stringSegment.Split("*");
                if (segmentArray != null)
                {
                    IEnumerable <string> values = Enum.GetValues(typeof(EDI835Segments))
                                                  .OfType <EDI835Segments>()
                                                  .Select(s => Convert.ToString(s));

                    if (values.Contains(segmentArray[0].TrimStart()))
                    {
                        if (segmentArray[0].TrimStart() != "CLP" && findNextCLP == true)
                        {
                            continue;
                        }
                        //else continue;
                        segmentValue = segmentArray[0].TrimStart();
                        if (claimSegment == "CLP")
                        {
                            segmentValue = "CLP";
                        }
                        switch (segmentValue)
                        {
                        case "ISA":
                        {
                            ISA ISA = GetSegmentInfo <ISA>(new ISA(), segmentArray);
                            ediSchemaModel.ISA = ISA;
                            break;
                        }

                        case "GS":
                        {
                            GS GS = GetSegmentInfo <GS>(new GS(), segmentArray);
                            ediSchemaModel.GS = GS;
                            break;
                        }

                        case "ST":
                        {
                            ST ST = GetSegmentInfo <ST>(new ST(), segmentArray);
                            ediSchemaModel.ST = ST;
                            break;
                        }

                        case "BPR":
                        {
                            BPR BPR = GetSegmentInfo <BPR>(new BPR(), segmentArray);
                            ediSchemaModel.BPR = BPR;
                            break;
                        }

                        case "TRN":
                        {
                            TRN TRN = GetSegmentInfo <TRN>(new TRN(), segmentArray);
                            ediSchemaModel.TRN = TRN;
                            break;
                        }

                        case "DTM":
                        {
                            DTM DTM = GetSegmentInfo <DTM>(new DTM(), segmentArray);
                            ediSchemaModel.DTM = DTM;
                            break;
                        }

                        case "N1":
                        {
                            if (segmentArray[1] == "PR")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayerInfo = N1;
                                payerSeg = true;
                            }
                            else if (segmentArray[1] == "PE")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayeeInfo = N1;
                                payeeSeg = true;
                            }
                            break;
                        }

                        case "N3":
                        {
                            if (payerSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayerAddress = N3;
                            }
                            else if (payeeSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayeeAddress = N3;
                            }

                            break;
                        }

                        case "N4":
                        {
                            if (payerSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayerCityStateZip = N4;
                                payerSeg = false;
                            }
                            else if (payeeSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayeeCityStateZip = N4;
                                payeeSeg = false;
                            }
                            break;
                        }

                        case "CLP":
                        {
                            claimSegment = "CLP";
                            switch (segmentArray[0].TrimStart())
                            {
                            case "CLP":
                            {
                                findNextCLP = false;
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp = null;
                                }
                                clp = GetSegmentInfo <CLP>(new CLP(), segmentArray);
                                break;
                            }

                            case "SVC":
                            {
                                //if (svc != null)
                                //{
                                //    if (clp.SVCList == null) clp.SVCList = new List<SVC>();
                                //    clp.SVCList.Add(svc);
                                //    svc = null;
                                //}
                                svc = GetSegmentInfo <SVC>(new SVC(), segmentArray);
                                if (clp != null && clp.SVCList == null)
                                {
                                    clp.SVCList = new List <SVC>();
                                }

                                clp.SVCList.Add(svc);
                                isServiceLineVisited = true;
                                break;
                            }

                            case "CAS":
                            {
                                if (isServiceLineVisited)
                                {
                                    CAS CAS = GetSegmentInfo <CAS>(new CAS(), segmentArray);
                                    if (svc.SVCAdjList == null)
                                    {
                                        svc.SVCAdjList = new List <CAS>();
                                    }
                                    svc.SVCAdjList.Add(CAS);
                                    CAS = null;
                                }
                                break;
                            }

                            case "REF":
                            {
                                if (segmentArray[1].Trim() == "6R" && svc != null && svc.REF == null)
                                {
                                    svc.REF = new REF();
                                    svc.REF = GetSegmentInfo <REF>(new REF(), segmentArray);
                                }
                                break;
                            }

                            case "GE":
                            {
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp         = null;
                                    findNextCLP = true;
                                }
                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }
                            break;
                        }
                        }
                    }
                }
            }
            return(ediSchemaModel);
        }
        /// <summary>
        /// 改变数字
        /// </summary>
        /// <param name="num">数字</param>
        public void ChangeNum(double num)
        {
            if (num >= 0 && !IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = true
                });
                IsPostive = true;
            }
            else if (num < 0 && IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = false
                });
                IsPostive = false;
            }
            num = Math.Abs(num);
            string numstr = num.ToString();

            if (numstr.IndexOf("E+") >= 0)
            {
                string[] numstmp = Regex.Split(numstr, "E+");
                numstr = numstmp[0];
                int x = 1;
                if (numstmp[0].IndexOf(".") >= 0)
                {
                    numstr = numstr.Replace(".", "");
                    x      = numstmp[0].Length - numstmp[0].IndexOf(".");
                }
                for (int i = x - 1; i < int.Parse(numstmp[1]); i++)
                {
                    numstr += "0";
                }
            }
            int[] numids = new int[6];
            if (num >= 10000)
            {
                if (num >= 100000000)
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 8); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -2;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            if (4 - i == 3)
                            {
                                numids[3] = 0;
                            }
                            else
                            {
                                numids[4 - i] = -3;
                            }
                        }
                    }
                }
                else
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 4); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -1;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            numids[4 - i] = -3;
                        }
                    }
                }
            }
            else
            {
                string[] tmp1 = numstr.Split('.');
                for (int i = 1; i <= 4; i++)
                {
                    if (tmp1[0].Length - i >= 0)
                    {
                        numids[4 - i] = int.Parse(tmp1[0].Substring(tmp1[0].Length - i, 1));
                    }
                    else
                    {
                        numids[4 - i] = -3;
                    }
                }
                if (tmp1.Length > 1)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (tmp1[1].Length - i > 0)
                        {
                            numids[4 + i] = int.Parse(tmp1[1].Substring(i, 1));
                        }
                        else
                        {
                            numids[4 + i] = 0;
                        }
                    }
                }
            }
            N4.ChangeNum(numids[0]);
            N3.ChangeNum(numids[1]);
            N2.ChangeNum(numids[2]);
            N1.ChangeNum(numids[3]);
            if (numids[4] == 0 && numids[5] == 0)
            {
                numpoint.Visibility = Visibility.Hidden;
                P1.Visibility       = Visibility.Hidden;
                P2.Visibility       = Visibility.Hidden;
                ViewPanel.Margin    = new Thickness(30, 0, -28, 0);
            }
            else
            {
                numpoint.Visibility = Visibility.Visible;
                P1.Visibility       = Visibility.Visible;
                P2.Visibility       = Visibility.Visible;
                ViewPanel.Margin    = new Thickness(1, 0, 1, 0);
                P1.ChangeNum(numids[4]);
                P2.ChangeNum(numids[5]);
            }
        }
        public string BuildEdi(List <Patient> patientList, InsuranceCompany insurance,
                               BillingProvider billingProvider)
        {
            var buildEdi = new StringBuilder();
            //Begin ISA
            var buildisa = new Isa();

            buildEdi.Append(buildisa.BuildIsa());

            //Begin GS
            var buildGs = new Gs();

            buildEdi.Append(buildGs.BuildGs());

            //Begin ST
            var buildSt = new St();

            buildEdi.Append(buildSt.BuildSt());

            //Begin BPR
            var buildBpr = new Bpr();

            buildEdi.Append(buildBpr.BuildBpr(insurance));

            //Build TRN
            var buildTrn = new Trn();

            buildEdi.Append(buildTrn.BuildTrn(insurance));

            //Ref Segment conditional, not included at this time
            //REF Receiver Identification
            //REF01 Receiver Reference Number
            //REF02 Receiver Reference Identification

            //Build DTM Loop Production Date
            var buildDtm = new Dtm();

            buildEdi.Append(buildDtm.BuildDtm(patientList));

            //Build N1 Insurance Company Identification Segment 1000A
            var buildNOne = new N1();

            buildEdi.Append(buildNOne.BuildNOne(insurance));

            //BuildN3 Insurance Company Identification Segment 1000A
            var buildNThree = new N3();

            buildEdi.Append(buildNThree.BuildNThree(insurance));

            // Build N4 Insurance Company Identification 1000A
            var buildNFour = new N4();

            buildEdi.Append(buildNFour.BuildN4(insurance));

            //Build Ref Insurance Company Identification 1000A
            var buildRef = new Ref();

            buildEdi.Append(buildRef.BuildRef());

            //Build Per Insurance Company Identification 1000A
            var buildPer = new Per();

            buildEdi.Append(buildPer.BuildPerPhone());

            //Build Per Insurance Company Website Information 1000A
            buildEdi.Append(buildPer.BuildPerWebSite());

            //Build N1 Provider Identifier Segment 1000B
            buildEdi.Append(buildNOne.BuildNOne(billingProvider));

            //Build N3 Provider Identifier Segment 1000B
            buildEdi.Append(buildNThree.BuildNThree(billingProvider));

            //Build N4 Provider Identifier Segment 1000B
            buildEdi.Append(buildNFour.BuildN4(billingProvider));

            //Build Ref Provider Identifier 1000B
            buildEdi.Append(buildRef.BuildRefAdditionalPayee());
            buildEdi.Append(buildRef.BuildRefAdditionalPayeeTwo());

            //LX Segment 2000B
            var buildLx = new Lx();

            buildEdi.Append(buildLx.BuildLx());

            //TS3 2000B NOT USED
            //TS2 2000B NOT USED
            //CLP Segment 2100

            foreach (Patient patient in patientList)
            {
                var buildClp = new Clp();
                buildEdi.Append(buildClp.BuildClp(patient));

                var buildNmOne = new Nm1();
                buildEdi.Append(buildNmOne.BuildNm1(patient));


                //MIA Inpatient Adjudication Information
                //MOA Outpatient Adjudication Information
                //REF Other CLaim Related Identification


                //Ref Rendering Provider Identifier 2100
                buildEdi.Append(buildRef.BuildRef(patient.Provider));

                //DTM Statement From or To Date 2100
                buildEdi.Append(buildDtm.BuildDtm(patient));

                //PER Claim Contact Information 2100

                //SVC Level 2110
                var buildSvc = new Svc();

                buildEdi.Append(buildSvc.BuildSvc(patient.Charge));
                buildEdi.Append(buildDtm.BuildDtm(patient.Charge));

                var buildCas = new Cas();
                if (patient.Charge.AdjustmentList != null)
                {
                    buildEdi.Append(buildCas.BuildCas(patient.Charge.AdjustmentList));
                    buildEdi.Append(buildCas.BuildCas(patient.Charge));
                }
                else
                {
                    buildEdi.Append(buildCas.BuildCas(patient.Charge));
                }
                buildEdi.Append(buildRef.BuildRefControlNumber());

                var buildAmt = new Amt();
                buildEdi.Append(buildAmt.BuildAmt(patient.Charge));
                //QTY 2110
                //LQ 2110
                //LQ01 Service Line Remittance Remark Code 1
                //LQ02 Service Line Remittance Remark Code 2

                foreach (AddonCharge addon in patient.Charge.AddonChargeList)
                {
                    buildEdi.Append(buildSvc.BuildSvc(addon));
                    buildEdi.Append(buildCas.BuildCas(addon.AdjustmentList));
                    buildEdi.Append(buildRef.BuildRefControlNumber());
                    buildEdi.Append(buildAmt.BuildAmt(addon));
                }
            }

            var buildSe = new Se();

            buildEdi.Append(buildSe.BuildSe());

            var buildGe = new Ge();

            buildEdi.Append(buildGe.BuildGe());

            var buildIea = new Iea();

            buildEdi.Append(buildIea.BuildIea());

            return(buildEdi.ToString());
        }