Diamonddrake 397 Master Poster

In a for loop you have to use a local variable that you create in the first part of the loop. you cannot use a variable created somewhere else.

if you want to use vars created somewhere else use a while loop.

while(i < n)
{
   textBox2.Text += " " + Convert.ToString(i);
    
   i++;
}
Diamonddrake 397 Master Poster

Library extensions written in C# are good when the programs using them will be written in VB, C#, or C++.net. I don't think it would go well if you tried to use it will Delphi as C# libraries are managed code compiled to an IL that requires a virtual run time to watch its execution.

If you intend on an entirely C# solution its no problem just remember that a Library extension is just a program without an entry point. It can't run by itself but can contain any code that could be in another program. Don't treat it any different.

Diamonddrake 397 Master Poster

I need to count the ticks from a simple switch attached to a gauge. The time it takes from the first detected tick to the 20th is the important data. To acquire the cycling on and off of the switch i have come up with 2 serial port techniques.

1) use the ready to send voltage through the switch and constantly poll in 10ms intervals the clear to send pin for its value and use that to determine the cycling.

2)loop pins 2 and 3 (- in and out) through the switch, constantly writing a character and using the datarecived event to increment a count. and using a checkcount from a timer to determin the cycling of the switch.

My question is, which one of these would be the best route? obviously (1) is the simplest. But I can't seem to determine which is the most accurate system. I don't have much knowledge of the speed and reliability of Serial Port communications and uses. Any thoughts beyond speculation would be appreciated. I have 2 working solutions. I need the most accurate. I have done testing and I can't see to figure which works best. And although the difference is minute, its important that I use the most accurate and reliable method.

Diamonddrake 397 Master Poster

This is a fun project. So long as you stay away from zooming and panning nothing gets complicated.

Programming is a lot more than knowing how the code works. Its more important to understand the process you are trying to emulate. Ryshad has already pointed out you need a collection to hold all the objects you want to draw, and when its time to draw. draw each one of them one at a time. Its obvious in your code you are leaving out some of what you are doing. a more clear cut sudo for simple lines only follows.

+when mouse down make note of the fact you are drawing and save the point you started.

+on mouse move save the point where the mouse currently is for preview drawing.

+on mouse up make note of the idea that you are no longer drawing. use the start point and the point of mouse up to up to create a new line object and add it to a collection of line objects.

+on paint - if you are drawing, draw the start and end points this show the preview of the line, either way loop through the collection of line objects and draw each one.

Understanding what must be done is the most important part. Turning this into code is simple. Adding the ability to move and resize the objects it just adding complications to the same events.

This could be a fun thing …

Diamonddrake 397 Master Poster

I needed a 5 minute countdown for a project I was working on so I hacked this up, It does nothing more and nothing less. Figured I would post it while I was here to save someone else the trouble. (Not that it's in anyway difficult to do.)

ddanbe commented: Nice! +6
Diamonddrake 397 Master Poster

I have it completely functional for the Wired USB PS2/3 Rockband drumkit. The wireless for PS3 and the Xbox versions I have yet to get information on So It just doesn't recognize them, I plan to put a choose controller / configure pads form that will let you use any HID compatible game controller but I have just been busy.

Current Features
+Dynamically loads WAV files from the drum sounds folder to allow easy addition of new drum sounds.
+Configurable Metronome
+Graphical representation of the drum kit with pad hit animation.
+Configurable drum sounds per pad.
+Much more only partially implemented.

This is a big priority of mine, but for the next week or so I am working on A program that is to be sold to a factory for testing equipment. So I kinda have to push this aside for a short while.

Diamonddrake 397 Master Poster

This will do a negative effect on a color vector. But a true invert needs to be done with either HSL color space or a ColorMatrix.

Color InvertAColor(Color ColorToInvert)
{
   return Color.FromArgb((byte)~ColorToInvert.R, (byte)~ColorToInvert.G, (byte)~ColorToInvert.B);
}
Diamonddrake 397 Master Poster

Ah, you don't want to create an end point, you want to watch the traffic. or a packetsniffer! for this you need to manually create a socket instead of using a tcpListner or httpListner subclass. and you need to do a rawbind giving you access to the port without taking ownership of it.

this example claims to be able to do it http://www.c-sharpcorner.com/uploadfile/leonidmolochniy/simplesnifferincs11222005232804pm/simplesnifferincs.aspxe Although there are errors in the code, the makefile doesn't work and and there is an error when it creates a dispose method by using an override keyword which shouldn't be there. Other than that it compiles but it has other errors. But the concept is there and you might be able to use it to do what you are looking for.

here is an explanation of how to create a RawSocket that doesn't block the data just allows you to look at it. http://forums.techpowerup.com/showthread.php?t=61792

an here is a codeproject example of a network sniffer http://www.codeproject.com/KB/IP/CSNetworkSniffer.aspx

Diamonddrake 397 Master Poster

Application.Run(form) doesn't return until the form is closed. So it would actually be a perfect place to end any background threads started with an application scope. Although you may still want to join the threads just to make sure that the background thread as stopped before the Main method returns.

Diamonddrake 397 Master Poster

Sounds like homework :) lol.

