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

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

BotBase Settings Form

Sinbeard

New Member
Joined
Oct 14, 2019
Messages
14
I'm mostly a linux dev in experience, and as a result have extremely little experience developing with any kind of GUI. As a result I've been having some pretty annoying trouble getting a settings window to work for a botbase I'm trying code.

I'm trying to use a WPF with a SettingsWindow.xaml and respective code behind file. I basically copied the files over from a blank WPF VS project and summoned them forth with my OnButtonPress() override. The code I'm using basically is the same from DeepDive botbase:
Code:
        private SettingsWindow _settings;
...
        public override void OnButtonPress()
        {
            if (_settings == null)
            {
                _settings = new SettingsWindow {
                    Title = "Garlean Resource Assimilator v" + _v
                };
                _settings.Closed += (o, e) => { _settings = null; };
            }

            try
            {
                _settings.Show();
            }
            catch (Exception)
            {
                // ignored
            }
        }

code behind code:

Code:
namespace Assimilator.GUI
{
   public partial class SettingsWindow : Window
    {
        public SettingsWindow()
        {
            InitializeComponent();
        }
    }
}

xaml

Code:
<Window
   x:Class="Assimilator.GUI.SettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Garlean Resource Assimilator"
   Height="Auto"
   Width="Auto"
    WindowStartupLocation="CenterScreen">
...
</Window>

Here are the errors I'm getting in the RB log:

Code:
[04:45:16.511 N] Compiler Error: C:\Users\<user>\Downloads\rb\BotBases\Assimilator\Assimilator.cs(43,21) : error CS0117: 'SettingsWindow' does not contain a definition for 'Title'

[04:45:16.511 N] Compiler Error: C:\Users\<user>\Downloads\rb\BotBases\Assimilator\Assimilator.cs(45,27) : error CS1061: 'SettingsWindow' does not contain a definition for 'Closed' and no extension method 'Closed' accepting a first argument of type 'SettingsWindow' could be found (are you missing a using directive or an assembly reference?)

[04:45:16.511 N] Compiler Error: C:\Users\<user>\Downloads\rb\BotBases\Assimilator\Assimilator.cs(50,27) : error CS1061: 'SettingsWindow' does not contain a definition for 'Show' and no extension method 'Show' accepting a first argument of type 'SettingsWindow' could be found (are you missing a using directive or an assembly reference?)

The annoying thing is that if I use MahApps Metro and compile the botbase into a .dll and use the loader file that's been floating around for ages the settings window launches fine in RB. However, I don't want to have to compile this code to a dll to use it. Also, the project builds just fine when I build it in VS.

I'm clearly doing something wrong, but I don't have the experience to easily guess at it. Does RB not have the System.Windows reference ...?
 
Getting WPF+ XAML to work is a really tedious process since XAML doesn't get included in the compile normally. IIRC @zzi had something that let you do it but I don't recall where he shared it.
 
Ugh classic.

After reading your comment I was able to google around a bit more easily. I can see that's part of the the .dll reflection that some devs use made it work for me. I did see in RbLeveGen that there is a xaml file with some other nonsense going on. I'll see if I can bang something like that into mine. In the mean time, you were able to point me in a needed direction so I'll also take a look on that route.

Thank you!
 
Back
Top