What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Created a Form on Visual Studio and can't get it to run with Plugin

Beetlebomb

New Member
Joined
Jan 1, 2011
Messages
131
Reaction score
0
I should say beforehand that I'm very new to working in visual studio. So excuse me if my questions are too simplistic :P

I have three .cs files. The original one containing PluginRun() and the default template provided by our developer Out. The other two were created by visual studio. Form1.cs and Form1.Designer.cs. My goal is to not have to manually cut and paste my code all into one cs file in order to have the form show up when the plugin is ran. The reason for this is because, if I want to make an adjustment to my windows form at all, i'd have to manually move all that source code from my windows form back into the plugin each and every time. So my question is, what is needed to declare a Form that's in another .cs file? I can provide the files if need be.

Thank you so much. This learning experience has been very exciting and rewarding.
 
Create an instance of the form in the main class so you have access to it then run the instance in a new thread.
 
What do you mean by instance? All the parameters of the form, label names, etc? I also only recently learned how to use threads but I've seen other plug-ins use forms without making the form in its own thread. Perhaps a new thread is only necessary if it's coming from a different cs file? Thanks for the help!
 
The main thing is to make sure any work you do isn't done on the same thread as the gui or it's going to freeze while AB performs long actions such as moving. You can either spawn the gui on the main thread and create a new thread for heavy tasks or create the gui in a new thread. I do it with 3.

e.g. here is one of my ui's:

View attachment 144966

The ui is created in a new thread and is owned by my main class. The Go/Stop buttons toggle a variable in the form class called _running. My main thread then checks against this variable (since it owns the window) and if it's true (you pressed go) and the worker thread isn't spawned it'll create the thread and begin the work, if it's false (you pressed stop) and the worker thread is running it'll call to cancel it. All the ui has to do is worry about ui stuff and toggling that flag when you press the buttons.
 
That link isn't working for me. Mind PM'ing it to me?

Also, I've been looking at how nick1988 made his form on LazyTrader, and it seemed like he simply copy and pasted the code into his main class after he was done. Either that or visual studio knows to write the code into the appropriate file instead of creating a new one. Is anyone familiar with that?

It really helps to see a lot of open source code that I can look at to learn. Thanks for your help :)
 
Oh it was just an image of the ui so you knew what I was talking about.

I'm not sure what you're talking about with copy/pasting code amongst classes though, not sure how that is related to your ui.
 
Last edited:
Maybe you shoul follow some basic form tutorials they explain things in great detail
 
Back
Top