Beispiel #1
0
 //Set up the instance of Pure-data
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
         PD = new Pd(numberOfInputChannel, numberOfOutputChannel, AudioSettings.outputSampleRate);
         //Uses this to get prints of Pure Data
         PD.Messaging.Print += delegate(object sender, PrintEventArgs e) {
             Debug.Log(e.Symbol.Value);
         };
         manager = PD.LoadPatch(APIPath("pdManager.pd"));
         if (MixerChannel == null)
         {
             Debug.LogWarning("Not found mixer channel...");
         }
         createPdMixer();
         if (pdDsp)
         {
             PD.Start();
         }
     }
     else if (!Instance.Equals((object)this))
     {
         Destroy(gameObject);
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return((Side == other.Side || Side != null && Side.Equals(other.Side)) &&
                   (Sv == other.Sv || Sv != null && Sv.Equals(other.Sv)) &&
                   (Pt == other.Pt || Pt != null && Pt.Equals(other.Pt)) &&
                   (Ot == other.Ot || Ot != null && Ot.Equals(other.Ot)) &&
                   (P == other.P || P != null && P.Equals(other.P)) &&
                   (Sc == other.Sc || Sc != null && Sc.Equals(other.Sc)) &&
                   (Rc == other.Rc || Rc != null && Rc.Equals(other.Rc)) &&
                   (S == other.S || S != null && S.Equals(other.S)) &&
                   (Pd == other.Pd || Pd != null && Pd.Equals(other.Pd)) &&
                   (Rac == other.Rac || Rac != null && Rac.Equals(other.Rac)) &&
                   (Md == other.Md || Md != null && Md.Equals(other.Md)) &&
                   (Sl == other.Sl || Sl != null && Sl.Equals(other.Sl)) &&
                   (Avp == other.Avp || Avp != null && Avp.Equals(other.Avp)) &&
                   (Sm == other.Sm || Sm != null && Sm.Equals(other.Sm)) &&
                   (Id == other.Id || Id != null && Id.Equals(other.Id)) &&
                   (Bsp == other.Bsp || Bsp != null && Bsp.Equals(other.Bsp)) &&
                   (Status == other.Status || Status != null && Status.Equals(other.Status)) &&
                   (Sr == other.Sr || Sr != null && Sr.Equals(other.Sr)) &&
                   (Cd == other.Cd || Cd != null && Cd.Equals(other.Cd)));
        }
Beispiel #3
0
 protected void AddMemberAttributePin(MemberInfo member, IEnumerable <Type> desiredattrtypes)
 {
     foreach (var attrtype in desiredattrtypes)
     {
         Attribute[] validattrs;
         try
         {
             validattrs = member.GetCustomAttributes(attrtype, true).Cast <Attribute>().ToArray();
         }
         catch (Exception e)
         {
             continue;
         }
         if (validattrs.Length == 0)
         {
             continue;
         }
         var pin = Pd.AddOutput(TransformType(attrtype, member), new OutputAttribute(member.Name + " " + attrtype.GetCSharpName())
         {
             Visibility = PinVisibility.OnlyInspector
         });
         pin.Spread.SliceCount = validattrs.Length;
         for (int i = 0; i < validattrs.Length; i++)
         {
             pin[i] = TransformOutput(validattrs[i], member, i);
         }
     }
 }
