当前位置: 首页>>代码示例>>C#>>正文


C# BitArray.CopyTo方法代码示例

本文整理汇总了C#中BitArray.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.CopyTo方法的具体用法?C# BitArray.CopyTo怎么用?C# BitArray.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitArray的用法示例。


在下文中一共展示了BitArray.CopyTo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

    // Update is called once per frame
    void Update()
    {
        if (ListenClient.ori != null && ListenClient.ori.Length > 4)
        {
            //Debug.Log (ListenClient.ori);
            string[] difPos = ListenClient.ori.Split('_');
            Debug.Log (difPos);
            string[] pos = difPos[0].Split(' ');

            double accel = double.Parse(difPos[1]);
            if (accel >= 7000 && !audio.isPlaying) {
                audio.Play ();
            }
            int button = int.Parse(difPos[2]);
            int trigger = int.Parse(difPos[3]);
            Debug.Log (button);
            b = new BitArray (new int[] { button });
            bool[] bits = new bool[32];
            if (button != 0) {
                b.CopyTo (bits, 0);

            }
            Debug.Log ("button " + bits[19]);
            if (bits [19]) {
                globalExtended = true;
            } else {
                globalExtended = false;
            }

            if (pos.Length >= 4)
            {
                Quaternion q = new Quaternion(float.Parse(pos[1]), float.Parse(pos[2]), float.Parse(pos[3]), float.Parse(pos[0]));
                //q = upInv * q;
                //q = Quaternion.Inverse(q);
                Vector3 e = q.eulerAngles;
                e.x *= -1;
                e.y *= -1;
                pivot.transform.rotation = Quaternion.Euler(e);
                //Debug.Log("transformed");
            }

        }

        if (ListenClient.pos != null && ListenClient.pos.Length > 5)
        {
            string[] strPos = ListenClient.pos.Split(';');
            for (int i = 0; i < strPos.Length; i++)
            {
                if (strPos[i].Contains("rwrist"))
                {
                    string[] headPos = strPos[i].Split(' ');
                    Debug.Log("POS: " + ListenClient.pos);
                    Debug.Log("i: " + strPos[i]);
                    transform.position =
                        new Vector3(float.Parse(headPos[1]) * 5, float.Parse(headPos[2]) * 5, 7 - float.Parse(headPos[3]) * 2);
                    break;
                }
            }
        }
    }
开发者ID:CaptainStouf,项目名称:TheKinectAwakens,代码行数:61,代码来源:Saber.cs

示例2: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     BitArray bitArr1;
     Boolean[] bolArr1;
     Boolean[] bolArr2;
     Int32 iNumOfElements;
     Random rnd1;
     try 
     {
         do
         {
             iNumOfElements = 10;
             rnd1 = new Random();
             strLoc = "Loc_742dsf!";
             iCountTestcases++;
             bolArr1 = new Boolean[iNumOfElements];
             for(int i=0; i<iNumOfElements; i++)
             {
                 if(rnd1.Next(10)>5)
                     bolArr1[i] = true;
                 else
                     bolArr1[i] = false;
             }
             bitArr1 = new BitArray(bolArr1);
             bolArr2 = new Boolean[iNumOfElements];
             bitArr1.CopyTo(bolArr2, 0);
             for(int i=0; i<iNumOfElements; i++)
             {
                 if(bolArr1[i] != bolArr2[i])
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_753qn_" + i + "! Wrong value returned, " + bolArr1[i] + " " + bolArr1[2]);
                 }
             }
             if(bitArr1.IsReadOnly)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_763dfsf! Wrong value returned");
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:61,代码来源:co3971get_isreadonly.cs

示例3: getIntFromBitArray

 //    public void initzialize(int UID) {
 //        //create texture with pattern form playerprefs
 //        pattern = new Texture2D((int)pattern_size.x,(int)pattern_size.y);
 //        pattern.filterMode = FilterMode.Point;
 //        BitArray pattern_array = new BitArray(System.BitConverter.GetBytes(UID));
 //        
 //        for(int x = 0; x < pattern.width; x++){
 //            for(int y = 0; y < pattern.height; y++){
 //                    if((pattern_array[x + (y*pattern.width)])){
 //                        pattern.SetPixel(x,y,new Color32(0,0,0,0));
 //                    }
 //                    else{
 //                        pattern.SetPixel(x,y,Color.white);
 //                    }
 //            }
 //        }
 //        pattern.Apply();
 //        billboard = (GameObject)Instantiate(Resources.Load("GUI/billboard_sign"),transform.position + Vector3.up*5f,Quaternion.identity);
 //        billboard.transform.LookAt(Camera.main.transform,Vector3.up);
 //        billboard.renderer.material.SetTexture("_MainTex",pattern);
 //    }
 //    void OnGUI(){
 //        if(pattern != null){
 //            Vector3 GOSP = Camera.main.WorldToScreenPoint(gameObject.transform.position);
 //            GOSP = new Vector3(GOSP.x,Screen.height - GOSP.y,GOSP.z); //converting screenspace go "lol" GUIspace
 //            
 //            int buttonWidth = (int)(32 * Mathf.Clamp(visibilityRange - GOSP.z,0.1f,1));
 //            int buttonHeight = (int)(32 * Mathf.Clamp(visibilityRange - GOSP.z,0.1f,1));
 //            
 //            if(GOSP.z < visibilityRange && GOSP.z > 0){ //if point is within frustrum and range
 //                Graphics.DrawTexture(new Rect(GOSP.x - buttonWidth/2 + offset.x ,GOSP.y - buttonHeight/2 + offset.y, buttonWidth, buttonHeight),pattern);
 //            }
 //        }
 //    }
 private int getIntFromBitArray(BitArray bitArray)
 {
     int[] array = new int[1];
     bitArray.CopyTo(array, 0);
     return array[0];
 }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:40,代码来源:EGravePattern.cs

示例4: binaryStringToBytes

    /* converts binary string to binary bytes */
    public byte[] binaryStringToBytes(string _binaryString)
    {
        string binary = _binaryString;
        int i = 0;
        int j = 0;
        BitArray bits = new BitArray(8);
        byte[] bytes = new byte[binary.Length/8];

        while (j!=binary.Length) {
            for (i=0;i!=8;i++) {

                bits.Set(i,(binary[j+i]=='1'?true:false));
            }

            bits.CopyTo(bytes,j/8);
            j+=8;
        }

        return bytes;
    }
开发者ID:Vsio,项目名称:Virulife,代码行数:21,代码来源:ecb.cs

示例5: DontDestroyOnLoad

	// Update is called once per frame
	//void Update () {
	//}
	
		// Use this for initialization
	/*void Awake()
    {
       DontDestroyOnLoad(this);
		
		GameObject M_TC1_01 = GameObject.Find("M_TC1_01");
		GameObject M_TC1_2 = GameObject.Find("M_TC1_01");
		
    }*/
	
	private byte[] BitArrayToByteArray(BitArray bits)
	{
		
	    byte[] ret = new byte[bits.Length / 8];
	    bits.CopyTo(ret, 0);
	    return ret;
	}
开发者ID:wiechars,项目名称:Emulation,代码行数:21,代码来源:CommunicationMaster.cs

示例6: Decode

    /*
     * Decodes received data (checks for validity, corrects network order, etc.).
     *
     * receive:	The bytes received from the server.
     * carry:	Bits that are being carried over from a previous packet.
     *
     * return:	A Decode object with decoded data or null if packet is too corrupt.
     */
    static byte[] Decode(byte[] receive)
    {
        int readcnt = 0;
        int readlen = (receive.Length-4) * 8;		// Bytes of data -> bits.
        readlen -= (readlen / 32) * 6;				// Each 32 bits has 6 parity bits.
        readlen -= (new int[] { 0, 4, 5, 5 })[receive.Length % 4];	// Parity bits for smaller packets.
        BitArray read = new BitArray(readlen);

        // Loop through each 32 bit packet after the first 32 bit header.
        for ( int i = 4; i < receive.Length; ) {
            int size = receive.Length - i;
            if ( size > 4 ) size = 4;				// Packet is between 1 and 4 bytes.

            BitArray[] data = new BitArray[size];
            for ( int e = size - 1; e >= 0; e-- )	// Copy out the bytes in reverse order.
                data[e] = Reversed(receive[i++]);	// Reverse the bits too.

            bool even;
            int badloc = -1;
            BitArray bits = Reversed(ToBits(data));	// Read in the bits.

            // Iterate through parity values (1, 2, 4, 8, ...), but skip the last parity.
            for ( int p = 1; p < bits.Length-1; p *= 2 ) {
                even = ! bits.Get(p-1);				// Even state is the opposite of the parity bit.
                // Iterate through starting points for take positions.
                for ( int l = p-1; l < bits.Length; l += p)
                    // Iterate through take values.
                    for ( int e = 0; e < p && l < bits.Length; e++, l++ )
                        // Check if take value is a parity bit.
                        if ( Math.Log(l+1, 2) % 1 != 0 )
                            even ^= bits.Get(l);	// Flip bit if 1.
                if ( ! even ) badloc += p;			// Bad bit = sum of failed parity values.
            }

            // Flip the bad bit if necessary.
            if ( badloc >= 0 ) bits.Set(badloc, ! bits.Get(badloc));

            even = true;							// Run the checksum over the full packet.
            foreach ( bool bit in bits ) even ^= bit;

            if ( ! even ) return null;				// Packet cant be fixed.

            // Extract parity bits.
            for ( int lb = bits.Length; lb > 0; lb-- )
                if ( Math.Log(lb, 2) % 1 != 0 )
                    read.Set(readcnt++, bits.Get(lb-1));
        }

        // Allocate a byte array space equal to the number of bytes read.
        byte[] bytes;
        if ( readlen % 8 == 0 )
            bytes = new byte[(readlen / 8)];
        else
            bytes = new byte[(readlen / 8) + (8 - readlen % 8)];
        read.CopyTo(bytes, 0);

        // Last block (block less than max size, 516), eliminate trailing nulls.
        if ( receive.Length < 516 ) {
            int size = bytes.Length;
            for ( ; size > 0 && bytes[size-1] == 0; size-- );
            byte[] trimmed = new byte[size];
            for ( int i = 0; i < size; i++ ) trimmed[i] = bytes[i];
            bytes = trimmed;
        }

        return bytes;
    }
开发者ID:PastyPilgrim,项目名称:datacomm,代码行数:75,代码来源:tftp.cs

示例7: GetData


//.........这里部分代码省略.........
                    ba.Set(8, true); ba.Set(9, false); ba.Set(10, true); ba.Set(11, false);
                    break;
                case ParaBorderStyle.PointGrayDashed3_4:
                    ba.Set(8, true); ba.Set(9, false); ba.Set(10, true); ba.Set(11, true);
                    break;
                default: // no borders
                    ba.Set(8, false); ba.Set(9, false); ba.Set(10, false); ba.Set(11, false); 
                    break;
            }
            #endregion

            #region BORDER COLOR

            /*
            0000    Black
            0001    Blue
            0010    Cyan
            0011    Green
            0100    Magenta
            0101    Red
            0110    Yellow
            0111    White
            1000    DarkBlue
            1001    DarkCyan
            1010    DarkGreen
            1011    DarkMagenta
            1100    DarkRed
            1101    DarkYellow
            1110    DarkGray
            1111    LightGray
            */

            switch (_color)
            {
                case ParaBorderColor.Black:
                    ba.Set(12, false); ba.Set(13, false); ba.Set(14, false); ba.Set(15, false);
                    break;
                case ParaBorderColor.Blue:
                    ba.Set(12, false); ba.Set(13, false); ba.Set(14, false); ba.Set(15, true);
                    break;
                case ParaBorderColor.Cyan:
                    ba.Set(12, false); ba.Set(13, false); ba.Set(14, true); ba.Set(15, false);
                    break;
                case ParaBorderColor.Green:
                    ba.Set(12, false); ba.Set(13, false); ba.Set(14, true); ba.Set(15, true);
                    break;
                case ParaBorderColor.Magenta:
                    ba.Set(12, false); ba.Set(13, true); ba.Set(14, false); ba.Set(15, false);
                    break;
                case ParaBorderColor.Red:
                    ba.Set(12, false); ba.Set(13, true); ba.Set(14, false); ba.Set(15, true);
                    break;
                case ParaBorderColor.Yellow:
                    ba.Set(12, false); ba.Set(13, true); ba.Set(14, true); ba.Set(15, false);
                    break;
                case ParaBorderColor.White:
                    ba.Set(12, false); ba.Set(13, true); ba.Set(14, true); ba.Set(15, true);
                    break;
                case ParaBorderColor.DarkBlue:
                    ba.Set(12, true); ba.Set(13, false); ba.Set(14, false); ba.Set(15, false);
                    break;
                case ParaBorderColor.DarkCyan:
                    ba.Set(12, true); ba.Set(13, false); ba.Set(14, false); ba.Set(15, true);
                    break;
                case ParaBorderColor.DarkGreen:
                    ba.Set(12, true); ba.Set(13, false); ba.Set(14, true); ba.Set(15, false);
                    break;
                case ParaBorderColor.DarkMagenta:
                    ba.Set(12, true); ba.Set(13, false); ba.Set(14, true); ba.Set(15, true);
                    break;
                case ParaBorderColor.DarkRed:
                    ba.Set(12, true); ba.Set(13, true); ba.Set(14, false); ba.Set(15, false);
                    break;
                case ParaBorderColor.DarkYellow:
                    ba.Set(12, true); ba.Set(13, true); ba.Set(14, false); ba.Set(15, true);
                    break;
                case ParaBorderColor.DarkGray:
                    ba.Set(12, true); ba.Set(13, true); ba.Set(14, true); ba.Set(15, false);
                    break;
                case ParaBorderColor.LightGray:
                    ba.Set(12, true); ba.Set(13, true); ba.Set(14, true); ba.Set(15, true);
                    break;
                default:
                    ba.Set(12, false); ba.Set(13, false); ba.Set(14, false); ba.Set(15, false); //Default to Black
                    break;
            }

            #endregion

            byte[] arr = (byte[])Array.CreateInstance(typeof(byte), 2);
            
            ba.CopyTo(arr, 0);
            
            return BitConverter.ToInt16(arr, 0);            
            //}
            //catch (Exception)
            //{
            //    return 0;
            //}
        }
开发者ID:minhnguyen31093,项目名称:Reminiscent,代码行数:101,代码来源:ExtendedRichTextBox.cs

示例8: CopyTo_Invalid

        public void CopyTo_Invalid()
        {
            ICollection bitArray = new BitArray(10);
            // Invalid array
            Assert.Throws<ArgumentNullException>("array", () => bitArray.CopyTo(null, 0));
            Assert.Throws<ArgumentException>(null, () => bitArray.CopyTo(new long[10], 0));
            Assert.Throws<ArgumentException>(null, () => bitArray.CopyTo(new int[10, 10], 0));

            // Invalid index
            Assert.Throws<ArgumentOutOfRangeException>("index", () => bitArray.CopyTo(new byte[10], -1));
            Assert.Throws<ArgumentException>(null, () => bitArray.CopyTo(new byte[1], 2));
            Assert.Throws<ArgumentException>(null, () => bitArray.CopyTo(new bool[10], 2));
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:13,代码来源:BitArray_GetSetTests.cs

示例9: GetFrequency

    private void GetFrequency(params bool[] twoBits)
    {
        int[] frequencyTable = GetFrequencyTable();

        Array.Reverse(twoBits);
        BitArray bArray = new BitArray(twoBits);
        byte[] index = new byte[1];
        bArray.CopyTo(index, 0);

        this.frequency = frequencyTable[index[0]];
    }
开发者ID:eGax,项目名称:customizemii,代码行数:11,代码来源:MP3Info.cs

示例10: GetBitrate

    private void GetBitrate(params bool[] fourBits)
    {
        int[] bitrateTable = GetBitrateTable();

        Array.Reverse(fourBits);
        BitArray bArray = new BitArray(fourBits);
        byte[] index = new byte[1];
        bArray.CopyTo(index, 0);

        this.bitrate = bitrateTable[index[0]];
    }
开发者ID:eGax,项目名称:customizemii,代码行数:11,代码来源:MP3Info.cs

示例11: ToByteArray

 public static byte[] ToByteArray(BitArray bits)
 {
     byte[] ret = new byte[bits.Length / 8];
         bits.CopyTo(ret, 0);
         return ret;
 }
开发者ID:ZerionSoftware,项目名称:iFormEsriIntegration,代码行数:6,代码来源:Utilities.cs

示例12: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     BitArray bitArr1;
     BitArray bitArr2;
     Boolean[] bolArr1;
     Boolean[] bolArr2;
     Byte[] bytArr1;
     Byte[] bytArr2;
     Int32[] intArr1;
     Int32[] intArr2;
     SByte[] sbtArr1;
     Int32 iNumOfElements;
     Random rnd1;
     try 
     {
         do
         {
             iNumOfElements = 10;
             rnd1 = new Random();
             strLoc = "Loc_742dsf!";
             iCountTestcases++;
             bolArr1 = new Boolean[iNumOfElements];
             for(int i=0; i<iNumOfElements; i++)
             {
                 if(rnd1.Next(10)>5)
                     bolArr1[i] = true;
                 else
                     bolArr1[i] = false;
             }
             bitArr1 = new BitArray(bolArr1);
             bolArr2 = new Boolean[iNumOfElements];
             bitArr1.CopyTo(bolArr2, 0);
             for(int i=0; i<iNumOfElements; i++)
             {
                 if(bolArr1[i] != bolArr2[i])
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_753qn_" + i + "! Wrong value returned, " + bolArr1[i] + " " + bolArr1[2]);
                 }
             }
             bolArr2 = new Boolean[iNumOfElements + 20];
             bitArr1.CopyTo(bolArr2, 20);
             for(int i=0; i<iNumOfElements; i++)
             {
                 if(bolArr1[i] != bolArr2[i+20])
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_763dfsf! Wrong value returned");
                 }
             }
             try
             {
                 bolArr2 = new Boolean[iNumOfElements];
                 bitArr1.CopyTo(bolArr2, 5);
                 iCountErrors++;
                 Console.WriteLine("Err_97452dsaf! No exception thrown");					
             }
             catch(ArgumentException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_742dsf! Unexpected exception thrown, " + ex);					
             }
             try
             {
                 bolArr2 = new Boolean[iNumOfElements-1];
                 bitArr1.CopyTo(bolArr2, 0);
                 iCountErrors++;
                 Console.WriteLine("Err_97452dsaf! No exception thrown");					
             }
             catch(ArgumentException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_753edfsf! Unexpected exception thrown, " + ex);					
             }
             try
             {
                 bolArr2 = new Boolean[iNumOfElements];
                 bitArr1.CopyTo(bolArr2, -1);
                 iCountErrors++;
                 Console.WriteLine("Err_97452dsaf! No exception thrown");					
             }
             catch(ArgumentOutOfRangeException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_742efsg! Unexpected exception thrown, " + ex);					
             }
             try
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co3968copyto_arrint.cs

示例13: ToByteArray

	public static byte[] ToByteArray(BitArray bits){
		var bytes = new byte[bits.Length / 8];
		bits.CopyTo(bytes,0);
		return bytes;
	}
开发者ID:rishabhjoshi,项目名称:Steganography-1,代码行数:5,代码来源:Steganography.cs


注:本文中的BitArray.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。