Valhalla Legends Forums Archive | .NET Platform | [C#] Making a Bot Core, using a UserControl

AuthorMessageTime
Smarter
I am attempting to make a independent BotCore. I plan to attempt to use a WCL (Windows Control Library) to house the basic controls, such as RichTextBox, TextBox, ListBox, and any other such controls. However I'm puzzled as to how best to go about it. I plan to use a tabbed interface, so I figure that's simple, in the BotCore program, simply make a form with a menu, and a TabControl, then make a few functions to add/remove controls, and then place the WCL in the page. But my confusion comes next. What I want is this core not even to house the connection, I want the BNCS Connection done in a plugin, as well as chat features, etc etc, and the Core just to serve as the tool to allow you to use all these plugins. Which still isn't all that confusing, what confuses me is first how to place the WCL into the tab, and also how my BNCS Plugin can send the correct data to each Profile etc. I'm sure I can call a new connection class out of the plugin for each profile, and then have that do the calls to the specific WCL, but how can I direct the correct data to the correct WCL, and I don't exactly know how to use WCL's....I mean I could call it like this:

[code]TabPage P = New TabPage();
p. // - All the page stuff..[/code]

Then add the WCL to the TabPage..

[code]userControl uc = new userControl();[/code] - I know not real but i'm brainstorming

then:

[code]BNCS a = new BNCS(uc);[/code] - which would call my connection class out of the plugin, and in the plugin:

I could call things like globally define the passed uc, as a user control:

[code]case "somechatevent":
    uc.AddChat("blah", Color.Blue);
    break;[/code] - Wouldn't it then call the functions out of that specific user control?


I am also having trouble trying to figure out how I can make my plugins interact, such as if I had a Moderation plugin, it would need to recieve the Chat Data, that is being handeled by the BNLS plugin, however I do not want my plugins to have to rely on other ones, I want each one to be able to work independent from one another, so i'm not exactly sure how I could globally send out Chat Events, or any events for that matter, so that any other plugin could grab them, and act upon them.

---------------------------------------------------------------------------------------------

I'm sure this was all very confusing, and I apologize, but I am still diligently learning C#, and some portions of it are still slightly hard for me to wrap my brain around, if there is a more efficient/easier way to do all this, please don't hesitate to tell me, but please no negative remarks, as I am simply looking to learn.
June 3, 2007, 5:10 AM
BreW
you've made a bot before, you should know it takes just too much code to make a user control out of. user controls are for small(er) things, unlike that. otherwise, great idea (i guess), and it has been done before (csb) except in an ocx.
June 3, 2007, 7:10 PM
Myndfyr
[quote author=brew link=topic=16752.msg169665#msg169665 date=1180897822]
you've made a bot before, you should know it takes just too much code to make a user control out of. user controls are for small(er) things, unlike that. otherwise, great idea (i guess), and it has been done before (csb) except in an ocx.
[/quote]

I very much disagree.  User controls are for, like most things, encapsulation.

Smarter: I think you're in a little over your head.  You should do a little bit of research and reading about different kinds of architecture patterns, such as service-oriented architecture or  model-view-controller.  Both of these are excellent architectural design patterns for plugin-based systems.

The catch about writing plugins, or more accurately, the ability to support plugins, is that you absolutely need to think through what kinds of functionality you want to alow your plugin to expose.  If you don't, you'll crash and burn into a pile of spaghetti code.
June 3, 2007, 10:56 PM
Smarter
That's my problem as a programmer tho, I sometimes have trouble planning the code out in my head, I know most of the coding it takes to create what I want, but I get confused in the planning. I made a usercontrol in a WCL, and it of course made a .dll, but i can't get it into my BotCore?
June 4, 2007, 12:14 AM
Quarantine
It helps to write ideas down on paper.
June 4, 2007, 1:05 AM
Smarter
Well, can anyone answer my questions:

1. How do I add a userControl (in Windows Control Library (.dll) format) to my project. (I tried and tried it won't add!)
2. How best can I go about the passing of information between core to plugins.

3. How best can I actually import/use plugins.
June 4, 2007, 1:43 AM
Myndfyr
[quote author=Smarter link=topic=16752.msg169684#msg169684 date=1180921419]
2. How best can I go about the passing of information between core to plugins.

3. How best can I actually import/use plugins.
[/quote]
[quote author=MyndFyre[vL] link=topic=16752.msg169673#msg169673 date=1180911401]
You should do a little bit of research and reading about different kinds of architecture patterns, such as service-oriented architecture or  model-view-controller.  Both of these are excellent architectural design patterns for plugin-based systems.

The catch about writing plugins, or more accurately, the ability to support plugins, is that you absolutely need to think through what kinds of functionality you want to alow your plugin to expose.  If you don't, you'll crash and burn into a pile of spaghetti code.
[/quote]
June 4, 2007, 2:10 AM
Smarter
Ok, I figured out how to add the usercontrol to my form, which works great, I can access the functions i created inside it, but now i'm having a problem:

[code]        public void AddTab(string TabName, string TabText)
        {
            BotControl.userControlMain uc = new BotControl.userControlMain();
            uc.BackColor = Color.Black;
            uc.ForeColor = Color.White;
            uc.Name = TabName;
            uc.Size = new System.Drawing.Size(506, 403);

            TabPage tp = new TabPage();
            tp.BackColor = Color.Black;
            tp.Controls.Add(uc);
            tp.ForeColor = Color.White;
            tp.Text = TabText;
            tabControlMain.Controls.Add(tp);

        }[/code]

That is a shitty addtab function I made up, but my problem i'm having is, somehow, when I load a profile, I need to be able to create a unique tab, and a unique usercontrol (like TP and UC), which isn't a problem, but what is a problem is how I can control that usercontrol in another area of coding, in another class, or even in another plugin. I have no idea how this is possible?
June 4, 2007, 4:43 AM

Search