Beispiel #4
0
        protected void AddMemberPin(MemberInfo member)
        {
            if (!AllowMember(member))
            {
                return;
            }
            var oattr = MemberAttributeHandler <OutputAttribute>(member);

            Type memberType = typeof(object);

            switch (member)
            {
            case FieldInfo field:
                memberType = field.FieldType;
                break;

            case PropertyInfo prop:
                memberType = prop.PropertyType;
                break;
            }
            var enumerable    = false;
            var dictionary    = false;
            var allowEnumconv = AllowEnumBinsizing(member, memberType);

            GetEnumerableGenerics(member, memberType, out var potentialGenDictT, out var potentialGenEnumT);

            if (allowEnumconv && potentialGenDictT != null)
            {
                var stype = potentialGenDictT.GenericTypeArguments;
                oattr.Name          = member.Name + " Values";
                oattr.BinVisibility = oattr.Visibility == PinVisibility.OnlyInspector
                    ? PinVisibility.OnlyInspector
                    : PinVisibility.Hidden;

                var kattr = (OutputAttribute)oattr.Clone();
                kattr.Name          = member.Name + " Keys";
                kattr.BinVisibility = PinVisibility.OnlyInspector;
                Pd.AddOutput(TransformType(stype[0], member), kattr, binSized: true);
                Pd.AddOutput(TransformType(stype[1], member), oattr, binSized: true);
                dictionary = true;
            }
            else if (allowEnumconv && potentialGenEnumT != null)
            {
                var stype = potentialGenEnumT.GenericTypeArguments[0];
                oattr.BinVisibility = oattr.Visibility == PinVisibility.OnlyInspector
                    ? PinVisibility.OnlyInspector
                    : PinVisibility.Hidden;
                Pd.AddOutput(TransformType(stype, member), oattr, binSized: true);
                enumerable = true;
            }
            else
            {
                Pd.AddOutput(TransformType(memberType, member), oattr);
                enumerable = false;
            }
            AddMemberAttributePin(member);
            IsMemberEnumerable.Add(member, enumerable);
            IsMemberDictionary.Add(member, dictionary);
        }
        public DiffSpreadPin AddInput(params InputAttribute[] attrs)
        {
            if (GroupType == null)
            {
                throw new TypeIsNullException();
            }

            return(attrs.Select(attr => Pd.AddInput(GroupType, attr)).ToArray()[0]);
        }
Beispiel #6
0
 void showWinPicture()
 {
     Text.text = "you win";
     Pnon.SetActive(false);
     Pa.SetActive(false);
     Pb.SetActive(false);
     Pc.SetActive(false);
     Pd.SetActive(false);
     Pe.SetActive(false);
     Pwin.SetActive(false);
     KK = ShowPic(WINNUM + 1, WIN);
 }
Beispiel #7
0
 /// <summary>
 /// Sets up communication with libPd.
 /// </summary>
 void SetUpPd()
 {
     // Init new Pd instance
     _pd = new Pd(0, 2, SampleRate);
     // Open Pd patch
     _patch = _pd.LoadPatch("../../../pd/test.pd");
     // Subscribe to receiver
     _pd.Messaging.Float += Pd_Float;
     _pd.Messaging.Bind(CursorReceiver);
     // Start audio
     _pd.Start();
 }
Beispiel #8
0
        private void AddMemberPin(PropertyInfo member)
        {
            if (!AllowMember(member))
            {
                return;
            }
            if (!member.CanWrite)
            {
                return;
            }

            var memberType = member.PropertyType;

            Properties.Add(member);

            var iattr = MemberAttributeHandler <InputAttribute>(member);

            var enumerable   = false;
            var dictionary   = false;
            var defaultValue = typeof(T).GetProperty(member.Name)?.GetValue(Default);

            var allowEnumconv = AllowEnumBinsizing(member, memberType);

            GetEnumerableGenerics(member, memberType, out var potentialGenDictT, out var potentialGenEnumT);

            if (allowEnumconv && potentialGenDictT != null)
            {
                var stype = potentialGenDictT.GenericTypeArguments;
                iattr.Name = member.Name + " Values";
                var kattr = (InputAttribute)iattr.Clone();
                kattr.Name = member.Name + " Keys";
                Pd.AddInput(TransformType(stype[0], member), kattr, binSized: true, obj: member);
                Pd.AddInput(TransformType(stype[1], member), iattr, binSized: true, obj: member);
                dictionary = true;
            }
            else if (allowEnumconv && potentialGenEnumT != null)
            {
                var stype = potentialGenEnumT.GenericTypeArguments[0];
                Pd.AddInput(TransformType(stype, member), iattr, binSized: true, obj: member);
                enumerable = true;
            }
            else
            {
                AddPinAndSetDefaultValue(member, iattr, defaultValue);
                enumerable = false;
            }
            IsMemberEnumerable.Add(member, enumerable);
            IsMemberDictionary.Add(member, dictionary);
        }
Beispiel #9
0
        protected void AddPinAndSetDefaultValue(PropertyInfo member, InputAttribute iattr, object defaultValue)
        {
            var defVals = TransformDefaultToValues(defaultValue);

            iattr.Name             = member.Name;
            iattr.DefaultValue     = defVals[0];
            iattr.DefaultValues    = defVals;
            iattr.DefaultString    = defaultValue?.ToString() ?? "";
            iattr.DefaultNodeValue = defaultValue;

            if (defaultValue is bool b)
            {
                iattr.DefaultBoolean = b;
            }
            if (defaultValue is RGBAColor vcol)
            {
                iattr.DefaultColor = new[] { vcol.R, vcol.G, vcol.B, vcol.A }
            }
            ;
            if (defaultValue is Color4 s4Col)
            {
                iattr.DefaultColor = new double[] { s4Col.Red, s4Col.Green, s4Col.Blue, s4Col.Alpha }
            }
            ;
            if (defaultValue is Color3 s3Col)
            {
                iattr.DefaultColor = new double[] { s3Col.Red, s3Col.Green, s3Col.Blue, 1 }
            }
            ;

            Pd.AddInput(TransformType(member.PropertyType, member), iattr);
            var spread = Pd.InputPins[member.Name].Spread;

            spread.SliceCount = 1;
            spread[0]         = TransformDefaultValue(defaultValue, member);
        }
    }
Beispiel #10
0
 public void Init()
 {
     _pd = new Pd(_inputs, _outputs, _sampleRate);
 }
Beispiel #11
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Side != null)
                {
                    hash = hash * 59 + Side.GetHashCode();
                }

                if (Sv != null)
                {
                    hash = hash * 59 + Sv.GetHashCode();
                }

                if (Pt != null)
                {
                    hash = hash * 59 + Pt.GetHashCode();
                }

                if (Ot != null)
                {
                    hash = hash * 59 + Ot.GetHashCode();
                }

                if (P != null)
                {
                    hash = hash * 59 + P.GetHashCode();
                }

                if (Sc != null)
                {
                    hash = hash * 59 + Sc.GetHashCode();
                }

                if (Rc != null)
                {
                    hash = hash * 59 + Rc.GetHashCode();
                }

                if (S != null)
                {
                    hash = hash * 59 + S.GetHashCode();
                }

                if (Pd != null)
                {
                    hash = hash * 59 + Pd.GetHashCode();
                }

                if (Rac != null)
                {
                    hash = hash * 59 + Rac.GetHashCode();
                }

                if (Md != null)
                {
                    hash = hash * 59 + Md.GetHashCode();
                }

                if (Sl != null)
                {
                    hash = hash * 59 + Sl.GetHashCode();
                }

                if (Avp != null)
                {
                    hash = hash * 59 + Avp.GetHashCode();
                }

                if (Sm != null)
                {
                    hash = hash * 59 + Sm.GetHashCode();
                }

                if (Id != null)
                {
                    hash = hash * 59 + Id.GetHashCode();
                }

                if (Bsp != null)
                {
                    hash = hash * 59 + Bsp.GetHashCode();
                }

                if (Status != null)
                {
                    hash = hash * 59 + Status.GetHashCode();
                }

                if (Sr != null)
                {
                    hash = hash * 59 + Sr.GetHashCode();
                }

                if (Cd != null)
                {
                    hash = hash * 59 + Cd.GetHashCode();
                }

                return(hash);
            }
        }
Beispiel #12
0
 public void Init()
 {
     _pd    = new Pd(_inputs, _outputs, _sampleRate);
     _patch = _pd.LoadPatch(@"../../test_csharp.pd");
     _pd.Start();
 }
Beispiel #13
0
        List <Product> GetProducts()
        {
            var Pds = new Dictionary <uint, Product>();

            string Cont = GetHtmlPrdcts();

            if (Cont.Contains("__GETTASK_ERROR__"))
            {
                return(Pds.Values.ToList());
            }

            string[] Lines = Cont.Split("\n".ToCharArray());

            foreach (string Line in Lines)
            {
                if (string.IsNullOrEmpty(Line.Trim()))
                {
                    continue;
                }

                var Cols = Line.Split("\"".ToCharArray());
                int I    = 0;
                var PdId = Cols[I++].ToUint();
                if (PdId == 0)
                {
                    continue;                            //No Product
                }
                Product Pd = null;
                if (Pds.ContainsKey(PdId))
                {
                    Pd = Pds[PdId];
                }
                else
                {
                    Pd = new Product {
                        Id = PdId
                    };
                    Pds[PdId] = Pd;
                }

                Pd.Name = Cols[I++].ToName();
                Pd.PDM  = Cols[I++].Trim();

                var PlanId = Cols[I++].ToUint();
                if (PlanId == 0)
                {
                    continue;                              //No Plan
                }
                var Plan = Pd.GetPlan(PlanId);
                Plan.Title = Cols[I++].ToName();
                Plan.Begin = Cols[I++].ToDt();
                Plan.End   = Cols[I++].ToDt();

                var Nd = new Need {
                    Id = Cols[I++].ToUint()
                };
                if (Nd.Id == 0)
                {
                    continue;                             //No Need.
                }
                Nd.Title = Cols[I++].ToName();
                Nd.St    = Need.ToStatus(Cols[I++].Trim());
                Nd.Stg   = Need.ToStage(Cols[I++].Trim());
                Plan.AddNeed(Nd);
            }

            return(Pds.Values.ToList());
        }
Beispiel #14
0
    void showPicture(char WH)
    {
        switch (WH)
        {
        case 'S':
            Text.text = "you're in next LEVEL";
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(true);
            Pnext1.SetActive(true);
            NEXTL.SetActive(false);
            break;

        case 'A':
            Text.text = "A" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(true);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'B':
            Text.text = "B" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(true);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'C':
            Text.text = "C" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(true);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'D':
            Text.text = "D" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(true);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'E':
            Text.text = "E" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(false);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(true);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'N':
            Text.text = "NON" + "X " + positionX + "Y " + positionY + "Z " + positionZ;
            Pnon.SetActive(true);
            Pwrong.SetActive(false);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            break;

        case 'W':
            Pnon.SetActive(false);
            Pwrong.SetActive(true);
            Pa.SetActive(false);
            Pb.SetActive(false);
            Pc.SetActive(false);
            Pd.SetActive(false);
            Pe.SetActive(false);
            Pwin.SetActive(false);
            Pnext.SetActive(false);
            Pnext1.SetActive(false);
            NEXTL.SetActive(false);
            //KKKEEP = false;
            break;
        }
    }
