sinterlkaas
New Member
- Joined
- Jan 17, 2012
- Messages
- 536
- Reaction score
- 14
This plugin is for developers only
It is a example on how to create the config window (finally)
What to do to create this xaml file?
Open VisualStudio and go to:
File -> new -> Project
open a WPF User Control Library
here you can start editing your xaml file and create a nice config UI
when you are done save this file and remove the red add green
now your usercontrol tag will look like this:
Update:
Fix for not closing bug when using a config window....
I dont know what will happen when all plugins that use a configwindow call the invoke shutdown workaround .....
It is a example on how to create the config window (finally)

What to do to create this xaml file?
Open VisualStudio and go to:
File -> new -> Project
open a WPF User Control Library
here you can start editing your xaml file and create a nice config UI
when you are done save this file and remove the red add green
Code:
<UserControl [COLOR="#FF0000"]x:Class="WpfControlLibrary2.UserControl1"[/COLOR]
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
[COLOR="#FF0000"]d:Design[/COLOR]Height="300" [COLOR="#FF0000"]d:Design[/COLOR]Width="300" [COLOR="#006400"]Name="mainControl"[/COLOR]>
now your usercontrol tag will look like this:
Code:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="300" Width="300" Name="mainControl">
Update:
Fix for not closing bug when using a config window....
I dont know what will happen when all plugins that use a configwindow call the invoke shutdown workaround .....
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Threading;
using System.Diagnostics;
using Zeta;
using Zeta.Common;
using Zeta.CommonBot;
using Zeta.Common.Plugins;
using Demonbuddy;
namespace MyPlugin
{
partial class MyPlugin : IPlugin
{
#region IPLUGIN
public string Author { get { return "sinterlkaas"; } }
public string Description { get { return ""; } }
public string Name { get { return "v" + Version.ToString(); } }
public Version Version { get { return new Version(0, 1); } }
public Window DisplayWindow { get {
Window w = new Window();
return w;
} }
public void Log(string message, LogLevel level = LogLevel.Normal)
{
Logging.Write(level, string.Format("[{0}] {1}", Name, message));
}
public void OnInitialize()
{
Log("Initialized");
}
public void OnShutdown()
{
}
public void OnEnabled()
{
Log("Enabled");
thCloseCheck = new Thread(new ThreadStart(worker));
//thCloseCheck.IsBackground = true;
thCloseCheck.Start();
}
public void OnDisabled()
{
Log("Disabled");
thCloseCheck.Abort();
}
public bool Equals(IPlugin other)
{
return (other.Name == Name) && (other.Version == Version);
}
public void OnPulse()
{
}
#endregion
Thread thCloseCheck;
void worker()
{
while (true)
{
if (isClosing)
{
App.Current.Dispatcher.Invoke(
new Action(
delegate()
{
App.Current.Shutdown();
}
));
break;
}
Thread.Sleep(100);
}
}
bool isClosing
{
get
{
IntPtr h = Process.GetCurrentProcess().MainWindowHandle;
return (h == IntPtr.Zero || h == null);
}
}
void shutdownfix()
{
App.Current.Dispatcher.Invoke(
new Action(
delegate()
{
App.Current.Shutdown();
}
));
}
}
}
Attachments
Last edited: