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

Launching a new WPF window from a plugin

Dgc2002

Member
Joined
Jan 15, 2010
Messages
197
Reaction score
0
Disclaimer: I've been away from OOP for quite a while, I've never really used c# before the past few days, and I haven't touched visual anything since visual basic almost 7 years ago. That having been said...


I'm attempting to create a new WPF window from a plugin. At this point I've edited the Example Plugin so the original config button would launch a new wpf window instead, it does this... However the window does not contain anything that I've added though the WPF designer. Instead it is blank with no title and has the Exile Buddy icon. Is there a step I'm missing? Any help would be appreciated!
 
dont forget to load the xaml file into the stand-alone form ;)
 
You might have to take the same approach the bot uses for getting WPF stuff loaded.

That is, if you look at the Control property of IConfigurable for any of the provided stuff, you'll see a common pattern of:

Code:
        public UserControl Control
        {
            get
            {
                using (var fs = new FileStream(@"Bots\ExampleBot\SettingsGui.xaml", FileMode.Open))
                {
                    var root = (UserControl) XamlReader.Load(fs);

                    // TODO: Your settings binding here.

                    // TODO: Your settings event handlers here.
                }
        }

This is setup to allow the bot to load 3rd party WPF code in a way that doesn't require an assembly, as typically xaml is compiled into a baml, and then included with the main assembly.

To start your own window, you'd just cast to a Window and then do the Show method I believe.

Give this a try, and if you can't get it, I'll get an example made for it soon.
 
You might have to take the same approach the bot uses for getting WPF stuff loaded.

That is, if you look at the Control property of IConfigurable for any of the provided stuff, you'll see a common pattern of:

Code:
        public UserControl Control
        {
            get
            {
                using (var fs = new FileStream(@"Bots\ExampleBot\SettingsGui.xaml", FileMode.Open))
                {
                    var root = (UserControl) XamlReader.Load(fs);

                    // TODO: Your settings binding here.

                    // TODO: Your settings event handlers here.
                }
        }

This is setup to allow the bot to load 3rd party WPF code in a way that doesn't require an assembly, as typically xaml is compiled into a baml, and then included with the main assembly.

To start your own window, you'd just cast to a Window and then do the Show method I believe.

Give this a try, and if you can't get it, I'll get an example made for it soon.

Thanks a ton Pushedx that did the trick. Still wrapping my head around some of this so thanks for taking the time to clear some things up.

I'm attempting to use Helixtoolkit as you had mentioned in another thread. My project recognizes everything fine however when I go to run the bot it throws "error CS0246: The type or namespace name 'HelixToolkit' could not be found (are you missing a using directive or an assembly reference?)." I've tried a few things to resolve this but to no avail. Does this have something to do with the bot or is it on my end? If its my end I'm sure standard WPF 3dViewport will meet my needs.
 
I'm attempting to use Helixtoolkit as you had mentioned in another thread. My project recognizes everything fine however when I go to run the bot it throws "error CS0246: The type or namespace name 'HelixToolkit' could not be found (are you missing a using directive or an assembly reference?)." I've tried a few things to resolve this but to no avail. Does this have something to do with the bot or is it on my end? If its my end I'm sure standard WPF 3dViewport will meet my needs.

The bot doesn't currently reference that assembly (normally it would if it had code using it), so inside one of your main code files, you need to add (just somewhere at the top under all your usings):
Code:
//!CompilerOption|AddRef|HelixToolkit.Wpf.dll

That tells the code compiler to add that assembly reference to your loaded code, so it should work properly now. The new change made in the last version allows absolute file paths to assemblies, so you can load system assemblies not in the GAC. For example, this.
 
Back
Top