This is so easy. rig up your mouse down and mouse up events and create class variables of type Point. Then get the mouse coordinates with the event arguments on mouse down, save it to the first. then on mouse up get the mouse coordinates with the event arguments and save it to the second Point var. then rig up an onPaint event and simply call the drawLine method of the graphics class from the first to the 2nd point. and don't forget to invalidate the form at then end of the mouse up.

Best of luck. This is too easy to just post the answer. Give it a shot. you can handle it.

ddanbe commented: Good answer! +6
Diamonddrake 397 Master Poster

Port 80 is the default port used by HTTP servers. only 1 program at a time can be the daemon of a local port. that's basic sockets 101. And by default on many XP installations there is a web server running. you might consider using a different port.

unless you are writing a web server, in which case you just need to find out which process is listening on port 80 and kill it.

Diamonddrake 397 Master Poster

Glad I could be of some help :)

Diamonddrake 397 Master Poster

Unfortunately because I am using events I have to use the windows message loop in my thread. so the while(true) loop concept doesn't apply here. I tried using thread.abort() but it doesn't stop a thread with a message loop. I come to the conclusion that i need to find a way to call Application.ExitThread() from the thread I want to stop. and I couldn't figure out how to do that because control.Invoke always invokes onto the the GUI thread. i can't seem to figure out how to invoke a method onto a background loop. I found out quick you can crash visual studio easy with application.exitThread though :)

I need to buy a book on this, there is very little online material around this matter and trial and error isn't all its cracked up tobe these days.

either way, the program is coming along quit nicely and its almost ready to make an appearance.

Diamonddrake 397 Master Poster

I Don't have the time explain all the things wrong with that.

but for starts you are passing an array of files to a method that only is suppose to take the path of 1 files, and you aren't giving the new file name to the files you are moving.

you MUST use a loop for this, you can't just toString an array in a move method. The code I posted is an acceptable method.

the file object's move method accepts the filename of the file you want to move, and the file name of the files you want to move it to. that means the full path of the existing file, and the full path of the file as it will be. So you need the file name of the file to be appended to the destination path. and you must do this method for each file. you can't just expect it to work all at the same time.

Try using the method I wrote for you. look at it and try and understand how it works. If you have any problems post them and I will try and explain it better. But that what you come up with is not an acceptable solution.

the line string[] filePaths = Directory.GetFiles(@"D:\New Folder\New Folder\wall papers\Bar Refaeli Wall", "*.jpg"); is ok. you could use that in the method before instead of checking the extension manually. but you still need to loop through all the files in that …

Geekitygeek commented: beat me to it AND with a fuller explaination...curse my slow fingers :p +1
Diamonddrake 397 Master Poster

The CultureInfo class holds culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions.

This just creates an array of cultureInfo classes by asking the system for all that it knows about, then attempts to extract a string from that object representing the culture's country.

The line where you get the error is where you are creating a regionInfo object that accepts a culture Identifier. The error you get is that one of the culture's in windows 7 allows the "invariant culture" object to show up when you ask for all cultures this way. and "invariant culture" represents an empty culture object with the ID 0x007F (or 127)

so we just check for that and it will work. just replace your getCountryList method to this one and it will all work fine.

public static List<string> getCountryList()
        {
            List<string> cultureList = new List<string>();
            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);

            foreach (CultureInfo culture in cultures)
            {
                if (culture.LCID != 127)
                {
                    RegionInfo region = new RegionInfo(culture.LCID);
                    //RegionInfo region = new RegionInfo(culture.LCID);

                    if (!(cultureList.Contains(region.EnglishName)))
                    {
                        cultureList.Add(region.EnglishName);
                    }
                }
            }

            cultureList.Sort(); //put the country list in alphabetic order.

            return cultureList;
        }

As for the KeyPressed and KeyDown events. Key pressed is when "some" keys are both depressed and released. and KeyDown is when any key is pressed down. but fires before its released. There are tons of articles out there about it. If you want to know more about using them in a error handling fashion ddanbe …

Diamonddrake 397 Master Poster

sorry theres a typo there. it should be

string extension = sFiles.Substring(sFile.LastIndexOf("."));

forgot the "s" in "sFiles"... but that should have been obvious.

