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

Using WPF with Archbuddy

zdennis

New Member
Joined
Aug 2, 2012
Messages
28
Reaction score
0
Hi I'm trying to create a GUI with WPF but I can't get it to work.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using ArcheBuddy.Bot.Classes;

namespace AutoLoot
{
    /// <summary>
    /// Interaktionslogik für AutoLootWindow.xaml
    /// </summary>
    public partial class AutoLootWindow : Window
    {
        public AutoLootWindow()
        {
            InitializeComponent();
        }
    }
    class Class1 : Core
    {
        public static string GetPluginAuthor()
        {
            return "Plugin Author";
        }

        public static string GetPluginVersion()
        {
            return "1.0.0.0";
        }

        public static string GetPluginDescription()
        {
            return "My plugin description";
        }

        public void test()
        {
            AutoLootWindow Window = new AutoLootWindow();
        }


        //Call on plugin start
        public void PluginRun()
        {
            Thread t = new Thread(test);
            t.TrySetApartmentState(ApartmentState.MTA);
            t.Start();
            while(true)
                Thread.Sleep(50);
        }
        //Call on plugin stop
        public void PluginStop()
        {
        }
    }
}

I tried it like this but it crashed the complete updater :p

Maybe someone can give me a hint



#edit: Sry I got it, please close thread

#edit2: here if you're interested in how it should look if it works:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using ArcheBuddy.Bot.Classes;

namespace AutoLoot
{
    /// <summary>
    /// Interaktionslogik für AutoLootWindow.xaml
    /// </summary>
    public partial class AutoLootWindow : Window
    {
        public AutoLootWindow()
        {
            InitializeComponent();
        }
    }

    class AutoLoot : Core
    {
        public static string GetPluginAuthor()
        {
            return "zdennis";
        }

        public static string GetPluginVersion()
        {
            return "1.0.0.0";
        }

        public static string GetPluginDescription()
        {
            return "My plugin description";
        }

        // Create a thread
        Thread GuiThread = new Thread(new ThreadStart(() =>
        {
            // Create and show the Window
            AutoLootWindow GUI = new AutoLootWindow();
            GUI.Show();
            // Start the Dispatcher Processing
            System.Windows.Threading.Dispatcher.Run();
        }));

        //Call on plugin start
        public void PluginRun()
        {
            // Set the apartment state
            GuiThread.SetApartmentState(ApartmentState.STA);
            // Make the thread a background thread
            GuiThread.IsBackground = true;
            // Start the thread
            GuiThread.Start();


            while (true)
                Thread.Sleep(50);
        }
        //Call on plugin stop
        public void PluginStop()
        {
            // Abort to close the window;
            GuiThread.Abort();
        }

    }
}
 
Last edited:
Back
Top