Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to you all. So I made an application that succesfully records my mouse movement to a log file. Now, I'd like to organise my application a bit more by adding Login section, so the records later could be easier to find. I made this as a first tab page of my WPF app. After clicking "Save" button, I'd like to make it that user gets automatically moved to second tab that provides you with record button, and your username you asigned. My records tab would be a place where all of the records are shown and listed by username. Later on I'll made some kind of a graph to see which section is most active, but primary thing I want to succeed: Auto jump to other tab after logging in, start recording as assigned username, all records saved and listed in "My records".

What I have tried:

I managed to record my mouse movement:
C#
private static void recordData()
        {
            Point current_pos, prev_pos;
            prev_pos.X = 0;
            prev_pos.Y = 0;

            do
            {
                Thread.Sleep(500);
                if (GetCursorPos(out current_pos))
                {
                    if ((current_pos.X != prev_pos.X) || (current_pos.Y != prev_pos.Y))
                    {
                        Console.WriteLine("({0},{1})", current_pos.X, current_pos.Y);
                        coords.Add(current_pos);
                    }
                    prev_pos.X = current_pos.X;
                    prev_pos.Y = current_pos.Y;
                }

            } while (record);
        }

Record and Stop button now work separately:
C#
private void recordButton_click(object sender, EventArgs e)
        {
            t = new Thread(new ThreadStart(recordData));
            record = true;
            if (!t.IsAlive)
            {
                t.Start();
            }
            recordButton.Enabled = false;
            button2.Enabled = true;
        }

C#
private void stopButton_Click(object sender, EventArgs e)
        {
            record = false;
            if (t.IsAlive)
            {
                t.Join();
            }

            string datum = DateTime.Now.ToString("MM-dd-yyyy_H_mm");
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);

            string path = appPath + @"\logdata\" + datum + ".txt";
            Console.WriteLine(path);
            Directory.CreateDirectory(appPath + @"\logdata\");
            using (System.IO.StreamWriter file =
                new System.IO.StreamWriter(path)) 
            {
                foreach (Point line in coords)
                {
                    file.WriteLine(line.ToString());
                }
            }
            recordButton.Enabled = true;
            button2.Enabled = false;
        }
Posted
Updated 23-Oct-20 8:36am
v2
Comments
Chris Copeland 23-Oct-20 8:24am    
What seems to be the actual problem here? You've explained what you've achieved, and you've explained when the next part of the process needs to be, but you've not actually described a problem or error that might need some help.

If the purpose of this post was to request help developing this, that's not what the question section is for. You need to build the code, build the interface, develop and debug things, and then if you hit a problem or impasse, we can provide help with that. If you've not actually developed anything yet then there's not much we can really do to help with that.
Chris Copeland 23-Oct-20 8:26am    
On the back of my previous comment perhaps sounding a bit ignorant or obtuse, have you looked into the WPF TabControl? That should give you a good starting place.
RomanDyack 24-Oct-20 8:15am    
Sorry if I didn't express my problem well. What I'd like to do and certainly don't know what exactly to search for is the problem with locked tabs in my WPF. I'd like to be able to go to another tab only after I put my name in Log in section. The same principle when you save demo in video games (I guess). And after recording you'd be able to search for that demo of recording and see the graph. Did I explain myself now better a bit? Here's my whole project you can see exactly what I'm working on https://easyupload.io/nugd7j

1 solution

What does "Login" have to do with "making records easier to find"?

Switching Tabs fires loaded and unloaded events; your solution has side effects and is "unconventional".

Use a "wizard" pattern or enable a (control) panel on success.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900