Diamonddrake 397 Master Poster
string sourceFolder = @"put your first folder here";
string destFolder = @"put your 2nd folder here path here";

 private void button1_Click(object sender, EventArgs e)
        {
            int filecount = 0;
            foreach (string  sfiles in Directory.GetFiles(sourceFolder))
            {
                string extension = sFile.Substring(sFile.LastIndexOf("."));
                if (extension == ".jpg" || extension == ".JPG")
                {
                     File.Move(sfiles, destFolder +   sFile.Substring(sFile.LastIndexOf(@"\")));
                }
            }

        }

Something like that should get it.

Diamonddrake 397 Master Poster

And just for fun I modified some code from that link and here is a class that you can simply call the "isWave" method and it will return true/false :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace CheckMimeForWav
{
    class MimeCheck
    {

        [DllImport(@"urlmon.dll", CharSet = CharSet.Auto)]
        private extern static System.UInt32 FindMimeFromData(
            System.UInt32 pBC,
            [MarshalAs(UnmanagedType.LPStr)] System.String pwzUrl,
            [MarshalAs(UnmanagedType.LPArray)] byte[] pBuffer,
            System.UInt32 cbSize,
            [MarshalAs(UnmanagedType.LPStr)] System.String pwzMimeProposed,
            System.UInt32 dwMimeFlags,
            out System.UInt32 ppwzMimeOut,
            System.UInt32 dwReserverd
        );

        public string getMimeFromFile(string filename)
        {
            if (!File.Exists(filename))
                throw new FileNotFoundException(filename + " not found");

            byte[] buffer = new byte[256];
            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
                if (fs.Length >= 256)
                    fs.Read(buffer, 0, 256);
                else
                    fs.Read(buffer, 0, (int)fs.Length);
            }
            try
            {
                System.UInt32 mimetype;
                FindMimeFromData(0, null, buffer, 256, null, 0, out mimetype, 0);
                System.IntPtr mimeTypePtr = new IntPtr(mimetype);
                string mime = Marshal.PtrToStringUni(mimeTypePtr);
                Marshal.FreeCoTaskMem(mimeTypePtr);
                return mime;
            }
            catch (Exception e)
            {
                return "unknown/unknown";
            }
        }

        public bool isWave(string FileName)
        {
            if ("audio/wav" == getMimeFromFile(FileName))
            {
                return true;
            }
            else
            {
                return false;
            }
        }


    }
}
ddanbe commented: Great! +6
Diamonddrake 397 Master Poster

What you want to do here is check the "MIME" type of the file. This is saved into the file in the header. Internet explorer does this to know what to do with a file, and Windows media player does this to know what code to use to render a file. Ever get the "file has a incorrect extention windows media player can attempt to play the file anyway" dialog? lol

Here is an example of doing so using the same lib that IE uses
http://stackoverflow.com/questions/58510/in-c-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature-not-th

Feel free to google around for more exact solutions. there are quite a few.

Diamonddrake 397 Master Poster

That is a complicated question presented so innocently.

I will recommend this life changing programming book to anyone, and everyone. It doesn't focus on language but on theory and expresses what's important in software design and producing useful and reusable code.

The Pragmatic Programmer

Diamonddrake 397 Master Poster

I am working on a really fun project. I have written much of a program that lets you use a RockBand or GuitarHero drum kit to play drum sounds on your PC, record, playback, ect. I have decided conclusively as I add features I need more than just a gui thread calling async play sound methods. I need extensive threading here and for the most part I know what to do.

But I have a Metronome class that uses async media timer and playsound methods. but still has trouble being accurate if something else on the form slows down the message loop. So I have started a new thread that uses Application.Run() to start that thread with its own message loop. then creates the timer class, starts it and hooks up an event. then in the event it calls the playsoundAsync method.

So now I have 2 problems, How do I safely change the timer objects Interval property from the GUI thread? and then How do I safely stop this type of thread? the standard while loop practice is useless here because I am using a MessageLoop to process events.

I have most often used threading to do some finite task that will return when its done. This is a new practice for me using threads to insure an accurate "on-beat" playing of audio.

I have lots of code bouncing around in my head, I just want some insight before I make a mess. Searching the …

Diamonddrake 397 Master Poster

Thanks for sharing!

Diamonddrake 397 Master Poster

Please mark the thread as solved using the "mark as solved"

Sorry it took you some time to adapt the code. I was going to post the whole project but I figured you would figure it out, as you have.

Diamonddrake 397 Master Poster

here is the code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace DaniwebThreading.DancingLabels
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Thread draw;

        private void Form1_Load(object sender, EventArgs e)
        {
            draw = new Thread(new ThreadStart(Display));
            draw.Start();
        }

        public void Display()
        {
           bool doloop = true;
           int X;
           int Y;

            Random objRandom = new Random();
           // for (int index = 1; index <= 100000; index++) //use while loop to keep it going forever!
            while(doloop)
            {
                X = objRandom.Next(200);
                Y = objRandom.Next(200);
                moveLabel(new Point(X, Y));
                Thread.Sleep(500);
            }
        }

        public delegate void MoveLabelDelegate(Point P);

        public void moveLabel(Point P)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new MoveLabelDelegate(moveLabel), P);
            }
            else
            {
                lblMessage.Location = P;
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            draw.Abort(); //kill the thread.
        }
    }
}

you need a delegate to usher the call on to the GUI thread by calling invoke. The trick here is creating a method that will check if its required, and if so invoke its self using the delegate. Its a good idea to create these type methods for all the controls you with to update information for.

The form closing event here is used to abort the thread so you don't get an exception when you close the form where the draw thread is still trying to modify the disposed control.

Threading gets complicated. Good luck with your endeavors.

Diamonddrake 397 Master Poster
File.Move(SourcePath, DestinationPath);

that's it.

Diamonddrake 397 Master Poster
System.IO.File.Move(path, path2);

might want to do some error checking too. but that's it.

Diamonddrake 397 Master Poster

Threading is a very complicated thing, and you can't access a control from another thread than the one it was created on which is almost always the GUI thread, or the thread that is started when the application runs.

The best idea here is to build a application modal that doesn't rely on the controls hosing the information, but just displaying it.

you have given no information about your error, just the error message and that's USELESS out of context. It could be that you need to pass a list of files or something to the worker thread as an object, or it could be that you need to use a delegate and invoke a call onto the control. But Its hard to tell. Post your code, We will help you.

Diamonddrake 397 Master Poster

Just use this method to download the html and save it to a variable, then parse out the IMG tags and save that to another variable. Then have a button that switches between them and loads the selected one into the webbrowser.

Diamonddrake 397 Master Poster

They are not downloaded at all, its just the text.

The browser first makes an tcp http request and asks for the text, That is what you have done with the get http method here. Then the browser parses the html and decides what it should look like and what else it needs to download from the server. Since you remove the IMG tags before you pass the html to the browser control the request for the images is never made.

Diamonddrake 397 Master Poster

IF you create a new form with the borderstyle set to none and have it accept a GridView in the constructor you can pass an instance of a gridview control that is created on the main form but not added to it. Then the new form can be animated in with EXAnimatedWindow api. and set the passed gridview to dock and fill the new form, then have an event that when it looses focus the new form closes and removes the gridview from the form's control collection as not to be disposed and then whatever changes and selections were made will be available via the original instance as it was only passed as a reference and not a copy.

I know this can sound complicated and it can be. But its really the only way to achieve a real drop down effect as the Show?hide method is sloppy and doesn't have a reusable drop in usability.

Sorry if i didn't explain this well. As I have done it before with the tree view and such I know it works in practice but here I have presented enough theory for you to be able to figure it out.

Diamonddrake 397 Master Poster

I don't know of anywhere that would have done this already but I'm sorry as I don't know

here is a class that lets you get the Title from an html document

public class WebHelper 
    { 
        public static string FetchHTML(string sUrl) 
        { 
            System.Net.WebClient oClient = new System.Net.WebClient(); 
            return oClient.DownloadString(sUrl); 
            //return new System.Text.UTF8Encoding().GetString(oClient.DownloadData(sUrl)); 
        } 
 
        public static string FetchTitleFromHTML(string sHtml) 
        { 
            string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)"; 
            System.Text.RegularExpressions.Regex ex = new System.Text.RegularExpressions.Regex(regex, System.Text.RegularExpressions.RegexOptions.IgnoreCase); 
            return ex.Match(sHtml).Value.Trim(); 
 
        } 
 
    }

using the fetch HTML to get the text and then using the string.Replace method can get rid of the "<IMG SRC=" tags and just how the URL of the image in instead. just load that string into the WebBrowser control and you should be golden.

user20000 commented: Diamonddrake rocks! Thanks mate! +0
Geekitygeek commented: great solution +1
Diamonddrake 397 Master Poster

If you want to emulate the same functionality as the red x and allow form closing events to work properly use, this.Close();

Diamonddrake 397 Master Poster

No there is no way to make the browser load the pictures in lower quality as the pictures are just transferred over the network as binary files that the browser then displays.

but if you write a tcp request and download the HTML of the page first and use regular expressions to remove the "IMG" html tags from the document then load that into the webbrowser control that will effectively show the text and not the pictures.

Diamonddrake 397 Master Poster

Wow, I never would have thought of that. kudos tino

Diamonddrake 397 Master Poster

I don't see how it would relate to the monitor as points are points and widths are widths regardless of aspect ratio. have you tried compiling the code without changing it on another computer. to see it is definitely the computer in question?

Diamonddrake 397 Master Poster

have you tried control.Capture = false; ?

ref

.NET Framework Class Library
Control..::.Capture Property
Gets or sets a value indicating whether the control has captured the mouse.

Diamonddrake 397 Master Poster

I would use a service from a web gateway company like websense that filters out questionable material. Or if I didnt want to pay big bucks I would write a proxy server app that blocks questionable websites and route all the computers in the cafe through it. with an optional override. displaying a message saying that the page has been blocked and if the user doesn't think that it should be have them tell the site url to the attendant and have him check it, if its clean they can use a 1 time password to access the site, or the attendant can optionally add it to the allow list on the proxy, or remove it from the deny list. or depending on how the proxy is written add it to the exceptions list.

and as for "the hardware owner is responsible for what their hardware is used for." if you had a lawyer write up a End user license agreement that displayed as the users first logged on and a click to accept button then you could have them digitally sign a contract saying that they alone are liable for their actions. Very similar to the "Skate at your own risk.!" Sign at skating rinks. under most circumstances if someone gets hurt at your business then you are liable, unless its posted that upon entering that one assumes responsibility for their own safety, then suddenly its not the business owner's problem. simply because there was a sign.

kvprajapati commented: helpful!! +7
Diamonddrake 397 Master Poster

This could very easily be written in C# but I don't think its a good idea for an internet cafe as you would be violating the privacy of the users. You wouldn't see the passwords but you would see everything else. You would have to tell the users they were being monitored if you didn't you could get sued, and personally if I knew someone were watching I wouldn't waste my timer there. I would leave.

now from a programmers standpoint. Writing an application that runs as a service that runs all the time and sends out screen information across a network would be very simple in C#. assuming all the computers are assigned static IPs the ability to get a 5 Frame per second screen shot in real time with an option to log out the user or lock the screen with a message, something just that simple could be thrown together in an afternoon. C# is a great candidate for this

but again, I think you might drive away customers.

Diamonddrake 397 Master Poster

You are creating another instance of the main form , you must pass the instance of the main form to the 2nd forms constructor to make the reference work EX

MainForm : Form
{
     ...

     public ListView mylistview
{
  get{return listview1;}
 set{listview1 = value;}
}

void openform2(object sender, eventhandler e)
{
   Form2 f2 = new form2(this);
    f2.show();
}
}  

and in form2

form2:form
{
mainform f;

  public form2(mainform f)
{
     this.f = f;
}

void buttonclick(object sender, eventargs e)
{
     f.mylistview.add("item1");
}

}

I know this code is hideous and don't copy and paste it as I am sure its not correctly cased. i typed it here in the quick reply box. but it should show you what you need to know.

Diamonddrake 397 Master Poster

you can do this easily. if you capture the entire screen as an image then just loop through it using the bitmap class's getpixel method and comparing it to the specified color, then saving its location in the image and moving the cursor location to those points.

I don't see the point in it as there are 786,432 possible points in a 1024X768 screen image. and many of them will the the same color.

you could take a count and try to move the mouse to the center of the largest area of similar colors based on a tolerance. which again wouldn't be that hard.

although I see no real world use for this outside of a bot, and I personally hate bots. I know... strong word, but its a strong feeling.

Diamonddrake 397 Master Poster

It appeared to me that the OP was trying to prevent the button from getting focus by using the arrow keys. So that the user couldn't cheat and just focus the button and hit enter.

if the button was disabled it would be grayed out and the user probably wouldn't even try to click the button so 1.1 would have been pointless.

But it does seem like an odd homework assignment.

Diamonddrake 397 Master Poster

check using your local IP address and see if it works, If it does then you know its a router setting problem. Other than that it should work, making a listener and an client are just a few lines of code you are showing it right so the problem must be else where.

Diamonddrake 397 Master Poster

TcpListener("Ipextern", 4296);

Why is IPextern in quotations. The TCPListner class takes an IPAddress object here, not a string. Or you could simply just just use the port number and no IPaddress and it should work fine.

the TCP Listener and TCP client classes make network programming dirt simple. Its easy to get confused. I had trouble starting it a while back. Sknake posted a project on my thread that was a working Client server pair if you are interested here is the link

http://www.daniweb.com/forums/thread228973.html

Diamonddrake 397 Master Poster

Most likely you have a router that is blocking your port. also its a good chance you don't have a static IP and your IP address is changing.

The server must be directly exposed to the net by forwarding the port it uses from your router to the local IP address of the computer running the server.

Diamonddrake 397 Master Poster

just put it in the body of the form. just like you would any other method.
Overrides replace a method in the class's baseclass, this method overrides the proccess command key method of the control class and stops it if it gets an arrow key.

If you can handle C++ then C# will come simple to you. Don't be afraid to read. There are a MILLION C# books out there. or you can experiment as I do. Visualstudio's intellisense really helps you explore a class's possibilites.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Joks1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((keyData == Keys.Right) || (keyData == Keys.Left) ||
                (keyData == Keys.Up) || (keyData == Keys.Down))
            {
                //Do custom stuff or nothing.
                //true if key was processed by control, false otherwise
                return true;
            }
            else
            {
                return base.ProcessCmdKey(ref msg, keyData);
            }
        }

        Random rnd = new Random();

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form2 jaunaForma = new Form2();
            jaunaForma.Show();
        }

        private void but_ja_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Text........","Joke...",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            this.Close();
        }

        private void but_ja_Move(object sender, MouseEventArgs e)
        {
// this part moves the 'yes' button around.
            but_ja.Top=rnd.Next(this.Size.Height-2*but_ja.Size.Height);
            but_ja.Left=rnd.Next(this.Size.Width-2*but_ja.Size.Width);
        }
    }
}
Diamonddrake 397 Master Poster

The arrow keys are processed differently as they are caught by the form its self. So in order to do this you must override that method that catches them.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((keyData == Keys.Right) || (keyData == Keys.Left) ||
                (keyData == Keys.Up) || (keyData == Keys.Down))
            {
                //Do custom stuff or nothing.
                //true if key was processed by control, false otherwise
                return true;
            }
            else
            {
                return base.ProcessCmdKey(ref msg, keyData);
            }
        }

This code snippet is from Sknake here on the forum. He answered a similar question of mine about a year back.

Diamonddrake 397 Master Poster

SQL lite its a server technology that has to be installed on the system to use. MS access requires nothing to be additionally installed. that's what I like about it. Although, its not optimal for heavy usage for many simultaneous users, That's why most people speak poorly of it. But if the database only needs to be accessed by 1 computer/ user at a time. Its a pretty good system. I used it for a program that helps track my bills. 2GB worth of data now and still working strong. Even used it to store information for the guest book on my website.

The only problem with these new OSes such as Vista and 7 is your application cannot write to the Program Files directories. So remember once your application gets chugging along to save the Database in a document folder!

Diamonddrake 397 Master Poster

MSAccess requires nothing to be installed. SQLlite requires SQL lite server to be installed. But if you really want to make the switch just duplicate the tables in the new database and write a little loop that gets all the info from the first database table and creates objects in a list. then loop through the list and save the objects to the new database.

Should be pretty simple.

Diamonddrake 397 Master Poster

I personally have no scrape with MS ACCESS as aside from changing the connection string the code is all the same. C# is perfect for this project. Just to clear it. C# can do everything VB can, and any VB code can be converted to C# very simply. there are hundreds of code converters out there. So if you find code in VB just convert it over if you need to. http://converter.telerik.com/ is pretty good.

I'm not the best person to help with database apps but Visual studio has TONS of tools for it. even a SQL query builder, but I would suggest finding a good Object Relation Mapping library to save yourself some headache.

Best of luck on your project. I admire that you had a problem and decided to tackle it head on. That's how I learned everything I know about programming. up to 4 languages now and still moving forward!

Diamonddrake 397 Master Poster

Using resources can be easily updated if you use an "languages" dll and have your app check for update versions from a webserver. but the XML approach isn't a bad one, just its important for speed that you don't access the file every time you need the information. Disk access is slow and so is parsing XML. if the form has a lot of text on it there could be a delay of opening a new form which can be annoying.

If you create an object in your application with all static members that match your language text, at application start you can check the language of the OS or Language setting and load all the information to the Language object then when new forms open you can use the Language object to get the necessary text.

But to each their own. I don't think there is a "best way" but there are many good ways. if you wanted to be far fetched you could use one of those google translation apis and have your application make web queries and just translate the English version on the fly using the web and instantly support any translation that api does. I wouldn't recommend it, but it could work. :)