|
If you need to keep all of the values, but still be able to retrieve the most recent one for a given key, you could use a List or LinkedList to store all the values and a Dictionary to save the values for a given key, something like this:
public class DataStructure
{
public void Add(int key,MyObject data)
{
DataList.AddTail(new Entry(key,data));
DataDictionary[key] = data;
}
public MyObject Find(key)
{
MyObject data = null;
DataDictionary.TryGetValue(key,out data);
return data;
}
private class Entry
{
public Entry(int key,MyObject data)
{
Key = key;
Data = data;
}
public int Key;
public MyObject Data;
}
private LinkedList<Entry> DataList = new LinkedList<Entry>();
private Dictionary<int,MyObject> DataDictionary = new Dictionary<int,MyObject>();
} Note that I've omitted some things here, like the ability to enumerate the list.
|
|
|
|
|
Hi Experts,
I have problems to block lists of keyboards key when my system running on that PC.say for example i need block the Windows Key when my application started, I'm try to do in .NET 2.0 framework windows application with C#, but still i haven't get success, Please help me to do this.And here my list of Keys
1.Windows Key
2.Control
3.Alt
4.Eacape
5.Function key
6.Print screen
Please help to to block this when my application load time.
Thank you
RRaveen
|
|
|
|
|
It's not possible.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
Hi Experts,
I think you may be known me very well, this time i got problems in my project.Here is that
I'm developing A custom browser , for that I'm using .NET 2.0 Web Browser control with all features and add more features.Now I need add a new features , what is that means? say now we are open tab and put our exam link in my address bar, its load the page in tab(home Tab) it fine.in that page we have list of Exam to do by students. Here student click a exam ,then it open new tab(child), it's also work fine, now he doing exam,in the intermediate time of the exam,he navigating to home page( by Home tab click) again he click same exam again.Here it open new tab(fresh tab).
Here is misleading to exam concept. i need prevent that, and open same tab and also need show he exam place which remain in he doing.
How i can do that with Web browser control ,C# in windows application?
Thank you
RRaveen
|
|
|
|
|
Hi.....please some one help me in my problem
i have tow forms the 1st has a button that opens the 2nd form,
on form closing event for 2nd form i called Hide() function ,<when i="" traced="" the="" code="" found="" that="" when="" close="" 2nd="" form="" it="" calls="" dispose="" mode="hold">so when i click the button again(to Show() 2nd form) it gives me the following error:cannot access a disposed object)
i do not know what to do?can it be to stop 2nd form from calling Dispose () when i Hide() it? or it would be some thing else?
by the way, i have to do what i did in this way, so any help is appreciated
|
|
|
|
|
The form is automatically disposed when it's closed. You can set e.Cancel to true in the FormClosing handler, but make sure you provide a way to eventually really close the form (by some boolean check maybe) otherwise it will just sit there in memory but invisible and cause you all sorts of problems.
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)
|
|
|
|
|
By what you say I suppose you have a reference in Form1 to Form2, something like:
class Form1 : Form
{
...
Form2 RefToForm2 = new Form2();
...
private void ButtonToShowForm2_Clicked(...)
{
RefToForm2.Show();
}
...
}
Now, as Dave said in his answer, you can use e.Cancel = true to avoid automatic disposal of Form2, but I think you should first consider if you need your instance of Form2 to stay in memory or you can simply create a new instance every time you need to show Form2. The latter is usually the best practice.
So, if you store some value in Form2 and you don't want to lose it, you should store it somewhere else and recover it when you load Form2. Then, you can simply do:
class Form1 : Form
{
...
private void ButtonToShowForm2_Clicked(...)
{
Form2 RefToForm2 = Application.OpenForms["Form2"];
if (RefToForm2 == null) RefToForm2 = new Form2();
RefToForm2.Show();
RefToForm2.Activate();
}
...
}
Or something similar.
Hope this can help.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Hi there,
Thanks for taking interest in my question. I need to develope WPF applications and thus I had to purchase Visual Studio.NET 2008 since 2005 doesn't support WPF or XAML or might need additional downloads. However, the setup file of Visual Studio.NET 2008 is in some .iso format. I search Google and found that it was an image file. They say to burn the file to a DVD or CD. But the problem is that, I dont have a DVD writer or maybe its not working.....I have to burn it to a CD-R disk, but the size of VS 2008 is much more that 700 MB (the maximum capacity of a CD-R). So, I'll need 2 CD-R disks. Can you guys help me with any tool or software which in particular burns iso image files to CD's? Please help me, its really urgent.
Long live Code Project,
Rajdeep.NET
|
|
|
|
|
You can't but there are alternative solutions.
An ISO is an image of a disk. The VS2008 is a DVD image, so that will never fit on a CD. The files can be extracted then put onto CDs but setup will not know where to look for the files it needs.
What you need is a virtual DVD drive that can mount the image. Power ISO, Magic ISO etc... there are many.
MS have an unsupported one (I've never used it) that's free. You can download it from here[^].
Read the notes on the page and in the readme file. It's a self-extracting zip so you'll need to extract to a suitable location then navigate to there.
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)
|
|
|
|
|
Hey Davey,
I think my DVD Writer's just working fine! Thanx 4 ur help man! U r a genius!
|
|
|
|
|
I would recommend Daemon Tools. They have a free version that offers plenty of protection circumventions (which you don't need for Visual Studio, but for many other things you do)
|
|
|
|
|
Hello
I download Dll file from your website.
It work in the .net 2005 but not work in .Net 2008.
Please help me.
|
|
|
|
|
Support for articles on code project is provided generally in the article's own forum.
We may be able to help, but you would need to supply more information such as:
The code that failing.
The exception/error message you're getting.
What you expect it to do.
Possibly a link to the article in question.
How do you expect us to help with what you have given us so far?
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)
|
|
|
|
|
Well I seem to have the video chat between two people working pretty good. I am going to post the code below to see what you guys think and if you see problems. I haven't tried it remotely, but on the internal network it seems to work well.
What I would like to do it enable multiple ones. Before I ask the question I am going to post what I have below:
For this project I used the modified DirectX.Capture provided by hpAng: DirectX Video Stream and frame capture[^]
Here I am listening on port 50000. Now if I wanted to do multiple videos from different people, I could just take the data and place it in certain panels or picture boxes depending on the IP address it came from right? An idea I have but have not tried it yet. How will that affect me sending that much data on one port? I will show how I am sending below:
private void bwGetUdp_DoWork(object sender, DoWorkEventArgs e)
{
receiveClient = new UdpClient(50000);
receivePoint = new IPEndPoint(new IPAddress(0), 0);
while (true)
{
if (bwGetUdp.CancellationPending)
{
receiveClient.Close();
e.Cancel = true;
}
else
{
byte[] data = receiveClient.Receive(ref receivePoint);
MemoryStream ms = new MemoryStream(data);
Invoke(new SetStreamPictureDelegate(SetStreamPicture), new object[] { Image.FromStream(ms) });
Invoke(new ChangeReceivingLabelDelegate(ChangeReceivingLabel), new object[] { receivePoint.Address + ":" + receivePoint.Port });
ms.Flush();
ms.Close();
}
}
}
Here I am showing the video in a panel (DirectX.Capture) and starting the timer to capture the picture.
I am also setting the IPEndPoint to the users IP I get from the chat window I created.
Filters filters = new Filters();
cam = new Capture(filters.VideoInputDevices[0], filters.AudioInputDevices[0]);
cam.PreviewWindow = panelMyVideo;
cam.FrameEvent2 += new Capture.HeFrame(CaptureDone);
sendClient = new UdpClient(50001);
sendPoint = new IPEndPoint(IPAddress.Parse(this.toUserIP), 50000);
timerTakePic.Enabled = true;
Here I am just using the code provided by the article and sending it to the users IP
private delegate void SetStreamPictureDelegate(Image img);
private void SetStreamPicture(Image img)
{
pictureBoxOtherVideo.Image = img;
}
private void CaptureDone(Bitmap e)
{
MemoryStream ms = new MemoryStream();
e.Save(ms, ImageFormat.Jpeg);
Invoke(new ChangeSendingLabelDelegate(ChangeSendingLabel), new object[] { sendPoint.Address + "... " + Convert.ToInt32(ms.ToArray().Length) / 1024 + "KB" });
sendClient.Send(ms.ToArray(), Convert.ToInt32(ms.Length), sendPoint);
ms.Flush();
ms.Close();
}
Obviously I'm using UDP which I hear you supposed to... this is my first time really messing with UDP or TCP for that matter. The timer is ticking every 50ms.. Now my next step is voice then multiple videos.. maybe visa versa.
Is there a better way I should be doing this?
|
|
|
|
|
Hi guys,
Thanks for taking interest in my question. Actually, I need to work on a ADO.NET project which will connect my application to a Database. However, I want that the UI of my application be different in terms of style and for that purpose, I thought of implementing a little WPF code to the buttons of my application which will make them glamorous and interactive. But the problem is that, I have to complete the entire project in Visual C# and not WPF. Is it possible to implement WPF in a complete Visual C# application? If yes, how? And will Visual Studio 2005 help or I have to use Visual Studio 2008? What more softwares will I have to use for this? Please help, I only want to use little WPF code to the buttons of my C# application to make it look interactive.
Your help will be truly appreciated,
Rajdeep.NET
|
|
|
|
|
|
Thanks for your help Sibugathulla...... I will see try that, but for that I need to install VS.NET 2008.
Thanx again,
Rajdeep.NET
|
|
|
|
|
I have a function that takes the image in a picture box and converts it to a bitmap (System.Drawing.Image Picturebox.Image to System.Drawing.Bitmap) with the following code:
private void freezeFrame_MouseClick(object sender, MouseEventArgs e)
{
Bitmap refImage = new Bitmap(freezeFrame.Image);
int rangeLimit = 20;
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
int mouseX = int.Parse(txtMouseX.Text);
int mouseY = int.Parse(txtMouseY.Text);
Color currentPixel = (refImage.GetPixel(mouseX, mouseY));
curPixelRed.Text = currentPixel.R.ToString();
curPixelGreen.Text = currentPixel.G.ToString();
curPixelBlue.Text = currentPixel.B.ToString();
redMinUpDown.Value = currentPixel.R - rangeLimit;
redMaxUpDown.Value = currentPixel.R + rangeLimit;
greenMinUpDown.Value = currentPixel.G - rangeLimit;
greenMaxUpDown.Value = currentPixel.G + rangeLimit;
blueMinUpDown.Value = currentPixel.B - rangeLimit;
blueMaxUpDown.Value = currentPixel.B + rangeLimit;
}
I keep getting an invalid parameter error for the first line of the function. What am I doing wrong?
|
|
|
|
|
Please Update your first line as follows
Bitmap refImage = new Bitmap((Bitmap)freezeFrame.Image);
Or Convert Image to Bitmap and use this Bitmap as parameter.
©Something Different
|
|
|
|
|
How can I convert the image? Sorry for the noobish question...
|
|
|
|
|
Um.. with the code he gave you to do it ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
he said that I can do what he told me too or convert the picturebox image to a bitmap...i still get the invalid parameters error when i click on the image ....how do i do the picturebox image to bitmap conversion...i think there is something wrong with my code that is causeing the error
|
|
|
|
|
Hi,
several comments:
1.
sebogawa wrote: txtMouseX.Text = e.X.ToString();
int mouseX = int.Parse(txtMouseX.Text);
What a waste. You already have e.X as a number, why do you need to parse a string then. Just write
int mouseX = e.X;
txtMouseX.Text = mouseX.ToString();
2.
Bitmap refImage = new Bitmap(freezeFrame.Image);
You claim the problem is here, I doubt that. There are two ways this could fail:
a) freezeFrame.Image being null would result in a NullReferenceException
b) freezeFrame.Image being of some special ImageFormat (such as EMF) might cause problems, I'm not sure though.
3.
Color currentPixel = (refImage.GetPixel(mouseX, mouseY)); would throw an ArgumentOutOfRangeException when mouseX and/or mouseY fall outside the image.
4.
redMinUpDown.Value = currentPixel.R - rangeLimit; may cause problems since the lowest achievable value is negative (-rangeLimit). If Value is set outside [Minimum,Maximum] an ArgumentOutOfRangeException will be thrown.
Overall, your code is low-quality as it lacks a lot of checks.
|
|
|
|
|