Beispiel #15
0
    //int frameRate = 250;

    // Use this for initialization
    void Start()
    {
        //  Time.captureFramerate = frameRate;

        Time.fixedDeltaTime = 1.0f;
        Pa.SetActive(false);
        Pb.SetActive(false);
        Pc.SetActive(false);
        Pd.SetActive(false);
        Pe.SetActive(false);
        Pwin.SetActive(false);
        Pnon.SetActive(true);
        Pwrong.SetActive(false);
        Pnext.SetActive(false);
        Pnext1.SetActive(false);
        NEXTL.SetActive(false);

        animatorhand = Hand.GetComponent <Animator>();
        //print(animatorhand.GetInstanceID ());

        La.SetActive(false); Ld.SetActive(false);
        Da.SetActive(false); Db.SetActive(false); Dc.SetActive(false); Dd.SetActive(false); De.SetActive(false); Hand.SetActive(false);
        whichF       = 0;
        nowKeep      = 0;
        showcount    = 0;
        playercount  = 0;
        currentlevel = 0;

        Last       = 'F';
        nowplaying = false;

        int temptnum;

        #region random
        System.Random randNum = new System.Random();


        for (int i = 0; i < flowerlight_L0.Length;)
        {
            temptnum = randNum.Next(Min, Max);
            if (i == 0)
            {
                flowerlight_L0[i] = 0;
                i++;
            }

            else if (i == 1)
            {
                flowerlight_L0[i] = 1;
                i++;
            }

            else if (i == 2)
            {
                flowerlight_L0[i] = 4;
                i++;
            }
        }

        for (int i = 0; i < flowerlight_L1.Length;)
        {
            temptnum = randNum.Next(Min, Max);
            if (i == 0)
            {
                flowerlight_L1[i] = 0;
                i++;
            }

            else if (temptnum != flowerlight_L1[i - 1])
            {
                flowerlight_L1[i] = temptnum;
                i++;
            }
        }

        for (int i = 0; i < flowerlight_L2.Length;)
        {
            temptnum = randNum.Next(Min, Max);
            if (i == 0)
            {
                flowerlight_L2[i] = 0;
                i++;
            }

            else if (temptnum != flowerlight_L2[i - 1])
            {
                flowerlight_L2[i] = temptnum;
                i++;
            }
        }

        for (int i = 0; i < flowerlight_L3.Length;)
        {
            temptnum = randNum.Next(Min, Max);
            if (i == 0)
            {
                flowerlight_L3[i] = 0;
                i++;
            }

            else if (temptnum != flowerlight_L3[i - 1])
            {
                flowerlight_L3[i] = temptnum;
                i++;
            }
        }
        #endregion
        cantouch = false;
        tempkeep = false;

        #region show WIN
        for (int i = 0; i < WINNUM; i++)
        {
            WIN[i].SetActive(false);
        }
        KK = false;
        #endregion
    }
Beispiel #16
0
        private void AddMemberPin(MemberInfo member)
        {
            if (!(member is FieldInfo) && !(member is PropertyInfo))
            {
                return;
            }
            Type memberType = typeof(object);

            switch (member)
            {
            case FieldInfo field:
                if (field.IsStatic)
                {
                    return;
                }
                if (field.FieldType.IsPointer)
                {
                    return;
                }
                if (!field.FieldType.IsPublic && !FExposePrivate[0])
                {
                    return;
                }

                memberType = field.FieldType;
                break;

            case PropertyInfo prop:
                if (!prop.CanRead)
                {
                    return;
                }
                if (prop.PropertyType.IsPointer)
                {
                    return;
                }
                if (prop.GetIndexParameters().Length > 0)
                {
                    return;
                }

                memberType = prop.PropertyType;
                break;
            }
            var enumerable = false;

            if ((memberType.GetInterface("IEnumerable") != null) && (memberType != typeof(string)))
            {
                try
                {
                    var interfaces = memberType.GetInterfaces().ToList();
                    interfaces.Add(memberType);
                    var stype = interfaces
                                .Where(type =>
                    {
                        try
                        {
                            var res = type.GetGenericTypeDefinition();
                            if (res == null)
                            {
                                return(false);
                            }
                            return(res == typeof(IEnumerable <>));
                        }
                        catch (Exception)
                        {
                            return(false);
                        }
                    })
                                .First().GenericTypeArguments[0];
                    Pd.AddOutput(TransformType(stype, member), new OutputAttribute(member.Name), binSized: true);
                    enumerable = true;
                }
                catch (Exception)
                {
                    Pd.AddOutput(TransformType(memberType, member), new OutputAttribute(member.Name));
                    enumerable = false;
                }
            }
            else
            {
                Pd.AddOutput(TransformType(memberType, member), new OutputAttribute(member.Name));
                enumerable = false;
            }
            IsMemberEnumerable.Add(member, enumerable);
        }
Beispiel #17
0
        private void BtnEnHoja_Click(object sender, EventArgs e)
        {
            //generar los vales y despues impromir pero en hoja
            try
            {
                dtVales2.Rows.Clear();
                Cursor = Cursors.WaitCursor;

                if (ds.Tables[0].Rows.Count != 0 & TxtDesde.Text != "")
                {
                    Encrypt objCrypto = new Encrypt(Encrypt.CryptoProvider.Rijndael);
                    objCrypto.Key = AppSettings.Key;
                    objCrypto.IV  = AppSettings.IV;

                    dtDetalle = new DataTable();
                    dtDetalle = new CL_Vales().getdetalleVales(NumComprobrante, Convert.ToInt32(CboTipoComprobante.SelectedValue));



                    string cadena;
                    if (dtDetalle.Rows.Count == 0)
                    {
                        int UltimoNumVale = new CL_Vales().getUltimoVale();

                        foreach (DataRow fila in ds.Tables[1].Rows)
                        {
                            int cant = Convert.ToInt32(fila["Cantidad"]);

                            for (int x = 0; x < cant; x++)
                            {
                                UltimoNumVale++;
                                DataRow row = dtVales2.NewRow();
                                row["ID"]          = x + 1;
                                row["Comprobante"] = NumComprobrante;
                                row["Cliente"]     = lblCliente.Text;
                                row["Codigo"]      = fila["ProductoID"].ToString();
                                row["Producto"]    = fila["NomProducto"].ToString().Remove(fila["NomProducto"].ToString().IndexOf("X"));
                                row["Peso"]        = string.Concat(string.Format("{0:0.##}", fila["Unidades"]), " KG");
                                row["NumVale"]     = UltimoNumVale;
                                cadena             = objCrypto.CifrarCadena(UltimoNumVale.ToString());

                                row["CodBar"]    = string.Concat("*", UltimoNumVale.ToString().PadLeft(4, '/'), cadena.Substring(0, 7), "*");
                                row["Numeros"]   = UltimoNumVale.ToString().PadLeft(4, '0');
                                row["Direccion"] = direccion;
                                row["Foto"]      = ImageToByteArray((Image)Halley.Presentacion.Properties.Resources.ResourceManager.GetObject(fila["Imagen"].ToString() + "2"));
                                dtVales2.Rows.Add(row);
                            }
                        }

                        new CL_Vales().Insert(AppSettings.UserID, lblSedeID.Text, dtVales2, Convert.ToInt32(CboTipoComprobante.SelectedValue));
                    }
                    else
                    {
                        int X = 1;
                        foreach (DataRow fila in dtDetalle.Rows)
                        {
                            DataRow row = dtVales2.NewRow();
                            row["ID"]          = X;
                            row["Comprobante"] = NumComprobrante;
                            row["Cliente"]     = fila["RazonSocial"].ToString();
                            row["Producto"]    = fila["NomProducto"].ToString().Remove(fila["NomProducto"].ToString().IndexOf("X"));
                            row["Peso"]        = string.Concat(string.Format("{0:0.##}", fila["Unidades"]), " KG");
                            row["NumVale"]     = fila["NumVale"];
                            cadena             = objCrypto.CifrarCadena(fila["NumVale"].ToString());

                            row["CodBar"]    = string.Concat("*", fila["NumVale"].ToString().PadLeft(4, '/'), cadena.Substring(0, 7), "*");
                            row["Numeros"]   = fila["NumVale"].ToString().PadLeft(4, '0');
                            row["Direccion"] = direccion;
                            row["Foto"]      = ImageToByteArray((Image)Halley.Presentacion.Properties.Resources.ResourceManager.GetObject(fila["Imagen"].ToString() + "2"));
                            dtVales2.Rows.Add(row);
                            ++X;
                        }
                    }

                    printDialog1.ShowDialog();
                    if (printDialog1.PrinterSettings.PrinterName != "")
                    {
                        Pd.Print();
                    }
                }
                else
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show("No existen vales o no se ha ingresado el inicio del vale", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }