|
Thank you..
I read it.
Can I get any sample projects anywhere in web?
|
|
|
|
|
Look into msdn sample applications for C#
|
|
|
|
|
Hi,
I need to plot the wave format on the usercontrol screen with the use of text file(having input values about 2gig). Horizontal Scrollbar is placed on the panel and if I move the scroll bar the panel should move for certain amount values.
Is it optimal to use the lazy loading technique here.How? Is there any other way to accomplish this task?
Consider the screen width is 300 and wave columnwidth of wave is 30 and the total numbers to plot wave is 3000.
Then 300/30 = 10 waves can be drawn.
How to set the Largechange and Smallchage in the Horizontal Scroll event?
Thanks,
Vel
|
|
|
|
|
I would suggest seperating out your problem.
0. File reading
What is the format of the file?
If it is a fixed length format, can you can read directly any portion of it?
1. Display scroll bar:
Set the scroll bars range to be 0-2990 - the max value is {number of items} - {items to be displayed}
Set the small change to 1, you are moving by a single frame.
Set the large change to 10, you are moving the entire page width.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Thanks Vilmos...
Text File format and it's not fixed length I read from text file and have the values in an ArrayList and I loop through it.
How to set the scroll bar range? Any property need to change?
Getting the 10 values from above arraylist and planning to plot the value as a wave during Horizontal_Scroll() function when scroll left and right? How to achive this?
Regards,
Subbu
|
|
|
|
|
Hi,
I would like to suggest you read this[^] carefully.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
spalanivel wrote: have the values in an ArrayList
This does produce an overhead in that you need to read everything in upfront, but it's not the end of the world.
spalanivel wrote: How to set the scroll bar range? Any property need to change?
Once you've read the file, you'll have the number of items in your list:
hScrollBar1.Maximum = this.listOfValues.Count - 10;
spalanivel wrote: Getting the 10 values from above arraylist and planning to plot the value as a wave during Horizontal_Scroll() function when scroll left and right? How to achive this?
for (int x = hScrollBar1.Value;
x < hScrollBar1.Value + 10;
x++) {
}
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Thanks Vilmos,
Still I need to clarify some doubts and i will send you the source code fully so that you can give the optimal solution. will you please give your email id?
Regards,
Subbu
|
|
|
|
|
I don't want to see your code, I have enough to deal with my own. Go figure out what you can and should you have any more questions then you are free to come back and ask. Someone is sure to answer if you ask well.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
|
I have looked in all my books and on the net and cant find a way to do this, it just tells me about shifting bits which will not be appropriate.
I have a program that recieves a byte[] from an external source.
The array elements represent different things eg(byte[0] bit 1 (rightmost)) = buzzer state (1 on: 0 off)
In the command i recieve there will be 3 bytes, with each contained bit representing a buzzer or LED and its state on or off;
Does anyone know how i can look through the bits and check there state?
Thanx George
|
|
|
|
|
You can use the BitArray class to check the value of single bits into a byte array.
|
|
|
|
|
Thanx for the advice this looks like a useful class.
I tried looking through the byte with .length but noticed there was a get() position which is what i was looking for. As somthing like getchar()/ charAt() is perfect.
|
|
|
|
|
I think this is the idea
BitArray byte1 = new BitArray(commandData.Data[0]);
enumLEDAndBuzzer lcdAndBuzzState = enumLEDAndBuzzer.NULL;
if ((byte1.Get(byte1.Count - 1)) == 0x31)
{
lcdAndBuzzState = enumLEDAndBuzzer.BUZZER_STATE;
}
else
{
lcdAndBuzzState = enumLEDAndBuzzer.NULL;
}
if((byte1.Get(byte1.Count - 2)) == 0x31)
{
}
else
{
lcdAndBuzzState = enumLEDAndBuzzer.NULL;
}
From my understanding i should be able to work from right to left by (count - 1++).
Thanx again
|
|
|
|
|
Hi,
shifting is the key.
byte b = 0xaa;
if ((b && 0x01) > 0)
{
}
else
{
}
if (((b >> 1) && 0x01) > 0)
{
}
else
{
} etc.
bye
|
|
|
|
|
It looks like a good idea i just cant get it to work as i cant compare the byte to 0x01
|
|
|
|
|
Hi,
yes, I'm sorry. I've made a little fault: not (byte1 && 0x01) > 0 but (byte1 & 0x01) > 0
sorry
|
|
|
|
|
It's a matter of using ANDs, and other boolean stuff (if you want to read multiple bits). Basically, you use the formula:
bitNSet = (originalInteger & (1 << N) == 1 << N)
Effectively, every integer is represented by a binary sequence. For example, 39 would be represented by 100111. Each one and zero is a bit. To get a bit, you have to AND it, which gets all the bits which are set in both of the numbers given to it. For example, 39 AND 4 would be worked out like so:
100111 AND
000100 =
------
000100
As you can see, you end up with a binary sequence, which is represented by 4 in decimal (base-10). You use the AND against a bit pattern to see if that bit is set. Now, unfortunately, you don't get a true or false value. Note that the result of 39 AND 4 was 4. So, we can apply this further, and say that if q AND n is equal to n, then bit n was set.
Now we just have to get a binary pattern to use against the AND. To get this, we just use the << operator. It will perform a left binary shift on the left operand. So 1 << 5 would result in 100000, 1 << 2 would result in 100, etc. Those numbers are in binary format by the way. So, shifting 1 left by N will give us a binary pattern where only the Nth bit is set. By ANDing that with the original integer, we can check if the bit is set
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
In addition to the excellent advice you've been given - all the Boolean logical operator variants are easy to implement as shown below. Also, using an enum with the Flags attribute can make getting individual bits easier as you can give your enum members more descriptive names.
class Program
{
static void Main(string[] args)
{
byte baseValue = 0x01;
byte otherValue = 0x07;
Console.WriteLine("Base Value = {0} : Other Value = {1}", baseValue, otherValue);
Console.WriteLine("AND result = {0}", baseValue & otherValue);
Console.WriteLine("OR result = {0}", baseValue | otherValue);
Console.WriteLine("XOR result = {0}", baseValue ^ otherValue);
Console.WriteLine("NOT result (Base only) = {0}", (byte)~baseValue);
Console.WriteLine("NAND result = {0}", (byte)~(baseValue & otherValue));
Console.WriteLine("NOR result = {0}", (byte)~(baseValue | otherValue));
Console.WriteLine("Bit0 of Base Value = {0}", baseValue & (byte)Bits.Bit0);
Console.WriteLine("Bit0 and Bit1 of Other Value = {0}", otherValue & (byte)(Bits.Bit0 | Bits.Bit1));
Console.ReadKey();
}
}
[Flags]
public enum Bits : byte
{
None = 0,
Bit0 = 1,
Bit1 = 2,
Bit2 = 4,
Bit3 = 8,
Bit4 = 16,
Bit5 = 32,
Bit6 = 64,
Bit7 = 128
} If you want to work with binary values directly, unfortunately there is no binary literal in C#. I made this article[^] quite a while ago to make it easier to work with binary strings, you may find it of some use.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
10!
This is what I would suggest.
|
|
|
|
|
Hi,
this code works like a bit getter on a byte array:
public static bool bitGetter(byte[] bytes, int index) {
int byteNumber=index/8;
int bitNumber=index%8;
int bitMask=1<<bitNumber;
int byt=bytes[byteNumber];
int bit=byt&bitMask;
if (bit==0) return false;
return true;
}
and the condensed version is:
public static bool bitGetter(byte[] bytes, int index) {
return 0!=bytes[index/8]&(1<<(index%8));
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
How to find the needless references in a project ?
I don't sure that everybody can understand my question, so I just made a sample:
1. create a c# sln in VS
2. add 3 classLib (named lib1,lib2,lib3) project into the sln
3. lib1 called some classes or functions which in lib2
4. for lib1, lib3 is useless.
My question is : how to find the needless references?( lib3 )
Is anybody can help me ?
i love star in the sky,i wish she will be seeing me forever...
|
|
|
|
|
I use resharper to do it, just click at "Find Usage..."
|
|
|
|
|
hai friends,
I want to play the live recording or video of a particular ip web cam when i give the particular ip address using C#.Net Windows application. How to send a live video through ip network and how get the remote video in a windows application.
by
Vasanth.A
|
|
|
|
|
IP Cameras usually have a web interface. If yours does then you can just use a web browser control to browse to the video feed. If it doesn't then you'll need to examine the cameras API to determine how to get the video off of it.
|
|
|
|